>>> import numpy >>> numpy.test('full') NumPy version 1.15.0 NumPy relaxed strides checking option: True .................x......................................................................................s............................................................................................ [ 3%] ..........s.......................................................s.................................................................................................................................. [ 7%] ................................................................................sss..........................................................................................................s....... [ 11%] ...............xx.................................................................................................................................................................................... [ 15%] ..................................................................................................................................................................................................... [ 19%] ..................................................................................................................................................................................................... [ 23%] ..........................................................................................................................................................x.......................................... [ 27%] ..................................................................................................................................................................................................... [ 31%] ...............s................................s....................s............................................................................................................................... [ 35%] ...........................................................................................................................................................ss.s..s.......s........................... [ 39%] .............................................................................ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 43%] sssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss [ 47%] ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss....................................................................................................................... [ 51%] .........................................................................................................s........................................................................................... [ 55%] ..................................................................................................................................................................................................... [ 59%] ..................................................................................................................................................................................................... [ 63%] ...............................................................................................F...............................................x....................F................................ [ 67%] .......................................................................................................................................................s............................................. [ 71%] ..........F.F.F.....................................................................s................................................................................................................ [ 75%] .....................................................................................................................................................................s.xx............................ [ 79%] ............................................FF....................................................................................................................................................... [ 83%] ......................................................................F.....................................................F........................................................................ [ 87%] ..................................FFFFFF............................................................................................................................................................F [ 91%] ................................F................................F................................F......................................F........................................................... [ 95%] ......................................................................................................................................................................................sss............ [ 99%] ................................................ [100%] ================================================================================================= FAILURES ================================================================================================== ___________________________________________________________________________________________ TestDocs.test_polyfit ___________________________________________________________________________________________ self = def test_polyfit(self): c = np.array([3., 2., 1.]) x = np.linspace(0, 2, 7) y = np.polyval(c, x) err = [1, -1, 1, -1, 1, -1, 1] weights = np.arange(8, 1, -1)**2/7.0 # Check exception when too few points for variance estimate. Note that # the Bayesian estimate requires the number of data points to exceed # degree + 3. assert_raises(ValueError, np.polyfit, [0, 1, 3], [0, 1, 3], deg=0, cov=True) # check 1D case > m, cov = np.polyfit(x, y+err, 2, cov=True) c = array([3., 2., 1.]) err = [1, -1, 1, -1, 1, -1, ...] self = weights = array([9.14285714, 7. , 5.14285714, 3.57142857, 2.28571429, 1.28571429, 0.57142857]) x = array([0. , 0.33333333, 0.66666667, 1. , 1.33333333, 1.66666667, 2. ]) y = array([ 1. , 2. , 3.66666667, 6. , 9. , 12.66666667, 17. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/tests/test_polynomial.py:145: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ x = array([0. , 0.33333333, 0.66666667, 1. , 1.33333333, 1.66666667, 2. ]) y = array([ 2. , 1. , 4.66666667, 5. , 10. , 11.66666667, 18. ]), deg = 2, rcond = 1.5543122344752192e-15, full = False, w = None, cov = True def polyfit(x, y, deg, rcond=None, full=False, w=None, cov=False): """ Least squares polynomial fit. Fit a polynomial ``p(x) = p[0] * x**deg + ... + p[deg]`` of degree `deg` to points `(x, y)`. Returns a vector of coefficients `p` that minimises the squared error. Parameters ---------- x : array_like, shape (M,) x-coordinates of the M sample points ``(x[i], y[i])``. y : array_like, shape (M,) or (M, K) y-coordinates of the sample points. Several data sets of sample points sharing the same x-coordinates can be fitted at once by passing in a 2D-array that contains one dataset per column. deg : int Degree of the fitting polynomial rcond : float, optional Relative condition number of the fit. Singular values smaller than this relative to the largest singular value will be ignored. The default value is len(x)*eps, where eps is the relative precision of the float type, about 2e-16 in most cases. full : bool, optional Switch determining nature of return value. When it is False (the default) just the coefficients are returned, when True diagnostic information from the singular value decomposition is also returned. w : array_like, shape (M,), optional Weights to apply to the y-coordinates of the sample points. For gaussian uncertainties, use 1/sigma (not 1/sigma**2). cov : bool, optional Return the estimate and the covariance matrix of the estimate If full is True, then cov is not returned. Returns ------- p : ndarray, shape (deg + 1,) or (deg + 1, K) Polynomial coefficients, highest power first. If `y` was 2-D, the coefficients for `k`-th data set are in ``p[:,k]``. residuals, rank, singular_values, rcond Present only if `full` = True. Residuals of the least-squares fit, the effective rank of the scaled Vandermonde coefficient matrix, its singular values, and the specified value of `rcond`. For more details, see `linalg.lstsq`. V : ndarray, shape (M,M) or (M,M,K) Present only if `full` = False and `cov`=True. The covariance matrix of the polynomial coefficient estimates. The diagonal of this matrix are the variance estimates for each coefficient. If y is a 2-D array, then the covariance matrix for the `k`-th data set are in ``V[:,:,k]`` Warns ----- RankWarning The rank of the coefficient matrix in the least-squares fit is deficient. The warning is only raised if `full` = False. The warnings can be turned off by >>> import warnings >>> warnings.simplefilter('ignore', np.RankWarning) See Also -------- polyval : Compute polynomial values. linalg.lstsq : Computes a least-squares fit. scipy.interpolate.UnivariateSpline : Computes spline fits. Notes ----- The solution minimizes the squared error .. math :: E = \\sum_{j=0}^k |p(x_j) - y_j|^2 in the equations:: x[0]**n * p[0] + ... + x[0] * p[n-1] + p[n] = y[0] x[1]**n * p[0] + ... + x[1] * p[n-1] + p[n] = y[1] ... x[k]**n * p[0] + ... + x[k] * p[n-1] + p[n] = y[k] The coefficient matrix of the coefficients `p` is a Vandermonde matrix. `polyfit` issues a `RankWarning` when the least-squares fit is badly conditioned. This implies that the best fit is not well-defined due to numerical error. The results may be improved by lowering the polynomial degree or by replacing `x` by `x` - `x`.mean(). The `rcond` parameter can also be set to a value smaller than its default, but the resulting fit may be spurious: including contributions from the small singular values can add numerical noise to the result. Note that fitting polynomial coefficients is inherently badly conditioned when the degree of the polynomial is large or the interval of sample points is badly centered. The quality of the fit should always be checked in these cases. When polynomial fits are not satisfactory, splines may be a good alternative. References ---------- .. [1] Wikipedia, "Curve fitting", http://en.wikipedia.org/wiki/Curve_fitting .. [2] Wikipedia, "Polynomial interpolation", http://en.wikipedia.org/wiki/Polynomial_interpolation Examples -------- >>> x = np.array([0.0, 1.0, 2.0, 3.0, 4.0, 5.0]) >>> y = np.array([0.0, 0.8, 0.9, 0.1, -0.8, -1.0]) >>> z = np.polyfit(x, y, 3) >>> z array([ 0.08703704, -0.81349206, 1.69312169, -0.03968254]) It is convenient to use `poly1d` objects for dealing with polynomials: >>> p = np.poly1d(z) >>> p(0.5) 0.6143849206349179 >>> p(3.5) -0.34732142857143039 >>> p(10) 22.579365079365115 High-order polynomials may oscillate wildly: >>> p30 = np.poly1d(np.polyfit(x, y, 30)) /... RankWarning: Polyfit may be poorly conditioned... >>> p30(4) -0.80000000000000204 >>> p30(5) -0.99999999999999445 >>> p30(4.5) -0.10547061179440398 Illustration: >>> import matplotlib.pyplot as plt >>> xp = np.linspace(-2, 6, 100) >>> _ = plt.plot(x, y, '.', xp, p(xp), '-', xp, p30(xp), '--') >>> plt.ylim(-2,2) (-2, 2) >>> plt.show() """ order = int(deg) + 1 x = NX.asarray(x) + 0.0 y = NX.asarray(y) + 0.0 # check arguments. if deg < 0: raise ValueError("expected deg >= 0") if x.ndim != 1: raise TypeError("expected 1D vector for x") if x.size == 0: raise TypeError("expected non-empty vector for x") if y.ndim < 1 or y.ndim > 2: raise TypeError("expected 1D or 2D array for y") if x.shape[0] != y.shape[0]: raise TypeError("expected x and y to have same length") # set rcond if rcond is None: rcond = len(x)*finfo(x.dtype).eps # set up least squares equation for powers of x lhs = vander(x, order) rhs = y # apply weighting if w is not None: w = NX.asarray(w) + 0.0 if w.ndim != 1: raise TypeError("expected a 1-d array for weights") if w.shape[0] != y.shape[0]: raise TypeError("expected w and y to have the same length") lhs *= w[:, NX.newaxis] if rhs.ndim == 2: rhs *= w[:, NX.newaxis] else: rhs *= w # scale lhs to improve condition number and solve scale = NX.sqrt((lhs*lhs).sum(axis=0)) lhs /= scale c, resids, rank, s = lstsq(lhs, rhs, rcond) c = (c.T/scale).T # broadcast scale coefficients # warn on rank reduction, which indicates an ill conditioned matrix if rank != order and not full: msg = "Polyfit may be poorly conditioned" warnings.warn(msg, RankWarning, stacklevel=2) if full: return c, resids, rank, s, rcond elif cov: Vbase = inv(dot(lhs.T, lhs)) Vbase /= NX.outer(scale, scale) # Some literature ignores the extra -2.0 factor in the denominator, but # it is included here because the covariance of Multivariate Student-T # (which is implied by a Bayesian uncertainty analysis) includes it. # Plus, it gives a slightly more conservative estimate of uncertainty. if len(x) <= order + 2: raise ValueError("the number of data points must exceed order + 2 " "for Bayesian estimate the covariance matrix") fac = resids / (len(x) - order - 2.0) if y.ndim == 1: > return c, Vbase * fac E ValueError: operands could not be broadcast together with shapes (3,3) (0,) Vbase = array([[ 0.96428571, -1.92857143, 0.53571429], [-1.92857143, 4.17857143, -1.39285714], [ 0.53571429, -1.39285714, 0.76190476]]) c = array([5.29966223, 3.17979734, 2.64575131]) cov = True deg = 2 fac = array([], dtype=float64) full = False lhs = array([[0. , 0. , 0.37796447], [0.0209657 , 0.10482848, 0.37796447], [0.08386279, 0.209656...15, 0.41931393, 0.37796447], [0.52414242, 0.52414242, 0.37796447], [0.75476508, 0.6289709 , 0.37796447]]) msg = 'Polyfit may be poorly conditioned' order = 3 rank = 16843008 rcond = 1.5543122344752192e-15 resids = array([], dtype=float64) rhs = array([ 2. , 1. , 4.66666667, 5. , 10. , 11.66666667, 18. ]) s = array([0., 1., 3.]) scale = array([5.29966223, 3.17979734, 2.64575131]) w = None x = array([0. , 0.33333333, 0.66666667, 1. , 1.33333333, 1.66666667, 2. ]) y = array([ 2. , 1. , 4.66666667, 5. , 10. , 11.66666667, 18. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/polynomial.py:602: ValueError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438800384) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _____________________________________________________________________________________ TestRegression.test_polyfit_build _____________________________________________________________________________________ self = def test_polyfit_build(self): # Ticket #628 ref = [-1.06123820e-06, 5.70886914e-04, -1.13822012e-01, 9.95368241e+00, -3.14526520e+02] x = [90, 91, 92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 129, 130, 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, 146, 147, 148, 149, 150, 151, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 172, 173, 174, 175, 176] y = [9.0, 3.0, 7.0, 4.0, 4.0, 8.0, 6.0, 11.0, 9.0, 8.0, 11.0, 5.0, 6.0, 5.0, 9.0, 8.0, 6.0, 10.0, 6.0, 10.0, 7.0, 6.0, 6.0, 6.0, 13.0, 4.0, 9.0, 11.0, 4.0, 5.0, 8.0, 5.0, 7.0, 7.0, 6.0, 12.0, 7.0, 7.0, 9.0, 4.0, 12.0, 6.0, 6.0, 4.0, 3.0, 9.0, 8.0, 8.0, 6.0, 7.0, 9.0, 10.0, 6.0, 8.0, 4.0, 7.0, 7.0, 10.0, 8.0, 8.0, 6.0, 3.0, 8.0, 4.0, 5.0, 7.0, 8.0, 6.0, 6.0, 4.0, 12.0, 9.0, 8.0, 8.0, 8.0, 6.0, 7.0, 4.0, 4.0, 5.0, 7.0] tested = np.polyfit(x, y, 4) > assert_array_almost_equal(ref, tested) E AssertionError: E Arrays are not almost equal to 6 decimals E E (mismatch 100.0%) E x: array([-1.061238e-06, 5.708869e-04, -1.138220e-01, 9.953682e+00, E -3.145265e+02]) E y: array([4.191277e+09, 2.668547e+07, 1.757346e+05, 1.216110e+03, E 9.000000e+00]) ref = [-1.0612382e-06, 0.000570886914, -0.113822012, 9.95368241, -314.52652] self = tested = array([4.19127652e+09, 2.66854699e+07, 1.75734565e+05, 1.21611019e+03, 9.00000000e+00]) x = [90, 91, 92, 93, 94, 95, ...] y = [9.0, 3.0, 7.0, 4.0, 4.0, 8.0, ...] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/tests/test_regression.py:104: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init __________________________________________________________________________________________ TestLstsq.test_sq_cases __________________________________________________________________________________________ self = , require = {'square'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: > case.check(self.do) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Frameworks/Pytho...ost equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([0., 0.], dtype=float32)\n' require = {'square'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:350: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , do = > def check(self, do): """ Run the function `do` on this test case, expanding arguments """ > do(self.a, self.b, tags=self.tags) do = > self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:85: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , a = array([[1., 2.], [3., 4.]], dtype=float32), b = array([2., 1.], dtype=float32), tags = frozenset({'square'}) def do(self, a, b, tags): if 'size-0' in tags: assert_raises(LinAlgError, linalg.lstsq, a, b) return arr = np.asarray(a) m, n = arr.shape u, s, vt = linalg.svd(a, 0) x, residuals, rank, sv = linalg.lstsq(a, b, rcond=-1) if m <= n: > assert_almost_equal(b, dot(a, x)) a = array([[1., 2.], [3., 4.]], dtype=float32) arr = array([[1., 2.], [3., 4.]], dtype=float32) b = array([2., 1.], dtype=float32) m = 2 n = 2 rank = 0 residuals = array([], dtype=float32) s = array([5.464986 , 0.3659662], dtype=float32) self = sv = array([0., 0.], dtype=float32) tags = frozenset({'square'}) u = array([[-0.4045536, -0.9145143], [-0.9145143, 0.4045536]], dtype=float32) vt = array([[-0.57604843, -0.81741554], [ 0.81741554, -0.57604843]], dtype=float32) x = array([0., 0.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:887: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = array([2., 1.], dtype=float32), b = array([0., 0.], dtype=float32), single_decimal = 6, double_decimal = 12, kw = {}, decimal = 6 def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw): if asarray(a).dtype.type in (single, csingle): decimal = single_decimal else: decimal = double_decimal > old_assert_almost_equal(a, b, decimal=decimal, **kw) a = array([2., 1.], dtype=float32) b = array([0., 0.], dtype=float32) decimal = 6 double_decimal = 12 kw = {} single_decimal = 6 /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:41: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ actual = array([2., 1.], dtype=float32), desired = array([0., 0.], dtype=float32), decimal = 6, err_msg = '', verbose = True def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): """ Raises an AssertionError if two items are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation in `assert_array_almost_equal` did up to rounding vagaries. An exception is raised at conflicting values. For ndarrays this delegates to assert_array_almost_equal Parameters ---------- actual : array_like The object to check. desired : array_like The expected object. decimal : int, optional Desired precision, default is 7. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- >>> import numpy.testing as npt >>> npt.assert_almost_equal(2.3333333333333, 2.33333334) >>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10) ... : Items are not equal: ACTUAL: 2.3333333333333002 DESIRED: 2.3333333399999998 >>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]), ... np.array([1.0,2.33333334]), decimal=9) ... : Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333333]) y: array([ 1. , 2.33333334]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import ndarray from numpy.lib import iscomplexobj, real, imag # Handle complex numbers: separate into real/imag to handle # nan/inf/negative zero correctly # XXX: catch ValueError for subclasses of ndarray where iscomplex fail try: usecomplex = iscomplexobj(actual) or iscomplexobj(desired) except ValueError: usecomplex = False def _build_err_msg(): header = ('Arrays are not almost equal to %d decimals' % decimal) return build_err_msg([actual, desired], err_msg, verbose=verbose, header=header) if usecomplex: if iscomplexobj(actual): actualr = real(actual) actuali = imag(actual) else: actualr = actual actuali = 0 if iscomplexobj(desired): desiredr = real(desired) desiredi = imag(desired) else: desiredr = desired desiredi = 0 try: assert_almost_equal(actualr, desiredr, decimal=decimal) assert_almost_equal(actuali, desiredi, decimal=decimal) except AssertionError: raise AssertionError(_build_err_msg()) if isinstance(actual, (ndarray, tuple, list)) \ or isinstance(desired, (ndarray, tuple, list)): > return assert_array_almost_equal(actual, desired, decimal, err_msg) __tracebackhide__ = True _build_err_msg = ._build_err_msg at 0x10c1f49d8> actual = array([2., 1.], dtype=float32) decimal = 6 desired = array([0., 0.], dtype=float32) err_msg = '' imag = iscomplexobj = ndarray = real = usecomplex = False verbose = True /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:568: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ x = array([2., 1.], dtype=float32), y = array([0., 0.], dtype=float32), decimal = 6, err_msg = '', verbose = True def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True): """ Raises an AssertionError if two objects are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies identical shapes and that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation did up to rounding vagaries. An exception is raised at shape mismatch or conflicting values. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions. Parameters ---------- x : array_like The actual object to check. y : array_like The desired, expected object. decimal : int, optional Desired precision, default is 6. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- the first assert does not raise an exception >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan], [1.0,2.333,np.nan]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33339,np.nan], decimal=5) ... : AssertionError: Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33339, NaN]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33333, 5], decimal=5) : ValueError: Arrays are not almost equal x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33333, 5. ]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import around, number, float_, result_type, array from numpy.core.numerictypes import issubdtype from numpy.core.fromnumeric import any as npany def compare(x, y): try: if npany(gisinf(x)) or npany( gisinf(y)): xinfid = gisinf(x) yinfid = gisinf(y) if not (xinfid == yinfid).all(): return False # if one item, x and y is +- inf if x.size == y.size == 1: return x == y x = x[~xinfid] y = y[~yinfid] except (TypeError, NotImplementedError): pass # make sure y is an inexact type to avoid abs(MIN_INT); will cause # casting of x later. dtype = result_type(y, 1.) y = array(y, dtype=dtype, copy=False, subok=True) z = abs(x - y) if not issubdtype(z.dtype, number): z = z.astype(float_) # handle object arrays return z < 1.5 * 10.0**(-decimal) assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose, header=('Arrays are not almost equal to %d decimals' % decimal), > precision=decimal) __tracebackhide__ = True around = array = compare = .compare at 0x10c1f4730> decimal = 6 err_msg = '' float_ = issubdtype = npany = number = result_type = verbose = True x = array([2., 1.], dtype=float32) y = array([0., 0.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:964: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ comparison = .compare at 0x10c1f4730>, x = array([2., 1.], dtype=float32), y = array([0., 0.], dtype=float32), err_msg = '', verbose = True header = 'Arrays are not almost equal to 6 decimals', precision = 6, equal_nan = True, equal_inf = True def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', precision=6, equal_nan=True, equal_inf=True): __tracebackhide__ = True # Hide traceback for py.test from numpy.core import array, isnan, inf, bool_ x = array(x, copy=False, subok=True) y = array(y, copy=False, subok=True) def isnumber(x): return x.dtype.char in '?bhilqpBHILQPefdgFDG' def istime(x): return x.dtype.char in "Mm" def func_assert_same_pos(x, y, func=isnan, hasval='nan'): """Handling nan/inf: combine results of running func on x and y, checking that they are True at the same locations.""" # Both the != True comparison here and the cast to bool_ at # the end are done to deal with `masked`, which cannot be # compared usefully, and for which .all() yields masked. x_id = func(x) y_id = func(y) if (x_id == y_id).all() != True: msg = build_err_msg([x, y], err_msg + '\nx and y %s location mismatch:' % (hasval), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) # If there is a scalar, then here we know the array has the same # flag as it everywhere, so we should return the scalar flag. if x_id.ndim == 0: return bool_(x_id) elif y_id.ndim == 0: return bool_(y_id) else: return y_id try: cond = (x.shape == () or y.shape == ()) or x.shape == y.shape if not cond: msg = build_err_msg([x, y], err_msg + '\n(shapes %s, %s mismatch)' % (x.shape, y.shape), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) flagged = bool_(False) if isnumber(x) and isnumber(y): if equal_nan: flagged = func_assert_same_pos(x, y, func=isnan, hasval='nan') if equal_inf: flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == +inf, hasval='+inf') flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == -inf, hasval='-inf') elif istime(x) and istime(y): # If one is datetime64 and the other timedelta64 there is no point if equal_nan and x.dtype.type == y.dtype.type: flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT") if flagged.ndim > 0: x, y = x[~flagged], y[~flagged] # Only do the comparison if actual values are left if x.size == 0: return elif flagged: # no sense doing comparison if everything is flagged. return val = comparison(x, y) if isinstance(val, bool): cond = val reduced = [0] else: reduced = val.ravel() cond = reduced.all() reduced = reduced.tolist() # The below comparison is a hack to ensure that fully masked # results, for which val.ravel().all() returns np.ma.masked, # do not trigger a failure (np.ma.masked != True evaluates as # np.ma.masked, which is falsy). if cond != True: match = 100-100.0*reduced.count(1)/len(reduced) msg = build_err_msg([x, y], err_msg + '\n(mismatch %s%%)' % (match,), verbose=verbose, header=header, names=('x', 'y'), precision=precision) > raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 6 decimals E E (mismatch 100.0%) E x: array([2., 1.], dtype=float32) E y: array([0., 0.], dtype=float32) __tracebackhide__ = True array = bool_ = comparison = .compare at 0x10c1f4730> cond = False equal_inf = True equal_nan = True err_msg = '' flagged = array([False, False]) func_assert_same_pos = .func_assert_same_pos at 0x10c1f4a60> header = 'Arrays are not almost equal to 6 decimals' inf = inf isnan = isnumber = .isnumber at 0x10c1f46a8> istime = .istime at 0x10c1f4840> match = 100.0 msg = '\nArrays are not almost equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([0., 0.], dtype=float32)' precision = 6 reduced = [False, False] val = array([False, False]) verbose = True x = array([2., 1.], dtype=float32) y = array([0., 0.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:780: AssertionError During handling of the above exception, another exception occurred: self = def test_sq_cases(self): self.check_cases(require={'square'}, > exclude={'generalized', 'size-0'}) self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:361: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , require = {'square'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: case.check(self.do) except Exception: msg = "In test case: %r\n\n" % case msg += traceback.format_exc() > raise AssertionError(msg) E AssertionError: In test case: E E Traceback (most recent call last): E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 350, in check_cases E case.check(self.do) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 85, in check E do(self.a, self.b, tags=self.tags) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 887, in do E assert_almost_equal(b, dot(a, x)) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 41, in assert_almost_equal E old_assert_almost_equal(a, b, decimal=decimal, **kw) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 568, in assert_almost_equal E return assert_array_almost_equal(actual, desired, decimal, err_msg) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 964, in assert_array_almost_equal E precision=decimal) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 780, in assert_array_compare E raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 6 decimals E E (mismatch 100.0%) E x: array([2., 1.], dtype=float32) E y: array([0., 0.], dtype=float32) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Frameworks/Pytho...ost equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([0., 0.], dtype=float32)\n' require = {'square'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:354: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438804480) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ________________________________________________________________________________________ TestLstsq.test_nonsq_cases _________________________________________________________________________________________ self = , require = {'nonsquare'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: > case.check(self.do) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Frameworks...t equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([ 6., 13.], dtype=float32)\n' require = {'nonsquare'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:350: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , do = > def check(self, do): """ Run the function `do` on this test case, expanding arguments """ > do(self.a, self.b, tags=self.tags) do = > self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:85: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , a = array([[1., 2., 3.], [3., 4., 6.]], dtype=float32), b = array([2., 1.], dtype=float32), tags = frozenset({'nonsquare'}) def do(self, a, b, tags): if 'size-0' in tags: assert_raises(LinAlgError, linalg.lstsq, a, b) return arr = np.asarray(a) m, n = arr.shape u, s, vt = linalg.svd(a, 0) x, residuals, rank, sv = linalg.lstsq(a, b, rcond=-1) if m <= n: > assert_almost_equal(b, dot(a, x)) a = array([[1., 2., 3.], [3., 4., 6.]], dtype=float32) arr = array([[1., 2., 3.], [3., 4., 6.]], dtype=float32) b = array([2., 1.], dtype=float32) m = 2 n = 3 rank = 0 residuals = array([], dtype=float32) s = array([8.650218 , 0.41681626], dtype=float32) self = sv = array([-1.0533684e-03, -7.4266063e-05], dtype=float32) tags = frozenset({'nonsquare'}) u = array([[-0.4303583 , -0.90265816], [-0.90265816, 0.4303583 ]], dtype=float32) vt = array([[-0.3628039 , -0.51690596, -0.775359 ], [ 0.9318655 , -0.2012474 , -0.3018711 ]], dtype=float32) x = array([1., 1., 1.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:887: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = array([2., 1.], dtype=float32), b = array([ 6., 13.], dtype=float32), single_decimal = 6, double_decimal = 12, kw = {}, decimal = 6 def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw): if asarray(a).dtype.type in (single, csingle): decimal = single_decimal else: decimal = double_decimal > old_assert_almost_equal(a, b, decimal=decimal, **kw) a = array([2., 1.], dtype=float32) b = array([ 6., 13.], dtype=float32) decimal = 6 double_decimal = 12 kw = {} single_decimal = 6 /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:41: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ actual = array([2., 1.], dtype=float32), desired = array([ 6., 13.], dtype=float32), decimal = 6, err_msg = '', verbose = True def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): """ Raises an AssertionError if two items are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation in `assert_array_almost_equal` did up to rounding vagaries. An exception is raised at conflicting values. For ndarrays this delegates to assert_array_almost_equal Parameters ---------- actual : array_like The object to check. desired : array_like The expected object. decimal : int, optional Desired precision, default is 7. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- >>> import numpy.testing as npt >>> npt.assert_almost_equal(2.3333333333333, 2.33333334) >>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10) ... : Items are not equal: ACTUAL: 2.3333333333333002 DESIRED: 2.3333333399999998 >>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]), ... np.array([1.0,2.33333334]), decimal=9) ... : Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333333]) y: array([ 1. , 2.33333334]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import ndarray from numpy.lib import iscomplexobj, real, imag # Handle complex numbers: separate into real/imag to handle # nan/inf/negative zero correctly # XXX: catch ValueError for subclasses of ndarray where iscomplex fail try: usecomplex = iscomplexobj(actual) or iscomplexobj(desired) except ValueError: usecomplex = False def _build_err_msg(): header = ('Arrays are not almost equal to %d decimals' % decimal) return build_err_msg([actual, desired], err_msg, verbose=verbose, header=header) if usecomplex: if iscomplexobj(actual): actualr = real(actual) actuali = imag(actual) else: actualr = actual actuali = 0 if iscomplexobj(desired): desiredr = real(desired) desiredi = imag(desired) else: desiredr = desired desiredi = 0 try: assert_almost_equal(actualr, desiredr, decimal=decimal) assert_almost_equal(actuali, desiredi, decimal=decimal) except AssertionError: raise AssertionError(_build_err_msg()) if isinstance(actual, (ndarray, tuple, list)) \ or isinstance(desired, (ndarray, tuple, list)): > return assert_array_almost_equal(actual, desired, decimal, err_msg) __tracebackhide__ = True _build_err_msg = ._build_err_msg at 0x10e33a048> actual = array([2., 1.], dtype=float32) decimal = 6 desired = array([ 6., 13.], dtype=float32) err_msg = '' imag = iscomplexobj = ndarray = real = usecomplex = False verbose = True /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:568: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ x = array([2., 1.], dtype=float32), y = array([ 6., 13.], dtype=float32), decimal = 6, err_msg = '', verbose = True def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True): """ Raises an AssertionError if two objects are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies identical shapes and that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation did up to rounding vagaries. An exception is raised at shape mismatch or conflicting values. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions. Parameters ---------- x : array_like The actual object to check. y : array_like The desired, expected object. decimal : int, optional Desired precision, default is 6. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- the first assert does not raise an exception >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan], [1.0,2.333,np.nan]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33339,np.nan], decimal=5) ... : AssertionError: Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33339, NaN]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33333, 5], decimal=5) : ValueError: Arrays are not almost equal x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33333, 5. ]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import around, number, float_, result_type, array from numpy.core.numerictypes import issubdtype from numpy.core.fromnumeric import any as npany def compare(x, y): try: if npany(gisinf(x)) or npany( gisinf(y)): xinfid = gisinf(x) yinfid = gisinf(y) if not (xinfid == yinfid).all(): return False # if one item, x and y is +- inf if x.size == y.size == 1: return x == y x = x[~xinfid] y = y[~yinfid] except (TypeError, NotImplementedError): pass # make sure y is an inexact type to avoid abs(MIN_INT); will cause # casting of x later. dtype = result_type(y, 1.) y = array(y, dtype=dtype, copy=False, subok=True) z = abs(x - y) if not issubdtype(z.dtype, number): z = z.astype(float_) # handle object arrays return z < 1.5 * 10.0**(-decimal) assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose, header=('Arrays are not almost equal to %d decimals' % decimal), > precision=decimal) __tracebackhide__ = True around = array = compare = .compare at 0x10e33a0d0> decimal = 6 err_msg = '' float_ = issubdtype = npany = number = result_type = verbose = True x = array([2., 1.], dtype=float32) y = array([ 6., 13.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:964: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ comparison = .compare at 0x10e33a0d0>, x = array([2., 1.], dtype=float32), y = array([ 6., 13.], dtype=float32), err_msg = '', verbose = True header = 'Arrays are not almost equal to 6 decimals', precision = 6, equal_nan = True, equal_inf = True def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', precision=6, equal_nan=True, equal_inf=True): __tracebackhide__ = True # Hide traceback for py.test from numpy.core import array, isnan, inf, bool_ x = array(x, copy=False, subok=True) y = array(y, copy=False, subok=True) def isnumber(x): return x.dtype.char in '?bhilqpBHILQPefdgFDG' def istime(x): return x.dtype.char in "Mm" def func_assert_same_pos(x, y, func=isnan, hasval='nan'): """Handling nan/inf: combine results of running func on x and y, checking that they are True at the same locations.""" # Both the != True comparison here and the cast to bool_ at # the end are done to deal with `masked`, which cannot be # compared usefully, and for which .all() yields masked. x_id = func(x) y_id = func(y) if (x_id == y_id).all() != True: msg = build_err_msg([x, y], err_msg + '\nx and y %s location mismatch:' % (hasval), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) # If there is a scalar, then here we know the array has the same # flag as it everywhere, so we should return the scalar flag. if x_id.ndim == 0: return bool_(x_id) elif y_id.ndim == 0: return bool_(y_id) else: return y_id try: cond = (x.shape == () or y.shape == ()) or x.shape == y.shape if not cond: msg = build_err_msg([x, y], err_msg + '\n(shapes %s, %s mismatch)' % (x.shape, y.shape), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) flagged = bool_(False) if isnumber(x) and isnumber(y): if equal_nan: flagged = func_assert_same_pos(x, y, func=isnan, hasval='nan') if equal_inf: flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == +inf, hasval='+inf') flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == -inf, hasval='-inf') elif istime(x) and istime(y): # If one is datetime64 and the other timedelta64 there is no point if equal_nan and x.dtype.type == y.dtype.type: flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT") if flagged.ndim > 0: x, y = x[~flagged], y[~flagged] # Only do the comparison if actual values are left if x.size == 0: return elif flagged: # no sense doing comparison if everything is flagged. return val = comparison(x, y) if isinstance(val, bool): cond = val reduced = [0] else: reduced = val.ravel() cond = reduced.all() reduced = reduced.tolist() # The below comparison is a hack to ensure that fully masked # results, for which val.ravel().all() returns np.ma.masked, # do not trigger a failure (np.ma.masked != True evaluates as # np.ma.masked, which is falsy). if cond != True: match = 100-100.0*reduced.count(1)/len(reduced) msg = build_err_msg([x, y], err_msg + '\n(mismatch %s%%)' % (match,), verbose=verbose, header=header, names=('x', 'y'), precision=precision) > raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 6 decimals E E (mismatch 100.0%) E x: array([2., 1.], dtype=float32) E y: array([ 6., 13.], dtype=float32) __tracebackhide__ = True array = bool_ = comparison = .compare at 0x10e33a0d0> cond = False equal_inf = True equal_nan = True err_msg = '' flagged = array([False, False]) func_assert_same_pos = .func_assert_same_pos at 0x10e33a268> header = 'Arrays are not almost equal to 6 decimals' inf = inf isnan = isnumber = .isnumber at 0x10e33a158> istime = .istime at 0x10e33a1e0> match = 100.0 msg = '\nArrays are not almost equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([ 6., 13.], dtype=float32)' precision = 6 reduced = [False, False] val = array([False, False]) verbose = True x = array([2., 1.], dtype=float32) y = array([ 6., 13.], dtype=float32) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:780: AssertionError During handling of the above exception, another exception occurred: self = def test_nonsq_cases(self): self.check_cases(require={'nonsquare'}, > exclude={'generalized', 'size-0'}) self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:372: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , require = {'nonsquare'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: case.check(self.do) except Exception: msg = "In test case: %r\n\n" % case msg += traceback.format_exc() > raise AssertionError(msg) E AssertionError: In test case: E E Traceback (most recent call last): E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 350, in check_cases E case.check(self.do) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 85, in check E do(self.a, self.b, tags=self.tags) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 887, in do E assert_almost_equal(b, dot(a, x)) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 41, in assert_almost_equal E old_assert_almost_equal(a, b, decimal=decimal, **kw) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 568, in assert_almost_equal E return assert_array_almost_equal(actual, desired, decimal, err_msg) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 964, in assert_array_almost_equal E precision=decimal) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 780, in assert_array_compare E raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 6 decimals E E (mismatch 100.0%) E x: array([2., 1.], dtype=float32) E y: array([ 6., 13.], dtype=float32) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Frameworks...t equal to 6 decimals\n\n(mismatch 100.0%)\n x: array([2., 1.], dtype=float32)\n y: array([ 6., 13.], dtype=float32)\n' require = {'nonsquare'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:354: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438804480) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ________________________________________________________________________________________ TestLstsq.test_future_rcond ________________________________________________________________________________________ self = def test_future_rcond(self): a = np.array([[0., 1., 0., 1., 2., 0.], [0., 2., 0., 0., 1., 0.], [1., 0., 1., 0., 0., 4.], [0., 0., 0., 2., 3., 0.]]).T b = np.array([1, 0, 0, 0, 0, 0]) with suppress_warnings() as sup: w = sup.record(FutureWarning, "`rcond` parameter will change") x, residuals, rank, s = linalg.lstsq(a, b) > assert_(rank == 4) E AssertionError a = array([[0., 0., 1., 0.], [1., 2., 0., 0.], [0., 0., 1., 0.], [1., 0., 0., 2.], [2., 1., 0., 3.], [0., 0., 4., 0.]]) b = array([1, 0, 0, 0, 0, 0]) rank = 1095761920 residuals = array([], dtype=float64) s = array([-0.40455358, -0.9145143 , -0.9145143 , 0.40455358]) self = sup = w = [] x = array([-0.43035828, -0.90265816, -0.90265816, 0.43035828]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:918: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438816768) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ________________________________________________________________________________________ TestPolynomial.test_polyfit ________________________________________________________________________________________ self = def test_polyfit(self): # Tests polyfit # On ndarrays x = np.random.rand(10) y = np.random.rand(20).reshape(-1, 2) assert_almost_equal(polyfit(x, y, 3), np.polyfit(x, y, 3)) # ON 1D maskedarrays x = x.view(MaskedArray) x[0] = masked y = y.view(MaskedArray) y[0, 0] = y[-1, -1] = masked # (C, R, K, S, D) = polyfit(x, y[:, 0], 3, full=True) (c, r, k, s, d) = np.polyfit(x[1:], y[1:, 0].compressed(), 3, full=True) for (a, a_) in zip((C, R, K, S, D), (c, r, k, s, d)): > assert_almost_equal(a, a_) C = array([1.10107647, 1.33707346, 1.75813242, 3. ]) D = 1.9984014443252818e-15 K = 16843009 R = array([], dtype=float64) S = array([1. , 0.5034478, 0.5034478, 1. ]) a = array([1. , 0.5034478, 0.5034478, 1. ]) a_ = array([0., 0., 0., 0.]) c = array([1.10107647, 1.33707346, 1.75813242, 3. ]) d = 1.9984014443252818e-15 k = 16843009 r = array([], dtype=float64) s = array([0., 0., 0., 0.]) self = x = masked_array(data=[--, 0.9241423902691124, 0.5615918401132496, 0.25356523046838064, 0.4678691307098...ask=[ True, False, False, False, False, False, False, False, False, False], fill_value=1e+20) y = masked_array( data=[[--, 0.07553868406697983], [0.5637507914837855, 0.9932431418933281], [0.94514463...], [False, False], [False, False], [False, False], [False, True]], fill_value=1e+20) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/tests/test_extras.py:1272: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:187: in assert_almost_equal err_msg=err_msg, verbose=verbose) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:268: in assert_array_almost_equal header='Arrays are not almost equal') _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ comparison = .compare at 0x10d9f8598>, x = masked_array(data=[1. , 0.5034478, 0.5034478, 1. ], mask=False, fill_value=1e+20) y = masked_array(data=[0., 0., 0., 0.], mask=False, fill_value=1e+20), err_msg = '', verbose = True, header = 'Arrays are not almost equal', fill_value = True def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', fill_value=True): """ Asserts that comparison between two masked arrays is satisfied. The comparison is elementwise. """ # Allocate a common mask and refill m = mask_or(getmask(x), getmask(y)) x = masked_array(x, copy=False, mask=m, keep_mask=False, subok=False) y = masked_array(y, copy=False, mask=m, keep_mask=False, subok=False) if ((x is masked) and not (y is masked)) or \ ((y is masked) and not (x is masked)): msg = build_err_msg([x, y], err_msg=err_msg, verbose=verbose, header=header, names=('x', 'y')) raise ValueError(msg) # OK, now run the basic tests on filled versions return np.testing.assert_array_compare(comparison, x.filled(fill_value), y.filled(fill_value), err_msg=err_msg, > verbose=verbose, header=header) E AssertionError: E Arrays are not almost equal E E (mismatch 100.0%) E x: array([1. , 0.503448, 0.503448, 1. ]) E y: array([0., 0., 0., 0.]) comparison = .compare at 0x10d9f8598> err_msg = '' fill_value = True header = 'Arrays are not almost equal' m = False verbose = True x = masked_array(data=[1. , 0.5034478, 0.5034478, 1. ], mask=False, fill_value=1e+20) y = masked_array(data=[0., 0., 0., 0.], mask=False, fill_value=1e+20) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:219: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _______________________________________________________________________________ TestPolynomial.test_polyfit_with_masked_NaNs ________________________________________________________________________________ self = def test_polyfit_with_masked_NaNs(self): x = np.random.rand(10) y = np.random.rand(20).reshape(-1, 2) x[0] = np.nan y[-1,-1] = np.nan x = x.view(MaskedArray) y = y.view(MaskedArray) x[0] = masked y[-1,-1] = masked (C, R, K, S, D) = polyfit(x, y, 3, full=True) (c, r, k, s, d) = np.polyfit(x[1:-1], y[1:-1,:], 3, full=True) for (a, a_) in zip((C, R, K, S, D), (c, r, k, s, d)): > assert_almost_equal(a, a_) C = array([[ 0.10055815, 0.10049137], [-0.01941448, -0.11460321], [ 0.07912554, -0.01445208], [-0.0267252 , 0.03503432]]) D = 1.7763568394002505e-15 K = 0 R = array([], dtype=float64) S = array([1.56110891, 2.31229114, 3.77085666, 8. ]) a = array([[ 0.10055815, 0.10049137], [-0.01941448, -0.11460321], [ 0.07912554, -0.01445208], [-0.0267252 , 0.03503432]]) a_ = array([[0.24052139, 0.61934872], [0.25971278, 0.5234543 ], [0.4704521 , 0.24757803], [0.25471504, 0.29736637]]) c = array([[0.24052139, 0.61934872], [0.25971278, 0.5234543 ], [0.4704521 , 0.24757803], [0.25471504, 0.29736637]]) d = 1.7763568394002505e-15 k = 0 r = array([], dtype=float64) s = array([1.56110891, 2.31229114, 3.77085666, 8. ]) self = x = masked_array(data=[--, 0.3005178781983737, 0.7738411999597311, 0.3949249488730213, 0.79597610287801...ask=[ True, False, False, False, False, False, False, False, False, False], fill_value=1e+20) y = masked_array( data=[[0.37568931468158495, 0.16236135212063585], [0.4371055455264542, 0.20680234608690984], ...], [False, False], [False, False], [False, False], [False, True]], fill_value=1e+20) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/tests/test_extras.py:1309: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:187: in assert_almost_equal err_msg=err_msg, verbose=verbose) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:268: in assert_array_almost_equal header='Arrays are not almost equal') _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ comparison = .compare at 0x10d9ce730> x = masked_array( data=[[ 0.10055815, 0.10049137], [-0.01941448, -0.11460321], [ 0.07912554, -0.01445208], [-0.0267252 , 0.03503432]], mask=False, fill_value=1e+20) y = masked_array( data=[[0.24052139, 0.61934872], [0.25971278, 0.5234543 ], [0.4704521 , 0.24757803], [0.25471504, 0.29736637]], mask=False, fill_value=1e+20), err_msg = '' verbose = True, header = 'Arrays are not almost equal', fill_value = True def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', fill_value=True): """ Asserts that comparison between two masked arrays is satisfied. The comparison is elementwise. """ # Allocate a common mask and refill m = mask_or(getmask(x), getmask(y)) x = masked_array(x, copy=False, mask=m, keep_mask=False, subok=False) y = masked_array(y, copy=False, mask=m, keep_mask=False, subok=False) if ((x is masked) and not (y is masked)) or \ ((y is masked) and not (x is masked)): msg = build_err_msg([x, y], err_msg=err_msg, verbose=verbose, header=header, names=('x', 'y')) raise ValueError(msg) # OK, now run the basic tests on filled versions return np.testing.assert_array_compare(comparison, x.filled(fill_value), y.filled(fill_value), err_msg=err_msg, > verbose=verbose, header=header) E AssertionError: E Arrays are not almost equal E E (mismatch 100.0%) E x: array([ 0.100558, 0.100491, -0.019414, -0.114603, 0.079126, -0.014452, E -0.026725, 0.035034]) E y: array([0.240521, 0.619349, 0.259713, 0.523454, 0.470452, 0.247578, E 0.254715, 0.297366]) comparison = .compare at 0x10d9ce730> err_msg = '' fill_value = True header = 'Arrays are not almost equal' m = False verbose = True x = masked_array( data=[[ 0.10055815, 0.10049137], [-0.01941448, -0.11460321], [ 0.07912554, -0.01445208], [-0.0267252 , 0.03503432]], mask=False, fill_value=1e+20) y = masked_array( data=[[0.24052139, 0.61934872], [0.25971278, 0.5234543 ], [0.4704521 , 0.24757803], [0.25471504, 0.29736637]], mask=False, fill_value=1e+20) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/testutils.py:219: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _______________________________________________________________________________________ TestLstsqMatrix.test_sq_cases _______________________________________________________________________________________ self = , require = {'square'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: > case.check(self.do) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Framework...o 12 decimals\n\n(mismatch 100.0%)\n x: matrix([[2., 1.]])\n y: matrix([[4.475004438720e-154, 1.044167702368e-153]])\n' require = {'square'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:350: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , do = > def check(self, do): """ Run the function `do` on this test case, expanding arguments """ > do(self.a, self.b, tags=self.tags) do = > self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:85: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , a = array([[1., 2.], [3., 4.]]), b = matrix([[2.], [1.]]), tags = frozenset({'square'}) def do(self, a, b, tags): if 'size-0' in tags: assert_raises(LinAlgError, linalg.lstsq, a, b) return arr = np.asarray(a) m, n = arr.shape u, s, vt = linalg.svd(a, 0) x, residuals, rank, sv = linalg.lstsq(a, b, rcond=-1) if m <= n: > assert_almost_equal(b, dot(a, x)) a = array([[1., 2.], [3., 4.]]) arr = array([[1., 2.], [3., 4.]]) b = matrix([[2.], [1.]]) m = 2 n = 2 rank = 16843009 residuals = matrix([], shape=(1, 0), dtype=float64) s = array([5.4649857 , 0.36596619]) self = sv = array([1.49166815e-154, 1.49166815e-154]) tags = frozenset({'square'}) u = array([[-0.40455358, -0.9145143 ], [-0.9145143 , 0.40455358]]) vt = array([[-0.57604844, -0.81741556], [ 0.81741556, -0.57604844]]) x = matrix([[1.49166815e-154], [1.49166815e-154]]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:887: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ a = matrix([[2.], [1.]]), b = matrix([[4.47500444e-154], [1.04416770e-153]]), single_decimal = 6, double_decimal = 12, kw = {}, decimal = 12 def assert_almost_equal(a, b, single_decimal=6, double_decimal=12, **kw): if asarray(a).dtype.type in (single, csingle): decimal = single_decimal else: decimal = double_decimal > old_assert_almost_equal(a, b, decimal=decimal, **kw) a = matrix([[2.], [1.]]) b = matrix([[4.47500444e-154], [1.04416770e-153]]) decimal = 12 double_decimal = 12 kw = {} single_decimal = 6 /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:41: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ actual = matrix([[2.], [1.]]), desired = matrix([[4.47500444e-154], [1.04416770e-153]]), decimal = 12, err_msg = '', verbose = True def assert_almost_equal(actual,desired,decimal=7,err_msg='',verbose=True): """ Raises an AssertionError if two items are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation in `assert_array_almost_equal` did up to rounding vagaries. An exception is raised at conflicting values. For ndarrays this delegates to assert_array_almost_equal Parameters ---------- actual : array_like The object to check. desired : array_like The expected object. decimal : int, optional Desired precision, default is 7. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- >>> import numpy.testing as npt >>> npt.assert_almost_equal(2.3333333333333, 2.33333334) >>> npt.assert_almost_equal(2.3333333333333, 2.33333334, decimal=10) ... : Items are not equal: ACTUAL: 2.3333333333333002 DESIRED: 2.3333333399999998 >>> npt.assert_almost_equal(np.array([1.0,2.3333333333333]), ... np.array([1.0,2.33333334]), decimal=9) ... : Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333333]) y: array([ 1. , 2.33333334]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import ndarray from numpy.lib import iscomplexobj, real, imag # Handle complex numbers: separate into real/imag to handle # nan/inf/negative zero correctly # XXX: catch ValueError for subclasses of ndarray where iscomplex fail try: usecomplex = iscomplexobj(actual) or iscomplexobj(desired) except ValueError: usecomplex = False def _build_err_msg(): header = ('Arrays are not almost equal to %d decimals' % decimal) return build_err_msg([actual, desired], err_msg, verbose=verbose, header=header) if usecomplex: if iscomplexobj(actual): actualr = real(actual) actuali = imag(actual) else: actualr = actual actuali = 0 if iscomplexobj(desired): desiredr = real(desired) desiredi = imag(desired) else: desiredr = desired desiredi = 0 try: assert_almost_equal(actualr, desiredr, decimal=decimal) assert_almost_equal(actuali, desiredi, decimal=decimal) except AssertionError: raise AssertionError(_build_err_msg()) if isinstance(actual, (ndarray, tuple, list)) \ or isinstance(desired, (ndarray, tuple, list)): > return assert_array_almost_equal(actual, desired, decimal, err_msg) __tracebackhide__ = True _build_err_msg = ._build_err_msg at 0x10ea23048> actual = matrix([[2.], [1.]]) decimal = 12 desired = matrix([[4.47500444e-154], [1.04416770e-153]]) err_msg = '' imag = iscomplexobj = ndarray = real = usecomplex = False verbose = True /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:568: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ x = matrix([[2.], [1.]]), y = matrix([[4.47500444e-154], [1.04416770e-153]]), decimal = 12, err_msg = '', verbose = True def assert_array_almost_equal(x, y, decimal=6, err_msg='', verbose=True): """ Raises an AssertionError if two objects are not equal up to desired precision. .. note:: It is recommended to use one of `assert_allclose`, `assert_array_almost_equal_nulp` or `assert_array_max_ulp` instead of this function for more consistent floating point comparisons. The test verifies identical shapes and that the elements of ``actual`` and ``desired`` satisfy. ``abs(desired-actual) < 1.5 * 10**(-decimal)`` That is a looser test than originally documented, but agrees with what the actual implementation did up to rounding vagaries. An exception is raised at shape mismatch or conflicting values. In contrast to the standard usage in numpy, NaNs are compared like numbers, no assertion is raised if both objects have NaNs in the same positions. Parameters ---------- x : array_like The actual object to check. y : array_like The desired, expected object. decimal : int, optional Desired precision, default is 6. err_msg : str, optional The error message to be printed in case of failure. verbose : bool, optional If True, the conflicting values are appended to the error message. Raises ------ AssertionError If actual and desired are not equal up to specified precision. See Also -------- assert_allclose: Compare two array_like objects for equality with desired relative and/or absolute precision. assert_array_almost_equal_nulp, assert_array_max_ulp, assert_equal Examples -------- the first assert does not raise an exception >>> np.testing.assert_array_almost_equal([1.0,2.333,np.nan], [1.0,2.333,np.nan]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33339,np.nan], decimal=5) ... : AssertionError: Arrays are not almost equal (mismatch 50.0%) x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33339, NaN]) >>> np.testing.assert_array_almost_equal([1.0,2.33333,np.nan], ... [1.0,2.33333, 5], decimal=5) : ValueError: Arrays are not almost equal x: array([ 1. , 2.33333, NaN]) y: array([ 1. , 2.33333, 5. ]) """ __tracebackhide__ = True # Hide traceback for py.test from numpy.core import around, number, float_, result_type, array from numpy.core.numerictypes import issubdtype from numpy.core.fromnumeric import any as npany def compare(x, y): try: if npany(gisinf(x)) or npany( gisinf(y)): xinfid = gisinf(x) yinfid = gisinf(y) if not (xinfid == yinfid).all(): return False # if one item, x and y is +- inf if x.size == y.size == 1: return x == y x = x[~xinfid] y = y[~yinfid] except (TypeError, NotImplementedError): pass # make sure y is an inexact type to avoid abs(MIN_INT); will cause # casting of x later. dtype = result_type(y, 1.) y = array(y, dtype=dtype, copy=False, subok=True) z = abs(x - y) if not issubdtype(z.dtype, number): z = z.astype(float_) # handle object arrays return z < 1.5 * 10.0**(-decimal) assert_array_compare(compare, x, y, err_msg=err_msg, verbose=verbose, header=('Arrays are not almost equal to %d decimals' % decimal), > precision=decimal) __tracebackhide__ = True around = array = compare = .compare at 0x10ea230d0> decimal = 12 err_msg = '' float_ = issubdtype = npany = number = result_type = verbose = True x = matrix([[2.], [1.]]) y = matrix([[4.47500444e-154], [1.04416770e-153]]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:964: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ comparison = .compare at 0x10ea230d0>, x = matrix([[2., 1.]]), y = matrix([[4.47500444e-154, 1.04416770e-153]]), err_msg = '', verbose = True header = 'Arrays are not almost equal to 12 decimals', precision = 12, equal_nan = True, equal_inf = True def assert_array_compare(comparison, x, y, err_msg='', verbose=True, header='', precision=6, equal_nan=True, equal_inf=True): __tracebackhide__ = True # Hide traceback for py.test from numpy.core import array, isnan, inf, bool_ x = array(x, copy=False, subok=True) y = array(y, copy=False, subok=True) def isnumber(x): return x.dtype.char in '?bhilqpBHILQPefdgFDG' def istime(x): return x.dtype.char in "Mm" def func_assert_same_pos(x, y, func=isnan, hasval='nan'): """Handling nan/inf: combine results of running func on x and y, checking that they are True at the same locations.""" # Both the != True comparison here and the cast to bool_ at # the end are done to deal with `masked`, which cannot be # compared usefully, and for which .all() yields masked. x_id = func(x) y_id = func(y) if (x_id == y_id).all() != True: msg = build_err_msg([x, y], err_msg + '\nx and y %s location mismatch:' % (hasval), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) # If there is a scalar, then here we know the array has the same # flag as it everywhere, so we should return the scalar flag. if x_id.ndim == 0: return bool_(x_id) elif y_id.ndim == 0: return bool_(y_id) else: return y_id try: cond = (x.shape == () or y.shape == ()) or x.shape == y.shape if not cond: msg = build_err_msg([x, y], err_msg + '\n(shapes %s, %s mismatch)' % (x.shape, y.shape), verbose=verbose, header=header, names=('x', 'y'), precision=precision) raise AssertionError(msg) flagged = bool_(False) if isnumber(x) and isnumber(y): if equal_nan: flagged = func_assert_same_pos(x, y, func=isnan, hasval='nan') if equal_inf: flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == +inf, hasval='+inf') flagged |= func_assert_same_pos(x, y, func=lambda xy: xy == -inf, hasval='-inf') elif istime(x) and istime(y): # If one is datetime64 and the other timedelta64 there is no point if equal_nan and x.dtype.type == y.dtype.type: flagged = func_assert_same_pos(x, y, func=isnat, hasval="NaT") if flagged.ndim > 0: x, y = x[~flagged], y[~flagged] # Only do the comparison if actual values are left if x.size == 0: return elif flagged: # no sense doing comparison if everything is flagged. return val = comparison(x, y) if isinstance(val, bool): cond = val reduced = [0] else: reduced = val.ravel() cond = reduced.all() reduced = reduced.tolist() # The below comparison is a hack to ensure that fully masked # results, for which val.ravel().all() returns np.ma.masked, # do not trigger a failure (np.ma.masked != True evaluates as # np.ma.masked, which is falsy). if cond != True: match = 100-100.0*reduced.count(1)/len(reduced) msg = build_err_msg([x, y], err_msg + '\n(mismatch %s%%)' % (match,), verbose=verbose, header=header, names=('x', 'y'), precision=precision) > raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 12 decimals E E (mismatch 100.0%) E x: matrix([[2., 1.]]) E y: matrix([[4.475004438720e-154, 1.044167702368e-153]]) __tracebackhide__ = True array = bool_ = comparison = .compare at 0x10ea230d0> cond = False equal_inf = True equal_nan = True err_msg = '' flagged = matrix([[False], [False]]) func_assert_same_pos = .func_assert_same_pos at 0x10ea232f0> header = 'Arrays are not almost equal to 12 decimals' inf = inf isnan = isnumber = .isnumber at 0x10ea23ea0> istime = .istime at 0x10ea23400> match = 100.0 msg = '\nArrays are not almost equal to 12 decimals\n\n(mismatch 100.0%)\n x: matrix([[2., 1.]])\n y: matrix([[4.475004438720e-154, 1.044167702368e-153]])' precision = 12 reduced = [[False, False]] val = matrix([[False, False]]) verbose = True x = matrix([[2., 1.]]) y = matrix([[4.47500444e-154, 1.04416770e-153]]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py:780: AssertionError During handling of the above exception, another exception occurred: self = def test_sq_cases(self): self.check_cases(require={'square'}, > exclude={'generalized', 'size-0'}) self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:361: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ self = , require = {'square'}, exclude = {'generalized', 'size-0'} def check_cases(self, require=set(), exclude=set()): """ Run func on each of the cases with all of the tags in require, and none of the tags in exclude """ for case in self.TEST_CASES: # filter by require and exclude if case.tags & require != require: continue if case.tags & exclude: continue try: case.check(self.do) except Exception: msg = "In test case: %r\n\n" % case msg += traceback.format_exc() > raise AssertionError(msg) E AssertionError: In test case: E E Traceback (most recent call last): E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 350, in check_cases E case.check(self.do) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 85, in check E do(self.a, self.b, tags=self.tags) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 887, in do E assert_almost_equal(b, dot(a, x)) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py", line 41, in assert_almost_equal E old_assert_almost_equal(a, b, decimal=decimal, **kw) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 568, in assert_almost_equal E return assert_array_almost_equal(actual, desired, decimal, err_msg) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 964, in assert_array_almost_equal E precision=decimal) E File "/opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/testing/_private/utils.py", line 780, in assert_array_compare E raise AssertionError(msg) E AssertionError: E Arrays are not almost equal to 12 decimals E E (mismatch 100.0%) E x: matrix([[2., 1.]]) E y: matrix([[4.475004438720e-154, 1.044167702368e-153]]) case = exclude = {'generalized', 'size-0'} msg = 'In test case: \n\nTraceback (most recent call last):\n File "/opt/local/Library/Framework...o 12 decimals\n\n(mismatch 100.0%)\n x: matrix([[2., 1.]])\n y: matrix([[4.475004438720e-154, 1.044167702368e-153]])\n' require = {'square'} self = /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/linalg/tests/test_linalg.py:354: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438804480) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _________________________________________________________________________________________ TestFitting.test_chebfit __________________________________________________________________________________________ self = def test_chebfit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, cheb.chebfit, [1], [1], -1) assert_raises(TypeError, cheb.chebfit, [[1]], [1], 0) assert_raises(TypeError, cheb.chebfit, [], [1], 0) assert_raises(TypeError, cheb.chebfit, [1], [[[1]]], 0) assert_raises(TypeError, cheb.chebfit, [1, 2], [1], 0) assert_raises(TypeError, cheb.chebfit, [1], [1, 2], 0) assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, cheb.chebfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, cheb.chebfit, [1], [1], [-1,]) assert_raises(ValueError, cheb.chebfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, cheb.chebfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = cheb.chebfit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(cheb.chebval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ -13.9110103, -21.5538453, -28.9493612, -35.9900612, E -42.5684484, -48.577026 , -53.9082971, -58.4547649, E -62.1089326, -64.7633034, -66.3103803, -66.6426665,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([ 7.07106781, 8.20651807, 20.98207809, 65.86924807]) f = .f at 0x10ea23488> f2 = .f2 at 0x10d9eb620> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_chebyshev.py:427: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ___________________________________________________________________________________________ test_fit[Polynomial] ____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 3.3609449, 3.6010559, 3.8249429, 4.033763 , 4.2286731, E 4.41083 , 4.5813906, 4.741512 , 4.892351 , 5.0350645, E 5.1708095, 5.3007428, 5.4260214, 5.5478022, 5.6672422,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10d9eb158> p = Polynomial([7.07106781, 4.16496564, 3.29047206, 2.83562932], domain=[0., 3.], window=[-1., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ____________________________________________________________________________________________ test_fit[Legendre] _____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 3.3558378, 3.7920559, 4.176589 , 4.5123368, 4.8021987, E 5.0490744, 5.2558636, 5.4254658, 5.5607806, 5.6647077, E 5.7401467, 5.7899972, 5.8171587, 5.824531 , 5.8150135,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10d9eb950> p = Legendre([7.07106781, 4.16496564, 3.29253795, 2.84280232], domain=[0., 3.], window=[-1., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ____________________________________________________________________________________________ test_fit[Chebyshev] ____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 2.8048058, 3.9280131, 4.8923547, 5.7059778, 6.3770296, E 6.9136571, 7.3240076, 7.6162282, 7.798466 , 7.8788683, E 7.8655822, 7.7667548, 7.5905333, 7.3450649, 7.0384967,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10ea1f400> p = Chebyshev([7.07106781, 4.16496564, 4.89091712, 4.99221346], domain=[0., 3.], window=[-1., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ____________________________________________________________________________________________ test_fit[Laguerre] _____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([18.0443235, 17.6113131, 17.1840627, 16.7625426, 16.3467228, E 15.9365734, 15.5320646, 15.1331665, 14.7398491, 14.3520826, E 13.9698372, 13.5930829, 13.2217898, 12.8559282, 12.4954679,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10ea1f048> p = Laguerre([7.07106781, 4.10325903, 3.35412731, 3.51586935], domain=[0., 3.], window=[0., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _____________________________________________________________________________________________ test_fit[Hermite] _____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 132.2039282, 143.5167037, 152.6160237, 159.6016254, E 164.5732461, 167.630623 , 168.8734935, 168.4015948, E 166.314664 , 162.7124386, 157.6946558, 151.3610527,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10ea1fd90> p = Hermite([ 7.07106781, 8.32993128, 9.78183425, 30.5572636 ], domain=[0., 3.], window=[-1., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ____________________________________________________________________________________________ test_fit[HermiteE] _____________________________________________________________________________________________ Poly = def test_fit(Poly): def f(x): return x*(x - 1)*(x - 2) x = np.linspace(0, 3) y = f(x) # check default value of domain and window p = Poly.fit(x, y, 3) assert_almost_equal(p.domain, [0, 3]) > assert_almost_equal(p(x), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 22.825942 , 22.5380432, 22.1716834, 21.7309262, 21.2198352, E 20.642474 , 20.0029061, 19.3051951, 18.5534047, 17.7515983, E 16.9038396, 16.0141921, 15.0867194, 14.1254852, 13.1345529,... E y: array([ 0. , 0.1114332, 0.2017527, 0.2723355, 0.3245586, E 0.3597991, 0.3794337, 0.3848397, 0.3773938, 0.3584731, E 0.3294546, 0.2917152, 0.2466319, 0.1955818, 0.1399417,... Poly = f = .f at 0x10ea18b70> p = HermiteE([7.07106781, 4.16496564, 5.11207676, 9.95991991], domain=[0., 3.], window=[-1., 1.]) x = array([0. , 0.06122449, 0.12244898, 0.18367347, 0.24489796, 0.30612245, 0.36734694, 0.42857143, 0.489795...59, 2.51020408, 2.57142857, 2.63265306, 2.69387755, 2.75510204, 2.81632653, 2.87755102, 2.93877551, 3. ]) y = array([ 0. , 0.11143316, 0.20175267, 0.27233551, 0.32455864, 0.35979906, 0.37943374, 0.38483965, ...414309, 2.3090379 , 2.71927513, 3.16623176, 3.65128475, 4.1758111 , 4.74118777, 5.34879174, 6. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_classes.py:146: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438808576) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _________________________________________________________________________________________ TestFitting.test_hermfit __________________________________________________________________________________________ self = def test_hermfit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, herm.hermfit, [1], [1], -1) assert_raises(TypeError, herm.hermfit, [[1]], [1], 0) assert_raises(TypeError, herm.hermfit, [], [1], 0) assert_raises(TypeError, herm.hermfit, [1], [[[1]]], 0) assert_raises(TypeError, herm.hermfit, [1, 2], [1], 0) assert_raises(TypeError, herm.hermfit, [1], [1, 2], 0) assert_raises(TypeError, herm.hermfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, herm.hermfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, herm.hermfit, [1], [1], [-1,]) assert_raises(ValueError, herm.hermfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, herm.hermfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = herm.hermfit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(herm.hermval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ -76.8572445, -121.1264933, -164.5303156, -206.7625738, E -247.5171306, -286.4878483, -323.3685896, -357.853217 , E -389.635593 , -418.4095801, -443.8690407, -465.7078375,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([ 7.07106781, 16.41303613, 41.96415618, 93.79366829]) f = .f at 0x10ea1f2f0> f2 = .f2 at 0x10ea18400> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_hermite.py:415: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init _________________________________________________________________________________________ TestFitting.test_hermefit _________________________________________________________________________________________ self = def test_hermefit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, herme.hermefit, [1], [1], -1) assert_raises(TypeError, herme.hermefit, [[1]], [1], 0) assert_raises(TypeError, herme.hermefit, [], [1], 0) assert_raises(TypeError, herme.hermefit, [1], [[[1]]], 0) assert_raises(TypeError, herme.hermefit, [1, 2], [1], 0) assert_raises(TypeError, herme.hermefit, [1], [1, 2], 0) assert_raises(TypeError, herme.hermefit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, herme.hermefit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, herme.hermefit, [1], [1], [-1,]) assert_raises(ValueError, herme.hermefit, [1], [1], [2, -1, 6]) assert_raises(TypeError, herme.hermefit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = herme.hermefit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(herme.hermeval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([-1.8852127, -2.7426461, -3.5662127, -4.3518875, -5.0956457, E -5.7934623, -6.4413124, -7.035171 , -7.5710132, -8.044814 , E -8.4525486, -8.7901919, -9.0537191, -9.2391051, -9.3423251,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([7.07106781, 8.20651807, 8.95628056, 9.86521087]) f = .f at 0x10ea18ea0> f2 = .f2 at 0x10ea18158> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_hermite_e.py:416: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init __________________________________________________________________________________________ TestFitting.test_lagfit __________________________________________________________________________________________ self = def test_lagfit(self): def f(x): return x*(x - 1)*(x - 2) # Test exceptions assert_raises(ValueError, lag.lagfit, [1], [1], -1) assert_raises(TypeError, lag.lagfit, [[1]], [1], 0) assert_raises(TypeError, lag.lagfit, [], [1], 0) assert_raises(TypeError, lag.lagfit, [1], [[[1]]], 0) assert_raises(TypeError, lag.lagfit, [1, 2], [1], 0) assert_raises(TypeError, lag.lagfit, [1], [1, 2], 0) assert_raises(TypeError, lag.lagfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, lag.lagfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, lag.lagfit, [1], [1], [-1,]) assert_raises(ValueError, lag.lagfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, lag.lagfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = lag.lagfit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(lag.lagval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([20.158221 , 19.1092779, 18.0883703, 17.0952239, 16.1295643, E 15.1911171, 14.2796079, 13.3947622, 12.5363056, 11.7039638, E 10.8974624, 10.1165269, 9.3608829, 8.6302561, 7.9243719,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([7.07106781, 4.16496564, 4.88674441, 4.03544314]) f = .f at 0x10ea188c8> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_laguerre.py:409: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init __________________________________________________________________________________________ TestFitting.test_legfit __________________________________________________________________________________________ self = def test_legfit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, leg.legfit, [1], [1], -1) assert_raises(TypeError, leg.legfit, [[1]], [1], 0) assert_raises(TypeError, leg.legfit, [], [1], 0) assert_raises(TypeError, leg.legfit, [1], [[[1]]], 0) assert_raises(TypeError, leg.legfit, [1, 2], [1], 0) assert_raises(TypeError, leg.legfit, [1], [1, 2], 0) assert_raises(TypeError, leg.legfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, leg.legfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, leg.legfit, [1], [1], [-1,]) assert_raises(ValueError, leg.legfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, leg.legfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = leg.legfit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(leg.legval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ -1.3331644, -3.6306353, -5.7994195, -7.7948375, -9.57221 , E -11.0868576, -12.2941009, -13.1492604, -13.6076569, -13.6246108, E -13.1554427, -12.1554734, -10.5800233, -8.3844131, -5.5239633,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([ 7.07106781, 8.20651807, 16.80846452, 43.80405673]) f = .f at 0x10ea18048> f2 = .f2 at 0x10d9ed620> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_legendre.py:416: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ___________________________________________________________________________________________ TestMisc.test_polyfit ___________________________________________________________________________________________ self = def test_polyfit(self): def f(x): return x*(x - 1)*(x - 2) def f2(x): return x**4 + x**2 + 1 # Test exceptions assert_raises(ValueError, poly.polyfit, [1], [1], -1) assert_raises(TypeError, poly.polyfit, [[1]], [1], 0) assert_raises(TypeError, poly.polyfit, [], [1], 0) assert_raises(TypeError, poly.polyfit, [1], [[[1]]], 0) assert_raises(TypeError, poly.polyfit, [1, 2], [1], 0) assert_raises(TypeError, poly.polyfit, [1], [1, 2], 0) assert_raises(TypeError, poly.polyfit, [1], [1], 0, w=[[1]]) assert_raises(TypeError, poly.polyfit, [1], [1], 0, w=[1, 1]) assert_raises(ValueError, poly.polyfit, [1], [1], [-1,]) assert_raises(ValueError, poly.polyfit, [1], [1], [2, -1, 6]) assert_raises(TypeError, poly.polyfit, [1], [1], []) # Test fit x = np.linspace(0, 2) y = f(x) # coef3 = poly.polyfit(x, y, 3) assert_equal(len(coef3), 4) > assert_almost_equal(poly.polyval(x, coef3), y) E AssertionError: E Arrays are not almost equal to 7 decimals E E (mismatch 100.0%) E x: array([ 7.0710678, 7.4289124, 7.8384896, 8.308744 , 8.8486206, E 9.4670639, 10.1730189, 10.9754302, 11.8832427, 12.905401 , E 14.05085 , 15.3285343, 16.7473989, 18.3163884, 20.0444476,... E y: array([ 0. , 0.0767027, 0.1438176, 0.2017527, 0.2509159, E 0.2917152, 0.3245586, 0.3498542, 0.3680099, 0.3794337, E 0.3845337, 0.3837177, 0.3773938, 0.36597 , 0.3498542,... coef3 = array([ 7.07106781, 8.20651807, 12.84168365, 21.92379918]) f = .f at 0x10d9ed840> f2 = .f2 at 0x10d9edbf8> self = x = array([0. , 0.04081633, 0.08163265, 0.12244898, 0.16326531, 0.20408163, 0.24489796, 0.28571429, 0.326530...06, 1.67346939, 1.71428571, 1.75510204, 1.79591837, 1.83673469, 1.87755102, 1.91836735, 1.95918367, 2. ]) y = array([ 0. , 0.07670273, 0.14381763, 0.20175267, 0.25091586, 0.29171519, 0.32455864, 0.34985423, ...800993, -0.34985423, -0.32455864, -0.29171519, -0.25091586, -0.20175267, -0.14381763, -0.07670273, 0. ]) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_polynomial.py:511: AssertionError ------------------------------------------------------------------------------------------- Captured stderr call -------------------------------------------------------------------------------------------- Python(85346,0x7fff9e546380) malloc: *** mach_vm_map(size=18446744072438812672) failed (error code=3) *** error: can't allocate region *** set a breakpoint in malloc_error_break to debug init_dgelsd failed init ============================================================================================= warnings summary ============================================================================================== numpy/lib/tests/test_polynomial.py::TestDocs::()::test_polyfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/unittest/case.py:178: RankWarning: Polyfit may be poorly conditioned callable_obj(*args, **kwargs) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/tests/test_polynomial.py:145: RankWarning: Polyfit may be poorly conditioned m, cov = np.polyfit(x, y+err, 2, cov=True) numpy/lib/tests/test_regression.py::TestRegression::()::test_polyfit_build /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/lib/tests/test_regression.py:103: RankWarning: Polyfit may be poorly conditioned tested = np.polyfit(x, y, 4) numpy/ma/tests/test_extras.py::TestPolynomial::()::test_polyfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/extras.py:1899: RankWarning: Polyfit may be poorly conditioned return np.polyfit(x, y, deg, rcond, full, w, cov) /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/ma/tests/test_extras.py:1261: RankWarning: Polyfit may be poorly conditioned assert_almost_equal(polyfit(x, y, 3), np.polyfit(x, y, 3)) numpy/polynomial/tests/test_chebyshev.py::TestFitting::()::test_chebfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_chebyshev.py:425: RankWarning: The fit may be poorly conditioned coef3 = cheb.chebfit(x, y, 3) numpy/polynomial/tests/test_classes.py::test_fit[Polynomial] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_classes.py::test_fit[Legendre] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_classes.py::test_fit[Chebyshev] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_classes.py::test_fit[Laguerre] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_classes.py::test_fit[Hermite] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_classes.py::test_fit[HermiteE] /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/_polybase.py:798: RankWarning: The fit may be poorly conditioned res = cls._fit(xnew, y, deg, w=w, rcond=rcond, full=full) numpy/polynomial/tests/test_hermite.py::TestFitting::()::test_hermfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_hermite.py:413: RankWarning: The fit may be poorly conditioned coef3 = herm.hermfit(x, y, 3) numpy/polynomial/tests/test_hermite_e.py::TestFitting::()::test_hermefit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_hermite_e.py:414: RankWarning: The fit may be poorly conditioned coef3 = herme.hermefit(x, y, 3) numpy/polynomial/tests/test_laguerre.py::TestFitting::()::test_lagfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_laguerre.py:407: RankWarning: The fit may be poorly conditioned coef3 = lag.lagfit(x, y, 3) numpy/polynomial/tests/test_legendre.py::TestFitting::()::test_legfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_legendre.py:414: RankWarning: The fit may be poorly conditioned coef3 = leg.legfit(x, y, 3) numpy/polynomial/tests/test_polynomial.py::TestMisc::()::test_polyfit /opt/local/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/numpy/polynomial/tests/test_polynomial.py:509: RankWarning: The fit may be poorly conditioned coef3 = poly.polyfit(x, y, 3) -- Docs: http://doc.pytest.org/en/latest/warnings.html 20 failed, 4529 passed, 417 skipped, 7 xfailed, 17 warnings in 161.32 seconds False >>>