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

Function test_tree_index_init

xarray/tests/test_nd_point_index.py:19–34  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17
18@requires_scipy
19def test_tree_index_init() -> None:
20 from xarray.indexes.nd_point_index import ScipyKDTreeAdapter
21
22 xx, yy = np.meshgrid([1.0, 2.0], [3.0, 4.0])
23 ds = xr.Dataset(coords={"xx": (("y", "x"), xx), "yy": (("y", "x"), yy)})
24
25 ds_indexed1 = ds.set_xindex(("xx", "yy"), NDPointIndex)
26 assert "xx" in ds_indexed1.xindexes
27 assert "yy" in ds_indexed1.xindexes
28 assert isinstance(ds_indexed1.xindexes["xx"], NDPointIndex)
29 assert ds_indexed1.xindexes["xx"] is ds_indexed1.xindexes["yy"]
30
31 ds_indexed2 = ds.set_xindex(
32 ("xx", "yy"), NDPointIndex, tree_adapter_cls=ScipyKDTreeAdapter
33 )
34 assert ds_indexed1.xindexes["xx"].equals(ds_indexed2.xindexes["yy"])
35
36
37@requires_scipy

Callers

nothing calls this directly

Calls 2

set_xindexMethod · 0.95
equalsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…