Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
)
ll_time = 0.0
elif args.grad:
params = [0.0] + list(coeffs)
params += [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark("solver.grad_log_likelihood(*params)",
"from __main__ import solver, params")
ll_time = 0.0
else:
params = [0.0] + list(coeffs)
params += [t[:n], yerr[:n]**2]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.dot_solve(y0)",
"from __main__ import solver, y0")
if xi == 0 and n <= 8192:
# Do numpy calculation
params = [kernel, t[:n], yerr[:n]]
np_comp_time = benchmark("numpy_compute(*params)",
"from __main__ import numpy_compute, "
"params")
factor = numpy_compute(*params)
params = [factor, y[:n]]
np_ll_time = benchmark("numpy_log_like(*params)",
"from __main__ import "
"numpy_log_like, params")
msg = ("{0},{1},{2},{3},{4:e},{5:e},{6:e},{7:e}\n"
.format(xi, yi, j, n, comp_time, ll_time, np_comp_time,
ll_time = benchmark("solver.lnlikelihood(y0)",
"from __main__ import solver, y0")
elif args.carma:
params = [arparams, maparams]
funcargs = [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark(
"solver = CARMASolver(0.0, *params)\n"
"solver.log_likelihood(*funcargs)",
"from __main__ import params, funcargs\n"
"from celerite.solver import CARMASolver"
)
ll_time = 0.0
elif args.grad:
params = [0.0] + list(coeffs)
params += [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark("solver.grad_log_likelihood(*params)",
"from __main__ import solver, params")
ll_time = 0.0
else:
params = [0.0] + list(coeffs)
params += [t[:n], yerr[:n]**2]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.dot_solve(y0)",
"from __main__ import solver, y0")
if xi == 0 and n <= 8192:
# Do numpy calculation
params = [kernel, t[:n], yerr[:n]]
np_comp_time = benchmark("numpy_compute(*params)",
for yi, n in enumerate(N):
np_comp_time = np.nan
np_ll_time = np.nan
if args.george:
params = [t[:n], yerr[:n]]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.lnlikelihood(y0)",
"from __main__ import solver, y0")
elif args.carma:
params = [arparams, maparams]
funcargs = [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark(
"solver = CARMASolver(0.0, *params)\n"
"solver.log_likelihood(*funcargs)",
"from __main__ import params, funcargs\n"
"from celerite.solver import CARMASolver"
)
ll_time = 0.0
elif args.grad:
params = [0.0] + list(coeffs)
params += [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark("solver.grad_log_likelihood(*params)",
"from __main__ import solver, params")
ll_time = 0.0
else:
params = [0.0] + list(coeffs)
params += [t[:n], yerr[:n]**2]
comp_time = benchmark("solver.compute(*params)",
"solver = CARMASolver(0.0, *params)\n"
"solver.log_likelihood(*funcargs)",
"from __main__ import params, funcargs\n"
"from celerite.solver import CARMASolver"
)
ll_time = 0.0
elif args.grad:
params = [0.0] + list(coeffs)
params += [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark("solver.grad_log_likelihood(*params)",
"from __main__ import solver, params")
ll_time = 0.0
else:
params = [0.0] + list(coeffs)
params += [t[:n], yerr[:n]**2]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.dot_solve(y0)",
"from __main__ import solver, y0")
if xi == 0 and n <= 8192:
# Do numpy calculation
params = [kernel, t[:n], yerr[:n]]
np_comp_time = benchmark("numpy_compute(*params)",
"from __main__ import numpy_compute, "
"params")
factor = numpy_compute(*params)
params = [factor, y[:n]]
np_ll_time = benchmark("numpy_log_like(*params)",
"from __main__ import "
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.dot_solve(y0)",
"from __main__ import solver, y0")
if xi == 0 and n <= 8192:
# Do numpy calculation
params = [kernel, t[:n], yerr[:n]]
np_comp_time = benchmark("numpy_compute(*params)",
"from __main__ import numpy_compute, "
"params")
factor = numpy_compute(*params)
params = [factor, y[:n]]
np_ll_time = benchmark("numpy_log_like(*params)",
"from __main__ import "
"numpy_log_like, params")
msg = ("{0},{1},{2},{3},{4:e},{5:e},{6:e},{7:e}\n"
.format(xi, yi, j, n, comp_time, ll_time, np_comp_time,
np_ll_time))
with open(fn, "a") as f:
f.write(msg)
print(msg, end="")
if comp_time + ll_time >= 5:
break
elif args.carma:
arparams = np.random.randn(2*j)
maparams = np.random.randn(2*j - 1)
else:
solver = CholeskySolver()
for yi, n in enumerate(N):
np_comp_time = np.nan
np_ll_time = np.nan
if args.george:
params = [t[:n], yerr[:n]]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.lnlikelihood(y0)",
"from __main__ import solver, y0")
elif args.carma:
params = [arparams, maparams]
funcargs = [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark(
"solver = CARMASolver(0.0, *params)\n"
"solver.log_likelihood(*funcargs)",
"from __main__ import params, funcargs\n"
"from celerite.solver import CARMASolver"
)
ll_time = 0.0
elif args.grad:
params = [0.0] + list(coeffs)
params += [t[:n], y[:n], yerr[:n]**2]
comp_time = benchmark("solver.grad_log_likelihood(*params)",
"from __main__ import solver, params")
"from __main__ import solver, params")
ll_time = 0.0
else:
params = [0.0] + list(coeffs)
params += [t[:n], yerr[:n]**2]
comp_time = benchmark("solver.compute(*params)",
"from __main__ import solver, params")
solver.compute(*params)
y0 = y[:n]
ll_time = benchmark("solver.dot_solve(y0)",
"from __main__ import solver, y0")
if xi == 0 and n <= 8192:
# Do numpy calculation
params = [kernel, t[:n], yerr[:n]]
np_comp_time = benchmark("numpy_compute(*params)",
"from __main__ import numpy_compute, "
"params")
factor = numpy_compute(*params)
params = [factor, y[:n]]
np_ll_time = benchmark("numpy_log_like(*params)",
"from __main__ import "
"numpy_log_like, params")
msg = ("{0},{1},{2},{3},{4:e},{5:e},{6:e},{7:e}\n"
.format(xi, yi, j, n, comp_time, ll_time, np_comp_time,
np_ll_time))
with open(fn, "a") as f:
f.write(msg)
print(msg, end="")
if comp_time + ll_time >= 5: