Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def compare(ic, inttime, numsteps):
times = numpy.linspace(0, inttime, numsteps)
### integrate the orbit in galpy using MWPotential2014 from galpy
g_orb_obj = galpy.orbit.Orbit([ic[0],ic[3],ic[5],ic[1],ic[4],ic[2]])
dt = time.time()
g_orb_obj.integrate(times, g_pot)
g_orb = g_orb_obj.getOrbit()
print 'Time to integrate orbit in galpy: %.4g s' % (time.time()-dt)
### integrate the orbit with the galpy routine, but using Agama potential instead
### (much slower because of repeated transfer of control between C++ and Python
dt = time.time()
g_orb_obj.integrate(times[:numsteps//10], a_pot)
a_orb = g_orb_obj.getOrbit()
print 'Time to integrate 1/10th of the orbit in galpy using Agama potential: %.4g s' % (time.time()-dt)
### integrate the same orbit (note different calling conventions - cartesian coordinates as input)
### using both the orbit integration routine and the potential from Agama - much faster
dt = time.time()
times_c, c_orb_car = agama.orbit(ic=[ic[0],0,ic[1],ic[3],ic[5],ic[4]], \