Skip to content

Should assert_identical also compare indexes? #11033

@ianhi

Description

@ianhi

What is your issue?

I would expect xr.testing.assert_identical to be true if the objects are identical, values, coords, attrs, and indexes. However, it does not test for what coords have an index attached to them. e.g i would expect this to fail, but it does not:

import xarray as xr

ds = xr.Dataset(
    {"data": ("time", [0, 1, 2, 3])},
    coords={"time": [0.1, 0.2, 0.3, 0.4], "time_metadata": ("time", [10, 15, 20, 25])},
)
ds_extra_index = ds.set_xindex("time_metadata")

xr.testing.assert_identical(ds, ds_extra_index)

I would contend that identical includes what has an index. But curious what others think

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs triageIssue that has not been reviewed by xarray team member

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions