Unit conversion issues with compound units and unit exponents
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 48/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- javascript
- 領域
- backend
調査の方向性
Start by locating the unit parsing, normalization, and implicit conversion logic used by the CQL execution engine; the issue does not name specific files or tests. Reproduce the negative exponent cancellation, compound unit division, and squared knot addition cases from the tables, then trace where their unit representations diverge. Done means those cases produce the expected equivalent units and values.
索引モデルが issue の本文から書いたものです。
説明
While experimenting with unit conversion for another issue, I noticed the unit conversion logic has some issues related to compound units and unit exponents. All of the following relate to the units themselves, not the value of the Quantities they are part of:
- Inverse Units not handled correctly when represented with negative exponent. UCUM allows both
1/xandx-1syntax and these should be equivalent.
| Expression | Expected | Actual |
|---|---|---|
define CancelUnits: 1 'm' * 1 'm-1' |
1 '1' |
1 'm' ❌ |
define CancelUnits2: 1 'm' * 1 '1/m' |
1 '1' |
1 '1' ✅ |
define Velocity: 1 'm' * 1 's-1' |
1 'm/s' |
1 'm.s' ❌ |
define Velocity2: 1 'm' * 1 '1/s' |
1 'm/s' |
1 'm/s' ✅ |
- Division of compound units doesn't always perform unit cancellation:
| Expression | Expected | Actual |
|---|---|---|
define DivideReducePower: 1 'm2/s2' / 1 'm/s' |
1 'm/s' |
1 'm2/s2/(m/s)' ❌ * |
define MultiplyThenDivide: (1 'm/s' * 1 'm/s') / 1 'm/s' |
1 'm/s' |
1 'm2/s2/(m/s)' ❌* |
define MultiplyDivideDivide: ((1 'm/s' * 1 'm/s') / 1 'm/s') / 1 'm/s' |
1 '1' |
1 '1' ✅ |
define MultiplyPlainUnits: (1 'm' * 1 'm') / 1 'm' |
1 'm' |
1 'm' ✅ |
* = These may not be technically incorrect, but they are definitely not ideal. The 2 correct tests show that these should be able to be reduced
- Simple units that map to a compound unit do not support arithmetic with implicit unit conversion, when the units have exponents.
For background, consider the knot (kt, kn, or in UCUM [kn_i]) where 1 kt is defined as 1 nautical mile per hour, or ~0.514 m/s. So a knot looks like a plain unit but it corresponds to a compound unit. Then a "square knot" (1 kt * 1 kt, probably not a meaningful unit in practice but useful to show the issue) 1 kt^2 = 0.265 (m^2)/(s^2), or in UCUM m2/s2.
Units that map cleanly in terms of compound units and powers can be added together just fine:
| Expression | Expected Unit | Actual |
|---|---|---|
define AddLinearSpeeds: 1 'm/s' + 1 '[mi_i]/h' |
m/s or [mi_i]/h |
3.23693629 '[mi_i]/h' ✅ |
define AddSquareSpeeds: 1 'm2/s2' + 1 '[mi_i]2/h2' |
m2/s2 or [mi_i]2/h2 |
6.00388397 '[mi_i]2/h2' ✅ |
And adding the linear units for knots together works ok:
| Expression | Expected Unit | Actual |
|---|---|---|
define ImplicitConvertLinear: 1 '[kn_i]' + 1 'm/s' |
[kn_i] or m/s |
2.94384449 '[kn_i]' ✅ |
But then when both terms use square units, this no longer works:
| Expression | Expected Unit | Actual |
|---|---|---|
define ImplicitConvertSquare: 1 '[kn_i]2' + 1 'm2/s2' |
[kn_i]2 or m2/s2 |
null ❌ |
And the issue is the implicit conversion logic, because it does work when an explicit conversion is used:
| Expression | Expected Unit | Actual |
|---|---|---|
define ExplicitConvertSquare: (convert 1 '[kn_i]2' to 'm2/s2') + 1 'm2/s2' |
m2/s2 |
1.26465309 'm2/s2' ✅ |
- 主要言語
- JavaScript
- スター
- 86
- フォーク
- 40
- PR マージ指標
- 30日以内にマージされた PR はありません
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
cqframework/cql-execution のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
cqframework/cql-execution#410 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
cqframework/cql-execution#407 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 62/100
cqframework/cql-execution#406 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
cqframework/cql-execution#414 ·
-
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
cqframework/cql-execution#413 ·
cqframework/cql-execution の issue をすべて見る
似ている issue
-
Mend: dependency security vulnerability
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
ManageIQ/manageiq-ui-service#2259 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
electerious/Ackee#411 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
babalae/bettergi-scripts-list#3905 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] "Configure Colota" opens Colota with "Invalid configuration: No configuration data in URL"オープン
難易度 1/5 1〜3時間 初心者へのやさしさ 87/100
dedicatedcode/reitti#1445 ·
メンテナーはふだん 1 日以内に返信