Skip to content

Conversation

AlexanderGroeger
Copy link
Contributor

@AlexanderGroeger AlexanderGroeger commented Sep 16, 2023

Fixes #10839

Summary

This PR addresses this issue where the Pauli operator's delete method does not gracefully handle an empty list parameter.

Details and comments

For the Pauli, PauliList, and PauliTable classes, performing a delete with an empty list argument will return a copy of the calling object.

Side note: I get unrelated errors with tox and tests sometimes, so I'm submitting this as a draft for now.

@qiskit-bot qiskit-bot added the Community PR PRs from contributors that are not 'members' of the Qiskit repo label Sep 16, 2023
@jakelishman
Copy link
Member

The test failure here in CI isn't unrelated: at the moment there's a place in the code where we accidentally call max([]), which is undefined because if there's a sequence of zero elements, there's nothing that can be the maximum. I didn't look deeply, but there's likely a place where we should have short-circuited out of the method before trying to call max.

@AlexanderGroeger
Copy link
Contributor Author

Thank you! It was a simply fix by reordering the checks for edge cases.

I looked at the logs for Run Docs build and am confused where the issue arises from. Not sure how to proceed.

@jakelishman
Copy link
Member

The docs failing wasn't your fault - just a dodgy connection from the VM to crates.io. I've re-run it, because it should just be ephemeral.

@AlexanderGroeger AlexanderGroeger marked this pull request as ready for review September 18, 2023 18:03
@AlexanderGroeger AlexanderGroeger requested review from ikkoham and a team as code owners September 18, 2023 18:03
@qiskit-bot
Copy link
Collaborator

Thank you for opening a new pull request.

Before your PR can be merged it will first need to pass continuous integration tests and be reviewed. Sometimes the review process can be slow, so please be patient.

While you're waiting, please feel free to review other open PRs. While only a subset of people are authorized to approve pull requests for merging, everyone is encouraged to review open pull requests. Doing reviews helps reduce the burden on the core team and helps make the project's code better for everyone.

One or more of the the following people are requested to review this:

  • @Qiskit/terra-core
  • @ikkoham

Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks solid and straightforward to me. I've just put in a comment showing how to add proper cross-references to the release note, but that's it.

Co-authored-by: Jake Lishman <jake@binhbar.com>
Copy link
Member

@jakelishman jakelishman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@jakelishman jakelishman added stable backport potential The bug might be minimal and/or import enough to be port to stable Changelog: Bugfix Include in the "Fixed" section of the changelog mod: quantum info Related to the Quantum Info module (States & Operators) labels Sep 22, 2023
@jakelishman jakelishman added this to the 0.25.2 milestone Sep 22, 2023
@jakelishman jakelishman added this pull request to the merge queue Sep 22, 2023
Merged via the queue into Qiskit:main with commit 6a38279 Sep 23, 2023
mergify bot pushed a commit that referenced this pull request Sep 23, 2023
* handle empty lists in delete methods, added release notes

* fixed ordering of empty list check in pauli delete method

* add proper cross-references to classes

Co-authored-by: Jake Lishman <jake@binhbar.com>

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
(cherry picked from commit 6a38279)
@AlexanderGroeger AlexanderGroeger deleted the support-empty-delete-paulis branch September 23, 2023 01:25
github-merge-queue bot pushed a commit that referenced this pull request Sep 23, 2023
* handle empty lists in delete methods, added release notes

* fixed ordering of empty list check in pauli delete method

* add proper cross-references to classes

Co-authored-by: Jake Lishman <jake@binhbar.com>

---------

Co-authored-by: Jake Lishman <jake@binhbar.com>
(cherry picked from commit 6a38279)

Co-authored-by: AlexanderGroeger <46076580+AlexanderGroeger@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changelog: Bugfix Include in the "Fixed" section of the changelog Community PR PRs from contributors that are not 'members' of the Qiskit repo mod: quantum info Related to the Quantum Info module (States & Operators) stable backport potential The bug might be minimal and/or import enough to be port to stable
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

support Pauli.delete([])
3 participants