numpy.ma.allclose() function - Python Last Updated : 05 May, 2020 Comments Improve Suggest changes Like Article Like Report 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) 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 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 : Python3 # Python program explaining # numpy.ma.allclose() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma a = geek.ma.array([1e10, 1e-8, 42.0], mask = [0, 0, 1]) b = geek.ma.array([1.00001e10, 1e-9, -42.0], mask = [0, 0, 1]) gfg = geek.ma.allclose(a, b) print (gfg) Output : True Code #2 : Python3 # Python program explaining # numpy.ma.allclose() function # importing numpy as geek # and numpy.ma module as ma import numpy as geek import numpy.ma as ma a = geek.ma.array([1e10, 1e-8, 42.0], mask = [0, 0, 1]) b = geek.ma.array([1.00001e10, 1e-9, -42.0], mask = [0, 0, 1]) gfg = geek.ma.allclose(a, b, masked_equal = False) print (gfg) Output : False Comment More infoAdvertise with us Next Article numpy.ma.allclose() function - Python S sanjoy_62 Follow Improve Article Tags : Machine Learning Python-numpy python Python Numpy-Masked Array Practice Tags : Machine Learningpython Similar Reads numpy.real_if_close() function - Python In this numpy.real_if_close()function, if complex input returns a real array then complex parts are close to zero. Syntax : numpy.real_if_close(arr, tol = 100) Parameters : arr : [array_like] Input array. tol : [float] âClose to zeroâ is defined as tol. Tolerance in machine epsilons for the complex 1 min read Python | numpy.assert_allclose() method With the help of numpy.assert_allclose() method, we can get the assertion errors when two array objects are not equal upto the mark by using numpy.assert_allclose(). Syntax : numpy.assert_allclose(actual_array, desired_array) Return : Return the Assertion error if two array objects are not equal. Ex 1 min read numpy.all() in Python The numpy.all() function tests whether all array elements along the mentioned axis evaluate to True. Syntax: numpy.all(array, axis = None, out = None, keepdims = class numpy._globals._NoValue at 0x40ba726c) Parameters :Â array :[array_like]Input array or object whose elements, we need to test. axis 3 min read Python any() function Python any() function returns True if any of the elements of a given iterable( List, Dictionary, Tuple, set, etc) are True else it returns False. Example Input: [True, False, False]Output: True Input: [False, False, False]Output: FalsePython any() Function Syntaxany() function in Python has the foll 5 min read How to Break a Function in Python? In Python, breaking a function allows us to exit from loops within the function. With the help of the return statement and the break keyword, we can control the flow of the loop.Using return keywordThis statement immediately terminates a function and optionally returns a value. Once return is execut 2 min read Like