Skip to content

CLN: assorted cleanups #31938

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion pandas/core/arrays/datetimes.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,8 @@ def __init__(self, values, dtype=_NS_DTYPE, freq=None, copy=False):
@classmethod
def _simple_new(cls, values, freq=None, dtype=_NS_DTYPE):
assert isinstance(values, np.ndarray)
if values.dtype == "i8":
if values.dtype != _NS_DTYPE:
assert values.dtype == "i8"
values = values.view(_NS_DTYPE)

result = object.__new__(cls)
Expand Down
1 change: 1 addition & 0 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3504,6 +3504,7 @@ def _slice(self: FrameOrSeries, slobj: slice, axis=0) -> FrameOrSeries:

Slicing with this method is *always* positional.
"""
assert isinstance(slobj, slice), type(slobj)
axis = self._get_block_manager_axis(axis)
result = self._constructor(self._data.get_slice(slobj, axis=axis))
result = result.__finalize__(self)
Expand Down
1 change: 0 additions & 1 deletion pandas/core/internals/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1316,7 +1316,6 @@ def _slice_take_blocks_ax0(self, slice_or_indexer, fill_tuple=None):
return blocks

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

if fill_value is None:
fill_value = np.nan
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/ops/array_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ def comp_method_OBJECT_ARRAY(op, x, y):
if isinstance(y, list):
y = construct_1d_object_array_from_listlike(y)

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

Expand Down
2 changes: 1 addition & 1 deletion pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -4378,7 +4378,7 @@ def between(self, left, right, inclusive=True) -> "Series":
# Convert to types that support pd.NA

def _convert_dtypes(
self: ABCSeries,
self,
infer_objects: bool = True,
convert_string: bool = True,
convert_integer: bool = True,
Expand Down
11 changes: 4 additions & 7 deletions pandas/tests/indexing/test_chaining_and_caching.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,20 +346,17 @@ def test_chained_getitem_with_lists(self):
# GH6394
# Regression in chained getitem indexing with embedded list-like from
# 0.12
def check(result, expected):
tm.assert_numpy_array_equal(result, expected)
assert isinstance(result, np.ndarray)

df = DataFrame({"A": 5 * [np.zeros(3)], "B": 5 * [np.ones(3)]})
expected = df["A"].iloc[2]
result = df.loc[2, "A"]
check(result, expected)
tm.assert_numpy_array_equal(result, expected)
result2 = df.iloc[2]["A"]
check(result2, expected)
tm.assert_numpy_array_equal(result2, expected)
result3 = df["A"].loc[2]
check(result3, expected)
tm.assert_numpy_array_equal(result3, expected)
result4 = df["A"].iloc[2]
check(result4, expected)
tm.assert_numpy_array_equal(result4, expected)

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