Test the various ArrFuncs
(self)
| 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""" |
| 316 | |
| 317 | # fill |
| 318 | assert_equal(np.arange(10, dtype=float16), |
| 319 | np.arange(10, dtype=float32)) |
| 320 | |
| 321 | # fillwithscalar |
| 322 | a = np.zeros((5,), dtype=float16) |
| 323 | a.fill(1) |
| 324 | assert_equal(a, np.ones((5,), dtype=float16)) |
| 325 | |
| 326 | # nonzero and copyswap |
| 327 | a = np.array([0, 0, -1, -1/1e20, 0, 2.0**-24, 7.629e-6], dtype=float16) |
| 328 | assert_equal(a.nonzero()[0], |
| 329 | [2, 5, 6]) |
| 330 | a = a.byteswap() |
| 331 | a = a.view(a.dtype.newbyteorder()) |
| 332 | assert_equal(a.nonzero()[0], |
| 333 | [2, 5, 6]) |
| 334 | |
| 335 | # dot |
| 336 | a = np.arange(0, 10, 0.5, dtype=float16) |
| 337 | b = np.ones((20,), dtype=float16) |
| 338 | assert_equal(np.dot(a, b), |
| 339 | 95) |
| 340 | |
| 341 | # argmax |
| 342 | a = np.array([0, -np.inf, -2, 0.5, 12.55, 7.3, 2.1, 12.4], dtype=float16) |
| 343 | assert_equal(a.argmax(), |
| 344 | 4) |
| 345 | a = np.array([0, -np.inf, -2, np.inf, 12.55, np.nan, 2.1, 12.4], dtype=float16) |
| 346 | assert_equal(a.argmax(), |
| 347 | 5) |
| 348 | |
| 349 | # getitem |
| 350 | a = np.arange(10, dtype=float16) |
| 351 | for i in range(10): |
| 352 | assert_equal(a.item(i), i) |
| 353 | |
| 354 | def test_spacing_nextafter(self): |
| 355 | """Test np.spacing and np.nextafter""" |