numpy.ma.allclose() function – Python
numpy.ma.allclose() function returns True if two arrays are element-wise equal within a tolerance. This function is equivalent to allclose except that masked values are treated as equal (default) or unequal, depending on the masked_equal argument.
Syntax : numpy.ma.allclose(a, b, masked_equal = True, rtol = 1e-05, atol = 1e-08)
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 atol. Default is 1e-8.
Return : [bool] Returns True if the two arrays are equal within the given tolerance, False otherwise. If either array contains NaN, then False is returned.
Code #1 :
Code #2 :
Attention geek! Strengthen your foundations with the Python Programming Foundation Course and learn the basics.
To begin with, your interview preparations Enhance your Data Structures concepts with the Python DS Course. And to begin with your Machine Learning Journey, join the Machine Learning – Basic Level Course