Return an array whose values are limited to ``[min, max]``. At least one of max or min must be given. Parameters ---------- min : None or Hashable, optional Minimum value. If None, no lower clipping is performed. max : None or Hashable, o
(
self,
min: ScalarOrArray | None = None,
max: ScalarOrArray | None = None,
*,
keep_attrs: bool | None = None,
)
| 460 | return self.isel(drop=drop, **dict.fromkeys(dims, 0)) |
| 461 | |
| 462 | def clip( |
| 463 | self, |
| 464 | min: ScalarOrArray | None = None, |
| 465 | max: ScalarOrArray | None = None, |
| 466 | *, |
| 467 | keep_attrs: bool | None = None, |
| 468 | ) -> Self: |
| 469 | """ |
| 470 | Return an array whose values are limited to ``[min, max]``. |
| 471 | At least one of max or min must be given. |
| 472 | |
| 473 | Parameters |
| 474 | ---------- |
| 475 | min : None or Hashable, optional |
| 476 | Minimum value. If None, no lower clipping is performed. |
| 477 | max : None or Hashable, optional |
| 478 | Maximum value. If None, no upper clipping is performed. |
| 479 | keep_attrs : bool or None, optional |
| 480 | If True, the attributes (`attrs`) will be copied from |
| 481 | the original object to the new one. If False, the new |
| 482 | object will be returned without attributes. |
| 483 | |
| 484 | Returns |
| 485 | ------- |
| 486 | clipped : same type as caller |
| 487 | This object, but with with values < min are replaced with min, |
| 488 | and those > max with max. |
| 489 | |
| 490 | See Also |
| 491 | -------- |
| 492 | numpy.clip : equivalent function |
| 493 | """ |
| 494 | from xarray.computation.apply_ufunc import apply_ufunc |
| 495 | |
| 496 | if keep_attrs is None: |
| 497 | # When this was a unary func, the default was True, so retaining the |
| 498 | # default. |
| 499 | keep_attrs = _get_keep_attrs(default=True) |
| 500 | |
| 501 | return apply_ufunc( |
| 502 | duck_array_ops.clip, self, min, max, keep_attrs=keep_attrs, dask="allowed" |
| 503 | ) |
| 504 | |
| 505 | def get_index(self, key: Hashable) -> pd.Index: |
| 506 | """Get an index for a dimension, with fall-back to a default RangeIndex""" |
nothing calls this directly
no test coverage detected