Skip to content

Commit 43e7a54

Browse files
authored
Upgrade to QUDT 3 (#110)
Upgrade the QUDT dependency to QUDT 3.1.4 See CHANGELOG.md for details
1 parent 22835f3 commit 43e7a54

File tree

38 files changed

+852
-1890
lines changed

38 files changed

+852
-1890
lines changed

CHANGELOG.md

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,38 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
### Changed
11+
12+
- Upgrade to QUDT 3.1.4
13+
- Calculation of scalings and factor units now happens in QUDT (see PR [1129](https://github.com/qudt/qudt-public-repo/pull/1129))
14+
However, a few things have changed:
15+
- rename `qudt:isScalingOf` to `qudt:scalingOf`
16+
- rename `qudt:factorUnit/qudt:unit` to `qudt:hasFactorUnit/qudt:hasUnit`
17+
- Currency units have changed:
18+
- they were moved back into the graph 'http://qudt.org/vocab/unit/'
19+
- their localnames have received the prefix `CCY_`
20+
- both changes are 'soft', ie, the old way is still available, but deprecated
21+
- for example: `http://qudt.org/vocab/currency/EUR` is now `http://qudt.org/vocab/unit/CCY_EUR`.
22+
- QUDTLib makes the change now instead of adopting the deprecation, as there are other breaking changes as well, so upgrading will require work anyway.
23+
- for QUDTLib constants, this means that the pattern `${CurrencyName}_Currency` is dropped in favor of the QUDT style `CCY_${CurrencyName}`, e.g. `Qudt.Units.EUR_Currency` becomes `Qudt.Units.CCY_EUR`
24+
- Many conversion multipliers were changed in QUDT. They now consistently have at most 34 significant digits (ie, BigDecimal's precision of 34). This fixes problems such as the one reported in [Conversion error from MilliSV__PER__HR to MicroSV__PER__HR](https://github.com/qudtlib/qudtlib-java/issues/109).
25+
- scalings of `unit:GM` deserve special mention:
26+
- in the upcoming QUDT release we have `unit:GM qudt:scalingOf unit:KiloGM`, making `qudt:scalingOf` and `qudt:conversionMultiplier` consistent in all cases
27+
- QUDTLib makes the change as well, with the effect that unit factorization does not use `Units.GM` (which probably surprised a few people) for the mass dimension but `Units.KiloGM` (which is what one would expect)
28+
- Sorting in `Qudt.derivedUnitListFromFactorUnits` now takes more aspects into account and ordering has changed in some cases.
29+
- When creating a Unit instance, its factor units are checked for factors `x^N^M`, where x has no more factors.
30+
Such factors are simplified as x^(N*M). The same is applied to newly instantiated `FactorUnits` objects.
31+
32+
### Fixed
33+
34+
- Fixed a sorting bug in `Qudt.derivedUnitListFromFactorUnits` that caused wrong sorting for some very similar units.
35+
36+
### Added
37+
38+
- `Unit.dependents` - the number of units that refer to that unit as one of its factor units or are scaled from that base unit.
39+
this value is required to achieve better sorting in `Qudt.derivedUnitListFromFactorUnits`, allowing to prefer
40+
more important units (those with more dependents)
41+
1042
## [6.8.1] - 2025-01-29
1143

1244
### Fixed
@@ -93,13 +125,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
93125

94126
### Changed
95127

96-
- Simplified BEST_MATCH algorithm for obtaining a unit from a set of factor units. Recent additions to the data model (isScalingOf and factorUnit relationships) led to a larger set of candidates and the complexity of the previous algorithm led to very high computation time.
128+
- Simplified BEST_MATCH algorithm for obtaining a unit from a set of factor units. Recent additions to the data model (scalingOf and factorUnit relationships) led to a larger set of candidates and the complexity of the previous algorithm led to very high computation time.
97129
- Changed the behaviour of Unit.hasFactorUnits() such that for a FactorUnits object with only one top-level factor unit (such as [N^1]), the method returns false.
98130

99131
### Fixed
100132

101133
- `unit:MHO`, `unit:MicroMHO`: fix dimension vector and quantity kind
102-
- `unit:F`: fix `unit:isScalingOf`
134+
- `unit:F`: fix `unit:scalingOf`
103135

104136
## [6.1.0] - 2024-01-05
105137

pom.xml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@
4949
<maven.compiler.source>17</maven.compiler.source>
5050
<maven.compiler.target>17</maven.compiler.target>
5151
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
52-
<qudt.release.version>2.1.47</qudt.release.version>
52+
<qudt.release.version>3.1.4</qudt.release.version>
5353
<spotless.format.version>1.25.0</spotless.format.version>
5454
</properties>
5555

@@ -331,6 +331,12 @@
331331
</plugins>
332332
</build>
333333
</profile>
334+
<profile>
335+
<id>skip-test</id>
336+
<properties>
337+
<maven.test.skip>true</maven.test.skip>
338+
</properties>
339+
</profile>
334340
</profiles>
335341
<distributionManagement>
336342
<snapshotRepository>

qudtlib-constants-gen/src/main/java/io/github/qudtlib/constgen/ConstantsGenerator.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ public class ConstantsGenerator {
3030
// input data
3131
private static final String DATA_UNITS = "qudtlib/qudt-units.ttl";
3232
private static final String DATA_QUANTITYKINDS = "qudtlib/qudt-quantitykinds.ttl";
33-
private static final String DATA_CURRENCY = "qudtlib/qudt-currency.ttl";
3433
private static final String DATA_PREFIXES = "qudtlib/qudt-prefixes.ttl";
3534
private static final String DATA_SYSTEMS_OF_UNITS = "qudtlib/qudt-systems-of-units.ttl";
3635
private static final String DATA_PHYSICAL_CONSTANTS = "qudtlib/qudt-constants.ttl";
@@ -148,9 +147,6 @@ private Map<String, Object> getConstantNamesByQuery(String queryFile, String...
148147
typeName.substring(0, 1).toLowerCase()
149148
+ typeName.substring(1)
150149
+ "FromLocalnameRequired";
151-
if (typeName.equals("Unit") && constName.endsWith("_Currency")) {
152-
valueFactory = "currencyFromLocalnameRequired";
153-
}
154150
Constant constant =
155151
new Constant(
156152
constName,

qudtlib-data-gen/src/main/java/io/github/qudtlib/data/DataGenerator.java

Lines changed: 7 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -35,27 +35,20 @@ public class DataGenerator {
3535

3636
// QUDT files
3737
private static final String UNITS_FILE = "qudt/vocab/unit/VOCAB_QUDT-UNITS-ALL.ttl";
38-
private static final String CURRENCIES_FILE =
39-
"qudt/vocab/currency/VOCAB_QUDT-UNITS-CURRENCY.ttl";
4038
private static final String PREFIXES_FILE = "qudt/vocab/prefixes/VOCAB_QUDT-PREFIXES.ttl";
4139
private static final String QUANTITYKINDS_FILE =
4240
"qudt/vocab/quantitykinds/VOCAB_QUDT-QUANTITY-KINDS-ALL.ttl";
4341

4442
private static final String CONSTANTS_FILE = "qudt/vocab/constants/VOCAB_QUDT-CONSTANTS.ttl";
4543

4644
// queries
47-
private static final String FACTOR_UNITS_QUERY = "factorUnit.rq";
48-
private static final String IS_SCALING_OF_QUERY = "isScalingOf.rq";
4945
private static final String MISSING_UNITS_QUERY = "missing-units.rq";
50-
private static final String DELETE_KILOGM_SCALINGS_QUERY = "delete-kiloGM-scalings.rq";
5146
private static final String DELETE_UNITS_QUERY = "delete-units.rq";
5247

53-
private static final String DELETE_FROM_UNITS_BY_QUERY_PATTERN =
54-
"delete-from-units-by-query[N].rq";
55-
private static final String DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN =
56-
"delete-from-quantitykinds-by-query[N].rq";
48+
private static final String UPDATE_UNITS_BY_QUERY_PATTERN = "update-units-by-query[N].rq";
49+
private static final String UPDATE_QUANTITYKINDS_BY_QUERY_PATTERN =
50+
"update-quantitykinds-by-query[N].rq";
5751
// additional data
58-
private static final String SI_BASE_UNITS_DATA = "si-base-units.ttl";
5952
private static final String ADD_TO_UNITS = "add-to-units.ttl";
6053
private static final String ADD_TO_QUANTITYKINDS = "add-to-quantitykinds.ttl";
6154
private static final String DELETE_FROM_UNITS = "delete-from-units.ttl";
@@ -137,11 +130,9 @@ private void processQuantityKinds() {
137130
Repository outputRepo = new SailRepository(new MemoryStore());
138131
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
139132
RdfOps.addStatementsFromFile(outputCon, QUANTITYKINDS_FILE);
140-
RdfOps.addStatementsFromFile(outputCon, CURRENCIES_FILE);
141133
RdfOps.updateDataUsingQuery(outputCon, DELETE_UNITS_QUERY);
142134
// remove unwanted individual triples
143-
RdfOps.updateDataUsingNQueries(
144-
outputCon, DELETE_FROM_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
135+
RdfOps.updateDataUsingNQueries(outputCon, UPDATE_QUANTITYKINDS_BY_QUERY_PATTERN, 5);
145136
RdfOps.removeStatementsFromFile(outputCon, DELETE_FROM_QUANTITYKINDS);
146137
// add missing triples
147138
RdfOps.addStatementsFromFile(outputCon, ADD_TO_QUANTITYKINDS);
@@ -157,30 +148,20 @@ void processUnits() {
157148
try (RepositoryConnection outputCon = outputRepo.getConnection()) {
158149
// start with the original units data in the INPUT repo
159150
RdfOps.addStatementsFromFile(inputCon, UNITS_FILE);
160-
RdfOps.addStatementsFromFile(inputCon, CURRENCIES_FILE);
161-
// deal with kg
162-
RdfOps.updateDataUsingQuery(inputCon, DELETE_KILOGM_SCALINGS_QUERY);
163151
// if we have identified wrong data in this query, remove it
164-
RdfOps.updateDataUsingNQueries(inputCon, DELETE_FROM_UNITS_BY_QUERY_PATTERN, 5);
152+
RdfOps.updateDataUsingNQueries(inputCon, UPDATE_UNITS_BY_QUERY_PATTERN, 5);
165153
// remove unwanted individual triples
166154
RdfOps.removeStatementsFromFile(inputCon, DELETE_FROM_UNITS);
167155
// add missing triples
168156
RdfOps.addStatementsFromFile(inputCon, ADD_TO_UNITS);
169-
// add SI base units
170-
RdfOps.addStatementsFromFile(outputCon, SI_BASE_UNITS_DATA);
171157
// put result in OUTPUT repo
172158
RdfOps.copyData(inputCon, outputCon);
173159
// add prefixes to INPUT repo (cannot be in output, but is required for queries!)
174160
RdfOps.addStatementsFromFile(inputCon, PREFIXES_FILE);
175-
// find isScalingOf where missing, write result in INPUT and OUTPUT repos
161+
// find scalingOf where missing, write result in INPUT and OUTPUT repos
176162
if (DEBUG) {
177163
RdfOps.writeTurtleFile(inputCon, new File("/tmp/scaling-data.ttl").toPath());
178164
}
179-
RdfOps.addDataUsingQuery(inputCon, IS_SCALING_OF_QUERY, inputCon, outputCon);
180-
// find factor units, write result in INPUT and OUTPUT repos
181-
RdfOps.addDataUsingQuery(inputCon, FACTOR_UNITS_QUERY, inputCon, outputCon);
182-
// we generate some units in the above, add basic unit info for those, write to
183-
// INPUT and OUTPUT repos
184165
RdfOps.addDataUsingQuery(inputCon, MISSING_UNITS_QUERY, inputCon, outputCon);
185166
copyNamespaces(inputCon, outputCon);
186167
// write units file from OUTPUT repo
@@ -215,7 +196,7 @@ private void compareWithExpected(RepositoryConnection outputCon) {
215196
.collect(Collectors.toList()));
216197
RdfOps.message(
217198
"\n\nExpected data subset of generated: " + Models.isomorphic(actual, expected));
218-
compareForProperty(expected, actual, QUDT.isScalingOf);
199+
compareForProperty(expected, actual, QUDT.scalingOf);
219200
compareForProperty(expected, actual, QUDTX.factorUnit);
220201
}
221202

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,2 @@
1-
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
2-
@prefix qudt: <http://qudt.org/schema/qudt/> .
3-
@prefix unit: <http://qudt.org/vocab/unit/> .
4-
5-
unit:DEG_C2
6-
qudt:symbol "°C²" .
7-
8-
unit:GM-PER-M2-HR
9-
qudt:symbol "g/m²·hr" .
10-
11-
unit:GM-PER-M2-YR
12-
qudt:symbol "g/m²·yr" .
13-
14-
unit:GM-PER-M3-CentiPOISE
15-
qudt:symbol "g/(m³·cP)" .
16-
17-
unit:GM-PER-M3-PA-SEC
18-
qudt:symbol "g/(m³Pa·s)" .
19-
20-
unit:KiloGM-PER-M2-DAY
21-
qudt:symbol "kg/(m²·d)" .
22-
23-
unit:KiloTONNE-PER-YR
24-
qudt:symbol "kt/yr" .
25-
26-
unit:MegaGM-PER-HA-YR
27-
qudt:symbol "Mg/(ha·yr)" .
28-
29-
unit:MegaJ-PER-M2-DAY
30-
qudt:symbol "MJ/(m²·d)" .
31-
32-
unit:MicroGM-PER-GM-HR
33-
qudt:symbol "μg/(g·h)" .
34-
35-
unit:MicroGM-PER-L-DAY
36-
qudt:symbol "μg/(L·d)" .
37-
38-
unit:MicroMOL-PER-M2-SEC2
39-
qudt:symbol "μmol/(m²·s²)" .
40-
41-
unit:MilliM-PER-M2
42-
qudt:symbol "mm/m²" .
43-
44-
unit:MilliMOL-PER-M2-HR
45-
qudt:symbol "mmol/(m²·h)" .
46-
47-
unit:NanoMOL-PER-GM-HR
48-
qudt:symbol "nmol/(g.h)" .
49-
50-
unit:NanoMOL-PER-M2-SEC
51-
qudt:symbol "nmol/(m²·s)" .
521

532

qudtlib-data-gen/src/main/resources/delete-from-quantitykinds-by-query1_dontfind.rq

Lines changed: 0 additions & 7 deletions
This file was deleted.

qudtlib-data-gen/src/main/resources/delete-from-units-by-query1.rq

Lines changed: 0 additions & 24 deletions
This file was deleted.

qudtlib-data-gen/src/main/resources/delete-from-units-by-query2_dontfind.rq

Lines changed: 0 additions & 10 deletions
This file was deleted.

qudtlib-data-gen/src/main/resources/delete-kiloGM-scalings.rq

Lines changed: 0 additions & 24 deletions
This file was deleted.

qudtlib-data-gen/src/main/resources/factorUnit.rq

Lines changed: 0 additions & 83 deletions
This file was deleted.

0 commit comments

Comments
 (0)