(self)
| 1129 | assert_almost_equal(res1[1], fdx_uneven_ord2) |
| 1130 | |
| 1131 | def test_specific_axes(self): |
| 1132 | # Testing that gradient can work on a given axis only |
| 1133 | v = [[1, 1], [3, 4]] |
| 1134 | x = np.array(v) |
| 1135 | dx = [np.array([[2., 3.], [2., 3.]]), |
| 1136 | np.array([[0., 0.], [1., 1.]])] |
| 1137 | assert_array_equal(gradient(x, axis=0), dx[0]) |
| 1138 | assert_array_equal(gradient(x, axis=1), dx[1]) |
| 1139 | assert_array_equal(gradient(x, axis=-1), dx[1]) |
| 1140 | assert_array_equal(gradient(x, axis=(1, 0)), [dx[1], dx[0]]) |
| 1141 | |
| 1142 | # test axis=None which means all axes |
| 1143 | assert_almost_equal(gradient(x, axis=None), [dx[0], dx[1]]) |
| 1144 | # and is the same as no axis keyword given |
| 1145 | assert_almost_equal(gradient(x, axis=None), gradient(x)) |
| 1146 | |
| 1147 | # test vararg order |
| 1148 | assert_array_equal(gradient(x, 2, 3, axis=(1, 0)), |
| 1149 | [dx[1]/2.0, dx[0]/3.0]) |
| 1150 | # test maximal number of varargs |
| 1151 | assert_raises(TypeError, gradient, x, 1, 2, axis=1) |
| 1152 | |
| 1153 | assert_raises(np.AxisError, gradient, x, axis=3) |
| 1154 | assert_raises(np.AxisError, gradient, x, axis=-3) |
| 1155 | # assert_raises(TypeError, gradient, x, axis=[1,]) |
| 1156 | |
| 1157 | def test_timedelta64(self): |
| 1158 | # Make sure gradient() can handle special types like timedelta64 |
nothing calls this directly
no test coverage detected