Skip to content

Commit 641ddec

Browse files
committed
Bump numpy
1 parent 7f1d642 commit 641ddec

File tree

14 files changed

+27
-103
lines changed

14 files changed

+27
-103
lines changed

pandas/compat/numpy/__init__.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@
99
# numpy versioning
1010
_np_version = np.__version__
1111
_nlv = Version(_np_version)
12-
np_version_gte1p24 = _nlv >= Version("1.24")
13-
np_version_gte1p24p3 = _nlv >= Version("1.24.3")
14-
np_version_gte1p25 = _nlv >= Version("1.25")
1512
np_version_gt2 = _nlv >= Version("2.0.0")
1613
is_numpy_dev = _nlv.dev is not None
17-
_min_numpy_ver = "1.23.5"
14+
_min_numpy_ver = "1.26.0"
1815

1916

2017
if _nlv < Version(_min_numpy_ver):
2118
raise ImportError(
22-
f"this version of pandas is incompatible with numpy < {_min_numpy_ver}\n"
23-
f"your numpy version is {_np_version}.\n"
24-
f"Please upgrade numpy to >= {_min_numpy_ver} to use this pandas version"
19+
f"Please upgrade numpy to >= {_min_numpy_ver} to use this pandas version.\n"
20+
f"Your numpy version is {_np_version}."
2521
)
2622

2723

@@ -49,5 +45,4 @@
4945
__all__ = [
5046
"_np_version",
5147
"is_numpy_dev",
52-
"np",
5348
]

pandas/core/common.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,10 @@
2929
cast,
3030
overload,
3131
)
32-
import warnings
3332

3433
import numpy as np
3534

3635
from pandas._libs import lib
37-
from pandas.compat.numpy import np_version_gte1p24
3836

3937
from pandas.core.dtypes.cast import construct_1d_object_array_from_listlike
4038
from pandas.core.dtypes.common import (
@@ -243,12 +241,7 @@ def asarray_tuplesafe(values: Iterable, dtype: NpDtype | None = None) -> ArrayLi
243241
return construct_1d_object_array_from_listlike(values)
244242

245243
try:
246-
with warnings.catch_warnings():
247-
# Can remove warning filter once NumPy 1.24 is min version
248-
if not np_version_gte1p24:
249-
# np.VisibleDeprecationWarning only in np.exceptions in 2.0
250-
warnings.simplefilter("ignore", np.VisibleDeprecationWarning) # type: ignore[attr-defined]
251-
result = np.asarray(values, dtype=dtype)
244+
result = np.asarray(values, dtype=dtype)
252245
except ValueError:
253246
# Using try/except since it's more performant than checking is_list_like
254247
# over each element

pandas/tests/apply/test_frame_apply_relabeling.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import numpy as np
2-
import pytest
3-
4-
from pandas.compat.numpy import np_version_gte1p25
52

63
import pandas as pd
74
import pandas._testing as tm
@@ -45,7 +42,6 @@ def test_agg_relabel_multi_columns_multi_methods():
4542
tm.assert_frame_equal(result, expected)
4643

4744

48-
@pytest.mark.xfail(np_version_gte1p25, reason="name of min now equals name of np.min")
4945
def test_agg_relabel_partial_functions():
5046
# GH 26513, test on partial, functools or more complex cases
5147
df = pd.DataFrame({"A": [1, 2, 1, 2], "B": [1, 2, 3, 4], "C": [3, 4, 5, 6]})
@@ -57,16 +53,16 @@ def test_agg_relabel_partial_functions():
5753

5854
result = df.agg(
5955
foo=("A", min),
60-
bar=("A", np.min),
56+
bar=("B", np.min),
6157
cat=("B", max),
6258
dat=("C", "min"),
6359
f=("B", np.sum),
6460
kk=("B", lambda x: min(x)),
6561
)
6662
expected = pd.DataFrame(
6763
{
68-
"A": [1.0, 1.0, np.nan, np.nan, np.nan, np.nan],
69-
"B": [np.nan, np.nan, 4.0, np.nan, 10.0, 1.0],
64+
"A": [1.0, np.nan, np.nan, np.nan, np.nan, np.nan],
65+
"B": [np.nan, 1.0, 4.0, np.nan, 10.0, 1.0],
7066
"C": [np.nan, np.nan, np.nan, 3.0, np.nan, np.nan],
7167
},
7268
index=pd.Index(["foo", "bar", "cat", "dat", "f", "kk"]),

pandas/tests/extension/test_period.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
iNaT,
2727
)
2828
from pandas.compat import is_platform_windows
29-
from pandas.compat.numpy import np_version_gte1p24
3029

3130
from pandas.core.dtypes.dtypes import PeriodDtype
3231

@@ -104,7 +103,7 @@ def check_reduce(self, ser: pd.Series, op_name: str, skipna: bool):
104103

105104
@pytest.mark.parametrize("periods", [1, -2])
106105
def test_diff(self, data, periods):
107-
if is_platform_windows() and np_version_gte1p24:
106+
if is_platform_windows():
108107
with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False):
109108
super().test_diff(data, periods)
110109
else:

pandas/tests/frame/methods/test_compare.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
import numpy as np
22
import pytest
33

4-
from pandas.compat.numpy import np_version_gte1p25
5-
64
import pandas as pd
75
import pandas._testing as tm
86

