[Numpy-discussion] code snippet: assert all close or large

josef.pktd at gmail.com josef.pktd at gmail.com
Thu Apr 30 14:27:39 EDT 2015


Sorry, hit the wrong key

just an example that I think is not covered by numpy.testing assert

absolute tolerance for `inf`: "assert x and y are allclose or x is large if
y is inf"

On Thu, Apr 30, 2015 at 2:24 PM, <josef.pktd at gmail.com> wrote:

>
>
>
def assert_allclose_large(x, y, rtol=1e-6, atol=0, ltol=1e30):

    """ assert x and y are allclose or x is large if y is inf

    """

    mask_inf = np.isinf(y) & ~np.isinf(x)

    assert_allclose(x[~mask_inf], y[~mask_inf], rtol=rtol, atol=atol)

    assert_array_less(ltol, x[mask_inf])


Josef
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20150430/4c364f5c/attachment.html>


More information about the NumPy-Discussion mailing list