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
Extended JSON encode/decode protocol #12796
Conversation
👋 Thank you for your draft pull request! Do you know that you can use |
ae70171
to
60c06c0
Compare
15e355c
to
01499f4
Compare
@mhvk, I put a number of examples in the opening comment. I think the structured ndarray is still a little too verbose, but other than that, it's looking pretty good. Do you have any comments / suggestions? |
Hello @nstarman 👋! It looks like you've made some changes in your pull request, so I've checked the code again for style.
Comment last updated at 2022-02-16 02:57:43 UTC |
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
00184d5
to
b8cdc7b
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
5ff1b72
to
9480c84
Compare
Signed-off-by: Nathaniel Starkman (@nstarman) <nstarkman@protonmail.com>
9480c84
to
896acb7
Compare
896acb7
to
3a82a96
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had only time for a very rough look, but like that we may actually support json fully. Two main comments/questions:
- How will this deal with larger arrays? My sense is that the binary blob used for yaml may be the best solution for anything that is not a scalar. I do worry that
float128
does not seem to roundtrip exactly. I thought the numpy machinery took care of using the right number of significant digits. - I worry about duplication... Would it be possible to share some of the machinery with the yaml encoders/decoders? That would also have the advantage of making the representation uniform. Similarly, there is asdf which also encodes all the astropy classes (and seems based on a combination of yaml and json).
p.s. Small question: do we care about the names of structured units?
Thanks @mhvk.
The A binary blob might work nicely for non-scalars. I can use
That would be a very good idea! I'll look into it. I fear the YAML code is pretty tailored to the YAML library. Sharing machinery might require a refactor to the YAML code. But the uniformity is a compelling argument. Especially since YAML is a superset of JSON.
Yes! I will correct that. I'll need to test what happens when a structured array with dtype names encounters a structured unit with names... |
Yes. The YAML code is not easily compatible with JSON. Getting them to a common code base will require a lot of work. |
I don't think I have the time to refactor the YAML I/O until it can work with JSON. |
Signed-off-by: Nathaniel Starkman (@nstarman) nstarkman@protonmail.com
Closes #12793
Improvement suggestions appreciated.
I now have the shape of things, but details need filling in. I like the idea of the registration system and the entry points.
The tests need work: they are repetitive and should be shortened using pytest features.
This is the code pattern showing how the following examples are displayed
Checklist for package maintainer(s)
This checklist is meant to remind the package maintainer(s) who will review this pull request of some common things to look for. This list is not exhaustive.
Extra CI
label.no-changelog-entry-needed
label. If this is a manual backport, use theskip-changelog-checks
label unless special changelog handling is necessary.astropy-bot
check might be missing; do not let the green checkmark fool you.backport-X.Y.x
label(s) before merge.