unitsofmeasurement / indriya

JSR 385 - Reference Implementation
Other
119 stars 42 forks source link

Make `AbstractUnits.ONE` a `Unit<AmountOfSubstance>` #368

Closed GregJohnStewart closed 2 years ago

GregJohnStewart commented 2 years ago

I believe the AbstractUnits.ONE should be a unit that describes AmountOfSubstance, similarly to how Units.Mole is.

Might also make sense to make k, 'm', 'g`, etc units as well, but that can be a different ask.

keilw commented 2 years ago

Sorry but that request seems odd to near spam. k, m, g, etc. ARE units already and there is no justification for turning the Dimensionless constant unit AbstractUnit.ONE to something else like AmountOfSubstance.

andi-huber commented 2 years ago

We might consider physical quantities to form a commutative group under multiplication. AbstractUnit.ONE is special as with Quantities.getQuantity(1, AbstractUnit.ONE) we identify the identity element of this group.

Turns out, there can be only one such special Unit instance, for the framework to produce consistent results. Hence its unlikely we ever need to change how its currently implemented.

GregJohnStewart commented 2 years ago

Not spam, just honest suggestion.

I could be wrong, but I see AbstractUnits.ONE a representation of "unit of one of something", or a way to count individual things. This is similar to how Units.Mole represents 6.02214076*10^23 individual things. I could be wrong and if there is already a better unit out there than ONE it would be good to know.

keilw commented 2 years ago

Thanks @andi-huber for chipping in, if any constant (that is not already part of the natural constants) was useful we might consider that but under a different name. KILOGRAM, METRE, GRAM (in certain systems while that is a bit redundant to kg) are all well-defined units, hence no need to change that seems necessary.

andi-huber commented 2 years ago

Note: the name AbstractUnit.ONE might be a bit misleading: it does not mean a 'quantity of one' but rather a dimension-less unit aka Unit<Dimensionless>.

desruisseaux commented 2 years ago

Right, this unit can also be understood as "scale factor of one", which is not a count.

GregJohnStewart commented 2 years ago

Agreed, it is misleading then.

I feel like these was some misconception on my "k, m, g" thing as well, which was not my main ask. My note there was that it might be useful to describe "one thousand of something", etc.

keilw commented 2 years ago

I think the closest might be a quantity type Each in uom-domain/retail/quantity ICU4J introduced constant units (or non-units) like BASE, etc. in the NoUnit class.