numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
allclose(a, b, masked_equal=True, rtol=1e-05, atol=1e-08)

This function is equivalent to allclose except that masked values are treated as equal (default) or unequal, depending on the masked_equal argument.

Notes

If the following equation is element-wise True, then allclose returns True:

absolute(`a` - `b`) <= (`atol` + `rtol` * absolute(`b`))

Return True if all elements of a and b are equal subject to given tolerances.

Parameters

a, b : array_like

Input arrays to compare.

masked_equal : bool, optional

Whether masked values in a and b are considered equal (True) or not (False). They are considered equal by default.

rtol : float, optional

Relative tolerance. The relative difference is equal to rtol * b . Default is 1e-5.

atol : float, optional

Absolute tolerance. The absolute difference is equal to :None:None:`atol`. Default is 1e-8.

Returns

y : bool

Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned.

Returns True if two arrays are element-wise equal within a tolerance.

See Also

all
any
numpy.allclose

the non-masked :None:None:`allclose`.

Examples

This example is valid syntax, but we were not able to check execution
>>> 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)
This example is valid syntax, but we were not able to check execution
>>> b = np.ma.array([1e10, 1e-8, -42.0], mask=[0, 0, 1])
... np.ma.allclose(a, b) False
This example is valid syntax, but we were not able to check execution
>>> 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
This example is valid syntax, but we were not able to check execution
>>> np.ma.allclose(a, b, masked_equal=False)
False

Masked values are not compared directly.

This example is valid syntax, but we were not able to check execution
>>> 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
This example is valid syntax, but we were not able to check execution
>>> np.ma.allclose(a, b, masked_equal=False)
False
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.ma.core.allequal

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/ma/core.py#7802
type: <class 'function'>
Commit: