67
67
PeriodDtype ,
68
68
)
69
69
from pandas .core .dtypes .generic import (
70
- ABCExtensionArray ,
71
70
ABCIndex ,
72
71
ABCSeries ,
73
72
)
@@ -463,17 +462,17 @@ def maybe_cast_pointwise_result(
463
462
464
463
cls = dtype .construct_array_type ()
465
464
if same_dtype :
466
- result = maybe_cast_to_extension_array (cls , result , dtype = dtype )
465
+ result = _maybe_cast_to_extension_array (cls , result , dtype = dtype )
467
466
else :
468
- result = maybe_cast_to_extension_array (cls , result )
467
+ result = _maybe_cast_to_extension_array (cls , result )
469
468
470
469
elif (numeric_only and dtype .kind in "iufcb" ) or not numeric_only :
471
470
result = maybe_downcast_to_dtype (result , dtype )
472
471
473
472
return result
474
473
475
474
476
- def maybe_cast_to_extension_array (
475
+ def _maybe_cast_to_extension_array (
477
476
cls : type [ExtensionArray ], obj : ArrayLike , dtype : ExtensionDtype | None = None
478
477
) -> ArrayLike :
479
478
"""
@@ -492,10 +491,6 @@ def maybe_cast_to_extension_array(
492
491
"""
493
492
from pandas .core .arrays .string_ import BaseStringArray
494
493
495
- assert isinstance (cls , type ), f"must pass a type: { cls } "
496
- assertion_msg = f"must pass a subclass of ExtensionArray: { cls } "
497
- assert issubclass (cls , ABCExtensionArray ), assertion_msg
498
-
499
494
# Everything can be converted to StringArrays, but we may not want to convert
500
495
if issubclass (cls , BaseStringArray ) and lib .infer_dtype (obj ) != "string" :
501
496
return obj
0 commit comments