(self)
| 1234 | assert_raises(TypeError, mm, z, z, axes=[0, 1], parrot=True) |
| 1235 | |
| 1236 | def test_axis_argument(self): |
| 1237 | # vecdot signature: '(n),(n)->()' |
| 1238 | a = np.arange(27.).reshape((3, 3, 3)) |
| 1239 | b = np.arange(10., 19.).reshape((3, 1, 3)) |
| 1240 | c = np.vecdot(a, b) |
| 1241 | assert_array_equal(c, (a * b).sum(-1)) |
| 1242 | c = np.vecdot(a, b, axis=-1) |
| 1243 | assert_array_equal(c, (a * b).sum(-1)) |
| 1244 | out = np.zeros_like(c) |
| 1245 | d = np.vecdot(a, b, axis=-1, out=out) |
| 1246 | assert_(d is out) |
| 1247 | assert_array_equal(d, c) |
| 1248 | c = np.vecdot(a, b, axis=0) |
| 1249 | assert_array_equal(c, (a * b).sum(0)) |
| 1250 | # Sanity checks on innerwt and cumsum. |
| 1251 | a = np.arange(6).reshape((2, 3)) |
| 1252 | b = np.arange(10, 16).reshape((2, 3)) |
| 1253 | w = np.arange(20, 26).reshape((2, 3)) |
| 1254 | assert_array_equal(umt.innerwt(a, b, w, axis=0), |
| 1255 | np.sum(a * b * w, axis=0)) |
| 1256 | assert_array_equal(umt.cumsum(a, axis=0), np.cumsum(a, axis=0)) |
| 1257 | assert_array_equal(umt.cumsum(a, axis=-1), np.cumsum(a, axis=-1)) |
| 1258 | out = np.empty_like(a) |
| 1259 | b = umt.cumsum(a, out=out, axis=0) |
| 1260 | assert_(out is b) |
| 1261 | assert_array_equal(b, np.cumsum(a, axis=0)) |
| 1262 | b = umt.cumsum(a, out=out, axis=1) |
| 1263 | assert_(out is b) |
| 1264 | assert_array_equal(b, np.cumsum(a, axis=-1)) |
| 1265 | # Check errors. |
| 1266 | # Cannot pass in both axis and axes. |
| 1267 | assert_raises(TypeError, np.vecdot, a, b, axis=0, axes=[0, 0]) |
| 1268 | # Not an integer. |
| 1269 | assert_raises(TypeError, np.vecdot, a, b, axis=[0]) |
| 1270 | # more than 1 core dimensions. |
| 1271 | mm = umt.matrix_multiply |
| 1272 | assert_raises(TypeError, mm, a, b, axis=1) |
| 1273 | # Output wrong size in axis. |
| 1274 | out = np.empty((1, 2, 3), dtype=a.dtype) |
| 1275 | assert_raises(ValueError, umt.cumsum, a, out=out, axis=0) |
| 1276 | # Regular ufuncs should not accept axis. |
| 1277 | assert_raises(TypeError, np.add, 1., 1., axis=0) |
| 1278 | |
| 1279 | def test_keepdims_argument(self): |
| 1280 | # vecdot signature: '(n),(n)->()' |
nothing calls this directly
no test coverage detected