Datasets:
Formats:
csv
Languages:
English
Size:
< 1K
Tags:
robotics
embodied-ai
human-demonstration
egocentric-video
bimanual-manipulation
tactile-sensing
License:
File size: 2,215 Bytes
2325508 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 | import numpy as np
from h5py import h5s
from h5py._selector import Selector
class Helper:
def __init__(self, shape: tuple):
self.shape = shape
def __getitem__(self, item) -> h5s.SpaceID:
if not isinstance(item, tuple):
item = (item,)
space = h5s.create_simple(self.shape)
sel = Selector(space)
sel.make_selection(item)
return space
def test_same_shape():
s1 = Helper((5, 6))[:3, :4]
s2 = Helper((5, 6))[2:, 2:]
assert s1.select_shape_same(s2)
s3 = Helper((5, 6))[:4, :3]
assert not s1.select_shape_same(s3)
def test_select_copy():
s1 = h5s.create_simple((50,))
s1.select_hyperslab((5,), (1,), block=(5,), op=h5s.SELECT_SET)
s2 = h5s.create_simple((50,))
s2.select_hyperslab((23,), (1,), block=(3,), op=h5s.SELECT_SET)
s2.select_copy(s1)
np.testing.assert_array_equal(
s1.get_select_hyper_blocklist(), s2.get_select_hyper_blocklist()
)
def test_combine_select():
# combine_select should create a new space without modifying the original
s1 = h5s.create_simple((50,))
s1.select_hyperslab((5,), (1,), block=(5,), op=h5s.SELECT_SET)
s2 = h5s.create_simple((50,))
s2.select_hyperslab((20,), (1,), block=(2,), op=h5s.SELECT_SET)
s3 = s1.combine_select(s2, op=h5s.SELECT_OR)
s2.select_hyperslab((5,), (1,), block=(5,), op=h5s.SELECT_OR)
np.testing.assert_array_equal(
s3.get_select_hyper_blocklist(), s2.get_select_hyper_blocklist()
)
assert not np.array_equal(
s3.get_select_hyper_blocklist(), s1.get_select_hyper_blocklist()
)
def test_modify_select():
# combine_select should create a new space without modifying the original
s1 = h5s.create_simple((50,))
s1.select_hyperslab((5,), (1,), block=(5,), op=h5s.SELECT_SET)
s2 = h5s.create_simple((50,))
s2.select_hyperslab((20,), (1,), block=(2,), op=h5s.SELECT_SET)
s1.modify_select(s2, op=h5s.SELECT_OR)
s2.select_hyperslab((5,), (1,), block=(5,), op=h5s.SELECT_OR)
np.testing.assert_array_equal(
s1.get_select_hyper_blocklist(), s2.get_select_hyper_blocklist()
)
|