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
14 changes: 13 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ This Changelog contains the changes for all packages of this monorepo, which all

## Unreleased

### Changed

- Upgrade to QUDT 3.1.5
QUDT now contains many more language-specific `rdfs:label`s. QUDTLib selects only `en` and `en-US` labels
(`en` is standard and together with `en-US` the labels meet the expectations of most romanic language users)

### Fixed

- Fixed handling of Currency units.
- Special handling of KiloGM in Qudt.scale()
- Exported more functions

## 7.0.0-beta.1 - 2025-07-26

### Added
Expand Down Expand Up @@ -93,7 +105,7 @@ This Changelog contains the changes for all packages of this monorepo, which all

### Changed

- 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.
- 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.
- 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.

## 6.0.0 - 2023-12-15
Expand Down
29,298 changes: 14,756 additions & 14,542 deletions allunits/src/units.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions allunits/test/units.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@
return unitList.map((u) => JSON.stringify(u)).sort();
}

const ALL_QUDT_UNITS = Qudt.allUnits();

Check warning on line 108 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

'ALL_QUDT_UNITS' is assigned a value but never used

test("Qudt.unit()", () => {
expect(Qudt.unit(Qudt.NAMESPACES.unit.makeIriInNamespace("M"))).toBe(Units.M);
Expand Down Expand Up @@ -1126,13 +1126,13 @@
});

test("Qudt.convert(Decimal, Unit, Unit) (missing values handling)", () => {
expect(() => Qudt.convert(new Decimal(1), Units.M, undefined!)).toThrowError(

Check warning on line 1129 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
"Parameter 'toUnit' is required"
);
expect(() => Qudt.convert(new Decimal(1), undefined!, Units.FT)).toThrowError(

Check warning on line 1132 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
"Parameter 'fromUnit' is required"
);
expect(() => Qudt.convert(undefined!, Units.M, Units.FT)).toThrowError(

Check warning on line 1135 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
"Parameter 'value' is required"
);
});
Expand Down Expand Up @@ -1225,10 +1225,10 @@
});

test("Unit.convert(Decimal, Unit) (missing values handling)", () => {
expect(() => Units.M.convert(new Decimal(1), undefined!)).toThrowError(

Check warning on line 1228 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
"Parameter 'toUnit' is required"
);
expect(() => Units.M.convert(undefined!, Units.FT)).toThrowError(

Check warning on line 1231 in allunits/test/units.test.ts

View workflow job for this annotation

GitHub Actions / build

Forbidden non-null assertion
"Parameter 'value' is required"
);
});
Expand Down Expand Up @@ -1867,7 +1867,7 @@
expect(units.includes(Units.FT)).toBe(false);
expect(units.includes(Units.OZ)).toBe(false);
expect(units.includes(Units.N__PER__M3)).toBe(true);
expect(units.length).toBe(1153);
expect(units.length).toBe(1167);
});

test("SystemOfUnits.allUnitsOfSystem(SystemsOfUnits.Imperial)", () => {
Expand All @@ -1883,7 +1883,7 @@
expect(units.includes(Units.FT)).toBe(true);
expect(units.includes(Units.OZ)).toBe(true);
expect(units.includes(Units.N__PER__M3)).toBe(false);
expect(units.length).toBe(441);
expect(units.length).toBe(443);
});

