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

Correctly describe the serialization format in the JSON schema #37

Closed
multimeric opened this issue Mar 14, 2024 · 4 comments
Closed

Correctly describe the serialization format in the JSON schema #37

multimeric opened this issue Mar 14, 2024 · 4 comments

Comments

@multimeric
Copy link

Currently, an Np1DArrayFp64 will generate a JSON schema with the following type:

"type": "np.ndarray[tuple[int], np.dtype[float64]"

This is incorrect, as I don't think it's a valid JSON schema type at all. What it should return is the JSON schema describing a NumpyDataDict, which is already in the repo:

class NumpyDataDict(TypedDict):
data_type: str
data: list

@multimeric
Copy link
Author

Here's a reproducible example:

>>> from pydantic.type_adapter import TypeAdapter
>>> from pydantic_numpy.typing import Np1DArrayFp64
>>> TypeAdapter(Np1DArrayFp64).json_schema()
{'strict_data_typing': False, 'type': 'np.ndarray[tuple[int], np.dtype[float64]'}

@caniko caniko added the bug Something isn't working label Mar 14, 2024
@multimeric
Copy link
Author

Are you open to a PR fixing this? Because it's moderately important to my use case.

@caniko
Copy link
Owner

caniko commented Mar 22, 2024

I will fix it, but it will have to wait till April. Welcome to make a PR if you can't wait in the meantime.

@caniko caniko removed the bug Something isn't working label Apr 1, 2024
@caniko
Copy link
Owner

caniko commented Apr 12, 2024

Fixed with #41

@caniko caniko closed this as completed Apr 12, 2024
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

2 participants