Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/h5py/__init__.py: 57%
53 statements
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 07:57 +0000
« prev ^ index » next coverage.py v7.4.0, created at 2024-01-03 07:57 +0000
1# This file is part of h5py, a Python interface to the HDF5 library.
2#
3# http://www.h5py.org
4#
5# Copyright 2008-2013 Andrew Collette and contributors
6#
7# License: Standard 3-clause BSD; see "license.txt" for full license terms
8# and contributor agreement.
10"""
11 This is the h5py package, a Python interface to the HDF5
12 scientific data format.
13"""
15from warnings import warn as _warn
16import atexit
19# --- Library setup -----------------------------------------------------------
21# When importing from the root of the unpacked tarball or git checkout,
22# Python sees the "h5py" source directory and tries to load it, which fails.
23# We tried working around this by using "package_dir" but that breaks Cython.
24try:
25 from . import _errors
26except ImportError:
27 import os.path as _op
28 if _op.exists(_op.join(_op.dirname(__file__), '..', 'setup.py')):
29 raise ImportError("You cannot import h5py from inside the install directory.\nChange to another directory first.")
30 else:
31 raise
33from . import version
35if version.hdf5_version_tuple != version.hdf5_built_version_tuple:
36 _warn(("h5py is running against HDF5 {0} when it was built against {1}, "
37 "this may cause problems").format(
38 '{0}.{1}.{2}'.format(*version.hdf5_version_tuple),
39 '{0}.{1}.{2}'.format(*version.hdf5_built_version_tuple)
40 ))
43_errors.silence_errors()
45from ._conv import register_converters as _register_converters, \
46 unregister_converters as _unregister_converters
47_register_converters()
48atexit.register(_unregister_converters)
50from .h5z import _register_lzf
51_register_lzf()
54# --- Public API --------------------------------------------------------------
56from . import h5a, h5d, h5ds, h5f, h5fd, h5g, h5r, h5s, h5t, h5p, h5z, h5pl
58from ._hl import filters
59from ._hl.base import is_hdf5, HLObject, Empty
60from ._hl.files import (
61 File,
62 register_driver,
63 unregister_driver,
64 registered_drivers,
65)
66from ._hl.group import Group, SoftLink, ExternalLink, HardLink
67from ._hl.dataset import Dataset
68from ._hl.datatype import Datatype
69from ._hl.attrs import AttributeManager
70from ._hl.vds import VirtualSource, VirtualLayout
72from ._selector import MultiBlockSlice
73from .h5 import get_config
74from .h5r import Reference, RegionReference
75from .h5t import (special_dtype, check_dtype,
76 vlen_dtype, string_dtype, enum_dtype, ref_dtype, regionref_dtype,
77 opaque_dtype,
78 check_vlen_dtype, check_string_dtype, check_enum_dtype, check_ref_dtype,
79 check_opaque_dtype,
80)
81from .h5s import UNLIMITED
83from .version import version as __version__
86def run_tests(args=''):
87 """Run tests with pytest and returns the exit status as an int.
88 """
89 # Lazy-loading of tests package to avoid strong dependency on test
90 # requirements, e.g. pytest
91 from .tests import run_tests
92 return run_tests(args)
95def enable_ipython_completer():
96 """ Call this from an interactive IPython session to enable tab-completion
97 of group and attribute names.
98 """
99 import sys
100 if 'IPython' in sys.modules:
101 ip_running = False
102 try:
103 from IPython.core.interactiveshell import InteractiveShell
104 ip_running = InteractiveShell.initialized()
105 except ImportError:
106 # support <ipython-0.11
107 from IPython import ipapi as _ipapi
108 ip_running = _ipapi.get() is not None
109 except Exception:
110 pass
111 if ip_running:
112 from . import ipy_completer
113 return ipy_completer.load_ipython_extension()
115 raise RuntimeError('Completer must be enabled in active ipython session')