Skip to content

Commit 5b580fb

Browse files
jbrockmendeljreback
authored andcommitted
CLN: annotate ndim, is_monotonic_decreasing, has_duplicates, is_, nlevels (#29561)
1 parent fe143e5 commit 5b580fb

File tree

10 files changed

+17
-17
lines changed

10 files changed

+17
-17
lines changed

pandas/_libs/indexing.pyx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ cdef class _NDFrameIndexerBase:
1111
self._ndim = None
1212

1313
@property
14-
def ndim(self):
14+
def ndim(self) -> int:
1515
# Delay `ndim` instantiation until required as reading it
1616
# from `obj` isn't entirely cheap.
1717
ndim = self._ndim

pandas/core/base.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -686,7 +686,7 @@ def transpose(self, *args, **kwargs):
686686
)
687687

688688
@property
689-
def _is_homogeneous_type(self):
689+
def _is_homogeneous_type(self) -> bool:
690690
"""
691691
Whether the object has a single dtype.
692692
@@ -711,7 +711,7 @@ def shape(self):
711711
return self._values.shape
712712

713713
@property
714-
def ndim(self):
714+
def ndim(self) -> int:
715715
"""
716716
Number of dimensions of the underlying data, by definition 1.
717717
"""
@@ -1467,7 +1467,7 @@ def is_monotonic(self):
14671467
is_monotonic_increasing = is_monotonic
14681468

14691469
@property
1470-
def is_monotonic_decreasing(self):
1470+
def is_monotonic_decreasing(self) -> bool:
14711471
"""
14721472
Return boolean if values in the object are
14731473
monotonic_decreasing.

pandas/core/computation/ops.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def name(self):
167167
return self._name
168168

169169
@property
170-
def ndim(self):
170+
def ndim(self) -> int:
171171
return self._value.ndim
172172

173173

pandas/core/generic.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,7 @@ def axes(self):
569569
return [self._get_axis(a) for a in self._AXIS_ORDERS]
570570

571571
@property
572-
def ndim(self):
572+
def ndim(self) -> int:
573573
"""
574574
Return an int representing the number of axes / array dimensions.
575575

pandas/core/indexes/base.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ def _update_inplace(self, result, **kwargs):
607607
# guard when called from IndexOpsMixin
608608
raise TypeError("Index can't be updated inplace")
609609

610-
def is_(self, other):
610+
def is_(self, other) -> bool:
611611
"""
612612
More flexible, faster check like ``is`` but that works through views.
613613
@@ -1452,7 +1452,7 @@ def rename(self, name, inplace=False):
14521452
# Level-Centric Methods
14531453

14541454
@property
1455-
def nlevels(self):
1455+
def nlevels(self) -> int:
14561456
"""
14571457
Number of levels.
14581458
"""
@@ -1677,7 +1677,7 @@ def is_monotonic_increasing(self):
16771677
return self._engine.is_monotonic_increasing
16781678

16791679
@property
1680-
def is_monotonic_decreasing(self):
1680+
def is_monotonic_decreasing(self) -> bool:
16811681
"""
16821682
Return if the index is monotonic decreasing (only equal or
16831683
decreasing) values.
@@ -1735,7 +1735,7 @@ def is_unique(self):
17351735
return self._engine.is_unique
17361736

17371737
@property
1738-
def has_duplicates(self):
1738+
def has_duplicates(self) -> bool:
17391739
return not self.is_unique
17401740

17411741
def is_boolean(self):

pandas/core/indexes/category.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ def is_monotonic_increasing(self):
463463
return self._engine.is_monotonic_increasing
464464

465465
@property
466-
def is_monotonic_decreasing(self):
466+
def is_monotonic_decreasing(self) -> bool:
467467
return self._engine.is_monotonic_decreasing
468468

469469
@Appender(_index_shared_docs["index_unique"] % _index_doc_kwargs)

pandas/core/indexes/interval.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,7 @@ def is_monotonic_increasing(self):
558558
return self._engine.is_monotonic_increasing
559559

560560
@cache_readonly
561-
def is_monotonic_decreasing(self):
561+
def is_monotonic_decreasing(self) -> bool:
562562
"""
563563
Return True if the IntervalIndex is monotonic decreasing (only equal or
564564
decreasing values), else False

pandas/core/indexes/multi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -675,7 +675,7 @@ def array(self):
675675
raise ValueError(msg)
676676

677677
@property
678-
def _is_homogeneous_type(self):
678+
def _is_homogeneous_type(self) -> bool:
679679
"""Whether the levels of a MultiIndex all have the same dtype.
680680
681681
This looks at the dtypes of the levels.
@@ -1427,7 +1427,7 @@ def is_monotonic_increasing(self):
14271427
return Index(self.values).is_monotonic
14281428

14291429
@cache_readonly
1430-
def is_monotonic_decreasing(self):
1430+
def is_monotonic_decreasing(self) -> bool:
14311431
"""
14321432
return if the index is monotonic decreasing (only equal or
14331433
decreasing) values.

pandas/core/indexes/range.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ def is_monotonic_increasing(self):
353353
return self._range.step > 0 or len(self) <= 1
354354

355355
@cache_readonly
356-
def is_monotonic_decreasing(self):
356+
def is_monotonic_decreasing(self) -> bool:
357357
return self._range.step < 0 or len(self) <= 1
358358

359359
@property
360-
def has_duplicates(self):
360+
def has_duplicates(self) -> bool:
361361
return False
362362

363363
def __contains__(self, key: Union[int, np.integer]) -> bool:

pandas/core/internals/managers.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ def shape(self):
166166
return tuple(len(ax) for ax in self.axes)
167167

168168
@property
169-
def ndim(self):
169+
def ndim(self) -> int:
170170
return len(self.axes)
171171

172172
def set_axis(self, axis, new_labels):

0 commit comments

Comments
 (0)