Skip to content

Improve error message for missing coordinate index - #9370

Merged
TomNicholas merged 3 commits into
pydata:mainfrom
nicrie:fix-issue-9201
Aug 16, 2024
Merged

Improve error message for missing coordinate index#9370
TomNicholas merged 3 commits into
pydata:mainfrom
nicrie:fix-issue-9201

Conversation

@nicrie

Copy link
Copy Markdown
Contributor

This simple PR improves the error message for cases where a coordinate is missing its corresponding index. Previously, a generic ValueError was raised, but now the error message specifically mentions which coordinate is without an index.

Provide a more informative error message, specifically which coordinate is without index.
@max-sixty

Copy link
Copy Markdown
Collaborator

Looks good! Can we fix the test which matches on the previous error message?

@nicrienicrie left a comment

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, thanks for the tip! I didn't realize this error message had already been tested. I removed the new test and reused the old one.

Comment threadxarray/tests/test_combine.py Outdated
combine_by_coords([da_1, da_2])


def test_combine_by_coords_raises_for_no_index():

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FWIW this was a nice test because it included the coord name! But no great stress

@TomNicholasTomNicholas added the topic-combine combine/concat/merge label Aug 16, 2024

@TomNicholasTomNicholas left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice, thanks @nicrie !

@TomNicholas
TomNicholas merged commit 5693ac7 into pydata:mainAug 16, 2024
dcherian added a commit to dcherian/xarray that referenced this pull request Aug 17, 2024
* main:
Improve error message for missing coordinate index (pydata#9370)
Add flaky to TestNetCDF4ViaDaskData (pydata#9373)
Make chunk manager an option in `set_options` (pydata#9362)
Revise (pydata#9371)
Remove duplicate word from docs (pydata#9367)
Adding open_groups to BackendEntryPointEngine, NetCDF4BackendEntrypoint, and H5netcdfBackendEntrypoint (pydata#9243)
dcherian added a commit to TomNicholas/xarray that referenced this pull request Aug 22, 2024
* main: (214 commits)
Adds copy parameter to __array__ for numpy 2.0 (pydata#9393)
`numpy 2` compatibility in the `pydap` backend (pydata#9391)
pyarrow dependency added to doc environment (pydata#9394)
Extend padding functionalities (pydata#9353)
refactor GroupBy internals (pydata#9389)
Combine `UnsignedIntegerCoder` and `CFMaskCoder` (pydata#9274)
passing missing parameters to ZarrStore.open_store when opening a datatree (pydata#9377)
Fix tests on big-endian systems (pydata#9380)
Improve error message on `ds['x', 'y']` (pydata#9375)
Improve error message for missing coordinate index (pydata#9370)
Add flaky to TestNetCDF4ViaDaskData (pydata#9373)
Make chunk manager an option in `set_options` (pydata#9362)
Revise (pydata#9371)
Remove duplicate word from docs (pydata#9367)
Adding open_groups to BackendEntryPointEngine, NetCDF4BackendEntrypoint, and H5netcdfBackendEntrypoint (pydata#9243)
Revise (pydata#9366)
Fix rechunking to a frequency with empty bins. (pydata#9364)
whats-new entry for dropping python 3.9 (pydata#9359)
drop support for `python=3.9` (pydata#8937)
Revise (pydata#9357)
...
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic-combinecombine/concat/merge

Projects

Status: To do

Development

Successfully merging this pull request may close these issues.

Unclear error message when combine_by_coords doesn't find an index

3 participants

@nicrie@max-sixty@TomNicholas