MCPcopy Create free account
hub / github.com/numpy/numpy / test_testCI

Method test_testCI

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

Source from the content-addressed store, hash-verified

206 assert_(eq(np.prod(x, 1), product(x, 1)))
207
208 def test_testCI(self):
209 # Test of conversions and indexing
210 x1 = np.array([1, 2, 4, 3])
211 x2 = array(x1, mask=[1, 0, 0, 0])
212 x3 = array(x1, mask=[0, 1, 0, 1])
213 x4 = array(x1)
214 # test conversion to strings
215 str(x2) # raises?
216 repr(x2) # raises?
217 assert_(eq(np.sort(x1), sort(x2, fill_value=0)))
218 # tests of indexing
219 assert_(type(x2[1]) is type(x1[1]))
220 assert_(x1[1] == x2[1])
221 assert_(x2[0] is masked)
222 assert_(eq(x1[2], x2[2]))
223 assert_(eq(x1[2:5], x2[2:5]))
224 assert_(eq(x1[:], x2[:]))
225 assert_(eq(x1[1:], x3[1:]))
226 x1[2] = 9
227 x2[2] = 9
228 assert_(eq(x1, x2))
229 x1[1:3] = 99
230 x2[1:3] = 99
231 assert_(eq(x1, x2))
232 x2[1] = masked
233 assert_(eq(x1, x2))
234 x2[1:3] = masked
235 assert_(eq(x1, x2))
236 x2[:] = x1
237 x2[1] = masked
238 assert_(allequal(getmask(x2), array([0, 1, 0, 0])))
239 x3[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
240 assert_(allequal(getmask(x3), array([0, 1, 1, 0])))
241 x4[:] = masked_array([1, 2, 3, 4], [0, 1, 1, 0])
242 assert_(allequal(getmask(x4), array([0, 1, 1, 0])))
243 assert_(allequal(x4, array([1, 2, 3, 4])))
244 x1 = np.arange(5) * 1.0
245 x2 = masked_values(x1, 3.0)
246 assert_(eq(x1, x2))
247 assert_(allequal(array([0, 0, 0, 1, 0], MaskType), x2.mask))
248 assert_(eq(3.0, x2.fill_value))
249 x1 = array([1, 'hello', 2, 3], object)
250 x2 = np.array([1, 'hello', 2, 3], object)
251 s1 = x1[1]
252 s2 = x2[1]
253 assert_equal(type(s2), str)
254 assert_equal(type(s1), str)
255 assert_equal(s1, s2)
256 assert_(x1[1:1].shape == (0,))
257
258 def test_testCopySize(self):
259 # Tests of some subtle points of copying and sizing.

Callers

nothing calls this directly

Calls 9

arrayFunction · 0.90
assert_Function · 0.90
sortFunction · 0.90
allequalFunction · 0.90
getmaskFunction · 0.90
masked_valuesFunction · 0.90
assert_equalFunction · 0.90
eqFunction · 0.85
sortMethod · 0.80

Tested by

no test coverage detected