Time for action – comparing objects

Suppose you need to compare two tuples. We can use the assert_equal function to do that:

  1. Call the assert_equal function:
    print "Equal?", np.testing.assert_equal((1, 2), (1, 3))

    An exception is thrown:

    Equal?
    Traceback (most recent call last):
      ...
    raiseAssertionError(msg)
    AssertionError:
    Items are not equal:
    item=1
    
     ACTUAL: 2
     DESIRED: 3

What just happened?

We compared two tuples with the assert_equal function—an exception was raised because the tuples were not equal to each other.

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

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