Tests conversions and indexing.
(self)
| 149 | |
| 150 | @np.errstate(all='ignore') |
| 151 | def test_2(self): |
| 152 | """ |
| 153 | Tests conversions and indexing. |
| 154 | |
| 155 | """ |
| 156 | x1 = np.array([1, 2, 4, 3]) |
| 157 | x2 = self.array(x1, mask=[1, 0, 0, 0]) |
| 158 | x3 = self.array(x1, mask=[0, 1, 0, 1]) |
| 159 | x4 = self.array(x1) |
| 160 | # test conversion to strings, no errors |
| 161 | str(x2) |
| 162 | repr(x2) |
| 163 | # tests of indexing |
| 164 | assert type(x2[1]) is type(x1[1]) |
| 165 | assert x1[1] == x2[1] |
| 166 | x1[2] = 9 |
| 167 | x2[2] = 9 |
| 168 | self.assert_array_equal(x1, x2) |
| 169 | x1[1:3] = 99 |
| 170 | x2[1:3] = 99 |
| 171 | x2[1] = self.masked |
| 172 | x2[1:3] = self.masked |
| 173 | x2[:] = x1 |
| 174 | x2[1] = self.masked |
| 175 | x3[:] = self.masked_array([1, 2, 3, 4], [0, 1, 1, 0]) |
| 176 | x4[:] = self.masked_array([1, 2, 3, 4], [0, 1, 1, 0]) |
| 177 | x1 = np.arange(5)*1.0 |
| 178 | x2 = self.masked_values(x1, 3.0) |
| 179 | x1 = self.array([1, 'hello', 2, 3], object) |
| 180 | x2 = np.array([1, 'hello', 2, 3], object) |
| 181 | # check that no error occurs. |
| 182 | x1[1] |
| 183 | x2[1] |
| 184 | assert x1[1:1].shape == (0,) |
| 185 | # Tests copy-size |
| 186 | n = [0, 0, 1, 0, 0] |
| 187 | m = self.make_mask(n) |
| 188 | m2 = self.make_mask(m) |
| 189 | assert(m is m2) |
| 190 | m3 = self.make_mask(m, copy=1) |
| 191 | assert(m is not m3) |
| 192 | |
| 193 | @np.errstate(all='ignore') |
| 194 | def test_3(self): |
nothing calls this directly
no test coverage detected