h5netcdf 1.7.1__py3-none-any.whl → 1.7.2__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/_version.py CHANGED
@@ -28,7 +28,7 @@ version_tuple: VERSION_TUPLE
28
28
  commit_id: COMMIT_ID
29
29
  __commit_id__: COMMIT_ID
30
30
 
31
- __version__ = version = '1.7.1'
32
- __version_tuple__ = version_tuple = (1, 7, 1)
31
+ __version__ = version = '1.7.2'
32
+ __version_tuple__ = version_tuple = (1, 7, 2)
33
33
 
34
34
  __commit_id__ = commit_id = None
h5netcdf/core.py CHANGED
@@ -12,7 +12,7 @@ from packaging import version
12
12
 
13
13
  from . import __version__
14
14
  from .attrs import Attributes
15
- from .dimensions import Dimension, Dimensions
15
+ from .dimensions import Dimension, Dimensions, _check_classic_unlimited
16
16
  from .utils import (
17
17
  CompatibilityError,
18
18
  Frozen,
@@ -1030,12 +1030,8 @@ class Group(Mapping):
1030
1030
 
1031
1031
  @dimensions.setter
1032
1032
  def dimensions(self, value):
1033
- if self._format == "NETCDF4_CLASSIC":
1034
- unlimited_dims = list(filter(lambda s: s in [None, 0], value.values()))
1035
- if len(unlimited_dims) > 1:
1036
- raise CompatibilityError(
1037
- "NETCDF4_CLASSIC format only allows one unlimited dimension."
1038
- )
1033
+ if self._root._format == "NETCDF4_CLASSIC":
1034
+ _check_classic_unlimited(value)
1039
1035
 
1040
1036
  for k, v in self._all_dimensions.maps[0].items():
1041
1037
  if k in value:
h5netcdf/dimensions.py CHANGED
@@ -1,12 +1,24 @@
1
1
  import weakref
2
2
  from collections import OrderedDict
3
- from collections.abc import MutableMapping
3
+ from collections.abc import Mapping, MutableMapping
4
4
 
5
5
  import numpy as np
6
6
 
7
7
  from .utils import CompatibilityError
8
8
 
9
9
 
10
+ def _check_classic_unlimited(value, unlimited=None):
11
+ if isinstance(value, Mapping):
12
+ multiple_unlimited_dimensions = sum(v in (None, 0) for v in value.values()) > 1
13
+ else:
14
+ multiple_unlimited_dimensions = unlimited and value in (None, 0)
15
+
16
+ if multiple_unlimited_dimensions:
17
+ raise CompatibilityError(
18
+ "Only one unlimited dimension allowed in the NETCDF4_CLASSIC format."
19
+ )
20
+
21
+
10
22
  class Dimensions(MutableMapping):
11
23
  def __init__(self, group):
12
24
  self._group_ref = weakref.ref(group)
@@ -25,14 +37,8 @@ class Dimensions(MutableMapping):
25
37
  raise RuntimeError("H5NetCDF: Write to read only")
26
38
  if name in self._objects:
27
39
  raise ValueError(f"dimension {name!r} already exists")
28
- if (
29
- size in [0, None]
30
- and self._unlimited()
31
- and self._group._format == "NETCDF4_CLASSIC"
32
- ):
33
- raise CompatibilityError(
34
- "Only one unlimited dimension allowed in the NETCDF4_CLASSIC format."
35
- )
40
+ if self._group._root._format == "NETCDF4_CLASSIC":
41
+ _check_classic_unlimited(size, self._unlimited())
36
42
 
37
43
  self._objects[name] = Dimension(self._group, name, size, create_h5ds=True)
38
44
 
@@ -211,7 +211,7 @@ def write_h5netcdf(tmp_netcdf, compression="gzip", format="NETCDF4"):
211
211
  if ds.data_model == "NETCDF4_CLASSIC":
212
212
  with raises(
213
213
  CompatibilityError,
214
- match="NETCDF4_CLASSIC format only allows one unlimited dimension.",
214
+ match="Only one unlimited dimension allowed",
215
215
  ):
216
216
  ds.dimensions = {"x": 4, "y": 5, "z": 6, "unlimited": None, "empty": 0}
217
217
 
@@ -2903,7 +2903,7 @@ def test_raise_on_closed_file(tmp_local_netcdf):
2903
2903
  v = f.create_variable("hello", ("x",), float)
2904
2904
  v[:] = np.ones(5)
2905
2905
  f.close()
2906
- with pytest.raises(
2906
+ with raises(
2907
2907
  ValueError,
2908
2908
  match=f"I/O operation on <Closed h5netcdf.File>: '{tmp_local_netcdf}'",
2909
2909
  ):
@@ -3013,3 +3013,30 @@ def test_attributes_list(tmp_local_netcdf, attr):
3013
3013
  assert hf.attrs["foo"][0] == attr[0]
3014
3014
  assert hf.attrs["foo"][1] == attr[1]
3015
3015
  assert isinstance(hf.attrs["foo"], list)
3016
+
3017
+
3018
+ def test_group_dimensions(tmp_local_netcdf):
3019
+ # regression test for https://github.com/h5netcdf/h5netcdf/issues/293
3020
+ with h5netcdf.File(tmp_local_netcdf, mode="w") as f:
3021
+ group = f.create_group("data")
3022
+ dims = {"y": 3, "x": 3, "z": None, "z1": None}
3023
+ group.dimensions = dims
3024
+ assert list(group.dimensions) == ["y", "x", "z", "z1"]
3025
+ group.dimensions["z2"] = None
3026
+ assert list(group.dimensions) == ["y", "x", "z", "z1", "z2"]
3027
+
3028
+
3029
+ def test_group_dimensions_classic(tmp_local_netcdf):
3030
+ # regression test for https://github.com/h5netcdf/h5netcdf/issues/293
3031
+ with h5netcdf.File(tmp_local_netcdf, mode="w", format="NETCDF4_CLASSIC") as f:
3032
+ group = f.create_group("data")
3033
+ dims = {"y": 3, "x": 3, "z": None, "z1": None}
3034
+ with raises(CompatibilityError, match=r"Only one unlimited dimension allowed"):
3035
+ group.dimensions = dims
3036
+ assert list(group.dimensions) == []
3037
+ dims = {"y": 3, "x": 3, "z": None}
3038
+ group.dimensions = dims
3039
+ assert list(group.dimensions) == ["y", "x", "z"]
3040
+ with raises(CompatibilityError, match=r"Only one unlimited dimension allowed"):
3041
+ group.dimensions["z1"] = None
3042
+ assert list(group.dimensions) == ["y", "x", "z"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h5netcdf
3
- Version: 1.7.1
3
+ Version: 1.7.2
4
4
  Summary: netCDF4 via h5py
5
5
  Author-email: Stephan Hoyer <shoyer@gmail.com>, Kai Mühlbauer <kmuehlbauer@wradlib.org>
6
6
  Maintainer-email: h5netcdf developers <devteam@h5netcdf.org>
@@ -0,0 +1,16 @@
1
+ h5netcdf/__init__.py,sha256=Y0EBCcmlJctwl1kCmj7yLijTVy9AioBTr2091vInAtw,456
2
+ h5netcdf/_version.py,sha256=veZJrH40zJtbmH4sd91I-OwvwjV0ha3xLhPSXrkCusQ,704
3
+ h5netcdf/attrs.py,sha256=GSq2lzv9q0tEkJBqr2Hyrwo0YJnWZHxtLRhhG9NVf4w,4575
4
+ h5netcdf/core.py,sha256=Dd0q1XNwrrqzCWSPauwGDFwtrVu55APIrhwOs0Gd7nQ,69508
5
+ h5netcdf/dimensions.py,sha256=BO126-7r9B0sF_bbcCSzTMnQY5wH7e_DSkbUO4F9q_o,8609
6
+ h5netcdf/legacyapi.py,sha256=MIZlht5Ad4hDFF1Slz2vXmKkgbv7Fhhf2YwNIe16Lfk,7682
7
+ h5netcdf/utils.py,sha256=btxKI-VZP-Wn0Rk_wmnhnUls-mrxO42w0s_uX_su4FI,6528
8
+ h5netcdf/tests/conftest.py,sha256=qS7XTZxos0NIRFtMCJwVEyx0paZw8Le1loPK1MtoQ_0,2350
9
+ h5netcdf/tests/pytest.ini,sha256=ruJxrLdCIA4bCPVuPQjxsLSlvVxuIsIakK6iQOmz-ak,107
10
+ h5netcdf/tests/test_h5netcdf.py,sha256=nQoKgCym6xxigicOEF-2nSBm5ba0k568GatfZnSo8BI,118407
11
+ h5netcdf-1.7.2.dist-info/licenses/AUTHORS.txt,sha256=LTKzUh9o4Wc_oT3aFC48cyDCCP6tdm6VEV_6RrNy4uo,272
12
+ h5netcdf-1.7.2.dist-info/licenses/LICENSE,sha256=Xer1Jg8iL_n9Da0xt0S99blk6tsg9tee_JdgH1rWTjs,1505
13
+ h5netcdf-1.7.2.dist-info/METADATA,sha256=_Gh6qQTBa-Oy7Q4wm8vMAoa7EJN1sdSHjjf2IuVMDb8,13396
14
+ h5netcdf-1.7.2.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
+ h5netcdf-1.7.2.dist-info/top_level.txt,sha256=Fb_KIpOE6MBqjSvxV1Ay7oYce1mdmQ1pO9JQJPDeGqg,9
16
+ h5netcdf-1.7.2.dist-info/RECORD,,
@@ -1,16 +0,0 @@
1
- h5netcdf/__init__.py,sha256=Y0EBCcmlJctwl1kCmj7yLijTVy9AioBTr2091vInAtw,456
2
- h5netcdf/_version.py,sha256=wcauG7D_isNqKUiP6L0WuH_5Dwe0oyUJa9LG3cC4WHk,704
3
- h5netcdf/attrs.py,sha256=GSq2lzv9q0tEkJBqr2Hyrwo0YJnWZHxtLRhhG9NVf4w,4575
4
- h5netcdf/core.py,sha256=Fg_68fF9vcyozlk-2vO1Qa0U_oRbvWfE976ax--CvxM,69698
5
- h5netcdf/dimensions.py,sha256=pxtt3ID55bTMp6djIpAka3RgXzioIUs9qBBgMqd9HhU,8336
6
- h5netcdf/legacyapi.py,sha256=MIZlht5Ad4hDFF1Slz2vXmKkgbv7Fhhf2YwNIe16Lfk,7682
7
- h5netcdf/utils.py,sha256=btxKI-VZP-Wn0Rk_wmnhnUls-mrxO42w0s_uX_su4FI,6528
8
- h5netcdf/tests/conftest.py,sha256=qS7XTZxos0NIRFtMCJwVEyx0paZw8Le1loPK1MtoQ_0,2350
9
- h5netcdf/tests/pytest.ini,sha256=ruJxrLdCIA4bCPVuPQjxsLSlvVxuIsIakK6iQOmz-ak,107
10
- h5netcdf/tests/test_h5netcdf.py,sha256=FWH2xJfIrBkUg7QEqOTvhrJYVvMU6flkDdkX-NWjI7s,117170
11
- h5netcdf-1.7.1.dist-info/licenses/AUTHORS.txt,sha256=LTKzUh9o4Wc_oT3aFC48cyDCCP6tdm6VEV_6RrNy4uo,272
12
- h5netcdf-1.7.1.dist-info/licenses/LICENSE,sha256=Xer1Jg8iL_n9Da0xt0S99blk6tsg9tee_JdgH1rWTjs,1505
13
- h5netcdf-1.7.1.dist-info/METADATA,sha256=tqEPGLxlIdLwfJjNy2NV60F_5jz95xr5YQ13KzfZa6I,13396
14
- h5netcdf-1.7.1.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
15
- h5netcdf-1.7.1.dist-info/top_level.txt,sha256=Fb_KIpOE6MBqjSvxV1Ay7oYce1mdmQ1pO9JQJPDeGqg,9
16
- h5netcdf-1.7.1.dist-info/RECORD,,