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

Support correct settings of vlen float arrays #194

Merged
merged 4 commits into from
May 7, 2024
Merged

Support correct settings of vlen float arrays #194

merged 4 commits into from
May 7, 2024

Conversation

jreadey
Copy link
Member

@jreadey jreadey commented May 6, 2024

With vlen datatypes, writing to the dataset would raise an error if the vlen types were uniform. i.e., an array like:

[ndarray[1, 2], ndarray[3,4], ndarray[5,6]] would be processed as [[1,2],[3,4],[5,6]] (a shape of (3,2) during the arrayToBytes conversion rather than (3), causing a broadcast error. This PR fixes that so the data can be written to the expected shape.

@jreadey jreadey requested a review from mattjala May 6, 2024 16:18

data = np.array([e0, e1], dtype=dtvlen)
try:
# This will fail on HSDS because data is a ndarray of shape (2,3) of floats
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this something that should fail due to how the API is defined, or just a bug?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like this is a bug in h5py. I'll submit an issue, but I expect they'll tell me the answer is to just set the dataset element by element in this case.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this example: https://gist.github.com/jreadey/884b59a30090b0f8122c3ab51291aa6c.

dset[...] = arr

Attempts to write to a shape (2,) dataset with a shape (2,) numpy array, but fails with a broadcast error.
Seems like a bug in h5py, so the test case has a special handler for the test running in h5py for now.

@mattjala mattjala merged commit f783446 into master May 7, 2024
20 checks passed
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

Successfully merging this pull request may close these issues.

2 participants