Commit 090742c
authored
Adding the missing BaseUnits (angularsen#1473)
Fixes angularsen#1463
Fixes angularsen#1043
- removed the `UnitSystem` constructor from the Dimensionless quantities
(which was previously throwing)
- `As`/`ToUnit(UnitSystem)` for all dimensionless 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)
There are only two dimensionless quantities (IMO) that don't fit the
definition:
- `RelativeHumidity`: currently has only the `Percent` unit, I think we
should add the `DecimalFraction`, setting it to be the `BaseUnit`
- `FuelEfficiency`: I think this could be defined as `"L": -2` with the
addition of the `MeterPerCubicMeter` unit (possibly setting it as its
`BaseUnit`, if we want to satisfy the `BaseUnit_HasSIBase` test)
You can look for `As_UnitSystem_ReturnsValueInDimensionlessUnit` if you
want to check the rest of the dimensionless quantities.
Regarding the removed `BaseUnits` (see `Force.json` or `Pressure.json`),
those were detected by some earlier tests I had in place, regarding the
multiplication/division operators where I used the following definition:
- A given operation between two quantities (either multiplication or
division) such as `A / B = C` is only defined if `A.Dimensions /
B.Dimensions = C.Dimensions`
- When the intersection between `A.Dimensions` and `B.Dimensions` is the
empty set, for every unit of `A` and `B` for which the `BaseUnits` is
not `Unidefined`, and every unit of `C`, having `BaseUnits` =
`A.BaseUnits union B.BaseUnits`, it must be true that `C.Value = A.Value
/ B.Value`.
- When the intersection between `A.Dimensions` and `B.Dimensions` is not
empty, and the intersecting `BaseUnits` of `A` , `B` and `C` are all the
same, then again we have the same condition, which I generally refer to
as "the conversion coefficient is 1"
- The same logic can be used to infer the unit-conversion coefficient
based off the `Dimensions` and a pair of `BaseUnits`, but special
attention needs to be taken w.r.t. the exponents (e.g. `Area` is `L2` so
the unit-conversion coefficients are squares of the ones from `Length`)
- If we want to extend this definition in the future, we should consider
introducing a way to override the "default conversion coefficient"
(`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)1 parent cdab29e commit 090742c
File tree
341 files changed
+17113
-8234
lines changed- CodeGen/Generators/UnitsNetGen
- Common/UnitDefinitions
- UnitsNet.NanoFramework/GeneratedCode/Quantities
- UnitsNet.Tests
- CustomCode
- QuantityInfos
- TestsBase
- GeneratedCode/TestsBase
- UnitsNet
- CustomCode/QuantityInfo
- GeneratedCode/Quantities
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
341 files changed
+17113
-8234
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
214 | 214 | | |
215 | 215 | | |
216 | 216 | | |
217 | | - | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
218 | 221 | | |
219 | 222 | | |
220 | 223 | | |
| |||
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | | - | |
229 | | - | |
230 | | - | |
231 | | - | |
232 | | - | |
233 | | - | |
234 | | - | |
235 | | - | |
236 | | - | |
237 | | - | |
| 231 | + | |
| 232 | + | |
238 | 233 | | |
239 | 234 | | |
| 235 | + | |
240 | 236 | | |
241 | 237 | | |
242 | 238 | | |
| |||
1000 | 996 | | |
1001 | 997 | | |
1002 | 998 | | |
1003 | | - | |
| 999 | + | |
1004 | 1000 | | |
1005 | 1001 | | |
1006 | 1002 | | |
1007 | 1003 | | |
1008 | | - | |
1009 | | - | |
1010 | | - | |
1011 | | - | |
1012 | | - | |
1013 | | - | |
1014 | | - | |
1015 | | - | |
1016 | | - | |
1017 | | - | |
| 1004 | + | |
1018 | 1005 | | |
1019 | 1006 | | |
1020 | 1007 | | |
1021 | 1008 | | |
1022 | | - | |
1023 | | - | |
1024 | | - | |
1025 | | - | |
1026 | | - | |
1027 | | - | |
1028 | | - | |
1029 | | - | |
1030 | | - | |
1031 | 1009 | | |
1032 | 1010 | | |
1033 | 1011 | | |
| |||
1123 | 1101 | | |
1124 | 1102 | | |
1125 | 1103 | | |
| 1104 | + | |
| 1105 | + | |
| 1106 | + | |
| 1107 | + | |
| 1108 | + | |
| 1109 | + | |
| 1110 | + | |
| 1111 | + | |
1126 | 1112 | | |
1127 | | - | |
1128 | | - | |
| 1113 | + | |
| 1114 | + | |
| 1115 | + | |
| 1116 | + | |
1129 | 1117 | | |
1130 | | - | |
| 1118 | + | |
1131 | 1119 | | |
1132 | 1120 | | |
1133 | | - | |
| 1121 | + | |
1134 | 1122 | | |
1135 | 1123 | | |
1136 | | - | |
1137 | | - | |
| 1124 | + | |
| 1125 | + | |
1138 | 1126 | | |
1139 | | - | |
1140 | | - | |
1141 | | - | |
1142 | | - | |
1143 | | - | |
1144 | | - | |
1145 | | - | |
1146 | | - | |
| 1127 | + | |
| 1128 | + | |
1147 | 1129 | | |
1148 | | - | |
| 1130 | + | |
1149 | 1131 | | |
1150 | 1132 | | |
1151 | 1133 | | |
| |||
1158 | 1140 | | |
1159 | 1141 | | |
1160 | 1142 | | |
| 1143 | + | |
| 1144 | + | |
1161 | 1145 | | |
1162 | 1146 | | |
1163 | 1147 | | |
| |||
0 commit comments