py: boolean-mask keys raise NotImplementedError, not TypeError
h5py supports boolean masks for reads and writes; clawhdf5 supports neither, so a mask is an unsupported operation (NotImplementedError, as for every other edit the bindings cannot do), not an invalid key. Tests: test_unsupported_edits_are_clear_errors (1-D, N-D and per-axis mask writes, file unchanged) and test_boolean_masks_are_refused (reads). Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
@@ -643,6 +643,13 @@ def test_unsupported_edits_are_clear_errors(h5py, tmp_path):
|
||||
f["chunk_ext"].resize(3, axis=2)
|
||||
with pytest.raises(TypeError):
|
||||
f["i4"][0] = np.array(["a"] * 10)
|
||||
# h5py writes through boolean masks; clawhdf5 does not.
|
||||
with pytest.raises(NotImplementedError, match="mask"):
|
||||
f["u1"][np.arange(16) % 2 == 0] = 5
|
||||
with pytest.raises(NotImplementedError, match="mask"):
|
||||
f["i4"][f["i4"][()] > 30] = 0
|
||||
with pytest.raises(NotImplementedError, match="mask"):
|
||||
f["i4"][np.ones(6, dtype=bool), 2] = 0
|
||||
assert snapshot(h5py, path) == before
|
||||
h5dump_reads(path)
|
||||
|
||||
|
||||
@@ -440,7 +440,7 @@ def test_unsupported_types_are_errors_not_data(pair):
|
||||
|
||||
def test_boolean_masks_are_refused(pair):
|
||||
ours, _, _ = pair
|
||||
with pytest.raises(TypeError):
|
||||
with pytest.raises(NotImplementedError, match="mask"):
|
||||
ours["num/le_i4_1d"][np.ones(37, dtype=bool)]
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user