Skip to content

PERF: remove is_1d_only_ea_obj #52605

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
Apr 11, 2023
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
4 changes: 2 additions & 2 deletions pandas/core/array_algos/take.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
from pandas.core.dtypes.cast import maybe_promote
from pandas.core.dtypes.common import (
ensure_platform_int,
is_1d_only_ea_obj,
is_1d_only_ea_dtype,
)
from pandas.core.dtypes.missing import na_value_for_dtype

Expand Down Expand Up @@ -105,7 +105,7 @@ def take_nd(
if not isinstance(arr, np.ndarray):
# i.e. ExtensionArray,
# includes for EA to catch DatetimeArray, TimedeltaArray
if not is_1d_only_ea_obj(arr):
if not is_1d_only_ea_dtype(arr.dtype):
# i.e. DatetimeArray, TimedeltaArray
arr = cast("NDArrayBackedExtensionArray", arr)
return arr.take(
Expand Down
18 changes: 0 additions & 18 deletions pandas/core/dtypes/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1243,23 +1243,6 @@ def is_bool_dtype(arr_or_dtype) -> bool:
return issubclass(dtype.type, np.bool_)


def is_1d_only_ea_obj(obj: Any) -> bool:
"""
ExtensionArray that does not support 2D, or more specifically that does
not use HybridBlock.
"""
from pandas.core.arrays import (
DatetimeArray,
ExtensionArray,
PeriodArray,
TimedeltaArray,
)

return isinstance(obj, ExtensionArray) and not isinstance(
obj, (DatetimeArray, TimedeltaArray, PeriodArray)
)


def is_1d_only_ea_dtype(dtype: DtypeObj | None) -> bool:
"""
Analogue to is_extension_array_dtype but excluding DatetimeTZDtype.
Expand Down Expand Up @@ -1676,7 +1659,6 @@ def is_all_strings(value: ArrayLike) -> bool:
"infer_dtype_from_object",
"INT64_DTYPE",
"is_1d_only_ea_dtype",
"is_1d_only_ea_obj",
"is_all_strings",
"is_any_real_numeric_dtype",
"is_array_like",
Expand Down
3 changes: 1 addition & 2 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
from pandas.core.dtypes.common import (
ensure_platform_int,
is_1d_only_ea_dtype,
is_1d_only_ea_obj,
is_dtype_equal,
is_list_like,
is_string_dtype,
Expand Down Expand Up @@ -356,7 +355,7 @@ def _split_op_result(self, result: ArrayLike) -> list[Block]:
# if we get a 2D ExtensionArray, we need to split it into 1D pieces
nbs = []
for i, loc in enumerate(self._mgr_locs):
if not is_1d_only_ea_obj(result):
if not is_1d_only_ea_dtype(result.dtype):
vals = result[i : i + 1]
else:
vals = result[i]
Expand Down