fix: dt duration unit incorrectly mapped to ns (#301)#317
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughThis PR fixes a bug where the backend-dependent Changesdt Duration Unit Preservation
🎯 2 (Simple) | ⏱️ ~10 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/pyqasm/visitor.py`:
- Line 2918: The overflow error message for box[...dt] is using a hardcoded 'ns'
instead of the resolved unit; update the code that constructs the box overflow
error to use the resolved unit returned by
self._resolve_duration_unit(_box_time_var) (the same value passed as
unit=self._resolve_duration_unit(_box_time_var)), so the error text reports the
preserved AST unit rather than always showing "ns".
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 986647fc-5e9b-4fbc-81ce-323067760282
📒 Files selected for processing (4)
CHANGELOG.mdsrc/pyqasm/visitor.pytests/qasm3/test_box.pytests/qasm3/test_delay.py
ryanhill1
left a comment
There was a problem hiding this comment.
LGTM, will wait for approval from @TheGupta2012 before merging
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
Thanks @ashmitjsg , changes look good! |
Summary
Fixes #301. The backend-dependent
dtduration unit was being relabeled asnsduring unrolling of
delayandboxstatements when nodevice_cycle_timeis set.Since
dtcan't be converted to SI units without a sample rate, it's now preserved.Root cause
In
_visit_delay_statement/_visit_box_statement, the output unit was chosensolely from whether
device_cycle_timewas set, ignoring the source unit. SI unitswere unaffected (the evaluator converts them to ns first); only
dtwas mislabeled.Changes
_resolve_duration_unithelper that preservesdtwhen the source literalwas
dt(or a device cycle time is set), elsens.dtpreservation intest_delay.pyandtest_box.py.Summary by CodeRabbit
Release Notes
Bug Fixes
dt(device time) unit is now correctly maintained when unrolling statements without a device cycle time.Tests