Skip to content

CI: pre-commit fixups #40468

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 1 commit into from
Mar 16, 2021
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
8 changes: 5 additions & 3 deletions pandas/core/arrays/timedeltas.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
from pandas.core.dtypes.common import (
DT64NS_DTYPE,
TD64NS_DTYPE,
is_categorical_dtype,
is_dtype_equal,
is_float_dtype,
is_integer_dtype,
Expand All @@ -53,7 +52,10 @@
pandas_dtype,
)
from pandas.core.dtypes.dtypes import DatetimeTZDtype
from pandas.core.dtypes.generic import ABCMultiIndex
from pandas.core.dtypes.generic import (
ABCCategorical,
ABCMultiIndex,
)
from pandas.core.dtypes.missing import isna

from pandas.core import nanops
Expand Down Expand Up @@ -970,7 +972,7 @@ def sequence_to_td64ns(
elif not isinstance(data, (np.ndarray, ExtensionArray)):
# GH#24539 e.g. xarray, dask object
data = np.asarray(data)
elif is_categorical_dtype(data.dtype):
elif isinstance(data, ABCCategorical):
data = data.categories.take(data.codes, fill_value=NaT)._values
copy = False

Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/arrays/test_datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -1372,9 +1372,9 @@ def array_likes(request):
data = memoryview(arr)
elif name == "array":
# stdlib array
from array import array
from array import array as array_stdlib
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MarcoGorelli I wonder is there a way to make the pre-commit check not trigger in cases like this (seems like this might be a false positive)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes...we can probably check that, if has been imported from pandas and there is pd., then trigger, but don't if it was imported from somewhere else

I do think I prefer aliasing array here if it's not from pandas, but I'll look into this nonetheless, thanks for bringing it up

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Personally I would say we should do import array / array.array(...). That should be clear?


data = array("i", arr)
data = array_stdlib("i", arr)
elif name == "dask":
import dask.array

Expand Down