Skip to content

Commit d925f67

Browse files
Debian Science Teamrebecca-palmer
authored andcommitted
On mips, 1**np.nan and np.nan**0 may be NaN not 1
Done this way not a plain xfail to allow only this difference, not clearly wrong answers (The same hardware's "invalid value encountered" warnings, probably from sNaN/qNaN being reversed, are ignored elsewhere: d/rules and xfail_tests_nonintel_io.patch) https://en.wikipedia.org/wiki/NaN#Encoding Author: Rebecca N. Palmer <[email protected]> Forwarded: no Gbp-Pq: Name mips_pow_nan.patch
1 parent ac09926 commit d925f67

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

pandas/tests/arrays/floating/test_arithmetic.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import operator
2+
import platform
23

34
import numpy as np
45
import pytest
@@ -69,6 +70,11 @@ def test_pow_scalar(dtype):
6970
np.array([np.nan, np.nan, 1, np.nan, np.nan], dtype=dtype.numpy_dtype),
7071
mask=a._mask,
7172
)
73+
if 'mips' in platform.uname()[4] and np.isnan(result[2]):
74+
expected = FloatingArray(
75+
np.array([np.nan, np.nan, np.nan, np.nan, np.nan], dtype=dtype.numpy_dtype),
76+
mask=a._mask,
77+
)
7278
tm.assert_extension_array_equal(result, expected)
7379

7480
# reversed
@@ -80,6 +86,12 @@ def test_pow_scalar(dtype):
8086

8187
result = 1**a
8288
expected = pd.array([1, 1, 1, 1], dtype=dtype)
89+
if 'mips' in platform.uname()[4] and np.isnan(result[2]):
90+
expected = FloatingArray(
91+
np.array([1, 1, np.nan, 1], dtype=dtype.numpy_dtype),
92+
mask=expected._mask,
93+
)
94+
8395
tm.assert_extension_array_equal(result, expected)
8496

8597
result = pd.NA**a
@@ -90,6 +102,11 @@ def test_pow_scalar(dtype):
90102
expected = FloatingArray(
91103
np.array([1, np.nan, np.nan, np.nan], dtype=dtype.numpy_dtype), mask=a._mask
92104
)
105+
if 'mips' in platform.uname()[4] and np.isnan(result[0]):
106+
expected = FloatingArray(
107+
np.array([np.nan, np.nan, np.nan, np.nan], dtype=dtype.numpy_dtype),
108+
mask=a._mask,
109+
)
93110
tm.assert_extension_array_equal(result, expected)
94111

95112

@@ -98,6 +115,8 @@ def test_pow_array(dtype):
98115
b = pd.array([0, 1, None, 0, 1, None, 0, 1, None], dtype=dtype)
99116
result = a**b
100117
expected = pd.array([1, 0, None, 1, 1, 1, 1, None, None], dtype=dtype)
118+
if 'mips' in platform.uname()[4] and np.isnan(result[5]):
119+
expected = FloatingArray(np.array([1, 0, np.nan, 1, 1, np.nan, np.nan, np.nan, np.nan], dtype=dtype.numpy_dtype), mask=expected._mask)
101120
tm.assert_extension_array_equal(result, expected)
102121

103122

pandas/tests/arrays/sparse/test_arithmetics.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import operator
2+
import platform
23

34
import numpy as np
45
import pytest
@@ -44,6 +45,8 @@ def _check_numeric_ops(self, a, b, a_dense, b_dense, mix: bool, op):
4445
result = op(a, b_dense).to_dense()
4546
else:
4647
result = op(a, b).to_dense()
48+
if 'mips' in platform.uname()[4] and op==operator.pow and a[1]==1 and np.isnan(b if np.isscalar(b) else b[1]) and np.isnan(expected[1]) and result[1]==1:
49+
expected[1]=1
4750

4851
self._assert(result, expected)
4952

0 commit comments

Comments
 (0)