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

Special treatment of NaN in JSON user attributes #412

Closed
meggart opened this issue Feb 27, 2019 · 3 comments
Closed

Special treatment of NaN in JSON user attributes #412

meggart opened this issue Feb 27, 2019 · 3 comments
Labels
bug Potential issues with the zarr-python library V2 Affects the v2 branch

Comments

@meggart
Copy link
Member

meggart commented Feb 27, 2019

This is a problem that showed up when testing the Zarr Julia interface. Currently nan-values in user-attribute values are not converted to strings (see example below), which does not adhere to JSON specs and causes the Julia JSON parser to fail. So I would suggest to do something analogous to the fill_value entry in .zarray, i.e. to either forbid nan in zarr user attributes or convert them to strings to make the resulting JSON valid.

import zarr
import numpy
z1 = zarr.open('attrtest')
z1.attrs['att1']=numpy.nan

with open('attrtest/.zattrs') as myfile:
    print(myfile.read())
@jakirkham jakirkham added the bug Potential issues with the zarr-python library label Feb 27, 2019
meggart added a commit to JuliaIO/Zarr.jl that referenced this issue Mar 22, 2019
@manzt
Copy link
Member

manzt commented Nov 13, 2020

Just want to keep track of this: zarr-developers/community#37 (comment)

NaN as fill_value seem to be converted to strings, but more care needs to be taken when parsing .zattrs in other languages since python will not but NaN into strings by default, and NaN is not valid JSON.

@Carreau
Copy link
Contributor

Carreau commented Nov 23, 2020

This is also related to zarr-developers/zarr-specs#81, the stdlib json does not respect the json spec, and we should decide what to do about this.

@jhamman
Copy link
Member

jhamman commented Oct 17, 2024

This was included in the v3 spec: https://zarr-specs.readthedocs.io/en/latest/v3/core/v3.0.html#fill-value

@jhamman jhamman closed this as completed Oct 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library V2 Affects the v2 branch
Projects
None yet
Development

No branches or pull requests

6 participants