Make sure comparisons are working right
(self)
| 289 | a_manual[bad_index])) |
| 290 | |
| 291 | def test_half_ordering(self): |
| 292 | """Make sure comparisons are working right""" |
| 293 | |
| 294 | # All non-NaN float16 values in reverse order |
| 295 | a = self.nonan_f16[::-1].copy() |
| 296 | |
| 297 | # 32-bit float copy |
| 298 | b = np.array(a, dtype=float32) |
| 299 | |
| 300 | # Should sort the same |
| 301 | a.sort() |
| 302 | b.sort() |
| 303 | assert_equal(a, b) |
| 304 | |
| 305 | # Comparisons should work |
| 306 | assert_((a[:-1] <= a[1:]).all()) |
| 307 | assert_(not (a[:-1] > a[1:]).any()) |
| 308 | assert_((a[1:] >= a[:-1]).all()) |
| 309 | assert_(not (a[1:] < a[:-1]).any()) |
| 310 | # All != except for +/-0 |
| 311 | assert_equal(np.nonzero(a[:-1] < a[1:])[0].size, a.size-2) |
| 312 | assert_equal(np.nonzero(a[1:] > a[:-1])[0].size, a.size-2) |
| 313 | |
| 314 | def test_half_funcs(self): |
| 315 | """Test the various ArrFuncs""" |