diff --git a/pandas/tests/frame/test_constructors.py b/pandas/tests/frame/test_constructors.py index 071d2409f1be2..7ff97c0abbc5f 100644 --- a/pandas/tests/frame/test_constructors.py +++ b/pandas/tests/frame/test_constructors.py @@ -1314,7 +1314,7 @@ def test_constructor_mixed_dict_and_Series(self): data["B"] = Series([4, 3, 2, 1], index=["bar", "qux", "baz", "foo"]) result = DataFrame(data) - assert result.index.is_monotonic + assert result.index.is_monotonic is True # ordering ambiguous, raise exception with pytest.raises(ValueError, match="ambiguous ordering"): diff --git a/pandas/tests/indexes/datetimes/test_datetime.py b/pandas/tests/indexes/datetimes/test_datetime.py index 6217f225d496e..e559f7b169427 100644 --- a/pandas/tests/indexes/datetimes/test_datetime.py +++ b/pandas/tests/indexes/datetimes/test_datetime.py @@ -212,17 +212,17 @@ def test_sort_values(self): idx = DatetimeIndex(["2000-01-04", "2000-01-01", "2000-01-02"]) ordered = idx.sort_values() - assert ordered.is_monotonic + assert ordered.is_monotonic is True ordered = idx.sort_values(ascending=False) - assert ordered[::-1].is_monotonic + assert ordered[::-1].is_monotonic is True ordered, dexer = idx.sort_values(return_indexer=True) - assert ordered.is_monotonic + assert ordered.is_monotonic is True tm.assert_numpy_array_equal(dexer, np.array([1, 2, 0], dtype=np.intp)) ordered, dexer = idx.sort_values(return_indexer=True, ascending=False) - assert ordered[::-1].is_monotonic + assert ordered[::-1].is_monotonic is True tm.assert_numpy_array_equal(dexer, np.array([0, 2, 1], dtype=np.intp)) def test_map_bug_1677(self): diff --git a/pandas/tests/indexes/datetimes/test_join.py b/pandas/tests/indexes/datetimes/test_join.py index 9a9c94fa19e6d..527909d201a80 100644 --- a/pandas/tests/indexes/datetimes/test_join.py +++ b/pandas/tests/indexes/datetimes/test_join.py @@ -80,7 +80,7 @@ def test_join_nonunique(self): idx1 = to_datetime(["2012-11-06 16:00:11.477563", "2012-11-06 16:00:11.477563"]) idx2 = to_datetime(["2012-11-06 15:11:09.006507", "2012-11-06 15:11:09.006507"]) rs = idx1.join(idx2, how="outer") - assert rs.is_monotonic + assert rs.is_monotonic is True @pytest.mark.parametrize("freq", ["B", "C"]) def test_outer_join(self, freq): diff --git a/pandas/tests/indexes/multi/test_integrity.py b/pandas/tests/indexes/multi/test_integrity.py index fd150bb4d57a2..51d4773935e48 100644 --- a/pandas/tests/indexes/multi/test_integrity.py +++ b/pandas/tests/indexes/multi/test_integrity.py @@ -219,10 +219,10 @@ def test_metadata_immutable(idx): def test_level_setting_resets_attributes(): ind = pd.MultiIndex.from_arrays([["A", "A", "B", "B", "B"], [1, 2, 1, 2, 3]]) - assert ind.is_monotonic + assert ind.is_monotonic is True ind.set_levels([["A", "B"], [1, 3, 2]], inplace=True) # if this fails, probably didn't reset the cache correctly. - assert not ind.is_monotonic + assert not ind.is_monotonic is True def test_rangeindex_fallback_coercion_bug(): diff --git a/pandas/tests/indexes/multi/test_sorting.py b/pandas/tests/indexes/multi/test_sorting.py index bb40612b9a55a..4934a6fbb2eb9 100644 --- a/pandas/tests/indexes/multi/test_sorting.py +++ b/pandas/tests/indexes/multi/test_sorting.py @@ -144,11 +144,11 @@ def test_reconstruct_sort(): # starts off lexsorted & monotonic mi = MultiIndex.from_arrays([["A", "A", "B", "B", "B"], [1, 2, 1, 2, 3]]) assert mi.is_lexsorted() - assert mi.is_monotonic + assert mi.is_monotonic is True recons = mi._sort_levels_monotonic() assert recons.is_lexsorted() - assert recons.is_monotonic + assert recons.is_monotonic is True assert mi is recons assert mi.equals(recons) @@ -160,11 +160,11 @@ def test_reconstruct_sort(): names=["one", "two"], ) assert not mi.is_lexsorted() - assert not mi.is_monotonic + assert not mi.is_monotonic is True recons = mi._sort_levels_monotonic() assert not recons.is_lexsorted() - assert not recons.is_monotonic + assert not recons.is_monotonic is True assert mi.equals(recons) assert Index(mi.values).equals(Index(recons.values)) @@ -176,11 +176,11 @@ def test_reconstruct_sort(): names=["col1", "col2"], ) assert not mi.is_lexsorted() - assert not mi.is_monotonic + assert not mi.is_monotonic is True recons = mi._sort_levels_monotonic() assert not recons.is_lexsorted() - assert not recons.is_monotonic + assert recons.is_monotonic is False assert mi.equals(recons) assert Index(mi.values).equals(Index(recons.values)) diff --git a/pandas/tests/indexes/period/test_period.py b/pandas/tests/indexes/period/test_period.py index 03f0be3f368cb..1385d384f0b86 100644 --- a/pandas/tests/indexes/period/test_period.py +++ b/pandas/tests/indexes/period/test_period.py @@ -653,7 +653,7 @@ def test_is_monotonic_with_nat(): for obj in [pi, pi._engine, dti, dti._engine, tdi, tdi._engine]: if isinstance(obj, Index): # i.e. not Engines - assert obj.is_monotonic + assert obj.is_monotonic is True assert obj.is_monotonic_increasing assert not obj.is_monotonic_decreasing assert obj.is_unique @@ -665,7 +665,7 @@ def test_is_monotonic_with_nat(): for obj in [pi1, pi1._engine, dti1, dti1._engine, tdi1, tdi1._engine]: if isinstance(obj, Index): # i.e. not Engines - assert not obj.is_monotonic + assert obj.is_monotonic is False assert not obj.is_monotonic_increasing assert not obj.is_monotonic_decreasing assert obj.is_unique @@ -677,7 +677,7 @@ def test_is_monotonic_with_nat(): for obj in [pi2, pi2._engine, dti2, dti2._engine, tdi2, tdi2._engine]: if isinstance(obj, Index): # i.e. not Engines - assert not obj.is_monotonic + assert obj.is_monotonic is False assert not obj.is_monotonic_increasing assert not obj.is_monotonic_decreasing assert obj.is_unique diff --git a/pandas/tests/indexes/timedeltas/test_timedelta.py b/pandas/tests/indexes/timedeltas/test_timedelta.py index 971203d6fc720..ca2c7eb4e1720 100644 --- a/pandas/tests/indexes/timedeltas/test_timedelta.py +++ b/pandas/tests/indexes/timedeltas/test_timedelta.py @@ -96,18 +96,18 @@ def test_sort_values(self): idx = TimedeltaIndex(["4d", "1d", "2d"]) ordered = idx.sort_values() - assert ordered.is_monotonic + assert ordered.is_monotonic is True ordered = idx.sort_values(ascending=False) - assert ordered[::-1].is_monotonic + assert ordered[::-1].is_monotonic is True ordered, dexer = idx.sort_values(return_indexer=True) - assert ordered.is_monotonic + assert ordered.is_monotonic is True tm.assert_numpy_array_equal(dexer, np.array([1, 2, 0]), check_dtype=False) ordered, dexer = idx.sort_values(return_indexer=True, ascending=False) - assert ordered[::-1].is_monotonic + assert ordered[::-1].is_monotonic is True tm.assert_numpy_array_equal(dexer, np.array([0, 2, 1]), check_dtype=False) diff --git a/pandas/tests/indexing/multiindex/test_sorted.py b/pandas/tests/indexing/multiindex/test_sorted.py index 4bec0f429a34e..f8518d40f59f3 100644 --- a/pandas/tests/indexing/multiindex/test_sorted.py +++ b/pandas/tests/indexing/multiindex/test_sorted.py @@ -44,16 +44,16 @@ def test_frame_getitem_not_sorted2(self): df2.index.set_levels(["b", "d", "a"], level="col1", inplace=True) df2.index.set_codes([0, 1, 0, 2], level="col1", inplace=True) assert not df2.index.is_lexsorted() - assert not df2.index.is_monotonic + assert not df2.index.is_monotonic is True assert df2_original.index.equals(df2.index) expected = df2.sort_index() assert expected.index.is_lexsorted() - assert expected.index.is_monotonic + assert expected.index.is_monotonic is True result = df2.sort_index(level=0) assert result.index.is_lexsorted() - assert result.index.is_monotonic + assert result.index.is_monotonic is True tm.assert_frame_equal(result, expected) def test_frame_getitem_not_sorted(self, multiindex_dataframe_random_data): diff --git a/pandas/tests/reductions/test_reductions.py b/pandas/tests/reductions/test_reductions.py index 211d0d52d8357..c4b9676e3ee83 100644 --- a/pandas/tests/reductions/test_reductions.py +++ b/pandas/tests/reductions/test_reductions.py @@ -216,11 +216,11 @@ def test_minmax_timedelta64(self): # monotonic idx1 = TimedeltaIndex(["1 days", "2 days", "3 days"]) - assert idx1.is_monotonic + assert idx1.is_monotonic is True # non-monotonic idx2 = TimedeltaIndex(["1 days", np.nan, "3 days", "NaT"]) - assert not idx2.is_monotonic + assert not idx2.is_monotonic is True for idx in [idx1, idx2]: assert idx.min() == Timedelta("1 days") @@ -339,13 +339,13 @@ def test_minmax_tz(self, tz_naive_fixture): tz = tz_naive_fixture # monotonic idx1 = pd.DatetimeIndex(["2011-01-01", "2011-01-02", "2011-01-03"], tz=tz) - assert idx1.is_monotonic + assert idx1.is_monotonic is True # non-monotonic idx2 = pd.DatetimeIndex( ["2011-01-01", pd.NaT, "2011-01-03", "2011-01-02", pd.NaT], tz=tz ) - assert not idx2.is_monotonic + assert idx2.is_monotonic is False for idx in [idx1, idx2]: assert idx.min() == Timestamp("2011-01-01", tz=tz) @@ -445,14 +445,14 @@ def test_minmax_period(self): # monotonic idx1 = pd.PeriodIndex([NaT, "2011-01-01", "2011-01-02", "2011-01-03"], freq="D") - assert not idx1.is_monotonic - assert idx1[1:].is_monotonic + assert idx1.is_monotonic is False + assert idx1[1:].is_monotonic is True # non-monotonic idx2 = pd.PeriodIndex( ["2011-01-01", NaT, "2011-01-03", "2011-01-02", NaT], freq="D" ) - assert not idx2.is_monotonic + assert idx2.is_monotonic is False for idx in [idx1, idx2]: assert idx.min() == pd.Period("2011-01-01", freq="D") diff --git a/pandas/tests/reshape/merge/test_join.py b/pandas/tests/reshape/merge/test_join.py index 725157b7c8523..b27b086993274 100644 --- a/pandas/tests/reshape/merge/test_join.py +++ b/pandas/tests/reshape/merge/test_join.py @@ -485,7 +485,7 @@ def test_join_inner_multiindex(self): expected = expected.drop(["first", "second"], axis=1) expected.index = joined.index - assert joined.index.is_monotonic + assert joined.index.is_monotonic is True tm.assert_frame_equal(joined, expected) # _assert_same_contents(expected, expected2.loc[:, expected.columns]) diff --git a/pandas/tests/reshape/merge/test_merge_asof.py b/pandas/tests/reshape/merge/test_merge_asof.py index 9b09f0033715d..0a3cd90fc5446 100644 --- a/pandas/tests/reshape/merge/test_merge_asof.py +++ b/pandas/tests/reshape/merge/test_merge_asof.py @@ -570,20 +570,20 @@ def test_non_sorted(self): quotes = self.quotes.sort_values("time", ascending=False) # we require that we are already sorted on time & quotes - assert not trades.time.is_monotonic - assert not quotes.time.is_monotonic + assert trades.time.is_monotonic is False + assert quotes.time.is_monotonic is False with pytest.raises(ValueError): merge_asof(trades, quotes, on="time", by="ticker") trades = self.trades.sort_values("time") - assert trades.time.is_monotonic - assert not quotes.time.is_monotonic + assert trades.time.is_monotonic is True + assert quotes.time.is_monotonic is False with pytest.raises(ValueError): merge_asof(trades, quotes, on="time", by="ticker") quotes = self.quotes.sort_values("time") - assert trades.time.is_monotonic - assert quotes.time.is_monotonic + assert trades.time.is_monotonic is True + assert quotes.time.is_monotonic is True # ok, though has dupes merge_asof(trades, self.quotes, on="time", by="ticker") diff --git a/pandas/tests/reshape/test_pivot.py b/pandas/tests/reshape/test_pivot.py index 75c3c565e9d58..0073f4bc33cca 100644 --- a/pandas/tests/reshape/test_pivot.py +++ b/pandas/tests/reshape/test_pivot.py @@ -1115,7 +1115,7 @@ def test_pivot_columns_lexsorted(self): aggfunc="mean", ) - assert pivoted.columns.is_monotonic + assert pivoted.columns.is_monotonic is True def test_pivot_complex_aggfunc(self): f = {"D": ["std"], "E": ["sum"]} diff --git a/pandas/tests/series/methods/test_asof.py b/pandas/tests/series/methods/test_asof.py index ad5a2de6eabac..c0e1eebd64110 100644 --- a/pandas/tests/series/methods/test_asof.py +++ b/pandas/tests/series/methods/test_asof.py @@ -147,7 +147,7 @@ def test_errors(self): ) # non-monotonic - assert not s.index.is_monotonic + assert s.index.is_monotonic is False with pytest.raises(ValueError): s.asof(s.index[0]) diff --git a/pandas/tests/series/test_analytics.py b/pandas/tests/series/test_analytics.py index 6f45b72154805..1a2b744262b53 100644 --- a/pandas/tests/series/test_analytics.py +++ b/pandas/tests/series/test_analytics.py @@ -146,7 +146,7 @@ def test_numpy_repeat(self): def test_is_monotonic(self): s = Series(np.random.randint(0, 10, size=1000)) - assert not s.is_monotonic + assert s.is_monotonic is False s = Series(np.arange(1000)) assert s.is_monotonic is True assert s.is_monotonic_increasing is True diff --git a/pandas/tests/test_multilevel.py b/pandas/tests/test_multilevel.py index 84279d874bae1..71f6ec166c700 100644 --- a/pandas/tests/test_multilevel.py +++ b/pandas/tests/test_multilevel.py @@ -2037,7 +2037,7 @@ def test_sort_index_and_reconstruction(self): ) result = result.sort_index() assert result.index.is_lexsorted() - assert result.index.is_monotonic + assert result.index.is_monotonic is True tm.assert_frame_equal(result, expected) @@ -2056,7 +2056,7 @@ def test_sort_index_and_reconstruction(self): result = concatted.sort_index() assert result.index.is_lexsorted() - assert result.index.is_monotonic + assert result.index.is_monotonic is True tm.assert_frame_equal(result, expected) @@ -2073,13 +2073,13 @@ def test_sort_index_and_reconstruction(self): pd.to_datetime(df.columns.levels[1]), level=1, inplace=True ) assert not df.columns.is_lexsorted() - assert not df.columns.is_monotonic + assert df.columns.is_monotonic is False result = df.sort_index(axis=1) assert result.columns.is_lexsorted() - assert result.columns.is_monotonic + assert result.columns.is_monotonic is True result = df.sort_index(axis=1, level=1) assert result.columns.is_lexsorted() - assert result.columns.is_monotonic + assert result.columns.is_monotonic is True def test_sort_index_and_reconstruction_doc_example(self): # doc example @@ -2090,7 +2090,7 @@ def test_sort_index_and_reconstruction_doc_example(self): ), ) assert df.index.is_lexsorted() - assert not df.index.is_monotonic + assert df.index.is_monotonic is False # sort it expected = DataFrame( @@ -2101,7 +2101,7 @@ def test_sort_index_and_reconstruction_doc_example(self): ) result = df.sort_index() assert result.index.is_lexsorted() - assert result.index.is_monotonic + assert result.index.is_monotonic is True tm.assert_frame_equal(result, expected) @@ -2109,7 +2109,7 @@ def test_sort_index_and_reconstruction_doc_example(self): result = df.sort_index().copy() result.index = result.index._sort_levels_monotonic() assert result.index.is_lexsorted() - assert result.index.is_monotonic + assert result.index.is_monotonic is True tm.assert_frame_equal(result, expected) diff --git a/pandas/tests/window/test_timeseries_window.py b/pandas/tests/window/test_timeseries_window.py index 5f5e10b5dd497..8f7f54aad2bc9 100644 --- a/pandas/tests/window/test_timeseries_window.py +++ b/pandas/tests/window/test_timeseries_window.py @@ -106,11 +106,11 @@ def test_monotonic_on(self): {"A": date_range("20130101", periods=5, freq="s"), "B": range(5)} ) - assert df.A.is_monotonic + assert df.A.is_monotonic is True df.rolling("2s", on="A").sum() df = df.set_index("A") - assert df.index.is_monotonic + assert df.index.is_monotonic is True df.rolling("2s").sum() def test_non_monotonic_on(self): @@ -123,7 +123,7 @@ def test_non_monotonic_on(self): non_monotonic_index[0] = non_monotonic_index[3] df.index = non_monotonic_index - assert not df.index.is_monotonic + assert df.index.is_monotonic is False with pytest.raises(ValueError): df.rolling("2s").sum()