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

Function create_pandas_da

properties/test_coordinate_transform.py:62–69  ·  view source on GitHub ↗

Create a DataArray with standard PandasIndex (range index).

(sizes: dict[str, int])

Source from the content-addressed store, hash-verified

60
61
62def create_pandas_da(sizes: dict[str, int]) -> xr.DataArray:
63 """Create a DataArray with standard PandasIndex (range index)."""
64 shape = tuple(sizes.values())
65 data = np.arange(np.prod(shape)).reshape(shape)
66 coords = {dim: np.arange(size) for dim, size in sizes.items()}
67 return xr.DataArray(
68 data, dims=list(sizes.keys()), coords=coords, name=DATA_VAR_NAME
69 )
70
71
72@given(

Callers 3

test_basic_indexingFunction · 0.85
test_outer_indexingFunction · 0.85
test_vectorized_indexingFunction · 0.85

Calls 5

arangeMethod · 0.80
itemsMethod · 0.80
keysMethod · 0.80
valuesMethod · 0.45
prodMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…