8000 CLN: follow-up cleanups (#40715) · pandas-dev/pandas@ea3741b · GitHub
[go: up one dir, main page]

Skip to content
Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit ea3741b

Browse files
authored
CLN: follow-up cleanups (#40715)
1 parent d3ae818 commit ea3741b

File tree

6 files changed

+12
-25
lines changed

6 files changed

+12
-25
lines changed

pandas/_libs/lib.pyx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2440,6 +2440,9 @@ class NoDefault(Enum):
24402440
# 2) because mypy does not understand singletons
24412441
no_default = "NO_DEFAULT"
24422442

2443+
def __repr__(self) -> str:
2444+
return "<no_default>"
2445+
24432446

24442447
# Note: no_default is exported to the public API in pandas.api.extensions
24452448
no_default = NoDefault.no_default # Sentinel indicating the default value.

pandas/core/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,7 +1164,7 @@ def is_monotonic_decreasing(self) -> bool:
11641164

11651165
return Index(self).is_monotonic_decreasing
11661166

1167-
def memory_usage(self, deep=False):
1167+
def _memory_usage(self, deep: bool = False) -> int:
11681168
"""
11691169
Memory usage of the values.
11701170

pandas/core/indexes/base.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
FrozenSet,
1313
Hashable,
1414
List,
15-
NewType,
1615
Optional,
1716
Sequence,
1817
Set,
@@ -195,9 +194,6 @@
195194
_o_dtype = np.dtype("object")
196195

197196

198-
_Identity = NewType("_Identity", object)
199-
200-
201197
def disallow_kwargs(kwargs: Dict[str, Any]):
202198
if kwargs:
203199
raise TypeError(f"Unexpected keyword arguments {repr(set(kwargs))}")
@@ -4405,9 +4401,9 @@ def _get_engine_target(self) -> np.ndarray:
44054401
# ndarray]", expected "ndarray")
44064402
return self._values # type: ignore[return-value]
44074403

4408-
@doc(IndexOpsMixin.memory_usage)
4404+
@doc(IndexOpsMixin._memory_usage)
44094405
def memory_usage(self, deep: bool = False) -> int:
4410-
result = super().memory_usage(deep=deep)
4406+
result = self._memory_usage(deep=deep)
44114407

44124408
# include our engine hashtable
44134409
result += self._engine.sizeof(deep=deep)

pandas/core/internals/blocks.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,7 @@ def is_bool(self) -> bool:
207207
def external_values(self):
208208
return external_values(self.values)
209209

210+
@final
210211
def internal_values(self):
211212
"""
212213
The array that Series._values returns (internal values).
@@ -593,8 +594,6 @@ def astype(self, dtype, copy: bool = False, errors: str = "raise"):
593594
Block
594595
"""
595596
values = self.values
596-
if values.dtype.kind in ["m", "M"]:
597-
values = self.array_values
598597

599598
new_values = astype_array_safe(values, dtype, copy=copy, errors=errors)
600599

@@ -1763,10 +1762,6 @@ def is_view(self) -> bool:
17631762
# check the ndarray values of the DatetimeIndex values
17641763
return self.values._ndarray.base is not None
17651764

1766-
def internal_values(self):
1767-
# Override to return DatetimeArray and TimedeltaArray
1768-
return self.values
1769-
17701765
def get_values(self, dtype: Optional[DtypeObj] = None) -> np.ndarray:
17711766
"""
17721767
return object dtype as boxed values, such as Timestamps/Timedelta
@@ -1878,7 +1873,6 @@ class DatetimeTZBlock(ExtensionBlock, DatetimeLikeBlockMixin):
18781873
is_extension = True
18791874
is_numeric = False
18801875

1881-
internal_values = Block.internal_values
18821876
diff = DatetimeBlock.diff
18831877
where = DatetimeBlock.where
18841878
putmask = DatetimeLikeBlockMixin.putmask

pandas/core/internals/managers.py

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1085,17 +1085,11 @@ def value_getitem(placement):
10851085
else:
10861086
if value.ndim == 2:
10871087
value = value.T
1088-
1089-
if value.ndim == self.ndim - 1:
1090-
value = ensure_block_shape(value, ndim=2)
1091-
1092-
def value_getitem(placement):
1093-
return value
1094-
10951088
else:
1089+
value = ensure_block_shape(value, ndim=2)
10961090

1097-
def value_getitem(placement):
1098-
return value[placement.indexer]
1091+
def value_getitem(placement):
1092+
return value[placement.indexer]
10991093

11001094
if value.shape[1:] != self.shape[1:]:
11011095
raise AssertionError(

pandas/core/series.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4609,7 +4609,7 @@ def shift(self, periods=1, freq=None, axis=0, fill_value=None) -> Series:
46094609
periods=periods, freq=freq, axis=axis, fill_value=fill_value
46104610
)
46114611

4612-
def memory_usage(self, index=True, deep=False):
4612+
def memory_usage(self, index: bool = True, deep: bool = False) -> int:
46134613
"""
46144614
Return the memory usage of the Series.
46154615
@@ -4658,7 +4658,7 @@ def memory_usage(self, index=True, deep=False):
46584658
>>> s.memory_usage(deep=True)
46594659
244
46604660
"""
4661-
v = super().memory_usage(deep=deep)
4661+
v = self._memory_usage(deep=deep)
46624662
if index:
46634663
v += self.index.memory_usage(deep=deep)
46644664
return v

0 commit comments

Comments
 (0)
0