Skip to content

Commit fe25c6b

Browse files
check failures
1 parent ed4b764 commit fe25c6b

File tree

1 file changed

+36
-45
lines changed

1 file changed

+36
-45
lines changed

pandas/core/arrays/base.py

Lines changed: 36 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -33,19 +33,17 @@
3333

3434

3535
def try_cast_to_ea(cls_or_instance, obj, dtype=None):
36-
"""
37-
Call to `_from_sequence` that returns the object unchanged on Exception.
36+
"""Call to `_from_sequence` that returns the object unchanged on Exception.
3837
3938
Parameters
40-
----------
39+
---------
4140
cls_or_instance : ExtensionArray subclass or instance
4241
obj : arraylike
4342
Values to pass to cls._from_sequence
4443
dtype : ExtensionDtype, optional
4544
4645
Returns
4746
-------
48-
ExtensionArray or obj
4947
"""
5048
try:
5149
result = cls_or_instance._from_sequence(obj, dtype=dtype)
@@ -181,7 +179,6 @@ class ExtensionArray:
181179
By default, ExtensionArrays are not hashable. Immutable subclasses may
182180
override this behavior.
183181
"""
184-
185182
# '_typ' is for pandas.core.dtypes.generic.ABCExtensionArray.
186183
# Don't override this.
187184
_typ = "extension"
@@ -238,6 +235,7 @@ def _from_sequence_of_strings(cls, strings, dtype=None, copy=False):
238235

239236
@classmethod
240237
def _from_factorized(cls, values, original):
238+
241239
"""
242240
Reconstruct an ExtensionArray after factorization.
243241
@@ -253,6 +251,7 @@ def _from_factorized(cls, values, original):
253251
factorize
254252
ExtensionArray.factorize
255253
"""
254+
256255
raise AbstractMethodError(cls)
257256

258257
# ------------------------------------------------------------------------
@@ -287,13 +286,13 @@ def __getitem__(self, item):
287286
if the slice is length 0 or 1.
288287
289288
For a boolean mask, return an instance of ``ExtensionArray``, filtered
290-
to the values where ``item`` is True.
289+
to the values where ``item`` is True.
291290
"""
292291
raise AbstractMethodError(self)
293292

294293
def __setitem__(self, key: Union[int, np.ndarray], value: Any) -> None:
295294
"""
296-
Set one or more values inplace.
295+
Set one or more values inplace.
297296
298297
This method is not required to satisfy the pandas extension array
299298
interface.
@@ -348,8 +347,7 @@ def __len__(self) -> int:
348347

349348
def __iter__(self):
350349
"""
351-
Iterate over elements of the array.
352-
"""
350+
Iterate over elements of the array."""
353351
# This needs to be implemented so that pandas recognizes extension
354352
# arrays as list-like. The default implementation makes successive
355353
# calls to ``__getitem__``, which may be slower than necessary.
@@ -395,9 +393,7 @@ def to_numpy(self, dtype=None, copy=False, na_value=lib.no_default):
395393

396394
@property
397395
def dtype(self) -> ExtensionDtype:
398-
"""
399-
An instance of 'ExtensionDtype'.
400-
"""
396+
"An instance of 'ExtensionDtype'."
401397
raise AbstractMethodError(self)
402398

403399
@property
@@ -430,9 +426,9 @@ def nbytes(self) -> int:
430426
def astype(self, dtype, copy=True):
431427
"""
432428
Cast to a NumPy array with 'dtype'.
433-
434429
Parameters
435430
----------
431+
436432
dtype : str or dtype
437433
Typecode or data-type to which the array is cast.
438434
copy : bool, default True
@@ -475,9 +471,6 @@ def _values_for_argsort(self) -> np.ndarray:
475471
476472
Returns
477473
-------
478-
ndarray
479-
The transformed values should maintain the ordering between values
480-
within the array.
481474
482475
See Also
483476
--------
@@ -510,8 +503,7 @@ def argsort(
510503
511504
See Also
512505
--------
513-
numpy.argsort : Sorting implementation used internally.
514-
"""
506+
numpy.argsort : Sorting implementation used internally."""
515507
# Implementor note: You have two places to override the behavior of
516508
# argsort.
517509
# 1. _values_for_argsort : construct the values passed to np.argsort
@@ -585,39 +577,39 @@ def dropna(self):
585577

586578
def shift(self, periods: int = 1, fill_value: object = None) -> ABCExtensionArray:
587579
"""
588-
Shift values by desired number.
580+
Shift values by desired number.
589581
590-
Newly introduced missing values are filled with
591-
``self.dtype.na_value``.
582+
Newly introduced missing values are filled with
583+
``self.dtype.na_value``.
592584
593-
.. versionadded:: 0.24.0
585+
.. versionadded:: 0.24.0
594586
595-
Parameters
596-
----------
597-
periods : int, default 1
598-
The number of periods to shift. Negative values are allowed
599-
for shifting backwards.
587+
Parameters
588+
----------
589+
periods : int, default 1
590+
The number of periods to shift. Negative values are allowed
591+
for shifting backwards.
600592
601-
fill_value : object, optional
602-
The scalar value to use for newly introduced missing values.
603-
The default is ``self.dtype.na_value``.
593+
fill_value : object, optional
594+
The scalar value to use for newly introduced missing values.
595+
The default is ``self.dtype.na_value``.
604596
605-
.. versionadded:: 0.24.0
597+
.. versionadded:: 0.24.0
606598
607-
Returns
608-
-------
609-
ExtensionArray
610-
Shifted.
599+
Returns
600+
-------
601+
ExtensionArray
602+
Shifted.
611603
612-
Notes
613-
-----
614-
If ``self`` is empty or ``periods`` is 0, a copy of ``self`` is
615-
returned.
604+
Notes
605+
-----
606+
If ``self`` is empty or ``periods`` is 0, a copy of ``self`` is
607+
returned.
616608
617-
If ``periods > len(self)``, then an array of size
618-
len(self) is returned, with all values filled with
619-
``self.dtype.na_value``.
620-
"""
609+
If ``periods > len(self)``, then an array of size
610+
len(self) is returned, with all values filled with
611+
``self.dtype.na_value``.
612+
"""
621613
# Note: this implementation assumes that `self.dtype.na_value` can be
622614
# stored in an instance of your ExtensionArray with `self.dtype`.
623615
if not len(self) or periods == 0:
@@ -638,8 +630,7 @@ def shift(self, periods: int = 1, fill_value: object = None) -> ABCExtensionArra
638630
return self._concat_same_type([a, b])
639631

640632
def unique(self):
641-
"""
642-
Compute the ExtensionArray of unique values.
633+
"""Compute the ExtensionArray of unique values.
643634
644635
Returns
645636
-------

0 commit comments

Comments
 (0)