(self)
| 102 | assert_equal(m.mean(axis=1), [[1.5], [3.5]]) |
| 103 | |
| 104 | def test_flat(self): |
| 105 | # Test that flat can return items even for matrices [#4585, #4615] |
| 106 | # test simple access |
| 107 | test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1]) |
| 108 | assert_equal(test.flat[1], 2) |
| 109 | assert_equal(test.flat[2], masked) |
| 110 | assert_(np.all(test.flat[0:2] == test[0, 0:2])) |
| 111 | # Test flat on masked_matrices |
| 112 | test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1]) |
| 113 | test.flat = masked_array([3, 2, 1], mask=[1, 0, 0]) |
| 114 | control = masked_array(np.matrix([[3, 2, 1]]), mask=[1, 0, 0]) |
| 115 | assert_equal(test, control) |
| 116 | # Test setting |
| 117 | test = masked_array(np.matrix([[1, 2, 3]]), mask=[0, 0, 1]) |
| 118 | testflat = test.flat |
| 119 | testflat[:] = testflat[np.array([2, 1, 0])] |
| 120 | assert_equal(test, control) |
| 121 | testflat[0] = 9 |
| 122 | # test that matrices keep the correct shape (#4615) |
| 123 | a = masked_array(np.matrix(np.eye(2)), mask=0) |
| 124 | b = a.flat |
| 125 | b01 = b[:2] |
| 126 | assert_equal(b01.data, np.array([[1., 0.]])) |
| 127 | assert_equal(b01.mask, np.array([[False, False]])) |
| 128 | |
| 129 | def test_allany_onmatrices(self): |
| 130 | x = np.array([[0.13, 0.26, 0.90], |
nothing calls this directly
no test coverage detected