GeezerVison is showing github.com — TST: Fix test_numeric on riscv64 · numpy/numpy@468678a
File tree
Expand file treeCollapse file tree
Open diff view settings
Expand file treeCollapse file tree
Open diff view settings
Collapse file
Copy file name to clipboardExpand all lines: numpy/_core/tests/test_numeric.py +8-1Lines changed: 8 additions & 1 deletion | Original file line number | Diff line number | Diff line change |
|---|
@@ -798,7 +798,14 @@ def setup_method(self): |
798 | 798 | self.signd[self.ed] *= -1. |
799 | 799 | self.signf[1::6][self.ef[1::6]] = -np.inf |
800 | 800 | self.signd[1::6][self.ed[1::6]] = -np.inf |
801 | | - self.signf[3::6][self.ef[3::6]] = -np.nan |
| 801 | + # On RISC-V, many operations that produce NaNs, such as converting |
| 802 | + # a -NaN from f64 to f32, return a canonical NaN. The canonical |
| 803 | + # NaNs are always positive. See section 11.3 NaN Generation and |
| 804 | + # Propagation of the RISC-V Unprivileged ISA for more details. |
| 805 | + # We disable the float32 sign test on riscv64 for -np.nan as the sign |
| 806 | + # of the NaN will be lost when it's converted to a float32. |
| 807 | + if platform.processor() != 'riscv64': |
| 808 | + self.signf[3::6][self.ef[3::6]] = -np.nan |
802 | 809 | self.signd[3::6][self.ed[3::6]] = -np.nan |
803 | 810 | self.signf[4::6][self.ef[4::6]] = -0. |
804 | 811 | self.signd[4::6][self.ed[4::6]] = -0. |
|