Skip to content

Commit

Permalink
Add CurrentPandasWarning
Browse files Browse the repository at this point in the history
  • Loading branch information
Aloqeely committed Jun 7, 2024
1 parent 2570d57 commit f4e0d00
Show file tree
Hide file tree
Showing 33 changed files with 116 additions and 115 deletions.
6 changes: 3 additions & 3 deletions pandas/_libs/tslibs/timestamps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ from pandas._libs.tslibs cimport ccalendar
from pandas._libs.tslibs.base cimport ABCTimestamp

from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)

Expand Down Expand Up @@ -1536,7 +1536,7 @@ class Timestamp(_Timestamp):
# GH#56680
"Timestamp.utcnow is deprecated and will be removed in a future "
"version. Use Timestamp.now('UTC') instead.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
return cls.now(UTC)
Expand Down Expand Up @@ -1564,7 +1564,7 @@ class Timestamp(_Timestamp):
# to match. GH#56680
"Timestamp.utcfromtimestamp is deprecated and will be removed in a "
"future version. Use Timestamp.fromtimestamp(ts, 'UTC') instead.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
return cls.fromtimestamp(ts, tz="UTC")
Expand Down
8 changes: 4 additions & 4 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@
doc,
)
from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)
from pandas.util._validators import (
Expand Down Expand Up @@ -2573,15 +2573,15 @@ def to_json(
warnings.warn(
"The default 'epoch' date format is deprecated and will be removed "
"in a future version, please use 'iso' date format instead.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
elif date_format == "epoch":
# GH#57063
warnings.warn(
"'epoch' date format is deprecated and will be removed in a future "
"version, please use 'iso' date format instead.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)

Expand Down Expand Up @@ -4309,7 +4309,7 @@ def _check_copy_deprecation(copy):
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
"a lazy copy mechanism that defers copies until necessary. Use "
".copy() to make an eager copy if necessary.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
doc,
)
from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)

Expand Down Expand Up @@ -2794,7 +2794,7 @@ def corrwith(
"""
warnings.warn(
"DataFrameGroupBy.corrwith is deprecated",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
result = self._op_via_apply(
Expand Down
6 changes: 3 additions & 3 deletions pandas/core/indexes/accessors.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

from pandas._libs import lib
from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)

Expand Down Expand Up @@ -221,7 +221,7 @@ def to_pytimedelta(self):
"in a future version this will return a Series containing python "
"datetime.timedelta objects instead of an ndarray. To retain the "
"old behavior, call `np.array` on the result",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
return cast(ArrowExtensionArray, self._parent.array)._dt_to_pytimedelta()
Expand Down Expand Up @@ -482,7 +482,7 @@ def to_pytimedelta(self) -> np.ndarray:
"in a future version this will return a Series containing python "
"datetime.timedelta objects instead of an ndarray. To retain the "
"old behavior, call `np.array` on the result",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)
return self._get_values().to_pytimedelta()
Expand Down
4 changes: 2 additions & 2 deletions pandas/core/internals/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import numpy as np

from pandas._libs.internals import BlockPlacement
from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning

from pandas.core.dtypes.common import pandas_dtype
from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -94,7 +94,7 @@ def make_block(
"make_block is deprecated and will be removed in a future version. "
"Use pd.api.internals.create_dataframe_from_blocks or "
"(recommended) higher-level public APIs instead.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=2,
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/core/reshape/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from pandas._libs import lib
from pandas.util._decorators import cache_readonly
from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)

Expand Down Expand Up @@ -385,7 +385,7 @@ def concat(
"version. Copy-on-Write is active in pandas since 3.0 which utilizes "
"a lazy copy mechanism that defers copies until necessary. Use "
".copy() to make an eager copy if necessary.",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
stacklevel=find_stack_level(),
)

Expand Down
4 changes: 2 additions & 2 deletions pandas/io/feather_format.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from pandas._libs import lib
from pandas.compat._optional import import_optional_dependency
from pandas.util._decorators import doc
from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning
from pandas.util._validators import check_dtype_backend

import pandas as pd
Expand Down Expand Up @@ -137,7 +137,7 @@ def read_feather(
warnings.filterwarnings(
"ignore",
"make_block is deprecated",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
)

return feather.read_feather(
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from pandas.compat._optional import import_optional_dependency
from pandas.errors import AbstractMethodError
from pandas.util._decorators import doc
from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning
from pandas.util._validators import check_dtype_backend

import pandas as pd
Expand Down Expand Up @@ -279,7 +279,7 @@ def read(
filterwarnings(
"ignore",
"make_block is deprecated",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
)
result = pa_table.to_pandas(**to_pandas_kwargs)

Expand Down Expand Up @@ -398,7 +398,7 @@ def read(
filterwarnings(
"ignore",
"make_block is deprecated",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
)
return parquet_file.to_pandas(
columns=columns, filters=filters, **kwargs
Expand Down
4 changes: 2 additions & 2 deletions pandas/io/parsers/arrow_parser_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
ParserWarning,
)
from pandas.util._exceptions import (
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
find_stack_level,
)

Expand Down Expand Up @@ -294,7 +294,7 @@ def read(self) -> DataFrame:
warnings.filterwarnings(
"ignore",
"make_block is deprecated",
Pandas40DeprecationWarning,
CurrentDeprecationWarning,
)
if dtype_backend == "pyarrow":
frame = table.to_pandas(types_mapper=pd.ArrowDtype)
Expand Down
20 changes: 10 additions & 10 deletions pandas/tests/copy_view/test_copy_deprecation.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import pytest

from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning

import pandas as pd
from pandas import (
Expand Down Expand Up @@ -40,34 +40,34 @@ def test_copy_deprecation(meth, kwargs):
df = df.set_index(["b", "c"])

if meth != "swaplevel":
with tm.assert_produces_warning(Pandas40DeprecationWarning, match="copy"):
with tm.assert_produces_warning(CurrentDeprecationWarning, match="copy"):
getattr(df, meth)(copy=False, **kwargs)

if meth != "transpose":
with tm.assert_produces_warning(Pandas40DeprecationWarning, match="copy"):
with tm.assert_produces_warning(CurrentDeprecationWarning, match="copy"):
getattr(df.a, meth)(copy=False, **kwargs)


def test_copy_deprecation_reindex_like_align():
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})
# Somehow the stack level check is incorrect here
with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
df.reindex_like(df, copy=False)

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
df.a.reindex_like(df.a, copy=False)

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
df.align(df, copy=False)

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
df.a.align(df.a, copy=False)

Expand All @@ -76,16 +76,16 @@ def test_copy_deprecation_merge_concat():
df = pd.DataFrame({"a": [1, 2, 3], "b": [4, 5, 6]})

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
df.merge(df, copy=False)

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
merge(df, df, copy=False)

with tm.assert_produces_warning(
Pandas40DeprecationWarning, match="copy", check_stacklevel=False
CurrentDeprecationWarning, match="copy", check_stacklevel=False
):
concat([df, df], copy=False)
6 changes: 3 additions & 3 deletions pandas/tests/extension/test_arrow.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
pa_version_under13p0,
pa_version_under14p0,
)
from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning
import pandas.util._test_decorators as td

from pandas.core.dtypes.dtypes import (
Expand Down Expand Up @@ -2863,14 +2863,14 @@ def test_dt_to_pytimedelta():
ser = pd.Series(data, dtype=ArrowDtype(pa.duration("ns")))

msg = "The behavior of ArrowTemporalProperties.to_pytimedelta is deprecated"
with tm.assert_produces_warning(Pandas40DeprecationWarning, match=msg):
with tm.assert_produces_warning(CurrentDeprecationWarning, match=msg):
result = ser.dt.to_pytimedelta()
expected = np.array(data, dtype=object)
tm.assert_numpy_array_equal(result, expected)
assert all(type(res) is timedelta for res in result)

msg = "The behavior of TimedeltaProperties.to_pytimedelta is deprecated"
with tm.assert_produces_warning(Pandas40DeprecationWarning, match=msg):
with tm.assert_produces_warning(CurrentDeprecationWarning, match=msg):
expected = ser.astype("timedelta64[ns]").dt.to_pytimedelta()
tm.assert_numpy_array_equal(result, expected)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/frame/methods/test_reindex_like.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import numpy as np
import pytest

from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning

from pandas import DataFrame
import pandas._testing as tm
Expand All @@ -24,10 +24,10 @@ def test_reindex_like(self, float_frame):
def test_reindex_like_methods(self, method, expected_values):
df = DataFrame({"x": list(range(5))})

with tm.assert_produces_warning(Pandas40DeprecationWarning):
with tm.assert_produces_warning(CurrentDeprecationWarning):
result = df.reindex_like(df, method=method, tolerance=0)
tm.assert_frame_equal(df, result)
with tm.assert_produces_warning(Pandas40DeprecationWarning):
with tm.assert_produces_warning(CurrentDeprecationWarning):
result = df.reindex_like(df, method=method, tolerance=[0, 0, 0, 0])
tm.assert_frame_equal(df, result)

Expand Down
6 changes: 3 additions & 3 deletions pandas/tests/groupby/test_all_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import pytest

from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning

import pandas as pd
from pandas import DataFrame
Expand All @@ -28,7 +28,7 @@ def test_multiindex_group_all_columns_when_empty(groupby_func):
method = getattr(gb, groupby_func)
args = get_groupby_method_args(groupby_func, df)
if groupby_func == "corrwith":
warn = Pandas40DeprecationWarning
warn = CurrentDeprecationWarning
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
else:
warn = None
Expand Down Expand Up @@ -74,7 +74,7 @@ def test_dup_labels_output_shape(groupby_func, idx):

args = get_groupby_method_args(groupby_func, df)
if groupby_func == "corrwith":
warn = Pandas40DeprecationWarning
warn = CurrentDeprecationWarning
warn_msg = "DataFrameGroupBy.corrwith is deprecated"
else:
warn = None
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/groupby/test_apply.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import numpy as np
import pytest

from pandas.util._exceptions import Pandas40DeprecationWarning
from pandas.util._exceptions import CurrentDeprecationWarning

import pandas as pd
from pandas import (
Expand Down Expand Up @@ -1200,7 +1200,7 @@ def test_apply_is_unchanged_when_other_methods_are_called_first(reduction_func):
grp = df.groupby(by="a")
args = get_groupby_method_args(reduction_func, df)
if reduction_func == "corrwith":
warn = Pandas40DeprecationWarning
warn = CurrentDeprecationWarning
msg = "DataFrameGroupBy.corrwith is deprecated"
else:
warn = None
Expand Down
Loading

0 comments on commit f4e0d00

Please sign in to comment.