(self)
| 328 | assert_(a[0] is dt) |
| 329 | |
| 330 | def test_indexing(self): |
| 331 | # Tests conversions and indexing |
| 332 | x1 = np.array([1, 2, 4, 3]) |
| 333 | x2 = array(x1, mask=[1, 0, 0, 0]) |
| 334 | x3 = array(x1, mask=[0, 1, 0, 1]) |
| 335 | x4 = array(x1) |
| 336 | # test conversion to strings |
| 337 | str(x2) # raises? |
| 338 | repr(x2) # raises? |
| 339 | assert_equal(np.sort(x1), sort(x2, endwith=False)) |
| 340 | # tests of indexing |
| 341 | assert_(type(x2[1]) is type(x1[1])) |
| 342 | assert_(x1[1] == x2[1]) |
| 343 | assert_(x2[0] is masked) |
| 344 | assert_equal(x1[2], x2[2]) |
| 345 | assert_equal(x1[2:5], x2[2:5]) |
| 346 | assert_equal(x1[:], x2[:]) |
| 347 | assert_equal(x1[1:], x3[1:]) |
| 348 | x1[2] = 9 |
| 349 | x2[2] = 9 |
| 350 | assert_equal(x1, x2) |
| 351 | x1[1:3] = 99 |
| 352 | x2[1:3] = 99 |
| 353 | assert_equal(x1, x2) |
| 354 | x2[1] = masked |
| 355 | assert_equal(x1, x2) |
| 356 | x2[1:3] = masked |
| 357 | assert_equal(x1, x2) |
| 358 | x2[:] = x1 |
| 359 | x2[1] = masked |
| 360 | assert_(allequal(getmask(x2), array([0, 1, 0, 0]))) |
| 361 | x3[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0]) |
| 362 | assert_(allequal(getmask(x3), array([0, 1, 1, 0]))) |
| 363 | x4[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0]) |
| 364 | assert_(allequal(getmask(x4), array([0, 1, 1, 0]))) |
| 365 | assert_(allequal(x4, array([1, 2, 3, 4]))) |
| 366 | x1 = np.arange(5) * 1.0 |
| 367 | x2 = masked_values(x1, 3.0) |
| 368 | assert_equal(x1, x2) |
| 369 | assert_(allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask)) |
| 370 | assert_equal(3.0, x2.fill_value) |
| 371 | x1 = array([1, 'hello', 2, 3], object) |
| 372 | x2 = np.array([1, 'hello', 2, 3], object) |
| 373 | s1 = x1[1] |
| 374 | s2 = x2[1] |
| 375 | assert_equal(type(s2), str) |
| 376 | assert_equal(type(s1), str) |
| 377 | assert_equal(s1, s2) |
| 378 | assert_(x1[1:1].shape == (0,)) |
| 379 | |
| 380 | def test_setitem_no_warning(self): |
| 381 | # Setitem shouldn't warn, because the assignment might be masked |
nothing calls this directly
no test coverage detected