(self)
| 233 | assert b[0, 0] != a[0, 0] |
| 234 | |
| 235 | def test_exceptions(self): |
| 236 | # test axis must be in bounds |
| 237 | for ndim in [1, 2, 3]: |
| 238 | a = np.ones((1,)*ndim) |
| 239 | np.concatenate((a, a), axis=0) # OK |
| 240 | assert_raises(np.AxisError, np.concatenate, (a, a), axis=ndim) |
| 241 | assert_raises(np.AxisError, np.concatenate, (a, a), axis=-(ndim + 1)) |
| 242 | |
| 243 | # Scalars cannot be concatenated |
| 244 | assert_raises(ValueError, concatenate, (0,)) |
| 245 | assert_raises(ValueError, concatenate, (np.array(0),)) |
| 246 | |
| 247 | # dimensionality must match |
| 248 | assert_raises_regex( |
| 249 | ValueError, |
| 250 | r"all the input arrays must have same number of dimensions, but " |
| 251 | r"the array at index 0 has 1 dimension\(s\) and the array at " |
| 252 | r"index 1 has 2 dimension\(s\)", |
| 253 | np.concatenate, (np.zeros(1), np.zeros((1, 1)))) |
| 254 | |
| 255 | # test shapes must match except for concatenation axis |
| 256 | a = np.ones((1, 2, 3)) |
| 257 | b = np.ones((2, 2, 3)) |
| 258 | axis = list(range(3)) |
| 259 | for i in range(3): |
| 260 | np.concatenate((a, b), axis=axis[0]) # OK |
| 261 | assert_raises_regex( |
| 262 | ValueError, |
| 263 | "all the input array dimensions except for the concatenation axis " |
| 264 | "must match exactly, but along dimension {}, the array at " |
| 265 | "index 0 has size 1 and the array at index 1 has size 2" |
| 266 | .format(i), |
| 267 | np.concatenate, (a, b), axis=axis[1]) |
| 268 | assert_raises(ValueError, np.concatenate, (a, b), axis=axis[2]) |
| 269 | a = np.moveaxis(a, -1, 0) |
| 270 | b = np.moveaxis(b, -1, 0) |
| 271 | axis.append(axis.pop(0)) |
| 272 | |
| 273 | # No arrays to concatenate raises ValueError |
| 274 | assert_raises(ValueError, concatenate, ()) |
| 275 | |
| 276 | def test_concatenate_axis_None(self): |
| 277 | a = np.arange(4, dtype=np.float64).reshape((2, 2)) |
nothing calls this directly
no test coverage detected