-
-
Notifications
You must be signed in to change notification settings - Fork 157
Clear ANN for arrays.sparse and arrays.boolean #1585
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,2 @@ | ||
| from pandas.core.arrays.sparse.accessor import ( | ||
| SparseAccessor as SparseAccessor, | ||
| SparseFrameAccessor as SparseFrameAccessor, | ||
| ) | ||
| from pandas.core.arrays.sparse.array import SparseArray as SparseArray | ||
| from pandas.core.arrays.sparse.dtype import SparseDtype as SparseDtype |
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,62 +1,97 @@ | ||
| from collections.abc import ( | ||
| Callable, | ||
| Hashable, | ||
| ) | ||
| from enum import Enum | ||
| import sys | ||
| from typing import ( | ||
| Any, | ||
| Literal, | ||
| Protocol, | ||
| final, | ||
| overload, | ||
| type_check_only, | ||
| ) | ||
|
|
||
| import numpy as np | ||
| from pandas.core.arrays import ExtensionArray | ||
| from pandas.core.series import Series | ||
| from typing_extensions import Self | ||
|
|
||
| from pandas._libs.sparse import SparseIndex | ||
| from pandas._typing import ( | ||
| AnyArrayLike, | ||
| Axis, | ||
| AxisInt, | ||
| NpDtype, | ||
| Scalar, | ||
| ScalarIndexer, | ||
| SequenceIndexer, | ||
| np_1darray, | ||
| np_ndarray, | ||
| np_ndarray_int, | ||
| ) | ||
|
|
||
| from pandas.core.dtypes.dtypes import SparseDtype | ||
|
|
||
| @type_check_only | ||
| class _SparseMatrixLike(Protocol): | ||
| @property | ||
| def shape(self, /) -> tuple[int, int]: ... | ||
|
|
||
| @final | ||
| class ellipsis(Enum): | ||
| Ellipsis = "..." | ||
|
|
||
| class SparseArray(ExtensionArray): | ||
| def __init__( | ||
| self, | ||
| data, | ||
| sparse_index=..., | ||
| fill_value=..., | ||
| kind: str = ..., | ||
| dtype=..., | ||
| copy: bool = ..., | ||
| ) -> None: ... | ||
| if sys.version_info >= (3, 11): | ||
| def __new__( | ||
| cls, | ||
| data: AnyArrayLike | Scalar, | ||
| sparse_index: SparseIndex | None = None, | ||
| fill_value: Scalar | None = None, | ||
| kind: str = "integer", | ||
| dtype: np.dtype | SparseDtype | None = ..., | ||
| copy: bool = ..., | ||
| ) -> Self: ... | ||
| else: | ||
| def __new__( | ||
| cls, | ||
| data: AnyArrayLike | Scalar, | ||
| sparse_index: SparseIndex | None = None, | ||
| fill_value: Scalar | None = None, | ||
| kind: str = "integer", | ||
| dtype: np.dtype[Any] | SparseDtype | None = ..., | ||
| copy: bool = ..., | ||
| ) -> Self: ... | ||
|
|
||
| @classmethod | ||
| def from_spmatrix(cls, data) -> Self: ... | ||
| def from_spmatrix(cls, data: _SparseMatrixLike) -> Self: ... | ||
| def __array__( | ||
| self, dtype: NpDtype | None = None, copy: bool | None = None | ||
| ) -> np_1darray: ... | ||
| def __setitem__(self, key, value) -> None: ... | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deleting for now, seems like it raises an error in any case, same in boolean |
||
| @property | ||
| def sp_index(self): ... | ||
| def sp_index(self) -> SparseIndex: ... | ||
| @property | ||
| def sp_values(self): ... | ||
| def sp_values(self) -> np_ndarray: ... | ||
| @property | ||
| def dtype(self): ... | ||
| def dtype(self) -> SparseDtype: ... | ||
| @property | ||
| def fill_value(self): ... | ||
| def fill_value(self) -> Any: ... | ||
| @fill_value.setter | ||
| def fill_value(self, value) -> None: ... | ||
| def fill_value(self, value: Any) -> None: ... | ||
| @property | ||
| def kind(self) -> str: ... | ||
| def kind(self) -> Literal["integer", "block"]: ... | ||
| @property | ||
| def nbytes(self) -> int: ... | ||
| @property | ||
| def density(self): ... | ||
| def density(self) -> float: ... | ||
| @property | ||
| def npoints(self) -> int: ... | ||
| def isna(self): ... | ||
| def shift(self, periods: int = 1, fill_value=...): ... | ||
| def unique(self): ... | ||
| def value_counts(self, dropna: bool = True): ... | ||
| def isna(self) -> Self: ... | ||
| def shift(self, periods: int = 1, fill_value: Hashable = None) -> Self: ... | ||
| def unique(self) -> Self: ... | ||
| def value_counts(self, dropna: bool = True) -> Series[int]: ... | ||
| @overload | ||
| def __getitem__( # pyrefly: ignore[bad-param-name-override] | ||
| self, key: ScalarIndexer | ||
|
|
@@ -65,15 +100,24 @@ class SparseArray(ExtensionArray): | |
| def __getitem__( # ty: ignore[invalid-method-override] | ||
| self, key: SequenceIndexer | tuple[int | ellipsis, ...] | ||
| ) -> Self: ... | ||
| def copy(self): ... | ||
| def map(self, mapper): ... | ||
| def to_dense(self): ... | ||
| def nonzero(self): ... | ||
| def all(self, axis=..., *args: Any, **kwargs: Any): ... | ||
| def any(self, axis: int = ..., *args: Any, **kwargs: Any): ... | ||
| def sum(self, axis: int = 0, *args: Any, **kwargs: Any): ... | ||
| def cumsum(self, axis: int = ..., *args: Any, **kwargs: Any): ... | ||
| def mean(self, axis: int = ..., *args: Any, **kwargs: Any): ... | ||
| def copy(self) -> Self: ... | ||
| def map( | ||
| self, mapper: dict[Any, Any] | Series[Any] | Callable[..., Any] | ||
| ) -> Self: ... | ||
| def to_dense(self) -> np_ndarray: ... | ||
| def nonzero(self) -> tuple[np_ndarray_int]: ... | ||
| def all(self, axis: Axis | None = None, *args: Any, **kwargs: Any) -> bool: ... | ||
| def any(self, axis: AxisInt = 0, *args: Any, **kwargs: Any) -> bool: ... | ||
| def sum( | ||
| self, | ||
| axis: AxisInt = 0, | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looked at the source code and it had more args than in the current stubs. |
||
| min_count: int = 0, | ||
| skipna: bool = True, | ||
| *args: Any, | ||
| **kwargs: Any, | ||
| ) -> Scalar: ... | ||
| def cumsum(self, axis: AxisInt = 0, *args: Any, **kwargs: Any) -> Self: ... | ||
| def mean(self, axis: AxisInt = 0, *args: Any, **kwargs: Any) -> Self: ... | ||
| @property | ||
| def T(self): ... | ||
| def __abs__(self): ... | ||
| def T(self) -> Self: ... | ||
| def __abs__(self) -> Self: ... | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Those are now in the
BaseMaskedArrayclass with the correct overloads.