unitsml 0.5.1 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/rake.yml +8 -0
  3. data/.github/workflows/release.yml +7 -1
  4. data/.rubocop.yml +18 -0
  5. data/.rubocop_todo.yml +498 -0
  6. data/Gemfile +16 -11
  7. data/Rakefile +5 -3
  8. data/bin/console +4 -3
  9. data/docs/README.adoc +2 -2
  10. data/lib/unitsml/dimension.rb +49 -35
  11. data/lib/unitsml/errors/base_error.rb +8 -0
  12. data/lib/unitsml/errors/plurimath_load_error.rb +1 -1
  13. data/lib/unitsml/errors.rb +8 -0
  14. data/lib/unitsml/extender.rb +21 -16
  15. data/lib/unitsml/fenced.rb +30 -10
  16. data/lib/unitsml/fenced_numeric.rb +13 -0
  17. data/lib/unitsml/formula.rb +29 -29
  18. data/lib/unitsml/intermediate_exp_rules.rb +58 -17
  19. data/lib/unitsml/model/dimension.rb +4 -14
  20. data/lib/unitsml/model/dimension_quantities/quantity.rb +2 -0
  21. data/lib/unitsml/model/dimension_quantities.rb +17 -0
  22. data/lib/unitsml/model/prefix.rb +4 -8
  23. data/lib/unitsml/model/prefixes/name.rb +5 -4
  24. data/lib/unitsml/model/prefixes/symbol.rb +3 -2
  25. data/lib/unitsml/model/prefixes.rb +10 -0
  26. data/lib/unitsml/model/quantities/name.rb +4 -3
  27. data/lib/unitsml/model/quantities.rb +9 -0
  28. data/lib/unitsml/model/quantity.rb +5 -7
  29. data/lib/unitsml/model/unit.rb +4 -9
  30. data/lib/unitsml/model/units/enumerated_root_unit.rb +1 -0
  31. data/lib/unitsml/model/units/name.rb +4 -3
  32. data/lib/unitsml/model/units/root_units.rb +3 -2
  33. data/lib/unitsml/model/units/symbol.rb +2 -1
  34. data/lib/unitsml/model/units/system.rb +4 -3
  35. data/lib/unitsml/model/units.rb +13 -0
  36. data/lib/unitsml/model.rb +15 -0
  37. data/lib/unitsml/namespace.rb +8 -0
  38. data/lib/unitsml/number.rb +79 -0
  39. data/lib/unitsml/parse.rb +20 -19
  40. data/lib/unitsml/parser.rb +13 -14
  41. data/lib/unitsml/prefix.rb +10 -10
  42. data/lib/unitsml/sqrt.rb +3 -3
  43. data/lib/unitsml/transform.rb +133 -71
  44. data/lib/unitsml/unit.rb +41 -33
  45. data/lib/unitsml/unitsdb/dimension.rb +3 -3
  46. data/lib/unitsml/unitsdb/dimensions.rb +2 -4
  47. data/lib/unitsml/unitsdb/prefixes.rb +0 -2
  48. data/lib/unitsml/unitsdb/quantities.rb +0 -2
  49. data/lib/unitsml/unitsdb/unit.rb +2 -2
  50. data/lib/unitsml/unitsdb/units.rb +2 -4
  51. data/lib/unitsml/unitsdb.rb +14 -9
  52. data/lib/unitsml/utility.rb +111 -73
  53. data/lib/unitsml/version.rb +3 -1
  54. data/lib/unitsml.rb +51 -33
  55. data/unitsdb/Gemfile +6 -0
  56. data/unitsdb/README.adoc +193 -11
  57. data/unitsdb/dimensions.yaml +360 -8
  58. data/unitsdb/prefixes.yaml +104 -4
  59. data/unitsdb/quantities.yaml +602 -0
  60. data/unitsdb/schemas/dimensions-schema.yaml +2 -6
  61. data/unitsdb/schemas/prefixes-schema.yaml +2 -6
  62. data/unitsdb/schemas/quantities-schema.yaml +2 -5
  63. data/unitsdb/schemas/scales-schema.yaml +2 -5
  64. data/unitsdb/schemas/unit_systems-schema.yaml +2 -6
  65. data/unitsdb/schemas/units-schema.yaml +2 -6
  66. data/unitsdb/spec/units_spec.rb +3 -1
  67. data/unitsdb/unit_systems.yaml +4 -0
  68. data/unitsdb/units.yaml +957 -6
  69. data/unitsdb/validate_schemas.rb +32 -37
  70. data/unitsml.gemspec +3 -1
  71. metadata +29 -17
  72. data/lib/unitsml/error.rb +0 -8
data/unitsdb/README.adoc CHANGED
@@ -252,13 +252,16 @@ names:
252
252
 
253
253
  ==== References
254
254
 
255
+ ===== General
256
+
255
257
  A reference object represents a link to an external resource or standard
256
258
  that provides additional context or information about the entity.
257
259
 
258
260
  Currently, UnitsDB units, quantities and prefixes link to:
259
261
 
