Skip to content

Commit

Permalink
Update typing to satiate mypy
Browse files Browse the repository at this point in the history
  • Loading branch information
jeichert60 committed May 26, 2022
1 parent 7ad0774 commit 2159b58
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions arkouda/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ class Series:
"""

@typechecked
def __init__(self, data: Optional[Union[Tuple, List, groupable_element_type]] = None,
def __init__(self, data: Union[Tuple, List, groupable_element_type],
index: Optional[pdarray] = None, **kwargs):

if "ar_tuple" in kwargs:
Expand All @@ -104,20 +104,18 @@ def __init__(self, data: Optional[Union[Tuple, List, groupable_element_type]] =
'Use keyword arguments instead (eg. ak.Series(data=values, index=indices)',
DeprecationWarning)

elif isinstance(data, (Tuple, List)) and len(data) == 2:
elif isinstance(data, (tuple, list)) and len(data) == 2:
if not isinstance(data[0], (pdarray, Iterable, Strings)):
raise TypeError("indices must be a pdarray, iterable, or string")
if not isinstance(data[1], (pdarray, Strings, Categorical)):
raise TypeError("values must be a pdarray, string, or categorical")
i = array(data[0]) if isinstance(data[0], (Tuple, List)) else data[0]
i = array(data[0]) if isinstance(data[0], (tuple, list)) else data[0]
self.values = data[1]
self.index = Index.factory(i)

# When only 1 positional argument it will be treated as data and not index
else:
if not isinstance(data, (pdarray, Strings, Categorical)):
self.values = array(data)
self.values = data
self.values = array(data) if not isinstance(data, Categorical) else data
self.index = Index.factory(index) if index is not None else Index(arange(self.values.size))

# TODO: Allow index to be an Index when index.py is updated
Expand Down

0 comments on commit 2159b58

Please sign in to comment.