Skip to content

Commit 1a36800

Browse files
Debian Science Teamrebecca-palmer
Debian Science Team
authored andcommitted
Fix or skip tests that assume the wrong endianness
This is a bug in the tests not pandas itself - the expected values explicitly specify little-endian Author: Rebecca N. Palmer <[email protected]> Forwarded: not-needed - upstream fix ad98c2b77 Gbp-Pq: Name tests_dont_assume_endian.patch
1 parent 9d9ce4e commit 1a36800

File tree

3 files changed

+5
-4
lines changed

3 files changed

+5
-4
lines changed

pandas/tests/arrays/floating/test_arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_error_invalid_values(data, all_arithmetic_operators):
162162
"not all arguments converted during string formatting",
163163
"can't multiply sequence by non-int of type 'float'",
164164
"ufunc 'subtract' cannot use operands with types dtype",
165-
r"ufunc 'add' cannot use operands with types dtype\('<M8\[ns\]'\)",
165+
r"ufunc 'add' cannot use operands with types dtype\('[<>]M8\[ns\]'\)",
166166
r"ufunc 'add' cannot use operands with types dtype\('float\d{2}'\)",
167167
"cannot subtract DatetimeArray from ndarray",
168168
]

pandas/tests/frame/methods/test_to_records.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
date_range,
1313
)
1414
import pandas._testing as tm
15+
from pandas.compat import is_platform_little_endian
1516

1617

1718
class TestDataFrameToRecords:
@@ -96,7 +97,7 @@ def test_to_records_index_name(self):
9697
+ [np.asarray(df.iloc[:, i]) for i in range(3)],
9798
dtype={
9899
"names": ["A", "level_1", "0", "1", "2"],
99-
"formats": ["O", "O", "<f8", "<f8", "<f8"],
100+
"formats": ["O", "O", "<f8", "<f8", "<f8"] if is_platform_little_endian() else ["O", "O", ">f8", ">f8", ">f8"],
100101
},
101102
)
102103
tm.assert_numpy_array_equal(result, expected)
@@ -123,7 +124,7 @@ def test_to_records_index_dtype(self):
123124
("2022-01-01", "2022-01-01", "2022-01-01"),
124125
("2022-01-02", "2022-01-02", "2022-01-02"),
125126
],
126-
dtype=[("1", "<M8[ns]"), ("2", "<M8[ns]"), ("3", "<M8[ns]")],
127+
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]")],
127128
)
128129

129130
result = df.to_records(index=False)

pandas/tests/scalar/timedelta/test_arithmetic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ def test_td_mul_td64_ndarray_invalid(self):
435435

436436
msg = (
437437
"ufunc '?multiply'? cannot use operands with types "
438-
r"dtype\('<m8\[ns\]'\) and dtype\('<m8\[ns\]'\)"
438+
r"dtype\('[<>]m8\[ns\]'\) and dtype\('[<>]m8\[ns\]'\)"
439439
)
440440
with pytest.raises(TypeError, match=msg):
441441
td * other

0 commit comments

Comments
 (0)