(self)
| 1270 | assert_almost_equal(res1[1], fdx_uneven_ord2) |
| 1271 | |
| 1272 | def test_specific_axes(self): |
| 1273 | # Testing that gradient can work on a given axis only |
| 1274 | v = [[1, 1], [3, 4]] |
| 1275 | x = np.array(v) |
| 1276 | dx = [np.array([[2., 3.], [2., 3.]]), |
| 1277 | np.array([[0., 0.], [1., 1.]])] |
| 1278 | assert_array_equal(gradient(x, axis=0), dx[0]) |
| 1279 | assert_array_equal(gradient(x, axis=1), dx[1]) |
| 1280 | assert_array_equal(gradient(x, axis=-1), dx[1]) |
| 1281 | assert_array_equal(gradient(x, axis=(1, 0)), [dx[1], dx[0]]) |
| 1282 | |
| 1283 | # test axis=None which means all axes |
| 1284 | assert_almost_equal(gradient(x, axis=None), [dx[0], dx[1]]) |
| 1285 | # and is the same as no axis keyword given |
| 1286 | assert_almost_equal(gradient(x, axis=None), gradient(x)) |
| 1287 | |
| 1288 | # test vararg order |
| 1289 | assert_array_equal(gradient(x, 2, 3, axis=(1, 0)), |
| 1290 | [dx[1] / 2.0, dx[0] / 3.0]) |
| 1291 | # test maximal number of varargs |
| 1292 | assert_raises(TypeError, gradient, x, 1, 2, axis=1) |
| 1293 | |
| 1294 | assert_raises(AxisError, gradient, x, axis=3) |
| 1295 | assert_raises(AxisError, gradient, x, axis=-3) |
| 1296 | # assert_raises(TypeError, gradient, x, axis=[1,]) |
| 1297 | |
| 1298 | def test_timedelta64(self): |
| 1299 | # Make sure gradient() can handle special types like timedelta64 |
nothing calls this directly
no test coverage detected