-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Confusing error (or lack thereof) when coordinate and variable share the same name #631
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
Comments
Oh my, this certainly does look like a bug (or several). |
This is related to #457. In the first case, I think that the error message must be improved, but I do not think that Error is itself is a bug. From the netCDF data model point of view, it does not make sense to define a two dimensional variable sharing the name with a one-dimensional coordinate. The second example does look like a bug, as it should raise an error too, in my opinion, as the function Dataset is given contradictory information (two different sets of values for the same variable "a"). In netCDF files you cannot have two variables with the same name, and coordinate variables are just regular variables. |
Yes, @markelg I think you describe each of these issues correctly. They should each result in more informative errors. |
The first example here was fixed in #1539. The second issue still exists but now requires In [9]: Dataset({"a": DataArray(np.zeros(3), dims='a', coords={"a": list("xyz")})})
...:
...:
Out[9]:
<xarray.Dataset>
Dimensions: (a: 3)
Coordinates:
* a (a) float64 0.0 0.0 0.0
Data variables:
*empty* Do we agree it is safe to say that no key should be repeated between |
Adding a v confusing error message which my colleague just hit (not exactly the same as this, but thought it wasn't worth a whole new issue):
...nothing to do with the |
All given examples work in recent xarray 2024.10.0. Please reopen with updated examples, if this is still an issue. |
It probably makes sense to prevent dataset to have variables sharing the names of coordinates (what would
dataset.varname
return?) but currentlyfails with
ValueError: an index variable must be defined with 1-dimensional data
, andactually creates an empty dataset using
[0, 0, 0]
as values for thea
coordinate instead ofx y z
:The text was updated successfully, but these errors were encountered: