-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Turn Waveform
into a bare array
#774
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## simplify-pulse-7 #774 +/- ##
====================================================
- Coverage 61.94% 61.68% -0.26%
====================================================
Files 52 51 -1
Lines 5723 5690 -33
====================================================
- Hits 3545 3510 -35
- Misses 2178 2180 +2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
271230c
to
a5b7248
Compare
40fbd69
to
ba476ee
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I did not test (further than CI), but looks good to me. I think we can postpone hardware testing to 0.2 branch after all these are merged because now it's already pointing to other branches.
However, I'm still using the trick explicitly in QM. Are you aware of any other place where the
Waveform
had to be hashable?
Personally, I am not aware. For QM, we need to associate a name (str
) to each waveform in order to register it in the config and assign it to pulses. In principle str(id(waveform))
would even work, but hash
is better because it is the same for equal waveforms, so we don't need to register the same waveform multiple times (eg. during unrolling), while id
is different for every instance (if I am correct). But I believe your current solution is okay (alternatives https://stackoverflow.com/questions/16589791/most-efficient-property-to-hash-for-numpy-array)
Now
Waveform
is only useful as a type hint.There is only one caveat:
Waveform
was hashable,np.ndarray
is not (because mutable). The gap was filled by callingarray.tobytes()
(since the generated bytes are immutable, as a snapshot of an array at a specific time).It's not optimal, since it's still a hash of an actually mutable object, but we just have to be consistent.
However, I'm still using the trick explicitly in QM.
Are you aware of any other place where the
Waveform
had to be hashable?