(self)
| 256 | assert_(x1[1:1].shape == (0,)) |
| 257 | |
| 258 | def test_testCopySize(self): |
| 259 | # Tests of some subtle points of copying and sizing. |
| 260 | n = [0, 0, 1, 0, 0] |
| 261 | m = make_mask(n) |
| 262 | m2 = make_mask(m) |
| 263 | assert_(m is m2) |
| 264 | m3 = make_mask(m, copy=True) |
| 265 | assert_(m is not m3) |
| 266 | |
| 267 | x1 = np.arange(5) |
| 268 | y1 = array(x1, mask=m) |
| 269 | assert_(y1._data is not x1) |
| 270 | assert_(allequal(x1, y1._data)) |
| 271 | assert_(y1._mask is m) |
| 272 | |
| 273 | y1a = array(y1, copy=0) |
| 274 | # For copy=False, one might expect that the array would just |
| 275 | # passed on, i.e., that it would be "is" instead of "==". |
| 276 | # See gh-4043 for discussion. |
| 277 | assert_(y1a._mask.__array_interface__ == |
| 278 | y1._mask.__array_interface__) |
| 279 | |
| 280 | y2 = array(x1, mask=m3, copy=0) |
| 281 | assert_(y2._mask is m3) |
| 282 | assert_(y2[2] is masked) |
| 283 | y2[2] = 9 |
| 284 | assert_(y2[2] is not masked) |
| 285 | assert_(y2._mask is m3) |
| 286 | assert_(allequal(y2.mask, 0)) |
| 287 | |
| 288 | y2a = array(x1, mask=m, copy=1) |
| 289 | assert_(y2a._mask is not m) |
| 290 | assert_(y2a[2] is masked) |
| 291 | y2a[2] = 9 |
| 292 | assert_(y2a[2] is not masked) |
| 293 | assert_(y2a._mask is not m) |
| 294 | assert_(allequal(y2a.mask, 0)) |
| 295 | |
| 296 | y3 = array(x1 * 1.0, mask=m) |
| 297 | assert_(filled(y3).dtype is (x1 * 1.0).dtype) |
| 298 | |
| 299 | x4 = arange(4) |
| 300 | x4[2] = masked |
| 301 | y4 = resize(x4, (8,)) |
| 302 | assert_(eq(concatenate([x4, x4]), y4)) |
| 303 | assert_(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0])) |
| 304 | y5 = repeat(x4, (2, 2, 2, 2), axis=0) |
| 305 | assert_(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3])) |
| 306 | y6 = repeat(x4, 2, axis=0) |
| 307 | assert_(eq(y5, y6)) |
| 308 | |
| 309 | def test_testPut(self): |
| 310 | # Test of put |
nothing calls this directly
no test coverage detected