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

Function test_vectorized_indexing

properties/test_coordinate_transform.py:120–135  ·  view source on GitHub ↗

Test vectorized indexing produces identical results for transform and pandas index.

(data, sizes)

Source from the content-addressed store, hash-verified

118 xrst.dimension_sizes(min_dims=2, max_dims=3, min_side=1, max_side=5),
119)
120def test_vectorized_indexing(data, sizes):
121 """Test vectorized indexing produces identical results for transform and pandas index."""
122 pandas_da = create_pandas_da(sizes)
123 transform_da = create_transform_da(sizes)
124 idxr = data.draw(xrst.vectorized_indexers(sizes=sizes))
125 pandas_result = pandas_da.isel(idxr)
126 transform_result = transform_da.isel(idxr)
127 assert_equal(pandas_result, transform_result)
128
129 label_idxr = {
130 dim: ind.copy(data=np.arange(pandas_da.sizes[dim])[ind.data])
131 for dim, ind in idxr.items()
132 }
133 pandas_result = pandas_da.sel(label_idxr, method="nearest")
134 transform_result = transform_da.sel(label_idxr, method="nearest")
135 assert_equal(pandas_result, transform_result)

Callers

nothing calls this directly

Calls 8

assert_equalFunction · 0.90
create_pandas_daFunction · 0.85
create_transform_daFunction · 0.85
arangeMethod · 0.80
itemsMethod · 0.80
iselMethod · 0.45
copyMethod · 0.45
selMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…