moved numpy to within function as suggested by Tom R to fix Travis build failure