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

Improve dtype for compound datasets #69

Merged
merged 1 commit into from
Jun 15, 2022
Merged

Improve dtype for compound datasets #69

merged 1 commit into from
Jun 15, 2022

Conversation

loichuder
Copy link
Member

@loichuder loichuder commented Jun 14, 2022

Let's take the example from Numpy:

with h5py.File("test.h5", "w") as h5file:
    h5file.create_dataset(
                "dogs",
                data=np.array(
                    [("Rex", 9, 81.0), ("Fido", 3, 27.0)],
                    dtype=[("name", "S10"), ("age", "i4"), ("weight", "f4")],
                ),
            )

When asking for the metadata, h5grove was returning:

{
  ...
  dtype='|V18'
}

Now it returns

{
  ...
  dtype={"name": "|S10", "age": "<i4", "weight": "<f4"}
}

@loichuder loichuder requested a review from t20100 June 14, 2022 15:21
@t20100
Copy link
Member

t20100 commented Jun 14, 2022

It seems compound types are recursive...

with h5py.File("test.h5", "w") as h5file: 
    h5file.create_dataset( 
        "dogs", 
        data=np.array( 
            [("Rex", (9, 81.0)), ("Fido", (3, 27.0))], 
            dtype=[("name", "S10"), ("combo", [("age", "i4"), ("weight", "f4")])], 
        ), 
    ) 

Do you want to support that?... else that would give {'name=': '|S10', 'combo': '|V8'}

Copy link
Member

@t20100 t20100 left a comment

Choose a reason for hiding this comment

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

LGTM, unless you want to handle recursive compound types.

@loichuder
Copy link
Member Author

Do you want to support that?

Yeah it is not much to add to support it. It just make the return type recursive which cannot be linted by mypy as it is not supported 😞 python/mypy#731

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