On this page
numpy.ma.allclose
- numpy.ma.allclose(a, b, masked_equal=True, rtol=1e-05, atol=1e-08)[source]
- 
    Returns True if two arrays are element-wise equal within a tolerance. This function is equivalent to allcloseexcept that masked values are treated as equal (default) or unequal, depending on themasked_equalargument.- Parameters
- 
      - a, barray_like
- 
        Input arrays to compare. 
- masked_equalbool, optional
- 
        Whether masked values in aandbare considered equal (True) or not (False). They are considered equal by default.
- rtolfloat, optional
- 
        Relative tolerance. The relative difference is equal to rtol * b. Default is 1e-5.
- atolfloat, optional
- 
        Absolute tolerance. The absolute difference is equal to atol. Default is 1e-8.
 
- Returns
- 
      - ybool
- 
        Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned. 
 
 NotesIf the following equation is element-wise True, then allclosereturns True:absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))Return True if all elements of aandbare equal subject to given tolerances.Examples>>> a = np.ma.array([1e10, 1e-7, 42.0], mask=[0, 0, 1]) >>> a masked_array(data=[10000000000.0, 1e-07, --], mask=[False, False, True], fill_value=1e+20) >>> b = np.ma.array([1e10, 1e-8, -42.0], mask=[0, 0, 1]) >>> np.ma.allclose(a, b) False>>> a = np.ma.array([1e10, 1e-8, 42.0], mask=[0, 0, 1]) >>> b = np.ma.array([1.00001e10, 1e-9, -42.0], mask=[0, 0, 1]) >>> np.ma.allclose(a, b) True >>> np.ma.allclose(a, b, masked_equal=False) FalseMasked values are not compared directly. >>> a = np.ma.array([1e10, 1e-8, 42.0], mask=[0, 0, 1]) >>> b = np.ma.array([1.00001e10, 1e-9, 42.0], mask=[0, 0, 1]) >>> np.ma.allclose(a, b) True >>> np.ma.allclose(a, b, masked_equal=False) False
© 2005–2020 NumPy Developers
Licensed under the 3-clause BSD License.
 https://numpy.org/doc/1.19/reference/generated/numpy.ma.allclose.html