I think there is one more point worth making here.  There is a suggestion that 
dimensional analysis can underpin a units system.  Actually, the idea that all 
units can be broken down into a small set of fundamental units is very limiting 
and results in many vexing issues.

For example, consider currencies.  There are currently hundreds of national 
currencies and thousands of cryptocurrencies.  They all have the same basic 
fundamental unit of “value”, but value is only loosely defined.  Furthermore, 
there is no fixed ratio between the currency and its value.  It varies over 
time, over location, and from person to person.

Consider units of a particular commodity.  The example of a ream of paper was 
recently mentioned. A ream is 500 sheets of paper.  However two reams may not 
be 
comparable.  They may refer to a different size of paper or a different quality 
of paper.  So all prices for reams of paper would have the same fundamental 
units of “value per each”, but both “value” and “each” are not necessarily 
comparable.  In effect, the fundamental unit system is not complete.  You also 
need to include information about what you are measuring.  For example, “each” 
could represent a single item of anything.  The unit is not complete until you 
include a description of what that anything is, and in effect, there is an 
unlimited number of things it could be.

Now consider the issue of “unitless units”.  In electrical circuit we often 
talk 
about gain, which it the ratio between the signal level at the output of 
a circuit relative to the signal level at the input.  But you need to be 
specific about how you measure signal level.  Typically, it would be a voltage, 
current, or power level.  Consider a circuit where both the input and output 
are 
measured in volts.  Then the gain would have units of "V/V", which is unitless 
in dimensional analysis.  But units of "V/V" (voltage gain) is much different 
from units of "A/A" (current gain) or "W/W" (power gain), even though they have 
the same dimensions.  Mixing them up results in errors and confusion.  An 
additional complication is that sometimes logarithmic units are used.  For 
example, decibels in voltage, or dBV, is 20*log(Vout/Vin).  Again, 
a dimensionless quantity, but nonetheless "dBV" much different from "V/V".

The same issue occurs with the arguments to trigonometric functions like sin(), 
cos() and tan().  Generally, we assume the arguments are given in radians, 
which 
is a dimensionless number.  But it could also be given in degrees, another 
dimensionless number.  Radians and degrees are indistinguishable from the 
perspective on dimensional analysis, but mixing them up results in errors.

This is not to knock the idea of dimensional analysis.  It is just not 
something 
that would be done in most programs that process physical quantities.  Rather 
it 
is something that is largely done as a one-time check on your analysis.  It is 
a “second opinion” on whether your hand calculation are correct, or at least 
plausible.  So dimensional analysis packages such as pint have their place, but 
dimensional analysis is not something that belongs in the base language or even 
the standard library.

However I do believe that a case can be made to allow numbers to be easily 
tagged with units in the base language, and then allowing those units to be 
accessed as an attribute of the number.  Packages such as pint and QuantiPhy 
could then use that attribute to provide processing of units that is 
appropriate 
for the particular application.

-Ken
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/A6BVGOUYE2BPO54M63KXFNDOE6FUSJ3F/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to