260
- * the SI Digital Framework
261
- * UCUM
262
+ * https://si-digital-framework.org[BIPM SI Digital Framework] (normative references)
263
+ * https://ucum.org/[UCUM] (informative references)
264
+ * https://qudt.org[QUDT] (informative references)
262
265
 
263
266
  A reference contains the following attributes:
264
267
 
@@ -271,33 +274,58 @@ A reference contains the following attributes:
271
274
  [source,yaml]
272
275
  ----
273
276
  references:
274
- - uri: http://si-digital-framework.org/SI/units/metre
275
- type: normative
277
+ - type: normative
278
+ uri: http://si-digital-framework.org/SI/units/metre
276
279
  authority: si-digital-framework
277
280
  - type: informative
278
- authority: ucum
279
281
  uri: ucum:base-unit:code:m
282
+ authority: ucum
283
+ - type: informative
284
+ uri: http://qudt.org/vocab/unit/M
285
+ authority: qudt
280
286
  ----
281
287
  ====
282
288
 
289
+
290
+ ===== SI Digital Framework
291
+
283
292
  The SI Digital Framework reference is a normative reference to the
284
293
  official SI unit definitions.
285
294
 
286
295
  SI references are added to:
287
296
 
288
- * units.yaml for units
289
- * quantities.yaml for quantities
290
- * prefixes.yaml for prefixes
291
- * dimensions.yaml for dimensions
297
+ * `units.yaml` for units
298
+ * `quantities.yaml` for quantities
299
+ * `prefixes.yaml` for prefixes
300
+ * `dimensions.yaml` for dimensions
292
301
 
293
302
 
303
+ ===== UCUM
304
+
294
305
  The UCUM URI format is a custom one used inside UnitsML with the pattern
295
306
  `ucum:{type}:{klass}:code:{unit_code}`, and is listed as informative.
296
307
 
297
308
  UCUM references are added to:
298
309
 
299
- * units.yaml for units
300
- * prefixes.yaml for prefixes
310
+ * `units.yaml` for units
311
+ * `prefixes.yaml` for prefixes
312
+
313
+ The UCUM file is located at: `spec/fixtures/ucum/ucum-essence.xml`
314
+
315
+
316
+ ===== QUDT
317
+
318
+ The QUDT URI format is a custom one used inside UnitsML with the pattern
319
+ `http://qudt.org/{version}/vocab/{vocab_type}/{code}`, and is listed as informative.
320
+
321
+ QUDT references are added to:
322
+
323
+ * `units.yaml` for units (`http://qudt.org/{version}/vocab/unit`)
324
+ * `quantities.yaml` for quantities (`http://qudt.org/{version}/vocab/quantitykind`)
325
+ * `dimensions.yaml` for dimensions (`http://qudt.org/{version}/vocab/dimensionvector`)
326
+ * `unit_systems.yaml` for unit systems (`http://qudt.org/{version}/vocab/sou`)
327
+
328
+ The current version mapped to QUDT is `3.1.2`.
301
329
 
302
330
 
303
331
  === Dimensions
@@ -1062,6 +1090,160 @@ Both release formats include version information in their filenames (e.g.,
1062
1090
  `unitsdb-2.0.0.yaml` and `unitsdb-2.0.0.zip`).
1063
1091
 
1064
1092
 
