Mercurial > hg > vamp-build-and-test
comparison DEPENDENCIES/mingw32/Python27/Lib/site-packages/numpy/ma/tests/test_regression.py @ 87:2a2c65a20a8b
Add Python libs and headers
author | Chris Cannam |
---|---|
date | Wed, 25 Feb 2015 14:05:22 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
86:413a9d26189e | 87:2a2c65a20a8b |
---|---|
1 from __future__ import division, absolute_import, print_function | |
2 | |
3 import numpy as np | |
4 from numpy.testing import * | |
5 from numpy.compat import sixu | |
6 | |
7 rlevel = 1 | |
8 | |
9 | |
10 class TestRegression(TestCase): | |
11 def test_masked_array_create(self,level=rlevel): | |
12 # Ticket #17 | |
13 x = np.ma.masked_array([0, 1, 2, 3, 0, 4, 5, 6], | |
14 mask=[0, 0, 0, 1, 1, 1, 0, 0]) | |
15 assert_array_equal(np.ma.nonzero(x), [[1, 2, 6, 7]]) | |
16 | |
17 def test_masked_array(self,level=rlevel): | |
18 # Ticket #61 | |
19 np.ma.array(1, mask=[1]) | |
20 | |
21 def test_mem_masked_where(self,level=rlevel): | |
22 # Ticket #62 | |
23 from numpy.ma import masked_where, MaskType | |
24 a = np.zeros((1, 1)) | |
25 b = np.zeros(a.shape, MaskType) | |
26 c = masked_where(b, a) | |
27 a-c | |
28 | |
29 def test_masked_array_multiply(self,level=rlevel): | |
30 # Ticket #254 | |
31 a = np.ma.zeros((4, 1)) | |
32 a[2, 0] = np.ma.masked | |
33 b = np.zeros((4, 2)) | |
34 a*b | |
35 b*a | |
36 | |
37 def test_masked_array_repeat(self, level=rlevel): | |
38 # Ticket #271 | |
39 np.ma.array([1], mask=False).repeat(10) | |
40 | |
41 def test_masked_array_repr_unicode(self): | |
42 # Ticket #1256 | |
43 repr(np.ma.array(sixu("Unicode"))) | |
44 | |
45 def test_atleast_2d(self): | |
46 # Ticket #1559 | |
47 a = np.ma.masked_array([0.0, 1.2, 3.5], mask=[False, True, False]) | |
48 b = np.atleast_2d(a) | |
49 assert_(a.mask.ndim == 1) | |
50 assert_(b.mask.ndim == 2) | |
51 | |
52 def test_set_fill_value_unicode_py3(self): | |
53 # Ticket #2733 | |
54 a = np.ma.masked_array(['a', 'b', 'c'], mask=[1, 0, 0]) | |
55 a.fill_value = 'X' | |
56 assert_(a.fill_value == 'X') | |
57 | |
58 def test_var_sets_maskedarray_scalar(self): | |
59 # Issue gh-2757 | |
60 a = np.ma.array(np.arange(5), mask=True) | |
61 mout = np.ma.array(-1, dtype=float) | |
62 a.var(out=mout) | |
63 assert_(mout._data == 0) | |
64 | |
65 def test_ddof_corrcoef(self): | |
66 # See gh-3336 | |
67 x = np.ma.masked_equal([1, 2, 3, 4, 5], 4) | |
68 y = np.array([2, 2.5, 3.1, 3, 5]) | |
69 r0 = np.ma.corrcoef(x, y, ddof=0) | |
70 r1 = np.ma.corrcoef(x, y, ddof=1) | |
71 # ddof should not have an effect (it gets cancelled out) | |
72 assert_allclose(r0.data, r1.data) | |
73 | |
74 if __name__ == "__main__": | |
75 run_module_suite() |