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

Method _parse_dimensions

xarray/namedarray/core.py:502–519  ·  view source on GitHub ↗
(self, dims: _DimsLike)

Source from the content-addressed store, hash-verified

500 self._dims = self._parse_dimensions(value)
501
502 def _parse_dimensions(self, dims: _DimsLike) -> _Dims:
503 dims = (dims,) if isinstance(dims, str) else tuple(dims)
504 if len(dims) != self.ndim:
505 raise ValueError(
506 f"dimensions {dims} must have the same length as the "
507 f"number of data dimensions, ndim={self.ndim}"
508 )
509 if len(set(dims)) < len(dims):
510 repeated_dims = {d for d in dims if dims.count(d) > 1}
511 warnings.warn(
512 f"Duplicate dimension names present: dimensions {repeated_dims} appear more than once in dims={dims}. "
513 "We do not yet support duplicate dimension names, but we do allow initial construction of the object. "
514 "We recommend you rename the dims immediately to become distinct, as most xarray functionality is likely to fail silently if you do not. "
515 "To rename the dimensions you will need to set the ``.dims`` attribute of each variable, ``e.g. var.dims=('x0', 'x1')``.",
516 UserWarning,
517 stacklevel=2,
518 )
519 return dims
520
521 @property
522 def attrs(self) -> dict[Any, Any]:

Callers 2

__init__Method · 0.95
dimsMethod · 0.95

Calls 1

countMethod · 0.45

Tested by

no test coverage detected