(self)
| 1040 | assert_raises(TypeError, mm, z, z, axes=[0, 1], parrot=True) |
| 1041 | |
| 1042 | def test_axis_argument(self): |
| 1043 | # inner1d signature: '(i),(i)->()' |
| 1044 | inner1d = umt.inner1d |
| 1045 | a = np.arange(27.).reshape((3, 3, 3)) |
| 1046 | b = np.arange(10., 19.).reshape((3, 1, 3)) |
| 1047 | c = inner1d(a, b) |
| 1048 | assert_array_equal(c, (a * b).sum(-1)) |
| 1049 | c = inner1d(a, b, axis=-1) |
| 1050 | assert_array_equal(c, (a * b).sum(-1)) |
| 1051 | out = np.zeros_like(c) |
| 1052 | d = inner1d(a, b, axis=-1, out=out) |
| 1053 | assert_(d is out) |
| 1054 | assert_array_equal(d, c) |
| 1055 | c = inner1d(a, b, axis=0) |
| 1056 | assert_array_equal(c, (a * b).sum(0)) |
| 1057 | # Sanity checks on innerwt and cumsum. |
| 1058 | a = np.arange(6).reshape((2, 3)) |
| 1059 | b = np.arange(10, 16).reshape((2, 3)) |
| 1060 | w = np.arange(20, 26).reshape((2, 3)) |
| 1061 | assert_array_equal(umt.innerwt(a, b, w, axis=0), |
| 1062 | np.sum(a * b * w, axis=0)) |
| 1063 | assert_array_equal(umt.cumsum(a, axis=0), np.cumsum(a, axis=0)) |
| 1064 | assert_array_equal(umt.cumsum(a, axis=-1), np.cumsum(a, axis=-1)) |
| 1065 | out = np.empty_like(a) |
| 1066 | b = umt.cumsum(a, out=out, axis=0) |
| 1067 | assert_(out is b) |
| 1068 | assert_array_equal(b, np.cumsum(a, axis=0)) |
| 1069 | b = umt.cumsum(a, out=out, axis=1) |
| 1070 | assert_(out is b) |
| 1071 | assert_array_equal(b, np.cumsum(a, axis=-1)) |
| 1072 | # Check errors. |
| 1073 | # Cannot pass in both axis and axes. |
| 1074 | assert_raises(TypeError, inner1d, a, b, axis=0, axes=[0, 0]) |
| 1075 | # Not an integer. |
| 1076 | assert_raises(TypeError, inner1d, a, b, axis=[0]) |
| 1077 | # more than 1 core dimensions. |
| 1078 | mm = umt.matrix_multiply |
| 1079 | assert_raises(TypeError, mm, a, b, axis=1) |
| 1080 | # Output wrong size in axis. |
| 1081 | out = np.empty((1, 2, 3), dtype=a.dtype) |
| 1082 | assert_raises(ValueError, umt.cumsum, a, out=out, axis=0) |
| 1083 | # Regular ufuncs should not accept axis. |
| 1084 | assert_raises(TypeError, np.add, 1., 1., axis=0) |
| 1085 | |
| 1086 | def test_keepdims_argument(self): |
| 1087 | # inner1d signature: '(i),(i)->()' |
nothing calls this directly
no test coverage detected