MCPcopy
hub / github.com/numpy/numpy / test_testCopySize

Method test_testCopySize

numpy/ma/tests/test_old_ma.py:320–369  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

318 assert_(x1[1:1].shape == (0,))
319
320 def test_testCopySize(self):
321 # Tests of some subtle points of copying and sizing.
322 n = [0, 0, 1, 0, 0]
323 m = make_mask(n)
324 m2 = make_mask(m)
325 assert_(m is m2)
326 m3 = make_mask(m, copy=True)
327 assert_(m is not m3)
328
329 x1 = np.arange(5)
330 y1 = array(x1, mask=m)
331 assert_(y1._data is not x1)
332 assert_(allequal(x1, y1._data))
333 assert_(y1._mask is m)
334
335 y1a = array(y1, copy=0)
336 # For copy=False, one might expect that the array would just
337 # passed on, i.e., that it would be "is" instead of "==".
338 # See gh-4043 for discussion.
339 assert_(y1a._mask.__array_interface__ ==
340 y1._mask.__array_interface__)
341
342 y2 = array(x1, mask=m3, copy=0)
343 assert_(y2._mask is m3)
344 assert_(y2[2] is masked)
345 y2[2] = 9
346 assert_(y2[2] is not masked)
347 assert_(y2._mask is m3)
348 assert_(allequal(y2.mask, 0))
349
350 y2a = array(x1, mask=m, copy=1)
351 assert_(y2a._mask is not m)
352 assert_(y2a[2] is masked)
353 y2a[2] = 9
354 assert_(y2a[2] is not masked)
355 assert_(y2a._mask is not m)
356 assert_(allequal(y2a.mask, 0))
357
358 y3 = array(x1 * 1.0, mask=m)
359 assert_(filled(y3).dtype is (x1 * 1.0).dtype)
360
361 x4 = arange(4)
362 x4[2] = masked
363 y4 = resize(x4, (8,))
364 assert_(eq(concatenate([x4, x4]), y4))
365 assert_(eq(getmask(y4), [0, 0, 1, 0, 0, 0, 1, 0]))
366 y5 = repeat(x4, (2, 2, 2, 2), axis=0)
367 assert_(eq(y5, [0, 0, 1, 1, 2, 2, 3, 3]))
368 y6 = repeat(x4, 2, axis=0)
369 assert_(eq(y5, y6))
370
371 def test_testPut(self):
372 # Test of put

Callers

nothing calls this directly

Calls 10

make_maskFunction · 0.90
assert_Function · 0.90
arrayFunction · 0.90
allequalFunction · 0.90
filledFunction · 0.90
resizeFunction · 0.90
concatenateFunction · 0.90
getmaskFunction · 0.90
eqFunction · 0.85
repeatFunction · 0.85

Tested by

no test coverage detected