Assert functions
Unit tests usually use functions, which assert something as part of the test. When doing numerical calculations, often we have the fundamental issue of trying to compare floating-point numbers that are almost equal. For integers, comparison is a trivial operation, but for floating-point numbers it is not, because of the inexact representation by computers. The NumPy testing
package has a number of utility functions that test whether a precondition is true or not, taking into account the problem of floating-point comparisons. The following table shows the different utility functions:
Function |
Description |
---|---|
|
This function raises an exception if two numbers are not equal up to a specified precision |
|
This function raises an exception if two numbers are not equal up to a certain significance |
|
This function raises an exception if two arrays are not equal up to a specified precision |
|