@@ -270,7 +268,7 @@ def test_compare_ea_and_np_dtype(val1, val2):
270268
# GH#18463 TODO: is this really the desired behavior?
271269
expected.loc[1, ("a", "self")] = np.nan
272270

273-
if val1 is pd.NA and np_version_gte1p25:
271+
if val1 is pd.NA:
274272
# can't compare with numpy array if it contains pd.NA
275273
with pytest.raises(TypeError, match="boolean value of NA is ambiguous"):
276274
result = df1.compare(df2, keep_shape=True)

pandas/tests/frame/test_unary.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
import numpy as np
44
import pytest
55

6-
from pandas.compat.numpy import np_version_gte1p25
7-
86
import pandas as pd
97
import pandas._testing as tm
108

@@ -123,13 +121,10 @@ def test_pos_object(self, df_data):
123121
def test_pos_object_raises(self):
124122
# GH#21380
125123
df = pd.DataFrame({"a": ["a", "b"]})
126-
if np_version_gte1p25:
127-
with pytest.raises(
128-
TypeError, match=r"^bad operand type for unary \+: \'str\'$"
129-
):
130-
tm.assert_frame_equal(+df, df)
131-
else:
132-
tm.assert_series_equal(+df["a"], df["a"])
124+
with pytest.raises(
125+
TypeError, match=r"^bad operand type for unary \+: \'str\'$"
126+
):
127+
tm.assert_frame_equal(+df, df)
133128

134129
def test_pos_raises(self):
135130
df = pd.DataFrame({"a": pd.to_datetime(["2017-01-22", "1970-01-01"])})

pandas/tests/indexes/test_common.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import pytest
1515

1616
from pandas.compat import IS64
17-
from pandas.compat.numpy import np_version_gte1p25
1817

1918
from pandas.core.dtypes.common import (
2019
is_integer_dtype,
@@ -381,13 +380,11 @@ def test_astype_preserves_name(self, index, dtype):
381380
else:
382381
index.name = "idx"
383382

384-
warn = None
385-
if index.dtype.kind == "c" and dtype in ["float64", "int64", "uint64"]:
386-
# imaginary components discarded
387-
if np_version_gte1p25:
388-
warn = np.exceptions.ComplexWarning
389-
else:
390-
warn = np.ComplexWarning
383+
warn = (
384+
np.exceptions.ComplexWarning
385+
if index.dtype.kind == "c" and dtype in ["float64", "int64", "uint64"]
386+
else None
387+
)
391388

392389
is_pyarrow_str = str(index.dtype) == "string[pyarrow]" and dtype == "category"
393390
try:

pandas/tests/io/parser/test_c_parser_only.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import pytest
2020

2121
from pandas.compat import WASM
22-
from pandas.compat.numpy import np_version_gte1p24
2322
from pandas.errors import (
2423
ParserError,
2524
ParserWarning,
@@ -90,10 +89,9 @@ def test_dtype_and_names_error(c_parser_only):
9089
3.0 3
9190
"""
9291
# fallback casting, but not castable
93-
warning = RuntimeWarning if np_version_gte1p24 else None
9492
if not WASM: # no fp exception support in wasm
9593
with pytest.raises(ValueError, match="cannot safely convert"):
96-
with tm.assert_produces_warning(warning, check_stacklevel=False):
94+
with tm.assert_produces_warning(RuntimeWarning, check_stacklevel=False):
9795
parser.read_csv(
9896
StringIO(data),
9997
sep=r"\s+",

pandas/tests/plotting/frame/test_frame_subplots.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import pytest
77

88
from pandas.compat import is_platform_linux
9-
from pandas.compat.numpy import np_version_gte1p24
109

1110
import pandas as pd
1211
from pandas import (
@@ -423,7 +422,7 @@ def test_subplots_dup_columns_secondary_y_no_subplot(self):
423422
assert len(ax.right_ax.lines) == 5
424423

425424
@pytest.mark.xfail(
426-
np_version_gte1p24 and is_platform_linux(),
425+
is_platform_linux(),
427426
reason="Weird rounding problems",
428427
strict=False,
429428
)
@@ -438,7 +437,7 @@ def test_bar_log_no_subplots(self):
438437
tm.assert_numpy_array_equal(ax.yaxis.get_ticklocs(), expected)
439438

440439
@pytest.mark.xfail(
441-
np_version_gte1p24 and is_platform_linux(),
440+
is_platform_linux(),
442441
reason="Weird rounding problems",
443442
strict=False,
444443
)

pandas/tests/plotting/test_series.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import pytest
88

99
from pandas.compat import is_platform_linux
10-
from pandas.compat.numpy import np_version_gte1p24
1110
import pandas.util._test_decorators as td
1211

1312
import pandas as pd
@@ -277,7 +276,7 @@ def test_line_use_index_false_diff_var(self):
277276
assert label2 == ""
278277

279278
@pytest.mark.xfail(
280-
np_version_gte1p24 and is_platform_linux(),
279+
is_platform_linux(),
281280
reason="Weird rounding problems",
282281
strict=False,
283282
)
@@ -290,7 +289,7 @@ def test_bar_log(self, axis, meth):
290289
tm.assert_numpy_array_equal(getattr(ax, axis).get_ticklocs(), expected)
291290

292291
@pytest.mark.xfail(
293-
np_version_gte1p24 and is_platform_linux(),
292+
is_platform_linux(),
294293
reason="Weird rounding problems",
295294
strict=False,
296295
)

0 commit comments

Comments
 (0)