(
self,
arg: _T | Mapping[Any, _T],
default: _T | None = None,
allow_default: bool = True,
allow_allsame: bool = True,
)
| 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: |
no test coverage detected