import sys import time import pickle import numpy as np import interp.bootstrap from interp.grid.delaunay import dgrid from interp.tools import improved_answer, friendly_exact_3D as exact def test_success(rcount, count): v = np.random.random((rcount, 3)) * 10 pickle.dump(v, open('/tmp/v.p', 'w')) q = np.array([exact(x) for x in v]) start = time.time() g = dgrid(v,q) end = time.time() print "cells: %d, verts: %d" % (len(g.cells), len(g.verts)) print end - start, " seconds to instantiate the dgrid object" results = {True:0, False:0} i = 0 outside = 0 while i < count: try: X = np.random.random((1,3))[0] a = g.run_baker(X, order = 3, extra_points = 32) e = exact(X) results[improved_answer(a, e)] += 1 i += 1 except Exception as e: outside += 1 print "total skipped points: %d" % outside return results if __name__ == '__main__': if len(sys.argv) != 3: print >> sys.stderr, "usage: %s " % sys.argv[0] sys.exit(1) rcount, count = (int(i) for i in sys.argv[1:]) print test_success(rcount, int(count))