Skip to content
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

Fix arrangement of test_infer_bounds_errors after xarray v2023.08.0 #151

Merged
merged 1 commit into from
Aug 22, 2023

Conversation

JoerivanEngelen
Copy link
Contributor

@JoerivanEngelen JoerivanEngelen commented Aug 22, 2023

A test is failing due to the most recent xarray v2023.08.0 update. Apparently the indexes attribute is not updated anymore when setting values on coordinates as follows:

up = xr.DataArray(
        data=np.arange(4),
        coords={"x": [2.0, 4.0, 6.0, 8.0]},
        dims=["x"],
        name="grid",
    )

up["x"].values[2] = 3.0

print(up["x"].indexes)
# up["x"].indexes not updated

But this works:

up = up.assign_coords(x = [2.0, 4.0, 3.0, 8.0])

print(up["x"].indexes)
# up["x"].indexes are updated

It turns out the first example is not what the xarray devs have in mind on how coords should be set, so this explains why this test is failing without this fix.

@JoerivanEngelen JoerivanEngelen merged commit 4d8ebd0 into main Aug 22, 2023
2 checks passed
@JoerivanEngelen JoerivanEngelen deleted the fix_test_xarray_202308 branch August 22, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant