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

Function _check_data_shape

xarray/core/dataarray.py:198–227  ·  view source on GitHub ↗
(
    data: Any,
    coords: (
        Sequence[Sequence | pd.Index | DataArray | Variable | np.ndarray]
        | Mapping
        | None
    ),
    dims: str | Iterable[Hashable] | None,
)

Source from the content-addressed store, hash-verified

196
197
198def _check_data_shape(
199 data: Any,
200 coords: (
201 Sequence[Sequence | pd.Index | DataArray | Variable | np.ndarray]
202 | Mapping
203 | None
204 ),
205 dims: str | Iterable[Hashable] | None,
206) -> Any:
207 if data is dtypes.NA:
208 data = np.nan
209 if coords is not None and utils.is_scalar(data, include_0d=False):
210 if utils.is_dict_like(coords):
211 if dims is None:
212 return data
213 else:
214 data_shape = tuple(
215 (
216 as_variable(coords[k], k, auto_convert=False).size
217 if k in coords.keys()
218 else 1
219 )
220 for k in dims
221 )
222 else:
223 data_shape = tuple(
224 as_variable(coord, "foo", auto_convert=False).size for coord in coords
225 )
226 data = np.full(data_shape, data)
227 return data
228
229
230class _LocIndexer(Generic[T_DataArray]):

Callers 1

__init__Method · 0.85

Calls 2

as_variableFunction · 0.90
keysMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…