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

Add documentation part about custom serializers #39

Closed
wants to merge 1 commit into from

Conversation

futurwasfree
Copy link
Contributor

@futurwasfree futurwasfree commented Mar 16, 2024

Doc(README): add documentation part about custom serializers
Chore(version): bump PATCH

Partial of #38

Copy link
Owner

@caniko caniko left a comment

Choose a reason for hiding this comment

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

I appreciate the quick reaction! Apologies for being so late on the review.

Recently implemented a fix for #37, we merge after.

README.md Outdated
Comment on lines 72 to 73
If you're not happy with default `NumpyDataDict` serialization, as defined in [typing.py](./pydantic_numpy/helper/typing.py), you could define your own type with custom serializer using `NpArrayPydanticAnnotation.factory`
and its `serialize_numpy_array_to_json` argument taking `Callable[[npt.ArrayLike], Iterable]`.
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe something like this?

Suggested change
If you're not happy with default `NumpyDataDict` serialization, as defined in [typing.py](./pydantic_numpy/helper/typing.py), you could define your own type with custom serializer using `NpArrayPydanticAnnotation.factory`
and its `serialize_numpy_array_to_json` argument taking `Callable[[npt.ArrayLike], Iterable]`.
If the default serialization of NumpyDataDict, as outlined in [typing.py](https://chat.openai.com/c/pydantic_numpy/helper/typing.py), doesn't meet your requirements, you have the option to define a custom type with its own serializer. This can be achieved using the NpArrayPydanticAnnotation.factory method, which accepts a custom serialization function through its serialize_numpy_array_to_json parameter. This parameter expects a function of the form Callable[[npt.ArrayLike], Iterable], allowing you to tailor the serialization process to your specific needs.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's the better wording, fixed it!

P.S. Wondering how did chat.openai.com ended up in your example url? 1st of April? :)

Copy link
Owner

Choose a reason for hiding this comment

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

No comment 😆

@caniko
Copy link
Owner

caniko commented Apr 19, 2024

Fixed with #43

@caniko caniko closed this Apr 19, 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

Successfully merging this pull request may close these issues.

2 participants