Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/tables/__init__.py: 65%

80 statements  

« prev     ^ index     » next       coverage.py v7.2.5, created at 2023-05-10 06:15 +0000

1"""PyTables, hierarchical datasets in Python. 

2 

3:URL: http://www.pytables.org/ 

4 

5PyTables is a package for managing hierarchical datasets and designed 

6to efficiently cope with extremely large amounts of data. 

7 

8""" 

9import os 

10from ctypes import cdll 

11from ctypes.util import find_library 

12import platform 

13 

14 

15# Load the blosc2 library, and if not found in standard locations, 

16# try this directory (it should be automatically copied in setup.py). 

17current_dir = os.path.dirname(__file__) 

18platform_system = platform.system() 

19blosc2_lib_hardcoded = "libblosc2" 

20if platform_system == "Linux": 

21 blosc2_lib_hardcoded += ".so" 

22elif platform_system == "Darwin": 

23 blosc2_lib_hardcoded += ".dylib" 

24else: 

25 blosc2_lib_hardcoded += ".dll" 

26blosc2_found = False 

27blosc2_search_paths = [blosc2_lib_hardcoded, 

28 os.path.join(current_dir, blosc2_lib_hardcoded), 

29 find_library("blosc2")] 

30for blosc2_lib in blosc2_search_paths: 

31 try: 

32 cdll.LoadLibrary(blosc2_lib) 

33 blosc2_found = True 

34 break 

35 except OSError: 

36 pass 

37if not blosc2_found: 

38 raise RuntimeError("Blosc2 library not found. " 

39 f"I looked for \"{', '.join(blosc2_search_paths)}\"") 

40 

41# Necessary imports to get versions stored on the cython extension 

42from .utilsextension import get_hdf5_version as _get_hdf5_version 

43 

44from ._version import __version__ 

45 

46hdf5_version = _get_hdf5_version() 

47"""The underlying HDF5 library version number. 

48 

49.. versionadded:: 3.0 

50 

51""" 

52 

53from .utilsextension import ( 

54 blosc_compcode_to_compname_ as blosc_compcode_to_compname, 

55 blosc2_compcode_to_compname_ as blosc2_compcode_to_compname, 

56 blosc_get_complib_info_ as blosc_get_complib_info, 

57 blosc2_get_complib_info_ as blosc2_get_complib_info, 

58) 

59 

60from .utilsextension import ( 

61 blosc_compressor_list, 

62 blosc2_compressor_list, 

63 is_hdf5_file, 

64 is_pytables_file, 

65 which_lib_version, 

66 set_blosc_max_threads, 

67 set_blosc2_max_threads, 

68 silence_hdf5_messages, 

69) 

70 

71from .misc.enum import Enum 

72from .atom import * 

73from .flavor import restrict_flavors 

74from .description import * 

75from .filters import Filters 

76 

77# Import the user classes from the proper modules 

78from .exceptions import * 

79from .file import File, open_file, copy_file 

80from .node import Node 

81from .group import Group 

82from .leaf import Leaf 

83from .table import Table, Cols, Column 

84from .array import Array 

85from .carray import CArray 

86from .earray import EArray 

87from .vlarray import VLArray 

88from .unimplemented import UnImplemented, Unknown 

89from .expression import Expr 

90from .tests import print_versions, test 

91 

92 

93# List here only the objects we want to be publicly available 