1093
+
1094
+ == Instructions for maintainers
1095
+
1096
+ === Pre-publication
1097
+
1098
+ Before publishing a new version of the UnitsDB, ensure that the following steps
1099
+ are completed:
1100
+
1101
+ . Run the normalization command to ensure all YAML files are consistent and
1102
+ properly formatted.
1103
+ . Run the validation commands to check for any issues with internal references,
1104
+ identifiers and external references.
1105
+
1106
+ === Normalize dataset
1107
+
1108
+ [source,sh]
1109
+ ----
1110
+ bundle exec unitsdb _modify normalize --all --database=spec/fixtures/unitsdb --sort=nist
1111
+ ----
1112
+
1113
+ === Validate dataset
1114
+
1115
+ Check for duplicate identifiers:
1116
+
1117
+ [source,sh]
1118
+ ----
1119
+ bundle exec unitsdb validate identifiers --database=spec/fixtures/unitsdb
1120
+ ----
1121
+
1122
+ Check for duplicate internal references (e.g. units referencing quantities,
1123
+ quantities referencing dimensions):
1124
+
1125
+ [source,sh]
1126
+ ----
1127
+ bundle exec unitsdb validate references --database=spec/fixtures/unitsdb
1128
+ ----
1129
+
1130
+ Check for duplicate SI references:
1131
+
1132
+ [source,sh]
1133
+ ----
1134
+ bundle exec unitsdb validate si_references --database=spec/fixtures/unitsdb
1135
+ ----
1136
+
1137
+ Check for duplicate UCUM references:
1138
+
1139
+ [source,sh]
1140
+ ----
1141
+ bundle exec unitsdb validate ucum_references --database=spec/fixtures/unitsdb
1142
+ ----
1143
+
1144
+
1145
+ Check for duplicate QUDT references:
1146
+
1147
+ [source,sh]
1148
+ ----
1149
+ bundle exec unitsdb validate qudt_references --database=spec/fixtures/unitsdb
1150
+ ----
1151
+
1152
+ QUDT references can be duplicated as some units do not uniquely map to a
1153
+ QUDT URI. This is acceptable as long as the duplicates are documented in the
1154
+ README file.
1155
+
1156
+ These are the duplicated units:
1157
+
1158
+ [source]
1159
+ ----
1160
+ QUDT URI: http://qudt.org/vocab/unit/IN3
1161
+ Used by 2 entities:
1162
+ - NISTu168 (cubic inch (en)) at index 81
1163
+ - NISTu209 (inch cubed (en)) at index 122
1164
+
1165
+ QUDT URI: http://qudt.org/vocab/unit/TSP
1166
+ Used by 3 entities:
1167
+ - NISTu303 (teaspoon (en)) at index 234
1168
+ - NISTu306 (teaspoon (FDA) (en)) at index 237
1169
+
1170
+ QUDT URI: http://qudt.org/vocab/unit/YD
1171
+ Used by 2 entities:
1172
+ - NISTu314 (yard (based on US survey foot) (en)) at index 246
1173
+ - NISTu84 (yard (en)) at index 362
1174
+
1175
+ QUDT URI: http://qudt.org/vocab/unit/IN
1176
+ Used by 2 entities:
1177
+ - NISTu316 (inch (based on US survey foot) (en)) at index 248
1178
+ - NISTu8 (inch (en)) at index 360
1179
+ ----
1180
+
1181
+ These are the duplicated quantities:
1182
+
1183
+ [source]
1184
+ ----
1185
+ QUDT URI: http://qudt.org/vocab/quantitykind/SecondAxialMomentOfArea
1186
+ Used by 2 entities:
1187
+ - NISTq127 (mass moment of inertia (en)) at index 31
1188
+ - NISTq144 (second axial moment of area (en)) at index 50
1189
+
1190
+ QUDT URI: http://qudt.org/vocab/quantitykind/Capacitance
1191
+ Used by 2 entities:
1192
+ - NISTq169 (electric capacitance (en)) at index 75
1193
+ - NISTq27 (capacitance (en)) at index 120
1194
+
1195
+ QUDT URI: http://qudt.org/vocab/quantitykind/Inductance
1196
+ Used by 2 entities:
1197
+ - NISTq171 (electric inductance (en)) at index 78
1198
+ - NISTq32 (inductance (en)) at index 126
1199
+ ----
1200
+
1201
+ UnitsDB and QUDT take a different approach to dimensions:
1202
+
1203
+ * QUDT focuses on the exponents of the dimensions, allowing only for
1204
+ a single dimension to have the same exponent combination.
1205
+
1206
+ * UnitsDB allows for multiple dimensions to have the same exponent combination,
1207
+ as long as they are associated with different quantities.
1208
+
1209
+ Naturally, multiple UnitsDB Dimensions can be mapped to a single QUDT Dimension,
1210
+ hence there are no duplicate dimensions.
1211
+
1212
+ The dimension mapping warnings are as follows (acceptable):
1213
+
1214
+ [source]
1215
+ ----
1216
+ QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L0I0M0H0T0D0
1217
+ Used by 12 entities:
1218
+ - NISTd100 (traffic intensity (en)) at index 2
1219
+ - NISTd102 (information content (en)) at index 4
1220
+ - NISTd64 (solid angle (en)) at index 63
1221
+ - NISTd67 (logarithmic ratio (en)) at index 66
1222
+ - NISTd80 (ratio quantity (en)) at index 81
1223
+ - NISTd83 (level of field quantity (en)) at index 82
1224
+ - NISTd84 (field power level (en)) at index 83
1225
+ - NISTd85 (mass mole fraction (en)) at index 84
1226
+ - NISTd9 (plane angle (en)) at index 85
1227
+ - NISTd94 (acidity index (en)) at index 86
1228
+ - NISTd95 (storage capacity (en)) at index 87
1229
+ - NISTd98 (phase (en)) at index 90
1230
+
1231
+ QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L-0dot5I0M0dot5H0T-1D0
1232
+ Used by 2 entities:
1233
+ - NISTd101 (symbol rate (en)) at index 3
1234
+ - NISTd24 (frequency (en)) at index 19
1235
+
1236
+ QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L1I0M-1H0T2D0
1237
+ Used by 2 entities:
1238
+ - NISTd63 (compressibility (en)) at index 62
1239
+ - NISTd70 (isothermal compressibility (en)) at index 70
1240
+
1241
+ QUDT URI: http://qudt.org/vocab/dimensionvector/A0E0L-2I0M0H0T0D0
1242
+ Used by 2 entities:
1243
+ - NISTd96 (fluence (en)) at index 88
1244
+ - NISTd99 (fuel efficiency (en)) at index 91
1245
+ ----
1246
+
1065
1247
  == Copyright and license
1066
1248
 
1067
1249
  Copyright CalConnect. Incorporates public domain work from NIST.