|
1 | 1 | """
|
2 | 2 | SparseArray data structure
|
3 | 3 | """
|
| 4 | +from __future__ import annotations |
| 5 | + |
4 | 6 | from collections import abc
|
5 | 7 | import numbers
|
6 | 8 | import operator
|
@@ -812,7 +814,7 @@ def _get_val_at(self, loc):
|
812 | 814 | val = maybe_box_datetimelike(val, self.sp_values.dtype)
|
813 | 815 | return val
|
814 | 816 |
|
815 |
| - def take(self, indices, *, allow_fill=False, fill_value=None) -> "SparseArray": |
| 817 | + def take(self, indices, *, allow_fill=False, fill_value=None) -> SparseArray: |
816 | 818 | if is_scalar(indices):
|
817 | 819 | raise ValueError(f"'indices' must be an array, not a scalar '{indices}'.")
|
818 | 820 | indices = np.asarray(indices, dtype=np.int32)
|
@@ -1403,7 +1405,7 @@ def _arith_method(self, other, op):
|
1403 | 1405 | other = SparseArray(other, fill_value=self.fill_value, dtype=dtype)
|
1404 | 1406 | return _sparse_array_op(self, other, op, op_name)
|
1405 | 1407 |
|
1406 |
| - def _cmp_method(self, other, op) -> "SparseArray": |
| 1408 | + def _cmp_method(self, other, op) -> SparseArray: |
1407 | 1409 | if not is_scalar(other) and not isinstance(other, type(self)):
|
1408 | 1410 | # convert list-like to ndarray
|
1409 | 1411 | other = np.asarray(other)
|
@@ -1431,19 +1433,19 @@ def _cmp_method(self, other, op) -> "SparseArray":
|
1431 | 1433 |
|
1432 | 1434 | _logical_method = _cmp_method
|
1433 | 1435 |
|
1434 |
| - def _unary_method(self, op) -> "SparseArray": |
| 1436 | + def _unary_method(self, op) -> SparseArray: |
1435 | 1437 | fill_value = op(np.array(self.fill_value)).item()
|
1436 | 1438 | values = op(self.sp_values)
|
1437 | 1439 | dtype = SparseDtype(values.dtype, fill_value)
|
1438 | 1440 | return type(self)._simple_new(values, self.sp_index, dtype)
|
1439 | 1441 |
|
1440 |
| - def __pos__(self) -> "SparseArray": |
| 1442 | + def __pos__(self) -> SparseArray: |
1441 | 1443 | return self._unary_method(operator.pos)
|
1442 | 1444 |
|
1443 |
| - def __neg__(self) -> "SparseArray": |
| 1445 | + def __neg__(self) -> SparseArray: |
1444 | 1446 | return self._unary_method(operator.neg)
|
1445 | 1447 |
|
1446 |
| - def __invert__(self) -> "SparseArray": |
| 1448 | + def __invert__(self) -> SparseArray: |
1447 | 1449 | return self._unary_method(operator.invert)
|
1448 | 1450 |
|
1449 | 1451 | # ----------
|
|
0 commit comments