On Tue, 5 Apr 2022 at 04:19, Ethan Furman <et...@stoneleaf.us> wrote:
>
> On 4/3/22 22:39, Chris Angelico wrote:
>  > On Mon, 4 Apr 2022 at 14:22, Brian McCall wrote:
>
>  >> Related to these questions, there is the question of what to do about 
> mixed systems?
>  > Should 2.54 in / 1 cm evaluate to 2.54 in/cm or should it evaluate to 1?
>  >
>  > I would say that 2.54in/1cm should be equal to 1. Units should
>  > completely cancel out.
>
> It seems like the point of this exercise is to *not* have units cancel out -- 
> at least, not unnecessarily.
>
> 2.54in / 1 cm should be 2.54in/cm, otherwise multiplying by 5 kelvin will be 
> one of those hard-to-find bugs.

Hmm, fair point, I guess. It gets tricky, though. For an example,
let's look at fuel efficiency.

Outside of the US, vehicle fuel economy is measured in liters per
hundred kilometers. What unit category should this be considered to
be?

5 L/100km in SI units is 5e-3 m³ / 1e5m. That's 5e-8 m². Or if you
prefer, 50mm².

Fuel economy is a unit of area.

https://what-if.xkcd.com/11/

This DOES, as Munroe points out, have a geometric interpretation. I
think it's reasonable to say that fuel economy cancels down to a unit
of area, and it's *also* reasonable to say that it doesn't, and that
it simply remains as volume-per-distance.

Some unit cancellations really do result in pure scalars. The ratio of
a circle's circumference to its diameter isn't a unit of m/m any more
than the ratio of a circle's area to that of a circumscribed square is
a unit of m²/m². They're both just numbers. On the other hand, a
radian is a very real unit of distance/distance (based on its
definition of arc length), and it's a unit of angle.

I suspect that the rules of cancellation would be best handed off to
libraries, and there will be different choices for different
applications.

Maybe at some time in the future, there'll be a proposal to lock it
down and define it more by the language. It wouldn't be the first time
- type hints are now the only officially supported form of
annotations, but the precise meanings of those hints is still partly
up to the library.

> Of course, it's actually 2.54cm/in.
>

(I actually didn't even spot that part)

ChrisA
_______________________________________________
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/T6GF6J53KOSO74USIQTFIE23H4G7LR4S/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to