zarr-python icon indicating copy to clipboard operation
zarr-python copied to clipboard

WIP: Add custom json encoder and decoder

Open constantinpape opened this issue 4 years ago • 5 comments

Add custom JsonEncoder / JsonDecoder to properly handle nan and inf attributes, see #412. Also adds a test to ensure these values are properly encoded / decoded. This is still WIP because:

  • I haven't tested the solution myself yet.
  • Potentially one could simplify the code here and here with this solution, but I am not sure this is a good idea, because I don't know if we can always assume that the metadata passes through zarr.util.json_dumps/json_loads
  • Potentially one could also add json encoding for numpy dtypes; this is an error that always annoys me a lot, but it's unrelated to #412.

TODO:

  • [x] Add unit tests and/or doctests in docstrings
  • [ ] Add docstrings and API docs for any new/modified user-facing classes and functions
  • [ ] New/modified features documented in docs/tutorial.rst
  • [ ] Changes documented in docs/release.rst
  • [ ] AppVeyor and Travis CI passes
  • [ ] Test coverage is 100% (Coveralls passes)

constantinpape avatar Jan 23 '20 20:01 constantinpape

Should the encoder/decoder bits be moved to Numcodecs?

jakirkham avatar Jan 23 '20 21:01 jakirkham

Should the encoder/decoder bits be moved to Numcodecs?

Happy to move it there if you think that would make more sense. Would you put it here?

constantinpape avatar Jan 23 '20 21:01 constantinpape

Tests pass, so the solution seems to be viable.

constantinpape avatar Jan 24 '20 08:01 constantinpape

Sorry, @constantinpape. Somehow I missed this when reviewing https://github.com/zarr-developers/zarr-python/pull/933 which maybe should been considered together.

joshmoore avatar May 06 '22 06:05 joshmoore

Zarr/JSON encoding came up again yesterday during the community call. I will try to resolve the conflicts here and see how things stand.

joshmoore avatar Sep 08 '22 08:09 joshmoore

This has unfortunately gone stale. Will it be revived or should we close this?

jhamman avatar Dec 07 '23 22:12 jhamman

Closing this out as stale. We'll keep the feature request open.

jhamman avatar Feb 13 '24 22:02 jhamman