94__all__ = [ 

95 # Exceptions and warnings: 

96 'HDF5ExtError', 

97 'ClosedNodeError', 'ClosedFileError', 'FileModeError', 

98 'NaturalNameWarning', 'NodeError', 'NoSuchNodeError', 

99 'UndoRedoError', 'UndoRedoWarning', 

100 'PerformanceWarning', 

101 'FlavorError', 'FlavorWarning', 

102 'FiltersWarning', 'DataTypeWarning', 

103 # Functions: 

104 'is_hdf5_file', 'is_pytables_file', 'which_lib_version', 

105 'copy_file', 'open_file', 'print_versions', 'test', 

106 'split_type', 'restrict_flavors', 

107 'set_blosc_max_threads', 'set_blosc2_max_threads', 

108 'silence_hdf5_messages', 

109 # Helper classes: 

110 'IsDescription', 'Description', 'Filters', 'Cols', 'Column', 

111 # Types: 

112 'Enum', 

113 # Atom types: 

114 'Atom', 'StringAtom', 'BoolAtom', 

115 'IntAtom', 'UIntAtom', 'Int8Atom', 'UInt8Atom', 'Int16Atom', 'UInt16Atom', 

116 'Int32Atom', 'UInt32Atom', 'Int64Atom', 'UInt64Atom', 

117 'FloatAtom', 'Float32Atom', 'Float64Atom', 

118 'ComplexAtom', 'Complex32Atom', 'Complex64Atom', 'Complex128Atom', 

119 'TimeAtom', 'Time32Atom', 'Time64Atom', 

120 'EnumAtom', 

121 'PseudoAtom', 'ObjectAtom', 'VLStringAtom', 'VLUnicodeAtom', 

122 # Column types: 

123 'Col', 'StringCol', 'BoolCol', 

124 'IntCol', 'UIntCol', 'Int8Col', 'UInt8Col', 'Int16Col', 'UInt16Col', 

125 'Int32Col', 'UInt32Col', 'Int64Col', 'UInt64Col', 

126 'FloatCol', 'Float32Col', 'Float64Col', 

127 'ComplexCol', 'Complex32Col', 'Complex64Col', 'Complex128Col', 

128 'TimeCol', 'Time32Col', 'Time64Col', 

129 'EnumCol', 

130 # Node classes: 

131 'Node', 'Group', 'Leaf', 'Table', 'Array', 'CArray', 'EArray', 'VLArray', 

132 'UnImplemented', 'Unknown', 

133 # The File class: 

134 'File', 

135 # Expr class 

136 'Expr', 

137] 

138 

139if 'Float16Atom' in locals(): 

140 # float16 is new in numpy 1.6.0 

141 __all__.extend(('Float16Atom', 'Float16Col')) 

142 

143 

144from .utilsextension import _broken_hdf5_long_double 

145if not _broken_hdf5_long_double(): 

146 if 'Float96Atom' in locals(): 

147 __all__.extend(('Float96Atom', 'Float96Col')) 

148 __all__.extend(('Complex192Atom', 'Complex192Col')) # XXX check 

149 

150 if 'Float128Atom' in locals(): 

151 __all__.extend(('Float128Atom', 'Float128Col')) 

152 __all__.extend(('Complex256Atom', 'Complex256Col')) # XXX check 

153 

154else: 

155 

156 from . import atom as _atom 

157 from . import description as _description 

158 try: 

159 del _atom.Float96Atom, _atom.Complex192Col 

160 del _description.Float96Col, _description.Complex192Col 

161 _atom.all_types.discard('complex192') 

162 _atom.ComplexAtom._isizes.remove(24) 

163 except AttributeError: 

164 try: 

165 del _atom.Float128Atom, _atom.Complex256Atom 

166 del _description.Float128Col, _description.Complex256Col 

167 _atom.all_types.discard('complex256') 

168 _atom.ComplexAtom._isizes.remove(32) 

169 except AttributeError: 

170 pass 

171 del _atom, _description 

172del _broken_hdf5_long_double 

173 

174 

175def get_pytables_version(): 

176 warnings.warn( 

177 "the 'get_pytables_version()' function is deprecated and could be " 

178 "removed in future versions. Please use 'tables.__version__'", 

179 DeprecationWarning) 

180 return __version__ 

181 

182def get_hdf5_version(): 

183 warnings.warn( 

184 "the 'get_hdf5_version()' function is deprecated and could be " 

185 "removed in future versions. Please use 'tables.hdf5_version'", 

186 DeprecationWarning) 

187 return hdf5_version