|
45 | 45 | DatetimeLike,
|
46 | 46 | DTypeLikeSave,
|
47 | 47 | ScalarOrArray,
|
| 48 | + Self, |
48 | 49 | SideOptions,
|
49 | 50 | T_Chunks,
|
50 | 51 | T_DataWithCoords,
|
@@ -381,11 +382,11 @@ class DataWithCoords(AttrAccessMixin):
|
381 | 382 | __slots__ = ("_close",)
|
382 | 383 |
|
383 | 384 | def squeeze(
|
384 |
| - self: T_DataWithCoords, |
| 385 | + self, |
385 | 386 | dim: Hashable | Iterable[Hashable] | None = None,
|
386 | 387 | drop: bool = False,
|
387 | 388 | axis: int | Iterable[int] | None = None,
|
388 |
| - ) -> T_DataWithCoords: |
| 389 | + ) -> Self: |
389 | 390 | """Return a new object with squeezed data.
|
390 | 391 |
|
391 | 392 | Parameters
|
@@ -414,12 +415,12 @@ def squeeze(
|
414 | 415 | return self.isel(drop=drop, **{d: 0 for d in dims})
|
415 | 416 |
|
416 | 417 | def clip(
|
417 |
| - self: T_DataWithCoords, |
| 418 | + self, |
418 | 419 | min: ScalarOrArray | None = None,
|
419 | 420 | max: ScalarOrArray | None = None,
|
420 | 421 | *,
|
421 | 422 | keep_attrs: bool | None = None,
|
422 |
| - ) -> T_DataWithCoords: |
| 423 | + ) -> Self: |
423 | 424 | """
|
424 | 425 | Return an array whose values are limited to ``[min, max]``.
|
425 | 426 | At least one of max or min must be given.
|
@@ -472,10 +473,10 @@ def _calc_assign_results(
|
472 | 473 | return {k: v(self) if callable(v) else v for k, v in kwargs.items()}
|
473 | 474 |
|
474 | 475 | def assign_coords(
|
475 |
| - self: T_DataWithCoords, |
| 476 | + self, |
476 | 477 | coords: Mapping[Any, Any] | None = None,
|
477 | 478 | **coords_kwargs: Any,
|
478 |
| - ) -> T_DataWithCoords: |
| 479 | + ) -> Self: |
479 | 480 | """Assign new coordinates to this object.
|
480 | 481 |
|
481 | 482 | Returns a new object with all the original data in addition to the new
|
@@ -620,9 +621,7 @@ def assign_coords(
|
620 | 621 | data.coords.update(results)
|
621 | 622 | return data
|
622 | 623 |
|
623 |
| - def assign_attrs( |
624 |
| - self: T_DataWithCoords, *args: Any, **kwargs: Any |
625 |
| - ) -> T_DataWithCoords: |
| 624 | + def assign_attrs(self, *args: Any, **kwargs: Any) -> Self: |
626 | 625 | """Assign new attrs to this object.
|
627 | 626 |
|
628 | 627 | Returns a new object equivalent to ``self.attrs.update(*args, **kwargs)``.
|
@@ -1061,9 +1060,7 @@ def _resample(
|
1061 | 1060 | restore_coord_dims=restore_coord_dims,
|
1062 | 1061 | )
|
1063 | 1062 |
|
1064 |
| - def where( |
1065 |
| - self: T_DataWithCoords, cond: Any, other: Any = dtypes.NA, drop: bool = False |
1066 |
| - ) -> T_DataWithCoords: |
| 1063 | + def where(self, cond: Any, other: Any = dtypes.NA, drop: bool = False) -> Self: |
1067 | 1064 | """Filter elements from this object according to a condition.
|
1068 | 1065 |
|
1069 | 1066 | Returns elements from 'DataArray', where 'cond' is True,
|
@@ -1208,9 +1205,7 @@ def close(self) -> None:
|
1208 | 1205 | self._close()
|
1209 | 1206 | self._close = None
|
1210 | 1207 |
|
1211 |
| - def isnull( |
1212 |
| - self: T_DataWithCoords, keep_attrs: bool | None = None |
1213 |
| - ) -> T_DataWithCoords: |
| 1208 | + def isnull(self, keep_attrs: bool | None = None) -> Self: |
1214 | 1209 | """Test each value in the array for whether it is a missing value.
|
1215 | 1210 |
|
1216 | 1211 | Parameters
|
@@ -1253,9 +1248,7 @@ def isnull(
|
1253 | 1248 | keep_attrs=keep_attrs,
|
1254 | 1249 | )
|
1255 | 1250 |
|
1256 |
| - def notnull( |
1257 |
| - self: T_DataWithCoords, keep_attrs: bool | None = None |
1258 |
| - ) -> T_DataWithCoords: |
| 1251 | + def notnull(self, keep_attrs: bool | None = None) -> Self: |
1259 | 1252 | """Test each value in the array for whether it is not a missing value.
|
1260 | 1253 |
|
1261 | 1254 | Parameters
|
@@ -1298,7 +1291,7 @@ def notnull(
|
1298 | 1291 | keep_attrs=keep_attrs,
|
1299 | 1292 | )
|
1300 | 1293 |
|
1301 |
| - def isin(self: T_DataWithCoords, test_elements: Any) -> T_DataWithCoords: |
| 1294 | + def isin(self, test_elements: Any) -> Self: |
1302 | 1295 | """Tests each value in the array for whether it is in test elements.
|
1303 | 1296 |
|
1304 | 1297 | Parameters
|
@@ -1347,15 +1340,15 @@ def isin(self: T_DataWithCoords, test_elements: Any) -> T_DataWithCoords:
|
1347 | 1340 | )
|
1348 | 1341 |
|
1349 | 1342 | def astype(
|
1350 |
| - self: T_DataWithCoords, |
| 1343 | + self, |
1351 | 1344 | dtype,
|
1352 | 1345 | *,
|
1353 | 1346 | order=None,
|
1354 | 1347 | casting=None,
|
1355 | 1348 | subok=None,
|
1356 | 1349 | copy=None,
|
1357 | 1350 | keep_attrs=True,
|
1358 |
| - ) -> T_DataWithCoords: |
| 1351 | + ) -> Self: |
1359 | 1352 | """
|
1360 | 1353 | Copy of the xarray object, with data cast to a specified type.
|
1361 | 1354 | Leaves coordinate dtype unchanged.
|
@@ -1422,7 +1415,7 @@ def astype(
|
1422 | 1415 | dask="allowed",
|
1423 | 1416 | )
|
1424 | 1417 |
|
1425 |
| - def __enter__(self: T_DataWithCoords) -> T_DataWithCoords: |
| 1418 | + def __enter__(self) -> Self: |
1426 | 1419 | return self
|
1427 | 1420 |
|
1428 | 1421 | def __exit__(self, exc_type, exc_value, traceback) -> None:
|
|
0 commit comments