Version of np.testing.assert_allclose with `atol` and `rtol` fields set in reasonable defaults. Arguments `actual` and `desired` are not interchangeable, since the function compares the `abs(actual-desired)` with `atol+rtol*abs(desired)`. Since we often allow `desired` to be close
(actual, desired, rtol=1e-7, atol=1e-7, verbose=True)
| 99 | |
| 100 | |
| 101 | def assert_allclose(actual, desired, rtol=1e-7, atol=1e-7, verbose=True): |
| 102 | """Version of np.testing.assert_allclose with `atol` and `rtol` fields set |
| 103 | in reasonable defaults. |
| 104 | |
| 105 | Arguments `actual` and `desired` are not interchangeable, since the function |
| 106 | compares the `abs(actual-desired)` with `atol+rtol*abs(desired)`. Since we |
| 107 | often allow `desired` to be close to zero, we generally want non-zero `atol`. |
| 108 | """ |
| 109 | actual = np.asanyarray(actual) |
| 110 | desired = np.asanyarray(desired) |
| 111 | np.testing.assert_allclose(actual.shape, desired.shape) |
| 112 | np.testing.assert_allclose(actual, desired, rtol=rtol, atol=atol, verbose=verbose) |
| 113 | |
| 114 | |
| 115 | def check_numerical_grads( |
no outgoing calls
searching dependent graphs…