Skip to content

Commit

Permalink
Fix forcevmoment test for new vmoment implementation and make sure to…
Browse files Browse the repository at this point in the history
… hit non-quantity output
  • Loading branch information
jobovy committed Sep 11, 2020
1 parent d24cedc commit 5c84aaa
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
5 changes: 5 additions & 0 deletions tests/test_quantity.py
Original file line number Diff line number Diff line change
Expand Up @@ -5911,6 +5911,11 @@ def test_sphericaldf_method_value():
assert numpy.fabs(dfa.vmomentdensity(1.1,0,0).to(1/units.kpc**3).value-dfa_nou.vmomentdensity(1.1,0,0)/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
assert numpy.fabs(dfh.vmomentdensity(1.1,1,0).to(1/units.kpc**3*units.km/units.s).value-dfh_nou.vmomentdensity(1.1,1,0)*vo/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
assert numpy.fabs(dfa.vmomentdensity(1.1,1,0).to(1/units.kpc**3*units.km/units.s).value-dfa_nou.vmomentdensity(1.1,1,0)*vo/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
# One with no quantity output
from galpy.util import conversion
conversion._APY_UNITS= False # Hack
assert numpy.fabs(dfh.vmomentdensity(1.1,0,2)-dfh_nou.vmomentdensity(1.1,0,2)*vo**2/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
conversion._APY_UNITS= True # Hack
assert numpy.fabs(dfh.vmomentdensity(1.1,0,2).to(1/units.kpc**3*units.km**2/units.s**2).value-dfh_nou.vmomentdensity(1.1,0,2)*vo**2/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
assert numpy.fabs(dfa.vmomentdensity(1.1,0,2).to(1/units.kpc**3*units.km**2/units.s**2).value-dfa_nou.vmomentdensity(1.1,0,2)*vo**2/ro**3) < 10.**-8., 'sphericaldf method vmomentdensity does not return correct Quantity'
assert numpy.fabs(dfh.sigmar(1.1).to(units.km/units.s).value-dfh_nou.sigmar(1.1)*vo) < 10.**-8., 'sphericaldf method sigmar does not return correct Quantity'
Expand Down
4 changes: 2 additions & 2 deletions tests/test_sphericaldf.py
Original file line number Diff line number Diff line change
Expand Up @@ -639,8 +639,8 @@ def check_sigmar_against_jeans_directint_forcevmoment(dfi,pot,tol,beta=0.,
class' vmomentdensity"""
from galpy.df.sphericaldf import sphericaldf
rs= numpy.linspace(rmin,rmax,bins)
intsr= numpy.array([numpy.sqrt(sphericaldf.vmomentdensity(dfi,r,2,0)/
sphericaldf.vmomentdensity(dfi,r,0,0))
intsr= numpy.array([numpy.sqrt(sphericaldf._vmomentdensity(dfi,r,2,0)/
sphericaldf._vmomentdensity(dfi,r,0,0))
for r in rs])
jeanssr= numpy.array([jeans.sigmar(pot,r,beta=beta,use_physical=False) for r in rs])
assert numpy.all(numpy.fabs(intsr/jeanssr-1) < tol), \
Expand Down

0 comments on commit 5c84aaa

Please sign in to comment.