`stretch` operands in duration arithmetic raise `TypeError: ... 'float' and 'NoneType'`
メンテナーはふだん 1 日以内に返信
評価
調査の方向性
The float + None error comes from Qasm3ExprEvaluator in src/pyqasm/expressions.py, and stretch declarations are handled in src/pyqasm/visitor.py; unit handling is in DURATION_UNITS in src/pyqasm/maps/expressions.py. Check open pull request #417 first, since it may already cover this. Done means a + s no longer raises a Python TypeError: it either survives symbolically or raises a ValidationError naming the stretch variable and its span, with tests in tests/qasm3/test_timing.py.
索引モデルが issue の本文から書いたものです。
説明
Limitation
Duration and stretch types defines
stretch as a duration that resolves at compile time, and
Operations on durations allows a
stretch to be combined with a duration in arithmetic. This is how the spec expresses
padding that absorbs whatever slack a schedule leaves.
pyqasm declares a stretch with a None value and then applies Python arithmetic to it,
producing an uncaught TypeError.
Example QASM failure
import pyqasm
m = pyqasm.loads('''
OPENQASM 3.0;
stretch s;
duration a = 300ns;
duration b = a + s;
''')
m.validate()
TypeError: unsupported operand type(s) for +: 'float' and 'NoneType'
A bare stretch s; declaration and delay[s] q[0]; both work today, so the gap is confined
to arithmetic involving a stretch operand.
Change Requested
- Duration expressions containing a
stretchoperand must not raise a PythonTypeError. - Preferred: represent a duration as an affine value
(constant_ns, {stretch: coefficient})
so thata + s,2 * s, anda + 2 * sare all representable symbolically and can be
emitted unchanged bydumps(). - Minimum acceptable: raise a
ValidationErrorstating that stretch arithmetic is not yet
supported, naming the stretch variable and its span. The current internal error is the only
unacceptable outcome.
Implementation Details
- Duration/stretch declarations are handled in
src/pyqasm/visitor.pyalongside the other
classical declarations; the numeric evaluation happens inQasm3ExprEvaluator
(src/pyqasm/expressions.py), which is where thefloat + Noneoccurs. - Unit conversion lives in
DURATION_UNITSinsrc/pyqasm/maps/expressions.py; the affine
representation should normalise the constant part to nanoseconds there, consistent with how
plain durations are already handled. - The affine form composes with the existing
box[...]duration validation anddelay[...]
handling, both of which currently expect a plain number — they will need to accept the new
type or explicitly reject a non-constant duration where a concrete one is required. - Full stretch resolution (solving for stretch values against a schedule) is a much larger
piece of work and is explicitly out of scope here. This issue only asks that stretch
operands survive expression evaluation. - Tests:
tests/qasm3/test_timing.py(or the existing delay/box tests) —a + s,2 * s,
a + 2 * s, a stretch insidebox[...], and adumps()round-trip.
- 主要言語
- Python
- スター
- 29
- フォーク
- 33
- 平均マージ
- 2日 4時間
- マージ済み PR(30日)
- 15
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
qBraid/pyqasm のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 63/100
メンテナーはふだん 1 日以内に返信
-
enhancement error-handling program-validation
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
Move the QASM 2 printer and its branch pre-processing out of qasm2.py対応中かも @danielgaskins が 9 日前に担当しました。 オープンenhancement qasm2
難易度 4/5 3〜5日 初心者へのやさしさ 22/100
qBraid/pyqasm#447 · コメント 2 件 ·
メンテナーはふだん 1 日以内に返信
-
[BUG] dumps() emits extern calls without a semicolon, producing unparsable QASM対応中かも @Jah-yee が 18 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 25/100
qBraid/pyqasm#438 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
Parse failures raise ValidationError with an empty message; the ANTLR diagnostic is lost対応中かも @tonycoder-hub が 11 日前に担当しました。 オープンbug
難易度 2/5 1〜3時間 初心者へのやさしさ 22/100
qBraid/pyqasm#436 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
style: article/section 📝 system: cloud.rc ☁️ system: security 🔐
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
uabrc/uabrc.github.io#1262 ·
-
documentation
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
NCAR/miles-credit#526 ·
-
documentation
難易度 1/5 1〜3時間 初心者へのやさしさ 76/100
conda/conda-lock#957 ·
メンテナーはふだん 1 日以内に返信
-
Type: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
aws-samples/sample-per-model-bedrock#464 ·
メンテナーはふだん 1 日以内に返信