From a3b7aa5bfe632fa70be805e20876c62b97a6c4ec Mon Sep 17 00:00:00 2001 From: chebee7i Date: Sun, 22 Feb 2015 18:01:28 -0600 Subject: [PATCH] MAINT: Minor code edits. --- numpy/core/numeric.py | 9 +++++---- numpy/testing/utils.py | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 1dba8af6aba9..aa68c94dc708 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -2337,10 +2337,11 @@ def within_tol(x, y, atol, rtol): x = array(a, copy=False, subok=True, ndmin=1) y = array(b, copy=False, subok=True, ndmin=1) - # make sure y is an inexact type to avoid abs(MIN_INT); will cause - # casting of x later. Make sure to allow subclasses (e.g., for numpy.ma). - dtype = multiarray.result_type(y, 1.) - y = array(y, dtype=dtype, copy=False, subok=True) + # Make sure y is an inexact type to avoid bad behavior on abs(MIN_INT). + # This will cause casting of x later. Also, make sure to allow subclasses + # (e.g., for numpy.ma). + dt = multiarray.result_type(y, 1.) + y = array(y, dtype=dt, copy=False, subok=True) xfin = isfinite(x) yfin = isfinite(y) diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index df186f63ce2a..1051288c2647 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -1292,7 +1292,7 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0, equal_nan=False, import numpy as np def compare(x, y): return np.core.numeric.isclose(x, y, rtol=rtol, atol=atol, - equal_nan=equal_nan) + equal_nan=equal_nan) actual, desired = np.asanyarray(actual), np.asanyarray(desired) header = 'Not equal to tolerance rtol=%g, atol=%g' % (rtol, atol)