-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Unclear error message when combine_by_coords doesn't find an index #9201
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
Hi @TomNicholas, I want to work on this issue. I'm new to the open-source world and eager to contribute. I'm currently going through the "How to Contribute" documentation. Could you please assign this issue to me? Thank you! |
Hi @Shripad1020! Thanks for your interest. We don't generally assign issues to people but you're welcome to submit a pull request. I think the trickiest part of this issue for a newcomer would be making a pure-xarray reproducer, but I can help you with that. |
Thank you for your response! I appreciate your offer to help with making a pure-xarray reproducer. I have gone through the xarray documentation and have a brief idea of what it is and how it works. Could you please explain more about what you mean by making a pure-xarray reproducer? |
Have you used xarray before?
Generally when raising an issue it is encouraged to post a snippet of code that reproduces the bug, where that code snippet is as simple as possible whilst still exposing the bug. In my example above I was a little lazy, and posted a snippet which uses another library which wraps xarray to reproduce a bug that's inside xarray. If my example had not used any other library it would be a "pure xarray reproducer" of the bug. One reason it's encouraged to post a pure xarray reproducer is that any pull request to fix a bug should included a new unit test to test that the bug has been fixed. These unit tests need to be written into xarray's test suite, and so cannot rely on external libraries. The pure xarray reproducer (also known as an MCVE) is usually a good starting point for this unit test. |
I guess the following works as a pure xarray reproducer: import xarray as xt
da1 = xr.DataArray([1, 2, 3], dims="x", coords={"x": [1, 2, 3]})
da2 = xr.DataArray([1, 2, 3], dims="x", coords={"x": [4, 5, 6]})
da1 = da1.drop_indexes("x")
da2 = da2.drop_indexes("x")
xr.combine_by_coords([da1, da2]) resulting in
|
What is your issue?
The error you get from inside
xr.combine_by_coords
when a 1D dimension coordinate is not backed by an index uses outdated verbiage. That's because it predates the indexes refactor, and this fail case wasn't anticipated at the time of writing.The reproducer below uses the
VirtualiZarr
package, but only as a shortcut to generate a dataset that has 1D coordinates not backed by indexes. You could construct a pure-xarray reproducer.In this reproducer the dimension
time
has a coordinate, it just doesn't have an index backing that coordinate. The error message also doesn't say which dimension is the problem.This error message should say something more like
"ValueError: Every dimension requires a corresponding 1D coordinate and index for inferring concatenation order but the coordinate 'time' has no corresponding index"
One could even argue that the name
combine_by_coords
should really becombine_using_indexes
...The text was updated successfully, but these errors were encountered: