mirror of
https://github.com/p2p-ld/numpydantic.git
synced 2024-11-12 17:54:29 +00:00
fix setting values
This commit is contained in:
parent
290a72f8ca
commit
2a93694cfc
2 changed files with 14 additions and 3 deletions
|
@ -112,9 +112,13 @@ class H5Proxy:
|
|||
):
|
||||
with h5py.File(self.file, "r+", locking=True) as h5f:
|
||||
obj = h5f.get(self.path)
|
||||
if self.field is not None:
|
||||
obj = obj.fields(self.field)
|
||||
obj[key] = value
|
||||
if self.field is None:
|
||||
obj[key] = value
|
||||
else:
|
||||
if isinstance(key, tuple):
|
||||
obj[*key, self.field] = value
|
||||
else:
|
||||
obj[key, self.field] = value
|
||||
|
||||
def open(self, mode: str = "r") -> "h5py.Dataset":
|
||||
"""
|
||||
|
|
|
@ -150,3 +150,10 @@ def test_compound_dtype(tmp_path):
|
|||
assert instance.array.dtype == np.dtype("int64")
|
||||
assert instance.array.shape == (10, 20)
|
||||
assert instance.array[0, 0] == 0
|
||||
|
||||
# set values too
|
||||
instance.array[0, :] = 1
|
||||
assert all(instance.array[0, :] == 1)
|
||||
assert all(instance.array[1, :] == 0)
|
||||
instance.array[1] = 2
|
||||
assert all(instance.array[1] == 2)
|
||||
|
|
Loading…
Reference in a new issue