From 21e3bfe47c8cbf559376ac2e932ddcf51715c7d8 Mon Sep 17 00:00:00 2001 From: Matthew Roeschke <10647082+mroeschke@users.noreply.github.com> Date: Mon, 25 Aug 2025 14:47:27 -0700 Subject: [PATCH] Backport PR #62190: TST: Adjust test_round for Numpy 2.4 behavior --- pandas/tests/copy_view/test_methods.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pandas/tests/copy_view/test_methods.py b/pandas/tests/copy_view/test_methods.py index 09738fe1023fb..4934ea745a9f9 100644 --- a/pandas/tests/copy_view/test_methods.py +++ b/pandas/tests/copy_view/test_methods.py @@ -18,6 +18,7 @@ ) import pandas._testing as tm from pandas.tests.copy_view.util import get_array +from pandas.util.version import Version def test_copy(using_copy_on_write): @@ -1199,8 +1200,9 @@ def test_round(using_copy_on_write, warn_copy_on_write, decimals): if using_copy_on_write: assert tm.shares_memory(get_array(df2, "b"), get_array(df, "b")) # TODO: Make inplace by using out parameter of ndarray.round? - if decimals >= 0: + if decimals >= 0 and Version(np.__version__) < Version("2.4.0.dev0"): # Ensure lazy copy if no-op + # TODO: Cannot rely on Numpy returning view after version 2.3 assert np.shares_memory(get_array(df2, "a"), get_array(df, "a")) else: assert not np.shares_memory(get_array(df2, "a"), get_array(df, "a"))