Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot set value to structured data by name which dtype's shape is multi-dimension #2317

Open
liyihc opened this issue Oct 3, 2023 · 0 comments

Comments

@liyihc
Copy link

liyihc commented Oct 3, 2023

import numpy as np
import h5py
f = h5py.File('new.h5', 'a')

# single dimension
e = f.create_dataset('e', shape=10,dtype=[('a', int), ('b', float, 6)])
# works
e['b'] == np.empty((10, 6), dtype=float)
# works
e['b'] = e['b'] 

# multi dimension
d = f.create_dataset('d', shape=10,dtype=[('a', int), ('b', float, (2,3))])

# works
d[0] = np.empty(1, dtype=[('a', int), ('b', float, (2,3))])
# ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.
d['b'] = d['b'] 
# ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.
d['b'] = np.empty((10, 2, 3), dtype=float)
# ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.
d['b', 0] = np.empty((2, 3), dtype=float)
# ValueError: When changing to a larger dtype, its size must be a divisor of the total size in bytes of the last axis of the array.
d['b', 0] = d['b', 0]

image

numpy doesn't have this problem

np_d = d[()]
# works
np_d['b'] =  np.empty((10, 2, 3), dtype=float)
# works
np_d['b'] = np_d['b']

image

h5py    3.9.0
HDF5    1.12.2
Python  3.10.4 | packaged by conda-forge | (main, Mar 30 2022, 08:38:02) [MSC v.1916 64 bit (AMD64)]
sys.platform    win32
sys.maxsize     9223372036854775807
numpy   1.23.3
cython (built with) 0.29.35
numpy (built against) 1.21.6
HDF5 (built against) 1.12.2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant