Skip to content
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

[REVIEW] Drop is_monotonic from Series and Index #12853

Merged
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
1 change: 0 additions & 1 deletion docs/cudf/source/api_docs/index_objects.rst
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ Properties
Index.has_duplicates
Index.duplicated
Index.hasnans
Index.is_monotonic
Index.is_monotonic_increasing
Index.is_monotonic_decreasing
Index.is_unique
Expand Down
19 changes: 0 additions & 19 deletions python/cudf/cudf/core/_base_index.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from __future__ import annotations

import pickle
import warnings
from functools import cached_property
from typing import Any, Set, TypeVar

Expand Down Expand Up @@ -189,24 +188,6 @@ def _clean_nulls_from_index(self):
"""
raise NotImplementedError

@property
def is_monotonic(self):
"""Return boolean if values in the object are monotonic_increasing.

This property is an alias for :attr:`is_monotonic_increasing`.

Returns
-------
bool
"""
warnings.warn(
"is_monotonic is deprecated and will be removed in a future "
"version. Use is_monotonic_increasing instead.",
FutureWarning,
)

return self.is_monotonic_increasing

@property
def is_monotonic_increasing(self):
"""Return boolean if values in the object are monotonically increasing.
Expand Down
23 changes: 2 additions & 21 deletions python/cudf/cudf/core/single_column_frame.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# Copyright (c) 2021-2022, NVIDIA CORPORATION.
# Copyright (c) 2021-2023, NVIDIA CORPORATION.

"""Base class for Frame types that only have a single column."""

from __future__ import annotations

import warnings
from typing import Any, Dict, Optional, Tuple, TypeVar, Union

import cupy
Expand Down Expand Up @@ -223,25 +223,6 @@ def is_unique(self):
"""
return self._column.is_unique

@property # type: ignore
@_cudf_nvtx_annotate
def is_monotonic(self):
"""Return boolean if values in the object are monotonically increasing.

This property is an alias for :attr:`is_monotonic_increasing`.

Returns
-------
bool
"""
warnings.warn(
"is_monotonic is deprecated and will be removed in a future "
"version. Use is_monotonic_increasing instead.",
FutureWarning,
)

return self.is_monotonic_increasing

@property # type: ignore
@_cudf_nvtx_annotate
def is_monotonic_increasing(self):
Expand Down
2 changes: 0 additions & 2 deletions python/cudf/cudf/tests/test_dataframe.py
Original file line number Diff line number Diff line change
Expand Up @@ -2518,8 +2518,6 @@ def test_unary_operators(func, pdf, gdf):
def test_is_monotonic(gdf):
pdf = pd.DataFrame({"x": [1, 2, 3]}, index=[3, 1, 2])
gdf = cudf.DataFrame.from_pandas(pdf)
with pytest.warns(FutureWarning):
assert not gdf.index.is_monotonic
assert not gdf.index.is_monotonic_increasing
assert not gdf.index.is_monotonic_decreasing

Expand Down
45 changes: 3 additions & 42 deletions python/cudf/cudf/tests/test_monotonic.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Copyright (c) 2019-2022, NVIDIA CORPORATION.
# Copyright (c) 2019-2023, NVIDIA CORPORATION.

"""
Tests related to is_unique and is_monotonic attributes
Tests related to is_unique, is_monotonic_increasing &
is_monotonic_decreasing attributes
"""
import numpy as np
import pandas as pd
Expand Down Expand Up @@ -30,11 +31,6 @@ def test_range_index(testrange):
)

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand All @@ -58,11 +54,6 @@ def test_generic_index(testlist):
index_pd = pd.Index(testlist)

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand All @@ -82,11 +73,6 @@ def test_string_index(testlist):
index_pd = pd.Index(testlist)

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand All @@ -102,11 +88,6 @@ def test_categorical_index(testlist):
index_pd = pd.CategoricalIndex(raw_cat)

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand Down Expand Up @@ -147,11 +128,6 @@ def test_datetime_index(testlist):
index_pd = pd.DatetimeIndex(testlist)

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand All @@ -174,11 +150,6 @@ def test_series(testlist):
series_pd = pd.Series(testlist)

assert series.is_unique == series_pd.is_unique
with pytest.warns(FutureWarning):
expect = series_pd.index.is_monotonic
with pytest.warns(FutureWarning):
got = series.index.is_monotonic
assert got == expect
assert series.is_monotonic_increasing == series_pd.is_monotonic_increasing
assert series.is_monotonic_decreasing == series_pd.is_monotonic_decreasing

Expand All @@ -203,11 +174,6 @@ def test_multiindex():
gdf = cudf.from_pandas(pdf)

assert pdf.index.is_unique == gdf.index.is_unique
with pytest.warns(FutureWarning):
expect = pdf.index.is_monotonic
with pytest.warns(FutureWarning):
got = gdf.index.is_monotonic
assert got == expect
assert (
pdf.index.is_monotonic_increasing == gdf.index.is_monotonic_increasing
)
Expand Down Expand Up @@ -242,11 +208,6 @@ def test_multiindex_tuples(testarr):
index_pd = pd.MultiIndex.from_tuples(tuples, names=testarr[1])

assert index.is_unique == index_pd.is_unique
with pytest.warns(FutureWarning):
expect = index_pd.is_monotonic
with pytest.warns(FutureWarning):
got = index.is_monotonic
assert got == expect
assert index.is_monotonic_increasing == index_pd.is_monotonic_increasing
assert index.is_monotonic_decreasing == index_pd.is_monotonic_decreasing

Expand Down