diff --git a/tests/test_max_rzw_harmonics.py b/tests/test_max_rzw_harmonics.py index f6e77686a..18dfb1ffc 100644 --- a/tests/test_max_rzw_harmonics.py +++ b/tests/test_max_rzw_harmonics.py @@ -1,8 +1,14 @@ +import sys +import time import numpy as np -from presto import presto from numpy.random import standard_normal as norm from numpy.random import uniform -import time +from presto import presto + +if sys.version_info[0]<3: + clk = time.clock +else: + clk = time.perf_counter N = 2**17 noiseamp = 1.0 @@ -36,7 +42,7 @@ offset = uniform(-1.0, 1.0, 3) * np.array([0.5, 2.0, 20.0]) / (0.5 * numharm) - a = time.clock() + a = clk() if (numharm > 1): [maxpow, rmax, zmax, rds] = presto.maximize_rz_harmonics(ft, r+offset[0], z+offset[1], numharm, @@ -45,10 +51,10 @@ [maxpow, rmax, zmax, rd] = presto.maximize_rz(ft, r+offset[0], z+offset[1], norm=1.0) - rztime += time.clock() - a + rztime += clk() - a rzerrs[n] = (maxpow/numharm - theo_max_pow) / theo_max_pow, rmax - r, zmax - z - a = time.clock() + a = clk() if (numharm > 1): [maxpow, rmax, zmax, wmax, rds] = presto.maximize_rzw_harmonics(ft, r+offset[0], z+offset[1], @@ -59,11 +65,11 @@ z+offset[1], w+offset[2], norm=1.0) - rzwtime += time.clock() - a + rzwtime += clk() - a rzwerrs[n] = (maxpow/numharm - theo_max_pow) / theo_max_pow, rmax - r, zmax - z, wmax - w -print("Time for rz: %s".format(rztime / numtrials)) -print("Time for rzw: %s".format(rzwtime / numtrials)) +print("Time for rz: %f" % (rztime / numtrials)) +print("Time for rzw: %f" % (rzwtime / numtrials)) print("rzerrs:") print(" avg: %6.3f %6.3f %6.3f" % tuple(rzerrs.mean(axis=0))) diff --git a/tests/test_presto_python.py b/tests/test_presto_python.py index 0b50d9e8e..e5c22f039 100644 --- a/tests/test_presto_python.py +++ b/tests/test_presto_python.py @@ -6,8 +6,6 @@ here = path.dirname(__file__) - - print("Testing FFT stuff...", end=' ') N = 20 x = np.random.standard_normal(N) @@ -66,9 +64,7 @@ psr = presto.psrepoch("J0737-3039A", 56000.0, verbose=False) assert(round(psr.dm-48.92, 7)==0) # This needs to change when we start using the actual psrcat.db file -print("\nTODO: fix the precision of the values in the catalog!!") -assert(round(psr.orb.p-8838.72, 7)==0) -#assert(round(psr.orb.p-8834.534998272, 7)==0) +assert(round(psr.orb.p-8834.534998272, 7)==0) print("success") print("Testing spectralpower and spectralphase...", end=' ') @@ -121,7 +117,6 @@ numbetween = 16 z = 5.0 w = 40.0 -# Should use w_resp_halfwidth() for this. Need to update that! bins_per_side = max([presto.r_resp_halfwidth(presto.LOWACC), \ presto.z_resp_halfwidth(z, presto.LOWACC), \ presto.w_resp_halfwidth(z, w, presto.LOWACC)]) @@ -133,7 +128,8 @@ pz = presto.spectralpower(zresp) pw = presto.spectralpower(wresp) rs = np.arange(float(nn))/numbetween - bins_per_side -if 0: +if False: + import matplotlib.pyplot as plt plt.plot(rs, pr, 'b-') plt.plot(rs, pz, 'g-') plt.plot(rs, pw, 'r-')