Skip to content

Commit 297a665

Browse files
jbrockmendelroberthdevries
authored andcommitted
CLN: assorted cleanups (pandas-dev#31938)
1 parent 616a038 commit 297a665

File tree

6 files changed

+10
-12
lines changed

6 files changed

+10
-12
lines changed

pandas/core/arrays/datetimes.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,8 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
283283
@classmethod
284284
def _simple_new(cls, values, freq=None, dtype=_NS_DTYPE):
285285
assert isinstance(values, np.ndarray)
286-
if values.dtype == "i8":
286+
if values.dtype != _NS_DTYPE:
287+
assert values.dtype == "i8"
287288
values = values.view(_NS_DTYPE)
288289

289290
result = object.__new__(cls)

pandas/core/generic.py

+1
Original file line numberDiff line numberDiff line change
@@ -3504,6 +3504,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries:
35043504
35053505
Slicing with this method is *always* positional.
35063506
"""
3507+
assert isinstance(slobj, slice), type(slobj)
35073508
axis = self._get_block_manager_axis(axis)
35083509
result = self._constructor(self._data.get_slice(slobj, axis=axis))
35093510
result = result.__finalize__(self)

pandas/core/internals/managers.py

-1
Original file line numberDiff line numberDiff line change
@@ -1316,7 +1316,6 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None):
13161316
return blocks
13171317

13181318
def _make_na_block(self, placement, fill_value=None):
1319-
# TODO: infer dtypes other than float64 from fill_value
13201319

13211320
if fill_value is None:
13221321
fill_value = np.nan

pandas/core/ops/array_ops.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ def comp_method_OBJECT_ARRAY(op, x, y):
4343
if isinstance(y, list):
4444
y = construct_1d_object_array_from_listlike(y)
4545

46-
# TODO: Should the checks below be ABCIndexClass?
4746
if isinstance(y, (np.ndarray, ABCSeries, ABCIndex)):
48-
# TODO: should this be ABCIndexClass??
47+
# Note: these checks can be for ABCIndex and not ABCIndexClass
48+
# because that is the only object-dtype class.
4949
if not is_object_dtype(y.dtype):
5050
y = y.astype(np.object_)
5151

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4378,7 +4378,7 @@ def between(self, left, right, inclusive=True) -> "Series":
43784378
# Convert to types that support pd.NA
43794379

43804380
def _convert_dtypes(
4381-
self: ABCSeries,
4381+
self,
43824382
infer_objects: bool = True,
43834383
convert_string: bool = True,
43844384
convert_integer: bool = True,

pandas/tests/indexing/test_chaining_and_caching.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -346,20 +346,17 @@ def test_chained_getitem_with_lists(self):
346346
# GH6394
347347
# Regression in chained getitem indexing with embedded list-like from
348348
# 0.12
349-
def check(result, expected):
350-
tm.assert_numpy_array_equal(result, expected)
351-
assert isinstance(result, np.ndarray)
352349

353350
df = DataFrame({"A": 5 * [np.zeros(3)], "B": 5 * [np.ones(3)]})
354351
expected = df["A"].iloc[2]
355352
result = df.loc[2, "A"]
356-
check(result, expected)
353+
tm.assert_numpy_array_equal(result, expected)
357354
result2 = df.iloc[2]["A"]
358-
check(result2, expected)
355+
tm.assert_numpy_array_equal(result2, expected)
359356
result3 = df["A"].loc[2]
360-
check(result3, expected)
357+
tm.assert_numpy_array_equal(result3, expected)
361358
result4 = df["A"].iloc[2]
362-
check(result4, expected)
359+
tm.assert_numpy_array_equal(result4, expected)
363360

364361
def test_cache_updating(self):
365362
# GH 4939, make sure to update the cache on setitem

0 commit comments

Comments
 (0)