June 2015
Beginner
348 pages
8h 44m
English
Let's compare strings. Both strings are the word "NumPy":
assert_string_equal() function to compare a string with itself. This test, of course, should pass:print("Pass", np.testing.assert_string_equal("NumPy", "NumPy"))The test passes:
Pass None
assert_string_equal() function to compare a string with another string with the same letters, but different casing. This test should throw an exception:print("Fail", np.testing.assert_string_equal("NumPy", "Numpy"))The test raises an error:
Fail Traceback (most recent call last): … raise AssertionError(msg) AssertionError: Differences in strings: - NumPy? ^ + Numpy? ^
We compared two strings with the assert_string_equal() function. ...
Read now
Unlock full access