astropy/astropy — pull request #579 by mdboom (2012-12-20 19:46:50+00:00)
Title: Add "compose" method to units.

Addresses #576.

Adds "compose" functionality to units -- it's the converse of
"decompose" and tries to reduce the number of components in a
CompositeUnit.

The Quantity.si and Quantity.cgs methods can then much more easily be
implemented in terms of this functionality.

Also addresses #576 be providing a way for the user to decompose into
a particular system.

Other changes along the way:

- PEP8-ify quantity.py

- Privatize the "_simplify" member on units, since it's confusing in
relation to "compose" and was never meant to be public anyway.

This doesn't have to make it into 0.2, but it doesn't really change the API in any meaningful way (note that none of the tests changed to make this all work). If it doesn't go into 0.2, it might be a good idea to at least privatize "simplify" on 0.2 so that users won't rely on it as a public method.