Skip to content

Commit 78c9151

Browse files
Adjustments for review.
1 parent ee07ee0 commit 78c9151

File tree

1 file changed

+7
-43
lines changed

1 file changed

+7
-43
lines changed

pandas/tests/indexing/test_loc.py

Lines changed: 7 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,12 @@
2323
DatetimeIndex,
2424
Index,
2525
IndexSlice,
26-
Int64Index,
2726
MultiIndex,
2827
Period,
29-
RangeIndex,
3028
Series,
3129
SparseDtype,
3230
Timedelta,
3331
Timestamp,
34-
UInt64Index,
3532
date_range,
3633
timedelta_range,
3734
to_datetime,
@@ -2089,55 +2086,22 @@ def test_loc_getitem_slice_columns_mixed_dtype(self):
20892086

20902087

20912088
class TestLocBooleanLabelsAndSlices(Base):
2092-
@pytest.mark.parametrize(
2093-
"index",
2094-
[
2095-
RangeIndex(4),
2096-
Int64Index(range(4)),
2097-
UInt64Index(range(4)),
2098-
pd.Float64Index(range(4)),
2099-
CategoricalIndex(range(4)),
2100-
date_range(0, periods=4, freq="ns"),
2101-
timedelta_range(0, periods=4, freq="ns"),
2102-
pd.interval_range(0, periods=4),
2103-
Index([0, 1, 2, 3], dtype=object),
2104-
MultiIndex.from_product([[0, 1], [0, 1]]),
2105-
pd.period_range("2018Q1", freq="Q", periods=4),
2106-
],
2107-
)
21082089
def test_loc_bool_incompatible_index_raises(self, index, frame_or_series):
21092090
# GH20432
21102091
message = "Boolean label can not be used without a boolean index"
2111-
obj = frame_or_series(range(4), index=index)
2112-
with pytest.raises(TypeError, match=message):
2113-
obj.loc[True]
2092+
if index.inferred_type != "boolean":
2093+
obj = frame_or_series(index=index)
2094+
with pytest.raises(TypeError, match=message):
2095+
obj.loc[True]
21142096

2115-
@pytest.mark.parametrize("index", [Index([True, False], dtype="boolean")])
2116-
def test_loc_bool_should_not_raise(self, index, frame_or_series):
2117-
obj = frame_or_series(range(2), index=index)
2097+
def test_loc_bool_should_not_raise(self, frame_or_series):
2098+
obj = frame_or_series(index=Index([True, False], dtype="boolean"))
21182099
obj.loc[True]
21192100

2120-
@pytest.mark.parametrize(
2121-
"index",
2122-
[
2123-
RangeIndex(4),
2124-
Int64Index(range(4)),
2125-
UInt64Index(range(4)),
2126-
pd.Float64Index(range(4)),
2127-
CategoricalIndex(range(4)),
2128-
date_range(0, periods=4, freq="ns"),
2129-
timedelta_range(0, periods=4, freq="ns"),
2130-
pd.interval_range(0, periods=4),
2131-
Index([0, 1, 2, 3], dtype=object),
2132-
Index([True, True, False, False], dtype=object),
2133-
MultiIndex.from_product([[0, 1], [0, 1]]),
2134-
pd.period_range("2018Q1", freq="Q", periods=4),
2135-
],
2136-
)
21372101
def test_loc_bool_slice_raises(self, index, frame_or_series):
21382102
# GH20432
21392103
message = "Boolean values can not be used in a slice"
2140-
obj = frame_or_series(range(4), index=index)
2104+
obj = frame_or_series(index=index)
21412105
with pytest.raises(TypeError, match=message):
21422106
obj.loc[True:False]
21432107

0 commit comments

Comments
 (0)