Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 55a88f3

Browse files
authored
Merge pull request h5py#2529 from h5py/h5s-select-same-shape
Expose H5Sselect_shape_same function
2 parents b09a209 + 9fe4357 commit 55a88f3

File tree

4 files changed

+62
-0
lines changed

4 files changed

+62
-0
lines changed

h5py/api_functions.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,8 @@ hdf5:
495495
htri_t H5Sis_regular_hyperslab(hid_t spaceid)
496496
htri_t H5Sget_regular_hyperslab(hid_t spaceid, hsize_t* start, hsize_t* stride, hsize_t* count, hsize_t* block)
497497

498+
1.10.7 htri_t H5Sselect_shape_same(hid_t space1_id, hid_t space2_id)
499+
498500

499501
# === H5T - Datatypes =========================================================
500502

h5py/h5s.pyx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,10 @@ cdef class SpaceID(ObjectID):
394394
efree(start)
395395
efree(end)
396396

397+
IF HDF5_VERSION >= (1, 10, 7):
398+
@with_phil
399+
def select_shape_same(self, SpaceID space2):
400+
return <bint>H5Sselect_shape_same(self.id, space2.id)
397401

398402
@with_phil
399403
def select_all(self):

h5py/tests/test_h5s.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import pytest
2+
3+
from h5py import h5s, version
4+
from h5py._selector import Selector
5+
6+
class Helper:
7+
def __init__(self, shape: tuple):
8+
self.shape = shape
9+
10+
def __getitem__(self, item) -> h5s.SpaceID:
11+
if not isinstance(item, tuple):
12+
item = (item,)
13+
space = h5s.create_simple(self.shape)
14+
sel = Selector(space)
15+
sel.make_selection(item)
16+
return space
17+
18+
19+
@pytest.mark.skipif(version.hdf5_version_tuple < (1, 10, 7),
20+
reason='H5Sselect_shape_same not available')
21+
def test_same_shape():
22+
s1 = Helper((5, 6))[:3, :4]
23+
s2 = Helper((5, 6))[2:, 2:]
24+
assert s1.select_shape_same(s2)
25+
26+
s3 = Helper((5, 6))[:4, :3]
27+
assert not s1.select_shape_same(s3)

news/h5s-select-same-shape.rst

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
New features
2+
------------
3+
4+
* <news item>
5+
6+
Deprecations
7+
------------
8+
9+
* <news item>
10+
11+
Exposing HDF5 functions
12+
-----------------------
13+
14+
* ``H5Sselect_shape_same`` exposed as :meth:`.SpaceID.select_shape_same`.
15+
16+
Bug fixes
17+
---------
18+
19+
* <news item>
20+
21+
Building h5py
22+
-------------
23+
24+
* <news item>
25+
26+
Development
27+
-----------
28+
29+
* <news item>

0 commit comments

Comments
 (0)