astropy/astropy — pull request #669 by astrofrog (2013-01-24 09:29:00+00:00)
Title: Conceptual issue with float conversion when quantity is dimensionless

I was using ``astropy.units`` to check some answers in a Physics tutorial, and one thing I tried instinctively was something like:

```
>>> a = 150 * u.nm
>>> d = 1.6e-7 * u.m
>>> P = np.exp(-a / d)
```

of course, the real answer is something like 2.55, because a / d = 0.93, but by default, float just uses the ``value`` of the quantity, and:

```
>>> a / d

>>> (a / d).value
937500000.0
```

so P ends up being zero, which is bad. I'm not exactly sure how we should deal with cases like this - should Quantities always check if they are actually dimensionless, and if so, automagically simplify themselves? So then we'd have:

```
>>> a / d

```

but then, sometimes people might actually want to keep a Quantity in e.g. ``m/kpc``, so this doesn't seem like a good solution.

This makes me wonder whether maybe it is too dangerous to have automatic float conversion work for everything, and whether we should make it so automatic float conversion only works for dimensionless quantities? (with an exception raised if not). It does mean that for a value in ``m/kpc``, ``q.value`` will be different from ``float(q)``, but maybe that's ok since then they have different purposes?

cc @mdboom @eteq @iguananaut @taldcroft