MCPcopy Index your code
hub / github.com/pydata/xarray / test_tree_index_sel_errors

Function test_tree_index_sel_errors

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

Source from the content-addressed store, hash-verified

121
122@requires_scipy
123def test_tree_index_sel_errors() -> None:
124 xx, yy = np.meshgrid([1.0, 2.0], [3.0, 4.0])
125 ds = xr.Dataset(coords={"xx": (("y", "x"), xx), "yy": (("y", "x"), yy)}).set_xindex(
126 ("xx", "yy"), NDPointIndex
127 )
128
129 with pytest.raises(ValueError, match="method='nearest'"):
130 ds.sel(xx=1.1, yy=3.1)
131
132 with pytest.raises(ValueError, match="missing labels"):
133 ds.sel(xx=1.1, method="nearest")
134
135 with pytest.raises(ValueError, match="invalid label value"):
136 # invalid array-like dimensions
137 ds.sel(xx=[1.1, 1.9], yy=[3.1, 3.9], method="nearest")
138
139 # error while trying to broadcast labels
140 with pytest.raises(xr.AlignmentError, match=r".*conflicting dimension sizes"):
141 ds.sel(
142 xx=xr.Variable("u", [1.1, 1.1, 1.1]),
143 yy=xr.Variable("u", [3.1, 3.1]),
144 method="nearest",
145 )
146
147
148@requires_scipy

Callers

nothing calls this directly

Calls 2

set_xindexMethod · 0.45
selMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…