diff options
author | lim <lim@stsci.edu> | 2012-03-29 11:31:13 -0400 |
---|---|---|
committer | lim <lim@stsci.edu> | 2012-03-29 11:31:13 -0400 |
commit | af99439c057871ea8974f5e4cdd674b8c6110dfe (patch) | |
tree | f82170a77c8cb63691f1f235e46ee14664895eb7 /lib/test/benchmarks.py | |
parent | 69e439b92cece8d8a2def7d38c2cb38b639eab0d (diff) | |
download | stsci.sphere-af99439c057871ea8974f5e4cdd674b8c6110dfe.tar.gz |
lim added files to sphere branch
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/branches/sphere@15878 fe389314-cf27-0410-b35b-8c050e845b92
Former-commit-id: b51412b5b545598ae101152eeaed470b08616176
Diffstat (limited to 'lib/test/benchmarks.py')
-rw-r--r-- | lib/test/benchmarks.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/test/benchmarks.py b/lib/test/benchmarks.py new file mode 100644 index 0000000..9711d7b --- /dev/null +++ b/lib/test/benchmarks.py @@ -0,0 +1,39 @@ +import os +import sys +import time + +import numpy as np +from sphere import * +from test_util import * + +def point_in_poly_lots(): + poly1 = SphericalPolygon.from_wcs( + os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[0, 87]) + poly2 = SphericalPolygon.from_wcs( + os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[20, 89]) + poly3 = SphericalPolygon.from_wcs( + os.path.join(ROOT_DIR, '1904-66_TAN.fits'), 64, crval=[180, 89]) + + points = get_point_set(density=25) + + count = 0 + for point in points: + if poly1.contains_point(point) or poly2.contains_point(point) or \ + poly3.contains_point(point): + count += 1 + + assert count == 5 + assert poly1.intersects_poly(poly2) + assert not poly1.intersects_poly(poly3) + assert not poly2.intersects_poly(poly3) + +if __name__ == '__main__': + for benchmark in [point_in_poly_lots]: + t = time.time() + sys.stdout.write(benchmark.__name__) + sys.stdout.write('...') + sys.stdout.flush() + benchmark() + sys.stdout.write(' %.03fs\n' % (time.time() - t)) + sys.stdout.flush() + |