Skip to content

Commit

Permalink
fix test_dataset_fancyselect to work with h5py
Browse files Browse the repository at this point in the history
  • Loading branch information
jreadey committed Sep 30, 2024
1 parent 23ef3c6 commit c50c2e1
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions test/hl/test_dataset_fancyselect.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,6 @@ def test_bigdset(self):
f = h5py.File(filename, "w")
# create a dataset
dset = f.create_dataset("dset", (5, 1000, 1000), dtype="i4", compression="gzip")
print(dset.id.id)
# write some values to the dataset
dset[:, 1, 10] = [95, 96, 97, 98, 99]
dset[:, 10, 100] = [195, 196, 197, 198, 199]
Expand All @@ -123,19 +122,27 @@ def test_bigdset(self):
self.assertTrue((arr[:, 1] == [195, 196, 197, 198, 199]).all())
self.assertTrue((arr[:, 2] == [0, 0, 0, 0, 0]).all())

# non-increasing indexes
arr = dset[:, 10, [100, 10, 500]]
self.assertEqual(arr.shape, (5, 3))
self.assertTrue((arr[:, 0] == [195, 196, 197, 198, 199]).all())
self.assertTrue((arr[:, 1] == [0, 0, 0, 0, 0]).all())
self.assertTrue((arr[:, 2] == [0, 0, 0, 0, 0]).all())
try:
# non-increasing indexes
arr = dset[:, 10, [100, 10, 500]]
self.assertEqual(arr.shape, (5, 3))
self.assertTrue((arr[:, 0] == [195, 196, 197, 198, 199]).all())
self.assertTrue((arr[:, 1] == [0, 0, 0, 0, 0]).all())
self.assertTrue((arr[:, 2] == [0, 0, 0, 0, 0]).all())

# test multiple coordinates
arr = dset[:, [1, 10, 100], [10, 100, 500]]
self.assertEqual(arr.shape, (5, 3))
self.assertTrue((arr[:, 0] == [95, 96, 97, 98, 99]).all())
self.assertTrue((arr[:, 1] == [195, 196, 197, 198, 199]).all())
self.assertTrue((arr[:, 2] == [295, 296, 297, 298, 299]).all())
except TypeError:
if config.get("use_h5py"):
pass # multiple indexing vectors not allowed with h5py
else:
self.assertTrue(False) # but should be ok with h5pyd/hsds

# test multiple coordinates
arr = dset[:, [1, 10, 100], [10, 100, 500]]
self.assertEqual(arr.shape, (5, 3))
self.assertTrue((arr[:, 0] == [95, 96, 97, 98, 99]).all())
self.assertTrue((arr[:, 1] == [195, 196, 197, 198, 199]).all())
self.assertTrue((arr[:, 2] == [295, 296, 297, 298, 299]).all())
f.close()


if __name__ == '__main__':
Expand Down

0 comments on commit c50c2e1

Please sign in to comment.