-
-
Notifications
You must be signed in to change notification settings - Fork 404
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
Support for None in attrs for to_netcdf
#2365
Comments
What is the error message? |
Here's the error message:
Definitely closely related with how xarray stores their data |
My main recomendation would be to use zarr instead. It is faster and supports none in attributes. As for the feature, if you check what
so when you use Given this is about inferencedata attributes, this should be implemented here, and I think we'd all be fine with a PR, but that might become more confusing down the line because So again, I think the optimal solution is moving to zarr instead of working on patches on top of netcdf based stuff. I know for now netcdf/h5netcdf is a dependency of arviz, but the idea is for it to stop being it (and it already is only an optional dependency of |
We could have an option to "sanitize" attrs or even user could create one for their need. That said, in the long run it is better to be aware what goes in to attrs and have a "system" of good habits. I personally keep everything as a JSON string there. That ofc limits what I save in there, but really is a good way to keep attrs netcdf compatible. |
Tell us about it
I am writing an InferenceData to netcdf where the InferenceData uses the
attrs
where some of the values areNoneType
. This type is json serializable withjson.dumps
. However, there is ValueError from an arviz check.Workaround is to use json.dumps on the on None before making it a value of the
attrs
. However, that then requires it to be parsed from json afteraz.from_netcdf
which is an additional stepExample script:
Thoughts on implementation
None type would be support in the attrs of InferenceData
Note: this is coming from xarray so might be better issue there. However, I get a bit of a different issue
The text was updated successfully, but these errors were encountered: