fix: dt duration unit incorrectly mapped to ns (#301)#317
Conversation
|
Warning Review limit reached
More reviews will be available in 47 minutes and 34 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
WalkthroughThis 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
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