import math,time,os,sys def test_numpy(): import numpy a=numpy.array(100) print "-> numpy OK" def test_scipy(): try: import scipy except ImportError: print "Could not import 'scipy' -> scipy failed" return import scipy.optimize import scipy.integrate if abs(scipy.integrate.quad(lambda x:x*x,0,6)[0] - 72.0) < 1e-6: print "scipy OK" else: print "scipy numerically wrong -> NOT OK" #this is impossible I hope def test_visual(): try: import visual except ImportError: print "Could not import 'visual' -> failed" return x=visual.sphere() print "visual OK (should have created a window showing a sphere)!" def test_pylab(): try: import pylab except ImportError: print "Could not import 'matplotlib/pylab' -> fail" return pylab.plot([x*0.01 for x in range(500)], [math.sin(x*0.01) for x in range(500)], "-",label="tan") pylab.legend() pylab.title("a test") testfilename='pylab-testfigure.png' pylab.savefig(testfilename) import os.path assert os.path.exists(testfilename) print "pylab OK" os.remove(testfilename) pylab.show() def test_sympy(): try: import sympy except ImportError: print "Could not import 'sympy' -> fail" return x=sympy.Symbol('x') my_f = x**2 assert sympy.diff(my_f,x) == 2*x #print "The derivative of %s is %s" % (my_f,sympy.diff(my_f,x)) print "OK" print "Testing numpy...", test_numpy() print "Testing scipy...", test_scipy() print "Testing visual...", test_visual() print "Testing pylab/matplotlib...", test_pylab() print "Testing sympy", test_sympy()