Skip to content
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

Return fast from transpile with empty input #7288

Merged
merged 2 commits into from
Nov 18, 2021

Conversation

jakelishman
Copy link
Member

Summary

Previously transpile([]) raised a warning. Now we just return quickly without further tests, similarly to how we return early if we're asked to transpile a list of Schedules.

Details and comments

Fix #7287.

@jakelishman jakelishman requested a review from a team as a code owner November 18, 2021 11:24
@jakelishman jakelishman added the Changelog: Bugfix Include in the "Fixed" section of the changelog label Nov 18, 2021
@coveralls
Copy link

coveralls commented Nov 18, 2021

Pull Request Test Coverage Report for Build 1478066876

  • 2 of 2 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.0006%) to 82.547%

Totals Coverage Status
Change from base Build 1478065403: 0.0006%
Covered Lines: 49856
Relevant Lines: 60397

💛 - Coveralls

Copy link
Member

@mtreinish mtreinish left a comment

Choose a reason for hiding this comment

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

Overall LGTM, just one quick question inline about potential side effects.

@@ -240,6 +240,9 @@ def callback_func(**kwargs):
arg_circuits_list = isinstance(circuits, list)
circuits = circuits if arg_circuits_list else [circuits]

if not circuits:
Copy link
Member

Choose a reason for hiding this comment

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

Are you concerned at all about the side effects of transpile(0), transpile(False)ortranspile(None)` here? I only ask because if a user did any of those I'd expect an error.

Copy link
Member Author

@jakelishman jakelishman Nov 18, 2021

Choose a reason for hiding this comment

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

Right before these lines, circuits is promoted to a 1-element list if it isn't one already, so in those cases, it'd all be promoted to circuits = [0], circuits = [False], etc. I didn't check to see if super invalid output fails somewhere else, but the boolean coercion shouldn't cause any more problems here.

Copy link
Member

Choose a reason for hiding this comment

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

Ok cool I see that now on L241. Heh I should have looked at more than just strict diff to see the surrounding context.

@mergify mergify bot merged commit 1dfa3c3 into Qiskit:main Nov 18, 2021
@jakelishman jakelishman deleted the fix/transpile-empty-list branch November 19, 2021 12:34
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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

An unrelated warning when transpiling an empty set of circuits
3 participants