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

Method _mapping_to_list

xarray/computation/rolling.py:234–252  ·  view source on GitHub ↗
(
        self,
        arg: _T | Mapping[Any, _T],
        default: _T | None = None,
        allow_default: bool = True,
        allow_allsame: bool = True,
    )

Source from the content-addressed store, hash-verified

232 count.__doc__ = _ROLLING_REDUCE_DOCSTRING_TEMPLATE.format(name="count")
233
234 def _mapping_to_list(
235 self,
236 arg: _T | Mapping[Any, _T],
237 default: _T | None = None,
238 allow_default: bool = True,
239 allow_allsame: bool = True,
240 ) -> list[_T]:
241 if utils.is_dict_like(arg):
242 if allow_default:
243 return [arg.get(d, default) for d in self.dim]
244 for d in self.dim:
245 if d not in arg:
246 raise KeyError(f"Argument has no dimension key {d}.")
247 return [arg[d] for d in self.dim]
248 if allow_allsame: # for single argument
249 return [arg] * self.ndim # type: ignore[list-item] # no check for negatives
250 if self.ndim == 1:
251 return [arg] # type: ignore[list-item] # no check for negatives
252 raise ValueError(f"Mapping argument is necessary for {self.ndim}d-rolling.")
253
254 def _get_keep_attrs(self, keep_attrs):
255 if keep_attrs is None:

Callers 3

__init__Method · 0.95
_constructMethod · 0.80
constructMethod · 0.80

Calls 1

getMethod · 0.45

Tested by

no test coverage detected