-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Add __len__ to Schedule in Pulse along with related tests. #4394
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
neonipun
requested review from
DanPuzzuoli,
eggerdj,
lcapelluto,
nkanazawa1989 and
taalexander
as code owners
May 5, 2020 07:44
taalexander
requested changes
May 5, 2020
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.
Thank you for your contribution @neonipun! just one small change I suggest.
Done! I committed your suggested change. Let me know if I missed or messed up a step for this PR to be merged! |
Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com>
taalexander
approved these changes
May 5, 2020
faisaldebouni
pushed a commit
to faisaldebouni/qiskit-terra
that referenced
this pull request
Aug 5, 2020
* Add __len__ to Schedule in Pulse along with its related tests (Qiskit#4171) * Update __len__ in Pulse Schedule (Qiskit#4171) * Update function name to test __len__ of Schedule in Pulse (Qiskit#4171) Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com> Co-authored-by: Thomas Alexander <thomasalexander2718@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
mtreinish
added
the
Changelog: New Feature
Include in the "Added" section of the changelog
label
Aug 6, 2020
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
Changelog: New Feature
Include in the "Added" section of the changelog
mod: pulse
Related to the Pulse module
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Issue: #4171
This commit adds a
__len__
function to theSchedule
class in Pulse, allowing users to obtain the number of instructions present in thatSchedule
object withlen()
.Enabling the use of
len()
on aSchedule
object also allows for checking if a schedule is empty. It acts as a replacement for bool() in the following situation -if not Schedule(): print('Empty')
, which will now print 'Empty'.Tests related to the above were written in
test/python/pulse/test_schedule.py
by asserting that an empty schedule isFalse
andlen()
equal to zero. Asserting the equality oflen()
and number of instructions appended to a schedule at each step were also tested.Details and comments
Although
__len__
being based onself.instructions
is a bit inefficient, I was assured that it will be mitigated in a new refactor.