Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Changed

- Bump QUDT version to [3.5.3](https://github.com/qudt/qudt-public-repo/releases/tag/v3.5.3)
Fix affected unit tests
- Report all candidate units when in unit parsing when the provided quantity kind is `qk:Unknown`

## [7.2.0] - 2026-02-11

### Added
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<qudt.release.version>3.1.5</qudt.release.version>
<qudt.release.version>3.5.3</qudt.release.version>
<spotless.format.version>1.33.0</spotless.format.version>
</properties>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ public Set<Unit> parse() {
if (!results.isEmpty()) {
if (this.quantityKind != null) {
Set<Unit> intermediateResults = new HashSet<>(results);
intermediateResults.retainAll(this.quantityKind.getApplicableUnits());
if (this.quantityKind.equals(Qudt.QuantityKinds.Unknown)) {
// Unknown has no applicable units; use the units' own classifications.
intermediateResults.removeIf(
u ->
u.isDeprecated()
|| !u.getQuantityKinds()
.contains(this.quantityKind));
} else {
intermediateResults.retainAll(this.quantityKind.getApplicableUnits());
}
// System.out.println("intermediateResults: " +
// intermediateResults);
if (intermediateResults.isEmpty()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import static org.hamcrest.number.BigDecimalCloseTo.closeTo;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assumptions.assumeFalse;

import io.github.qudtlib.model.*;
import java.math.BigDecimal;
Expand Down Expand Up @@ -456,6 +457,10 @@ public static Stream<Arguments> getSymbol() {
@ParameterizedTest
@MethodSource
public void testConversionMultiplierOpt(Unit unit) {
// TODO: Re-enable MeV/c on the next QUDT upgrade; its multipliers are fixed on QUDT main.
assumeFalse(
unit.equals(MegaEV__PER__SpeedOfLight),
"QUDT 3.5.3 has zero conversion multipliers for SpeedOfLight and MeV/c");
Optional<BigDecimal> result = unit.getFactorUnits().getConversionMultiplierOpt();
if (hasNoFactorUnitsWithoutConversionMultiplier(unit)) {
assertTrue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public static Stream<Arguments> testExactMatches() {
EnergyPerElectricCharge),
Arguments.of(ElectromagneticEnergyDensity, VolumicElectromagneticEnergy),
Arguments.of(Permeability, ElectromagneticPermeability),
Arguments.of(EnergyInternal, InternalEnergy, ThermodynamicEnergy),
Arguments.of(InversePressure, IsothermalCompressibility));
Arguments.of(InternalEnergy, ThermodynamicEnergy));
}

static class VarargsAggregator implements ArgumentsAggregator {
Expand Down
5 changes: 3 additions & 2 deletions qudtlib-test/src/test/java/io/github/qudtlib/QudtTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public void testUnit() {
@Test
public void testQuantityKind() {
QuantityKind length = Qudt.QuantityKinds.Length;
Assertions.assertTrue(length.hasLabel("length"));
Assertions.assertTrue(length.hasLabel("Length"));
Assertions.assertEquals(Qudt.quantityKindRequired(length.getIri()), length);
Assertions.assertEquals(Qudt.quantityKindRequired(length.getIri()), length);
}
Expand Down Expand Up @@ -857,7 +857,6 @@ public void testExactMatches(@AggregateWith(VarargsAggregator.class) Unit... uni

public static Stream<Arguments> testExactMatches() {
return Stream.of(
Arguments.of(S__PER__M, KiloGM__PER__M2__PA__SEC),
Arguments.of(KiloGM__PER__M2__SEC, KiloGM__PER__SEC__M2),
Arguments.of(KiloTONNE, KiloTON_Metric),
Arguments.of(LB_F__PER__IN2, PSI),
Expand Down Expand Up @@ -1004,6 +1003,8 @@ private void testParseUnit(String input, QuantityKind quantityKind, Set<Unit> ex

public static Stream<Arguments> testParseUnit_specificCases() {
return Stream.of(
Arguments.of("lbm/psi", QuantityKinds.Unknown, Set.of(Units.LB__PER__PSI)),
Arguments.of("%/1000", QuantityKinds.Unknown, Set.of(Units.PERCENT__PER__THOUSAND)),
Arguments.of("g/Mole", QuantityKinds.MolarMass, Set.of(Units.GM__PER__MOL)),
Arguments.of("g/mole", QuantityKinds.MolarMass, Set.of(Units.GM__PER__MOL)),
Arguments.of("m", QuantityKinds.Length, Set.of(Units.M)),
Expand Down
Loading