Skip to content

TYP: check_untyped_defs arrays.sparse.array #32099

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

Merged
merged 3 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions pandas/core/arrays/sparse/array.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from collections import abc
import numbers
import operator
from typing import Any, Callable
from typing import Any, Callable, Union
import warnings

import numpy as np
Expand Down Expand Up @@ -479,7 +479,7 @@ def sp_index(self):
return self._sparse_index

@property
def sp_values(self):
def sp_values(self) -> np.ndarray:
"""
An ndarray containing the non- ``fill_value`` values.

Expand Down Expand Up @@ -798,13 +798,13 @@ def _get_val_at(self, loc):
val = com.maybe_box_datetimelike(val, self.sp_values.dtype)
return val

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

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

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

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

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

return taken

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

Expand Down
3 changes: 0 additions & 3 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,6 @@ check_untyped_defs=False
[mypy-pandas.core.arrays.interval]
check_untyped_defs=False

[mypy-pandas.core.arrays.sparse.array]
check_untyped_defs=False

[mypy-pandas.core.base]
check_untyped_defs=False

Expand Down