[AstroPy] unit equivalency testing

John K. Parejko parejkoj at uw.edu
Thu Feb 23 14:44:13 EST 2017

Hello astropy,

I’m looking for a way to check whether astropy units are “convertible” to each other. For now, asking if the two units have the same physical type is a good start for me (which might be a handy utility method on a quantity: `quantity1.convertible_to(quantity2)`):

u.get_physical_type(quantity.unit) == u.get_physical_type(self.unit)

but I see that there’s a rich unit equivalency system available. What I’d like is something like `quantity1.equivalent_to(quantity2)`, that returns True/False whether those units are equivalent, based on the defined equivalencies of that unit. Is there such a feature available?

Thank you,

More information about the AstroPy mailing list