-
Notifications
You must be signed in to change notification settings - Fork 384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding the missing BaseUnits #1473
base: release/v6
Are you sure you want to change the base?
Conversation
- removed the UnitSystem constructor from the Dimensionless quantities (which was previously throwing) - As/ToUnit(UnitSystem) for all Dimensionsless quantities now convert to their BaseUnit (i.e. the "DecimalFraction") - As/ToUnit(UnitSystem) for all other quantities refactored using the QuantityInfoExtensions - added tests for the UnitSystem methods, skipping the tests for all quantities that fail with UnitSystem.SI (with a reason)
@angularsen I initially thought about not touching the unit definitions, and just [Skip] the tests - but after seeing that the tests failed for 61 quantities, decided that it would be simpler to just add the Hopefully you wont find the json files too difficult to review.. PS In #1463 I had totally forgotten that the generator does not (yet) handle the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've got a bunch more extensions in here, for the time being they are internal- with one two good candidates for being public.
Anyway- tell me if you want to move them to another location / namepsace..
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The property is no longer used (other than the overrides) - but I didn't want to remove it just yet, as I wanted to only have the failing tests show up in this PR.
Once this is merged, I'll create another one that just removes the property.
I took some other notes while preparing this PR: The initial size for
Still ahead, but if we include the "prefixed" base units- things will likely even out (possibly even setting us back some). PS Finally, here is how this would look with the
|
Also noted the coverage 😄 :
And now:
|
Oh, forgot about the tests in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one wasn't re-generated from the last commit.
Fixes #1463
UnitSystem
constructor from the Dimensionless quantities (which was previously throwing)As
/ToUnit(UnitSystem)
for all dimensionless quantities now convert to theirBaseUnit
(i.e. the "DecimalFraction") *As/ToUnit(UnitSystem)
for all other quantities refactored using the QuantityInfoExtensionsUnitSystem
methods, skipping the tests for all quantities that fail withUnitSystem.SI
(with a reason)There are only two dimensionless quantities (IMO) that don't fit the definition:
RelativeHumidity
: currently has only thePercent
unit, I think we should add theDecimalFraction
, setting it to be theBaseUnit
FuelEfficiency
: I think this could be defined as"L": -2
with the addition of theMeterPerCubicMeter
unit (possibly setting it as itsBaseUnit
, if we want to satisfy theBaseUnit_HasSIBase
test)You can look for
As_UnitSystem_ReturnsValueInDimensionlessUnit
if you want to check the rest of the dimensionless quantities.Regarding the removed
BaseUnits
(seeForce.json
orPressure.json
), those were detected by some earlier tests I had in place, regarding the multiplication/division operators where I used the following definition:A / B = C
is only defined ifA.Dimensions / B.Dimensions = C.Dimensions
A.Dimensions
andB.Dimensions
is the empty set, for every unit ofA
andB
for which theBaseUnits
is notUnidefined
, and every unit ofC
, havingBaseUnits
=A.BaseUnits union B.BaseUnits
, it must be true thatC.Value = A.Value / B.Value
.A.Dimensions
andB.Dimensions
is not empty, and the intersectingBaseUnits
ofA
,B
andC
are all the same, then again we have the same condition, which I generally refer to as "the conversion coefficient is 1"Dimensions
and a pair ofBaseUnits
, but special attention needs to be taken w.r.t. the exponents (e.g.Area
isL2
so the unit-conversion coefficients are squares of the ones fromLength
)1
)..Here are some links:
https://en.wikipedia.org/wiki/Dimensional_analysis
https://en.wikipedia.org/wiki/International_System_of_Units#Definition
https://en.wikipedia.org/wiki/Coherence_(units_of_measurement)