Fix or skip tests that assume the wrong endianness
authorDebian Science Team <debian-science-maintainers@lists.alioth.debian.org>
Tue, 31 Jan 2023 13:21:16 +0000 (13:21 +0000)
committerPeter Michael Green <plugwash@raspbian.org>
Tue, 31 Jan 2023 13:21:16 +0000 (13:21 +0000)
This is a bug in the tests not pandas itself -
the expected values explicitly specify little-endian

Author: Rebecca N. Palmer <rebecca_palmer@zoho.com>
Forwarded: not-needed - upstream fix ad98c2b77

Gbp-Pq: Name tests_dont_assume_endian.patch

pandas/tests/arrays/floating/test_arithmetic.py
pandas/tests/frame/methods/test_to_records.py
pandas/tests/scalar/timedelta/test_arithmetic.py

index ec7419d6346a8ea2e7b2aa7d55ed191c4bc588d3..bc9d8c01f6bb8742180b99c91ecce2efd8c37a8d 100644 (file)
@@ -162,7 +162,7 @@ def test_error_invalid_values(data, all_arithmetic_operators):
             "not all arguments converted during string formatting",
             "can't multiply sequence by non-int of type 'float'",
             "ufunc 'subtract' cannot use operands with types dtype",
-            r"ufunc 'add' cannot use operands with types dtype\('<M8\[ns\]'\)",
+            r"ufunc 'add' cannot use operands with types dtype\('[<>]M8\[ns\]'\)",
             r"ufunc 'add' cannot use operands with types dtype\('float\d{2}'\)",
             "cannot subtract DatetimeArray from ndarray",
         ]
index 32cccddc9d51554c3d1eef0073630f6fb91c3c7e..acd29ccf607799be18dfa5241f6f9deb5fde60b3 100644 (file)
@@ -12,6 +12,7 @@ from pandas import (
     date_range,
 )
 import pandas._testing as tm
+from pandas.compat import is_platform_little_endian
 
 
 class TestDataFrameToRecords:
@@ -96,7 +97,7 @@ class TestDataFrameToRecords:
             + [np.asarray(df.iloc[:, i]) for i in range(3)],
             dtype={
                 "names": ["A", "level_1", "0", "1", "2"],
-                "formats": ["O", "O", "<f8", "<f8", "<f8"],
+                "formats": ["O", "O", "<f8", "<f8", "<f8"] if is_platform_little_endian() else ["O", "O", ">f8", ">f8", ">f8"],
             },
         )
         tm.assert_numpy_array_equal(result, expected)
@@ -123,7 +124,7 @@ class TestDataFrameToRecords:
                 ("2022-01-01", "2022-01-01", "2022-01-01"),
                 ("2022-01-02", "2022-01-02", "2022-01-02"),
             ],
-            dtype=[("1", "<M8[ns]"), ("2", "<M8[ns]"), ("3", "<M8[ns]")],
+            dtype=[("1", "<M8[ns]"), ("2", "<M8[ns]"), ("3", "<M8[ns]")] if is_platform_little_endian() else [("1", ">M8[ns]"), ("2", ">M8[ns]"), ("3", ">M8[ns]")],
         )
 
         result = df.to_records(index=False)
index f3b84388b0f705c6222e922a395ddfbe4653d556..d7ecd022ac282bfee4c3827374aec34a5ac911b9 100644 (file)
@@ -435,7 +435,7 @@ class TestTimedeltaMultiplicationDivision:
 
         msg = (
             "ufunc '?multiply'? cannot use operands with types "
-            r"dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
+            r"dtype\('[<>]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)"
         )
         with pytest.raises(TypeError, match=msg):
             td * other