You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Under the assumption that deterministic output is preferred whenever feasible, I'd like to point out that the variable names written into "coordinates" attributes with .to_netcdf are not ordered deterministically. For pipelines that depend on file hashes to validate dependencies, this can be a real headache.
Consider the dataset xarray.Dataset({"x": ((), 0)}, coords={"a": 0, "b": 0}). The NetCDF file XArray writes will include either:
variables:
int64 x ;
x:coordinates = "a b" ;
int64 a ;
int64 b ;
or
variables:
int64 x ;
x:coordinates = "b a" ;
int64 a ;
int64 b ;
My review of _encode_coordinates leads me to think the behavior results from collecting names in a set. I'd be happy to offer a PR to make the coordinates attribute deterministic. I am not aware of a CF convention regarding any ordering, but would research and follow if it exists. If not, then I would probably sort at L701 and L722.
The text was updated successfully, but these errors were encountered:
What is your issue?
Under the assumption that deterministic output is preferred whenever feasible, I'd like to point out that the variable names written into "coordinates" attributes with
.to_netcdf
are not ordered deterministically. For pipelines that depend on file hashes to validate dependencies, this can be a real headache.Consider the dataset
xarray.Dataset({"x": ((), 0)}, coords={"a": 0, "b": 0})
. The NetCDF file XArray writes will include either:or
My review of
_encode_coordinates
leads me to think the behavior results from collecting names in aset
. I'd be happy to offer a PR to make the coordinates attribute deterministic. I am not aware of a CF convention regarding any ordering, but would research and follow if it exists. If not, then I would probablysort
at L701 and L722.The text was updated successfully, but these errors were encountered: