@@ -182,7 +182,11 @@ def new_meth(self, *args, **kwargs):
182
182
return cast (F , new_meth )
183
183
184
184
185
- class DatetimeLikeArrayMixin (OpsMixin , NDArrayBackedExtensionArray ):
185
+ # error: Definition of "_concat_same_type" in base class "NDArrayBacked" is
186
+ # incompatible with definition in base class "ExtensionArray"
187
+ class DatetimeLikeArrayMixin ( # type: ignore[misc]
188
+ OpsMixin , NDArrayBackedExtensionArray
189
+ ):
186
190
"""
187
191
Shared Base/Mixin class for DatetimeArray, TimedeltaArray, PeriodArray
188
192
@@ -505,42 +509,6 @@ def view(self, dtype: Dtype | None = None) -> ArrayLike:
505
509
# are present in this file.
506
510
return super ().view (dtype )
507
511
508
- # ------------------------------------------------------------------
509
- # ExtensionArray Interface
510
-
511
- @classmethod
512
- def _concat_same_type (
513
- cls ,
514
- to_concat : Sequence [Self ],
515
- axis : AxisInt = 0 ,
516
- ) -> Self :
517
- new_obj = super ()._concat_same_type (to_concat , axis )
518
-
519
- obj = to_concat [0 ]
520
- dtype = obj .dtype
521
-
522
- new_freq = None
523
- if isinstance (dtype , PeriodDtype ):
524
- new_freq = obj .freq
525
- elif axis == 0 :
526
- # GH 3232: If the concat result is evenly spaced, we can retain the
527
- # original frequency
528
- to_concat = [x for x in to_concat if len (x )]
529
-
530
- if obj .freq is not None and all (x .freq == obj .freq for x in to_concat ):
531
- pairs = zip (to_concat [:- 1 ], to_concat [1 :])
532
- if all (pair [0 ][- 1 ] + obj .freq == pair [1 ][0 ] for pair in pairs ):
533
- new_freq = obj .freq
534
-
535
- new_obj ._freq = new_freq
536
- return new_obj
537
-
538
- def copy (self , order : str = "C" ) -> Self :
539
- # error: Unexpected keyword argument "order" for "copy"
540
- new_obj = super ().copy (order = order ) # type: ignore[call-arg]
541
- new_obj ._freq = self .freq
542
- return new_obj
543
-
544
512
# ------------------------------------------------------------------
545
513
# Validation Methods
546
514
# TODO: try to de-duplicate these, ensure identical behavior
@@ -2085,6 +2053,7 @@ def _with_freq(self, freq) -> Self:
2085
2053
return arr
2086
2054
2087
2055
# --------------------------------------------------------------
2056
+ # ExtensionArray Interface
2088
2057
2089
2058
def factorize (
2090
2059
self ,
@@ -2102,6 +2071,34 @@ def factorize(
2102
2071
# FIXME: shouldn't get here; we are ignoring sort
2103
2072
return super ().factorize (use_na_sentinel = use_na_sentinel )
2104
2073
2074
+ @classmethod
2075
+ def _concat_same_type (
2076
+ cls ,
2077
+ to_concat : Sequence [Self ],
2078
+ axis : AxisInt = 0 ,
2079
+ ) -> Self :
2080
+ new_obj = super ()._concat_same_type (to_concat , axis )
2081
+
2082
+ obj = to_concat [0 ]
2083
+
2084
+ if axis == 0 :
2085
+ # GH 3232: If the concat result is evenly spaced, we can retain the
2086
+ # original frequency
2087
+ to_concat = [x for x in to_concat if len (x )]
2088
+
2089
+ if obj .freq is not None and all (x .freq == obj .freq for x in to_concat ):
2090
+ pairs = zip (to_concat [:- 1 ], to_concat [1 :])
2091
+ if all (pair [0 ][- 1 ] + obj .freq == pair [1 ][0 ] for pair in pairs ):
2092
+ new_freq = obj .freq
2093
+ new_obj ._freq = new_freq
2094
+ return new_obj
2095
+
2096
+ def copy (self , order : str = "C" ) -> Self :
2097
+ # error: Unexpected keyword argument "order" for "copy"
2098
+ new_obj = super ().copy (order = order ) # type: ignore[call-arg]
2099
+ new_obj ._freq = self .freq
2100
+ return new_obj
2101
+
2105
2102
2106
2103
# -------------------------------------------------------------------
2107
2104
# Shared Constructor Helpers
0 commit comments