-
Notifications
You must be signed in to change notification settings - Fork 402
Adding the missing BaseUnits #1473
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
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 |
|
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 Before merging from upstream
After merging from upstream:
|
|
Also noted the coverage 😄 :
And now:
|
|
Oh, forgot about the tests in |
angularsen
left a comment
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.
Great work! Just a few comments/questions.
…s use the GetDefaultUnit extension
|
@lipchev As far as I'm concerned, this is ready to go. If you want to make any last minute changes, just merge whenever you want 👍 |
angularsen
left a comment
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.
Looks good to me, merge whenever you are ready
Fixes #1463
Fixes #1043
UnitSystemconstructor 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 QuantityInfoExtensionsUnitSystemmethods, 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 thePercentunit, I think we should add theDecimalFraction, setting it to be theBaseUnitFuelEfficiency: I think this could be defined as"L": -2with the addition of theMeterPerCubicMeterunit (possibly setting it as itsBaseUnit, if we want to satisfy theBaseUnit_HasSIBasetest)You can look for
As_UnitSystem_ReturnsValueInDimensionlessUnitif you want to check the rest of the dimensionless quantities.Regarding the removed
BaseUnits(seeForce.jsonorPressure.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 = Cis only defined ifA.Dimensions / B.Dimensions = C.DimensionsA.DimensionsandB.Dimensionsis the empty set, for every unit ofAandBfor which theBaseUnitsis notUnidefined, and every unit ofC, havingBaseUnits=A.BaseUnits union B.BaseUnits, it must be true thatC.Value = A.Value / B.Value.A.DimensionsandB.Dimensionsis not empty, and the intersectingBaseUnitsofA,BandCare all the same, then again we have the same condition, which I generally refer to as "the conversion coefficient is 1"Dimensionsand a pair ofBaseUnits, but special attention needs to be taken w.r.t. the exponents (e.g.AreaisL2so 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)