[AstroPy] Dimensionless units

Demitri Muna demitri.muna at gmail.com
Thu Oct 24 20:26:39 EDT 2013


On 24 Oct 2013, at 12:25 PM, Michael Droettboom <mdroe at stsci.edu> wrote:

> This was determined early on in the development of astropy.units that we need a way to distinguish between "no unit was defined", and "the unit is dimensionless".  "None" indicates no unit is assigned to the value.  This is helpful, for example, for tools that read from files where units may be missing when they should be specified.
> 
> See this:
> 
> http://docs.astropy.org/en/latest/units/standard_units.html#the-dimensionless-unit


I can't really argue with that. Looking at the link above though, two thoughts occur to me.

First, this doesn't seem consistent:

>>> from astropy import units as u
>>> u.dimensionless_unscaled
Unit(dimensionless)
It seems to me that dealing with the "scaled-ness" is not the common case, and that is a very long constant name. I'd propose that the constant be "u.dimensionless" - the same thing that the __repr__ is displaying, and that if one wants to indicate that it's scaled, that the constant be "u.dimensionless_scaled". I just think the latter is much less frequently used. This won't break things as we can just deprecate "u.dimensionless_unscaled" but have it equal to "u.dimensionless".

Second, I really don't like `Unit(1)` to mean dimensionless. It's not intuitive at all that that is the meaning. I'd like to deprecate that form. The docs specifically say the other form is recommended for readability - I'd like to have that enforced as I fear many people will use the unintuitive form.

Cheers,
Demitri

_________________________________________
Demitri Muna

Department of Astronomy
Il Ohio State University

http://scicoder.org/



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/astropy/attachments/20131024/c76a8a12/attachment.html>


More information about the AstroPy mailing list