test("Unit.normalize()", () => {
Expand Down
2 changes: 1 addition & 1 deletion core/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion core/src/assignmentProblem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export class Solution {
}
}

class ValueWithIndex {
export class ValueWithIndex {
readonly value: number;
readonly index: number;

Expand Down
8 changes: 4 additions & 4 deletions core/src/qudt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
import {
arrayContains,
arrayDeduplicate,
arrayMax,

Check warning on line 5 in core/src/qudt.ts

View workflow job for this annotation

GitHub Actions / build

'arrayMax' is defined but never used
arrayMin,
BooleanComparator,
compareUsingEquals,
findInIterable,
getLastIriElement,

Check warning on line 10 in core/src/qudt.ts

View workflow job for this annotation

GitHub Actions / build

'getLastIriElement' is defined but never used
NumberComparator,
StringComparator,
OrderComparator,
Expand All @@ -20,7 +20,7 @@
import { DerivedUnitSearchMode } from "./derivedUnitSearchMode.js";
import { FactorUnit } from "./factorUnit.js";
import { FactorUnits } from "./factorUnits.js";
import { AssignmentProblem } from "./assignmentProblem.js";

Check warning on line 23 in core/src/qudt.ts

View workflow job for this annotation

GitHub Actions / build

'AssignmentProblem' is defined but never used
import { QuantityValue } from "./quantityValue.js";
import { LangString } from "./langString.js";
import { Decimal } from "decimal.js";
Expand Down Expand Up @@ -403,7 +403,7 @@
Qudt.bestMatchForFactorUnitsComparator(selection)
);
} else {
const requestedUnits: FactorUnit[] =

Check warning on line 406 in core/src/qudt.ts

View workflow job for this annotation

GitHub Actions / build

'requestedUnits' is assigned a value but never used
selection.contractExponents().factorUnits;
return [
arrayMin(
Expand Down Expand Up @@ -622,16 +622,16 @@
prefix instanceof Prefix ? prefix : this.prefixRequired(prefix);
const theUnit =
baseUnit instanceof Unit ? baseUnit : this.unitRequired(baseUnit);
// special case: KiloGM is not a scaling of GM, it's the other way round. Handle special case here.
if (thePrefix.iri.endsWith("/Kilo") && theUnit.iri.endsWith("/GM")) {
return this.unitFromLocalname("KiloGM");
}
const candidates = this.getUnitsWithSameDimensionVector(theUnit);
for (const u of candidates) {
if (u.prefix?.equals(thePrefix) && u.scalingOf?.equals(theUnit)) {
return u;
}
}
// special case: KiloGM is not a scaling of GM, it's the other way round. Handle special case here.
if (thePrefix.iri.endsWith("/Kilo") && theUnit.iri.endsWith("/GM")) {
return this.unitFromLocalname("KiloGM");
}
throw `No scaled unit found with base unit ${theUnit.toString()} and prefix ${thePrefix.toString()}`;
}

Expand Down
1 change: 0 additions & 1 deletion core/src/qudtNamespaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ export const QudtNamespaces = Object.freeze({
qudt: new Namespace("http://qudt.org/schema/qudt/", "qudt"),
quantityKind: new Namespace("http://qudt.org/vocab/quantitykind/", "qk"),
unit: new Namespace("http://qudt.org/vocab/unit/", "unit"),
currency: new Namespace("http://qudt.org/vocab/currency/", "cur"),
prefix: new Namespace("http://qudt.org/vocab/prefix/", "prefix"),
systemOfUnits: new Namespace("http://qudt.org/vocab/sou/", "sou"),
dimensionVector: new Namespace(
Expand Down
6 changes: 2 additions & 4 deletions core/src/unit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,11 @@ export class Unit implements SupportsEquals<Unit> {
}

getIriAbbreviated(): string {
return this.isCurrencyUnit()
? QudtNamespaces.currency.abbreviate(this.iri)
: QudtNamespaces.unit.abbreviate(this.iri);
return QudtNamespaces.unit.abbreviate(this.iri);
}

isCurrencyUnit(): boolean {
return QudtNamespaces.currency.isFullNamespaceIri(this.iri);
return this.getIriLocalname().startsWith("CCY_");
}

matchesFactorUnitSpec(...factorUnitSpec: (number | Unit)[]): boolean {
Expand Down
2 changes: 1 addition & 1 deletion core/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function getLastIriElement(iri: string) {
return iri.replaceAll(/.+\/([^\/]+)/g, "$1");
}

interface EqualsComparator<Type> {
export interface EqualsComparator<Type> {
(left: Type, right: Type): boolean;
}

Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": true,
"version": "7.0.0-beta.1"
}
}