(self)
| 1118 | assert_array_equal(gradient(v), dx) |
| 1119 | |
| 1120 | def test_args(self): |
| 1121 | dx = np.cumsum(np.ones(5)) |
| 1122 | dx_uneven = [1., 2., 5., 9., 11.] |
| 1123 | f_2d = np.arange(25).reshape(5, 5) |
| 1124 | |
| 1125 | # distances must be scalars or have size equal to gradient[axis] |
| 1126 | gradient(np.arange(5), 3.) |
| 1127 | gradient(np.arange(5), np.array(3.)) |
| 1128 | gradient(np.arange(5), dx) |
| 1129 | # dy is set equal to dx because scalar |
| 1130 | gradient(f_2d, 1.5) |
| 1131 | gradient(f_2d, np.array(1.5)) |
| 1132 | |
| 1133 | gradient(f_2d, dx_uneven, dx_uneven) |
| 1134 | # mix between even and uneven spaces and |
| 1135 | # mix between scalar and vector |
| 1136 | gradient(f_2d, dx, 2) |
| 1137 | |
| 1138 | # 2D but axis specified |
| 1139 | gradient(f_2d, dx, axis=1) |
| 1140 | |
| 1141 | # 2d coordinate arguments are not yet allowed |
| 1142 | assert_raises_regex(ValueError, '.*scalars or 1d', |
| 1143 | gradient, f_2d, np.stack([dx] * 2, axis=-1), 1) |
| 1144 | |
| 1145 | def test_badargs(self): |
| 1146 | f_2d = np.arange(25).reshape(5, 5) |
nothing calls this directly
no test coverage detected