8000 FIX Fixes memory regression for inspecting extension arrays (#26106) · Veghit/scikit-learn@cc8428a · GitHub
[go: up one dir, main page]

Skip to content

Commit cc8428a

Browse files
thomasjpfanItay
authored andcommitted
FIX Fixes memory regression for inspecting extension arrays (scikit-learn#26106)
1 parent 6d5a7c6 commit cc8428a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

doc/whats_new/v1.3.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ Changelog
452452
:user:`Jérémie du Boisberranger <jeremiedbb>`.
453453

454454
- |FIX| Fixes :func:`utils.validation.check_array` to properly convert pandas
455-
extension arrays. :pr:`25813` by `Thomas Fan`_.
455+
extension arrays. :pr:`25813` and :pr:`26106` by `Thomas Fan`_.
456456

457457
- |Fix| :func:`utils.validation.check_array` now suports pandas DataFrames with
458458
extension arrays and object dtypes by return an ndarray with object dtype.

sklearn/utils/validation.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -628,12 +628,8 @@ def _pandas_dtype_needs_early_conversion(pd_dtype):
628628

629629

630630
def _is_extension_array_dtype(array):
631-
try:
632-
from pandas.api.types import is_extension_array_dtype
633-
634-
return is_extension_array_dtype(array)
635-
except ImportError:
636-
return False
631+
# Pandas extension arrays have a dtype with an na_value
632+
return hasattr(array, "dtype") and hasattr(array.dtype, "na_value")
637633

638634

639635
def check_array(

0 commit comments

Comments
 (0)
0