astropy/astropy — pull request #1409 by mhvk (2013-09-05 03:03:26+00:00)
Title: Introduce percent unit

In the context of #1161, where it was discussed that radians sometimes are dimensionless, there was a more general question about support of units which are scaled dimensionless one. The prime example of this is "%", which is a handy unit to have (e.g., for fractional pulsation amplitudes). As written, the units code does not allow scaled dimensionless ones, but @mdboom showed how at least in principle it could work. Reality was slightly more tricky, in part because unlike all other units, '%' is not written with letters and thus cannot be an attribute (i.e., no `u.%`). Still, with this PR it is possible to do `Quantity(5, "%")` and use it as expected.

There is a one small part that does not work:
```
Unit("%").decompose().to_string()
```
gives `u'0.01'`, which cannot be used to produce a `Unit`, hence `%` does not round-trip and some of the tests had to be adjusted accordingly. (It is fairly easy to make it roundtrip, but only by allowing `Unit('0.01')` or any other sole number as a string.)