Skip to content

Commit a712c29

Browse files
simonjayhawkinsroberthdevries
authored andcommitted
TYP: check_untyped_defs arrays.sparse.array (pandas-dev#32099)
1 parent 2ad3dcf commit a712c29

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

pandas/core/arrays/sparse/array.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from collections import abc
55
import numbers
66
import operator
7-
from typing import Any, Callable
7+
from typing import Any, Callable, Union
88
import warnings
99

1010
import numpy as np
@@ -479,7 +479,7 @@ def sp_index(self):
479479
return self._sparse_index
480480

481481
@property
482-
def sp_values(self):
482+
def sp_values(self) -> np.ndarray:
483483
"""
484484
An ndarray containing the non- ``fill_value`` values.
485485
@@ -798,13 +798,13 @@ def _get_val_at(self, loc):
798798
val = com.maybe_box_datetimelike(val, self.sp_values.dtype)
799799
return val
800800

801-
def take(self, indices, allow_fill=False, fill_value=None):
801+
def take(self, indices, allow_fill=False, fill_value=None) -> "SparseArray":
802802
if is_scalar(indices):
803803
raise ValueError(f"'indices' must be an array, not a scalar '{indices}'.")
804804
indices = np.asarray(indices, dtype=np.int32)
805805

806806
if indices.size == 0:
807-
result = []
807+
result = np.array([], dtype="object")
808808
kwargs = {"dtype": self.dtype}
809809
elif allow_fill:
810810
result = self._take_with_fill(indices, fill_value=fill_value)
@@ -815,7 +815,7 @@ def take(self, indices, allow_fill=False, fill_value=None):
815815

816816
return type(self)(result, fill_value=self.fill_value, kind=self.kind, **kwargs)
817817

818-
def _take_with_fill(self, indices, fill_value=None):
818+
def _take_with_fill(self, indices, fill_value=None) -> np.ndarray:
819819
if fill_value is None:
820820
fill_value = self.dtype.na_value
821821

@@ -878,7 +878,7 @@ def _take_with_fill(self, indices, fill_value=None):
878878

879879
return taken
880880

881-
def _take_without_fill(self, indices):
881+
def _take_without_fill(self, indices) -> Union[np.ndarray, "SparseArray"]:
882882
to_shift = indices < 0
883883
indices = indices.copy()
884884

setup.cfg

-3
Original file line numberDiff line numberDiff line change
@@ -150,9 +150,6 @@ check_untyped_defs=False
150150
[mypy-pandas.core.arrays.interval]
151151
check_untyped_defs=False
152152

153-
[mypy-pandas.core.arrays.sparse.array]
154-
check_untyped_defs=False
155-
156153
[mypy-pandas.core.base]
157154
check_untyped_defs=False
158155

0 commit comments

Comments
 (0)