Skip to content

Commit

Permalink
rename SnapshotPotential in tests (#212)
Browse files Browse the repository at this point in the history
  • Loading branch information
jobovy committed Dec 2, 2014
1 parent c50ccc4 commit 15410b9
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 52 deletions.
16 changes: 8 additions & 8 deletions nose/test_orbit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def test_energy_jacobi_conservation():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -390,7 +390,7 @@ def test_liouville_planar():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
#rmpots.append('BurkertPotential')
#Don't have C implementations of the relevant 2nd derivatives
rmpots.append('DoubleExponentialDiskPotential')
Expand Down Expand Up @@ -491,7 +491,7 @@ def test_eccentricity():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -607,7 +607,7 @@ def test_pericenter():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -723,7 +723,7 @@ def test_apocenter():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -839,7 +839,7 @@ def test_zmax():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -941,7 +941,7 @@ def test_analytic_ecc_rperi_rap():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -1137,7 +1137,7 @@ def test_analytic_zmax():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down
24 changes: 12 additions & 12 deletions nose/test_potential.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def test_normalize_potential():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -68,8 +68,8 @@ def test_forceAsDeriv_potential():
pots.append('testplanarMWPotential')
pots.append('testlinearMWPotential')
pots.append('mockInterpRZPotential')
pots.append('mockSnapshotPotential')
pots.append('mockInterpSnapshotPotential')
pots.append('mockSnapshotRZPotential')
pots.append('mockInterpSnapshotRZPotential')
pots.append('mockCosmphiDiskPotentialT1')
pots.append('mockCosmphiDiskPotentialTm1')
pots.append('mockCosmphiDiskPotentialTm5')
Expand All @@ -90,7 +90,7 @@ def test_forceAsDeriv_potential():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -223,7 +223,7 @@ def test_2ndDeriv_potential():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -413,7 +413,7 @@ def test_poisson_potential():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -495,7 +495,7 @@ def test_evaluateAndDerivs_potential():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -729,7 +729,7 @@ def test_toVertical_toPlanar():
'MovingObjectPotential',
'interpRZPotential', 'linearPotential', 'planarAxiPotential',
'planarPotential', 'verticalPotential','PotentialError',
'SnapshotPotential','InterpSnapshotPotential']
'SnapshotRZPotential','InterpSnapshotRZPotential']
if False: #_TRAVIS: #travis CI
rmpots.append('DoubleExponentialDiskPotential')
rmpots.append('RazorThinExponentialDiskPotential')
Expand Down Expand Up @@ -1359,22 +1359,22 @@ def __init__(self):
logR=True,
interpPot=True,interpRforce=True,
interpzforce=True,interpDens=True)
class mockSnapshotPotential(potential.SnapshotPotential):
class mockSnapshotRZPotential(potential.SnapshotRZPotential):
def __init__(self):
# Test w/ equivalent of KeplerPotential: one mass
kp= potential.KeplerPotential(amp=1.)
s= pynbody.new(star=1)
s['mass']= 1./numpy.fabs(kp.Rforce(1.,0.)) #forces vc(1,0)=1
s['eps']= 0.
potential.SnapshotPotential.__init__(self,s)
class mockInterpSnapshotPotential(potential.InterpSnapshotPotential):
potential.SnapshotRZPotential.__init__(self,s)
class mockInterpSnapshotRZPotential(potential.InterpSnapshotRZPotential):
def __init__(self):
# Test w/ equivalent of KeplerPotential: one mass
kp= potential.KeplerPotential(amp=1.)
s= pynbody.new(star=1)
s['mass']= 1./numpy.fabs(kp.Rforce(1.,0.)) #forces vc(1,0)=1
s['eps']= 0.
potential.InterpSnapshotPotential.__init__(self,s,
potential.InterpSnapshotRZPotential.__init__(self,s,
rgrid=(0.01,2.,101),
zgrid=(0.,0.3,101),
logR=False,
Expand Down
64 changes: 32 additions & 32 deletions nose/test_snapshotpotential.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,38 @@ def test_snapshotKeplerPotential_eval():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(0.5,0.)-kp(0.5,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.5)-kp(1.,0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,-0.5)-kp(1.,-0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(0.5,0.)-kp(0.5,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.5)-kp(1.,0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,-0.5)-kp(1.,-0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_Rforce():
# Set up a snapshot with just one unit mass at the origin
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
assert numpy.fabs(sp.Rforce(1.,0.)-kp.Rforce(1.,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(0.5,0.)-kp.Rforce(0.5,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(1.,0.5)-kp.Rforce(1.,0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(1.,-0.5)-kp.Rforce(1.,-0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(1.,0.)-kp.Rforce(1.,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(0.5,0.)-kp.Rforce(0.5,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(1.,0.5)-kp.Rforce(1.,0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.Rforce(1.,-0.5)-kp.Rforce(1.,-0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_zforce():
# Set up a snapshot with just one unit mass at the origin
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
assert numpy.fabs(sp.zforce(1.,0.)-kp.zforce(1.,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(0.5,0.)-kp.zforce(0.5,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(1.,0.5)-kp.zforce(1.,0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(1.,-0.5)-kp.zforce(1.,-0.5)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(1.,0.)-kp.zforce(1.,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(0.5,0.)-kp.zforce(0.5,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(1.,0.5)-kp.zforce(1.,0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp.zforce(1.,-0.5)-kp.zforce(1.,-0.5)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_hash():
Expand All @@ -47,10 +47,10 @@ def test_snapshotKeplerPotential_hash():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.fabs(sp(1.,0.)-kp(1.,0.)) < 10.**-8., 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_grid():
Expand All @@ -59,11 +59,11 @@ def test_snapshotKeplerPotential_grid():
s= pynbody.new(star=1)
s['mass']= 2.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=2.) #should be the same
rs= numpy.arange(3)+1
zs= 0.1
assert numpy.all(numpy.fabs(sp(rs,zs)-kp(rs,zs)) < 10.**-8.), 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.all(numpy.fabs(sp(rs,zs)-kp(rs,zs)) < 10.**-8.), 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_eval_array():
Expand All @@ -72,11 +72,11 @@ def test_snapshotKeplerPotential_eval_array():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
rs= numpy.ones(3)*0.5+0.5
zs= (numpy.zeros(3)-1.)/2.
assert numpy.all(numpy.fabs(sp(rs,zs)-kp(rs,zs)) < 10.**-8.), 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.all(numpy.fabs(sp(rs,zs)-kp(rs,zs)) < 10.**-8.), 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_Rforce_array():
Expand All @@ -85,11 +85,11 @@ def test_snapshotKeplerPotential_Rforce_array():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
rs= numpy.ones(3)*0.5+0.5
zs= (numpy.zeros(3)-1.)/2.
assert numpy.all(numpy.fabs(sp.Rforce(rs,zs)-kp.Rforce(rs,zs)) < 10.**-8.), 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.all(numpy.fabs(sp.Rforce(rs,zs)-kp.Rforce(rs,zs)) < 10.**-8.), 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_snapshotKeplerPotential_zforce_array():
Expand All @@ -98,19 +98,19 @@ def test_snapshotKeplerPotential_zforce_array():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.SnapshotPotential(s)
sp= potential.SnapshotRZPotential(s)
kp= potential.KeplerPotential(amp=1.) #should be the same
rs= numpy.ones(3)*0.5+0.5
zs= (numpy.zeros(3)-1.)/2.
assert numpy.all(numpy.fabs(sp.zforce(rs,zs)-kp.zforce(rs,zs)) < 10.**-8.), 'SnapshotPotential with single unit mass does not correspond to KeplerPotential'
assert numpy.all(numpy.fabs(sp.zforce(rs,zs)-kp.zforce(rs,zs)) < 10.**-8.), 'SnapshotRZPotential with single unit mass does not correspond to KeplerPotential'
return None

def test_interpsnapshotKeplerPotential_eval():
# Set up a snapshot with just one unit mass at the origin
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(0.01,2.,201),
zgrid=(0.,0.2,201),
logR=False,
Expand Down Expand Up @@ -141,7 +141,7 @@ def test_interpsnapshotKeplerPotential_logR_eval():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(numpy.log(0.01),numpy.log(20.),
251),
logR=True,
Expand All @@ -162,7 +162,7 @@ def test_interpsnapshotKeplerPotential_noc_eval():
s= pynbody.new(star=1)
s['mass']= 1.
s['eps']= 0.
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(0.01,2.,201),
zgrid=(0.,0.2,201),
logR=False,
Expand All @@ -184,7 +184,7 @@ def test_interpsnapshotKeplerPotential_normalize():
s= pynbody.new(star=1)
s['mass']= 4.
s['eps']= 0.
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(0.01,3.,201),
zgrid=(0.,0.2,201),
logR=False,
Expand All @@ -211,7 +211,7 @@ def test_interpsnapshotKeplerPotential_noc_normalize():
s= pynbody.new(star=1)
s['mass']= 4.
s['eps']= 0.
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(numpy.log(0.01),numpy.log(3.),201),
zgrid=(0.,0.2,201),
logR=True,
Expand Down Expand Up @@ -241,7 +241,7 @@ def test_interpsnapshotKeplerPotential_normalize_units():
s['eps']= 0.
s['pos'].units= 'kpc'
s['vel'].units= 'km s**-1'
sp= potential.InterpSnapshotPotential(s,
sp= potential.InterpSnapshotRZPotential(s,
rgrid=(0.01,3.,201),
zgrid=(0.,0.2,201),
logR=False,
Expand Down

0 comments on commit 15410b9

Please sign in to comment.