h5netcdf 1.7.2__tar.gz → 1.7.3__tar.gz

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.

Files changed (33) hide show
  1. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/CHANGELOG.rst +5 -0
  2. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/PKG-INFO +1 -1
  3. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/_version.py +3 -3
  4. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/core.py +26 -19
  5. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/tests/test_h5netcdf.py +7 -0
  6. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf.egg-info/PKG-INFO +1 -1
  7. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/.pre-commit-config.yaml +0 -0
  8. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/AUTHORS.txt +0 -0
  9. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/LICENSE +0 -0
  10. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/README.rst +0 -0
  11. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/Makefile +0 -0
  12. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/api.rst +0 -0
  13. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/changelog.rst +0 -0
  14. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/conf.py +0 -0
  15. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/devguide.rst +0 -0
  16. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/feature.rst +0 -0
  17. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/index.rst +0 -0
  18. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/doc/legacyapi.rst +0 -0
  19. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/__init__.py +0 -0
  20. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/attrs.py +0 -0
  21. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/dimensions.py +0 -0
  22. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/legacyapi.py +0 -0
  23. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/tests/conftest.py +0 -0
  24. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/tests/pytest.ini +0 -0
  25. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf/utils.py +0 -0
  26. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf.egg-info/SOURCES.txt +0 -0
  27. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf.egg-info/dependency_links.txt +0 -0
  28. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf.egg-info/requires.txt +0 -0
  29. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/h5netcdf.egg-info/top_level.txt +0 -0
  30. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/licenses/H5PY_LICENSE.txt +0 -0
  31. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/licenses/PSF_LICENSE.txt +0 -0
  32. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/pyproject.toml +0 -0
  33. {h5netcdf-1.7.2 → h5netcdf-1.7.3}/setup.cfg +0 -0
@@ -1,6 +1,11 @@
1
1
  Change Log
2
2
  ----------
3
3
 
4
+ Version 1.7.3 (October 21st, 2025):
5
+
6
+ - Fix indexing with empty arrays and lists (:pull:``).
7
+ By `Kai Mühlbauer <https://github.com/kmuehlbauer>`_
8
+
4
9
  Version 1.7.2 (October 17th, 2025):
5
10
 
6
11
  - Fix regression where format was requested from group instance instead of _root. Simplify logic to check and raise ``CompatibilityError``. (:issue:`293`, :pull:`294`).
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h5netcdf
3
- Version: 1.7.2
3
+ Version: 1.7.3
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>
@@ -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.2'
32
- __version_tuple__ = version_tuple = (1, 7, 2)
31
+ __version__ = version = '1.7.3'
32
+ __version_tuple__ = version_tuple = (1, 7, 3)
33
33
 
34
- __commit_id__ = commit_id = 'g0a7fc48ba'
34
+ __commit_id__ = commit_id = 'g6bd08d40a'
@@ -55,20 +55,13 @@ def _invalid_netcdf_feature(feature, allow):
55
55
 
56
56
  def _transform_1d_boolean_indexers(key):
57
57
  """Find and transform 1D boolean indexers to int"""
58
- # return key, if not iterable
59
- try:
60
- key = [
61
- (
62
- np.asanyarray(k).nonzero()[0]
63
- if isinstance(k, (np.ndarray, list)) and type(k[0]) in (bool, np.bool_)
64
- else k
65
- )
66
- for k in key
67
- ]
68
- except TypeError:
69
- return key
70
-
71
- return tuple(key)
58
+ # Convert 1D boolean arrays/lists to integer indices,
59
+ # leaving all other types unchanged
60
+ return tuple(
61
+ np.flatnonzero(arr) if arr.dtype == bool else k
62
+ for k in key
63
+ for arr in [np.asanyarray(k)]
64
+ )
72
65
 
73
66
 
74
67
  def _expanded_indexer(key, ndim):
@@ -526,13 +519,27 @@ class BaseVariable(BaseObject):
526
519
  h5ds_shape = self._h5ds.shape
527
520
  shape = self.shape
528
521
 
529
- # check for ndarray and list
530
522
  # see https://github.com/pydata/xarray/issues/7154
523
+ # see https://github.com/pydata/xarray/issues/10867
531
524
  # first get maximum index
532
- max_index = [
533
- max(k) + 1 if isinstance(k, (np.ndarray, list)) else k.stop
534
- for k in key0
535
- ]
525
+ def _get_max_index(k):
526
+ # Return the maximum index for ndarray, list, slice, or int,
527
+ # handling empty arrays/lists safely
528
+ if isinstance(k, np.ndarray):
529
+ if k.size == 0:
530
+ return None
531
+ return k.max() + 1
532
+ elif isinstance(k, list):
533
+ return max(k) + 1 if k else None
534
+ elif isinstance(k, slice):
535
+ return k.stop
536
+ elif isinstance(k, int):
537
+ return k + 1
538
+ else:
539
+ return None
540
+
541
+ max_index = [_get_max_index(k) for k in key0]
542
+
536
543
  # second convert to max shape
537
544
  # we take the minimum of shape vs max_index to not return
538
545
  # slices larger than expected data
@@ -1973,6 +1973,13 @@ def test_fancy_indexing(tmp_local_or_remote_netcdf):
1973
1973
  np.testing.assert_array_equal(ds["hello"][[4, 5, 6], 1], [41, 0, 0])
1974
1974
  np.testing.assert_array_equal(ds["hello"][slice(4, 7), 1], [41, 0, 0])
1975
1975
 
1976
+ # test empty slices
1977
+ # regression test for https://github.com/pydata/xarray/pull/10870
1978
+ empty = np.empty(0, dtype="int64")
1979
+ np.testing.assert_array_equal(ds["hello"][1, []], empty)
1980
+ np.testing.assert_array_equal(ds["hello"][1, np.array([], dtype="int")], empty)
1981
+ np.testing.assert_array_equal(ds["hello"][1, slice(0, 0)], empty)
1982
+
1976
1983
 
1977
1984
  def test_h5py_chunking(tmp_local_netcdf):
1978
1985
  with h5netcdf.File(tmp_local_netcdf, "w") as ds:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: h5netcdf
3
- Version: 1.7.2
3
+ Version: 1.7.3
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>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes