MCPcopy
hub / github.com/pydata/xarray / test_sel_float_multiindex

Method test_sel_float_multiindex

xarray/tests/test_dataarray.py:1211–1224  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1209 assert_equal(actual, expected)
1210
1211 def test_sel_float_multiindex(self) -> None:
1212 # regression test https://github.com/pydata/xarray/issues/5691
1213 # test multi-index created from coordinates, one with dtype=float32
1214 lvl1 = ["a", "a", "b", "b"]
1215 lvl2 = np.array([0.1, 0.2, 0.3, 0.4], dtype=np.float32)
1216 da = xr.DataArray(
1217 [1, 2, 3, 4], dims="x", coords={"lvl1": ("x", lvl1), "lvl2": ("x", lvl2)}
1218 )
1219 da = da.set_index(x=["lvl1", "lvl2"])
1220
1221 actual = da.sel(lvl1="a", lvl2=0.1)
1222 expected = da.isel(x=0)
1223
1224 assert_equal(actual, expected)
1225
1226 def test_sel_no_index(self) -> None:
1227 array = DataArray(np.arange(10), dims="x").assign_coords(

Callers

nothing calls this directly

Calls 4

set_indexMethod · 0.95
selMethod · 0.95
iselMethod · 0.95
assert_equalFunction · 0.90

Tested by

no test coverage detected