h5netcdf 1.2.0__py3-none-any.whl → 1.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of h5netcdf might be problematic. Click here for more details.
- h5netcdf/__init__.py +1 -0
- h5netcdf/_version.py +14 -2
- h5netcdf/attrs.py +2 -2
- h5netcdf/core.py +565 -95
- h5netcdf/dimensions.py +6 -9
- h5netcdf/legacyapi.py +26 -5
- h5netcdf/tests/test_h5netcdf.py +619 -63
- {h5netcdf-1.2.0.dist-info → h5netcdf-1.4.0.dist-info}/METADATA +26 -27
- h5netcdf-1.4.0.dist-info/RECORD +16 -0
- {h5netcdf-1.2.0.dist-info → h5netcdf-1.4.0.dist-info}/WHEEL +1 -1
- h5netcdf-1.2.0.dist-info/RECORD +0 -16
- {h5netcdf-1.2.0.dist-info → h5netcdf-1.4.0.dist-info}/AUTHORS.txt +0 -0
- {h5netcdf-1.2.0.dist-info → h5netcdf-1.4.0.dist-info}/LICENSE +0 -0
- {h5netcdf-1.2.0.dist-info → h5netcdf-1.4.0.dist-info}/top_level.txt +0 -0
h5netcdf/dimensions.py
CHANGED
|
@@ -2,7 +2,6 @@ import weakref
|
|
|
2
2
|
from collections import OrderedDict
|
|
3
3
|
from collections.abc import MutableMapping
|
|
4
4
|
|
|
5
|
-
import h5py
|
|
6
5
|
import numpy as np
|
|
7
6
|
|
|
8
7
|
|
|
@@ -23,7 +22,7 @@ class Dimensions(MutableMapping):
|
|
|
23
22
|
if not self._group._root._writable:
|
|
24
23
|
raise RuntimeError("H5NetCDF: Write to read only")
|
|
25
24
|
if name in self._objects:
|
|
26
|
-
raise ValueError("dimension
|
|
25
|
+
raise ValueError(f"dimension {name:!r} already exists")
|
|
27
26
|
|
|
28
27
|
self._objects[name] = Dimension(self._group, name, size, create_h5ds=True)
|
|
29
28
|
|
|
@@ -48,9 +47,8 @@ class Dimensions(MutableMapping):
|
|
|
48
47
|
def __repr__(self):
|
|
49
48
|
if self._group._root._closed:
|
|
50
49
|
return "<Closed h5netcdf.Dimensions>"
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
)
|
|
50
|
+
dims = ", ".join(f"{k}={v!r}" for k, v in self._objects.items())
|
|
51
|
+
return f"<h5netcdf.Dimensions: {dims}>"
|
|
54
52
|
|
|
55
53
|
|
|
56
54
|
def _join_h5paths(parent_path, child_path):
|
|
@@ -138,7 +136,7 @@ class Dimension:
|
|
|
138
136
|
|
|
139
137
|
@property
|
|
140
138
|
def _isscale(self):
|
|
141
|
-
return
|
|
139
|
+
return self._root._h5py.h5ds.is_scale(self._h5ds.id)
|
|
142
140
|
|
|
143
141
|
@property
|
|
144
142
|
def _dimid(self):
|
|
@@ -151,8 +149,7 @@ class Dimension:
|
|
|
151
149
|
|
|
152
150
|
if not self.isunlimited():
|
|
153
151
|
raise ValueError(
|
|
154
|
-
"Dimension '
|
|
155
|
-
% self.name
|
|
152
|
+
f"Dimension '{self.name}' is not unlimited and thus cannot be resized."
|
|
156
153
|
)
|
|
157
154
|
self._h5ds.resize((size,))
|
|
158
155
|
|
|
@@ -234,7 +231,7 @@ class Dimension:
|
|
|
234
231
|
|
|
235
232
|
def __repr__(self):
|
|
236
233
|
if not self._phony and self._parent._root._closed:
|
|
237
|
-
return "<Closed
|
|
234
|
+
return f"<Closed {self._cls_name}>"
|
|
238
235
|
special = ""
|
|
239
236
|
if self._phony:
|
|
240
237
|
special += " (phony_dim)"
|
h5netcdf/legacyapi.py
CHANGED
|
@@ -41,8 +41,7 @@ def _check_return_dtype_endianess(endian="native"):
|
|
|
41
41
|
pass
|
|
42
42
|
else:
|
|
43
43
|
raise ValueError(
|
|
44
|
-
"'endian' keyword argument must be 'little','big' or 'native', got '
|
|
45
|
-
% endian
|
|
44
|
+
f"'endian' keyword argument must be 'little','big' or 'native', got '{endian}'"
|
|
46
45
|
)
|
|
47
46
|
return endianess
|
|
48
47
|
|
|
@@ -105,22 +104,44 @@ class Variable(core.BaseVariable, HasAttributesMixin):
|
|
|
105
104
|
|
|
106
105
|
@property
|
|
107
106
|
def dtype(self):
|
|
108
|
-
"""Return netCDF4.Variable
|
|
107
|
+
"""Return netCDF4.Variable numpy dtype."""
|
|
109
108
|
dt = self._h5ds.dtype
|
|
110
109
|
if h5py.check_dtype(vlen=dt) is str:
|
|
111
110
|
return str
|
|
112
111
|
return dt
|
|
113
112
|
|
|
114
113
|
|
|
114
|
+
class EnumType(core.EnumType):
|
|
115
|
+
_cls_name = "h5netcdf.legacyapi.EnumType"
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
class VLType(core.VLType):
|
|
119
|
+
_cls_name = "h5netcdf.legacyapi.VLType"
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
class CompoundType(core.CompoundType):
|
|
123
|
+
_cls_name = "h5netcdf.legacyapi.CompoundType"
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
class UserType(core.UserType):
|
|
127
|
+
_cls_name = "h5netcdf.legacyapi.UserType"
|
|
128
|
+
|
|
129
|
+
|
|
115
130
|
class Group(core.Group, HasAttributesMixin):
|
|
116
131
|
_cls_name = "h5netcdf.legacyapi.Group"
|
|
117
132
|
_variable_cls = Variable
|
|
133
|
+
_enumtype_cls = EnumType
|
|
134
|
+
_vltype_cls = VLType
|
|
135
|
+
_cmptype_cls = CompoundType
|
|
118
136
|
|
|
119
137
|
@property
|
|
120
138
|
def _group_cls(self):
|
|
121
139
|
return Group
|
|
122
140
|
|
|
123
141
|
createGroup = core.Group.create_group
|
|
142
|
+
createEnumType = core.Group.create_enumtype
|
|
143
|
+
createVLType = core.Group.create_vltype
|
|
144
|
+
createCompoundType = core.Group.create_cmptype
|
|
124
145
|
|
|
125
146
|
def createDimension(self, name, size):
|
|
126
147
|
"""Creates a new dimension with given name and size.
|
|
@@ -161,8 +182,8 @@ class Group(core.Group, HasAttributesMixin):
|
|
|
161
182
|
varname : str
|
|
162
183
|
Name of the new variable. If given as a path, intermediate groups will be created,
|
|
163
184
|
if not existent.
|
|
164
|
-
datatype : numpy.dtype, str
|
|
165
|
-
|
|
185
|
+
datatype : numpy.dtype, str, UserType (Enum, VL, Compound)
|
|
186
|
+
Datatype of the new variable.
|
|
166
187
|
dimensions : tuple
|
|
167
188
|
Tuple containing dimension name strings. Defaults to empty tuple, effectively
|
|
168
189
|
creating a scalar variable.
|