Time for action – checking the array order

Let's check whether one array is strictly greater than another array:

  1. Call the assert_array_less function with two strictly ordered arrays:
    print "Pass", np.testing.assert_array_less([0, 0.123456789, np.nan], [1, 0.23456780, np.nan])

    The result:

    Pass None
  2. Call the assert_array_less function on failing the test:
    print "Fail", np.testing.assert_array_less([0, 0.123456789,
    np.nan], [0, 0.123456780, np.nan])

    An exception is thrown:

    Fail
    Traceback (most recent call last):
      ...
    raiseAssertionError(msg)
    AssertionError:
    Arrays are not less-ordered
    
    (mismatch 100.0%)
    x: array([ 0.        ,  0.12345679,         nan])
     y: array([ 0.        ,  0.12345678,         nan])

What just happened?

We checked the ordering of two arrays with the assert_array_less function.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset