Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

little h issue with to/from_astropy #74

Open
brittonsmith opened this issue Mar 21, 2019 · 0 comments
Open

little h issue with to/from_astropy #74

brittonsmith opened this issue Mar 21, 2019 · 0 comments

Comments

@brittonsmith
Copy link
Member

  • unyt version: v1.0.7+73.ge9bbdf5
  • Python version: 3.7.1
  • Operating System: Mac OS 10.12.6

Description

This may not qualify as an issue, but perhaps just a note for the future. In which case, feel free to close.

Adding the Hubble constant, little h, to a UnitRegistry produces some unintended behavior when converting to astropy and back from astropy. This seems to be because "h" in astropy.units is already defined to mean hour. I bring this up because using little h as the Hubble constant is now quite common in yt and other places with cosmological datasets.

What I Did

from unyt import UnitRegistry, unyt_quantity
from unyt.dimensions import dimensionless

ur = UnitRegistry()
ur.add('h', 0.7, dimensionless)

L = unyt_quantity(1, 'Mpc/h', registry=ur)
L2 = L.from_astropy(L.to_astropy())

print (L)
print (L2)

This gives:

1 Mpc/h
1.0 Mpc/hr

Maybe there is nothing that can be done about this, but I thought I'd make it known in case it wasn't previously.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant