computing integrals if we cannot make tests like = what should we then dothe answer is that we must accept some small inaccuracy and make test with tolerance here is the recipea expected computed diff abs(expected computedtol - diff tol true here we have set the tolerance for comparison to but calculating ( shows that it equals - - so lower tolerance could be used in this particular example howeverin other calculations we have little idea about how accurate the answer is (there could be accumulation of rounding errors in more complicated algorithms)so or are robust values as we demonstrate belowthese tolerances depend on the magnitude of the numbers in the calculations doing an experiment with : : : for shows that the answer (which should be zerois around this means that the tolerance must be larger if we compute with larger numbers setting proper tolerance therefore requires some experiments to see what level of accuracy one can expect way out of this difficulty is to work with relative instead of absolute differences in relative difference we divide by one of the operandse : : : /cd ab computing this for various shows value around safer procedure is thus to use relative differences constructing unit tests and writing test functions python has several frameworks for automatically running and checking potentially very large number of tests for parts of your software by one command this is an extremely useful feature during program developmentwhenever you have done some changes to one or more fileslaunch the test command and make sure nothing is broken because of your edits the test frameworks nose and py test are particularly attractive as they are very easy to use tests are placed in special test functions that the frameworks can recognize and run for you the requirements to test function are simplethe name must start with test_ the test function cannot have any arguments the tests inside test functions must be boolean expressions boolean expression must be tested with assert bmsgwhere msg is an optional object (string or numberto be written out when is false