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

Add support for DEFGATE ... AS PAULI-SUM #1125

Merged
merged 14 commits into from
Dec 18, 2019
Merged

Add support for DEFGATE ... AS PAULI-SUM #1125

merged 14 commits into from
Dec 18, 2019

Conversation

ecpeterson
Copy link
Contributor

@ecpeterson ecpeterson commented Dec 16, 2019

Description

Adds support for DEFGATE ... AS PAULI-SUM, which allows gate definition via an exponentiated Hamiltonian.

cf. quil-lang/quil#38 , quil-lang/quilc#498

Todo

  • Check that the type relaxation in paulis.py is not too damaging.
  • Check whether the gate is expected to be 'instantiated' in some way by pyQVM. (Compare against the behavior for DEFGATE ... AS PERMUTATION.)

Checklist

  • The above description motivates these changes.
  • There is a unit test that covers these changes.
  • All new and existing tests pass locally and on Semaphore.
  • Parameters have type hints with PEP 484 syntax.
  • Functions and classes have useful sphinx-style docstrings.
  • (New Feature) The docs have been updated accordingly.
  • The changelog is updated,
    including author and PR number (@username, gh-xxx).

@ecpeterson ecpeterson requested a review from a team as a code owner December 16, 2019 20:11
@ecpeterson ecpeterson mentioned this pull request Dec 16, 2019
3 tasks
Copy link
Contributor

@appleby appleby left a comment

Choose a reason for hiding this comment

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

some comments for your consideration. no blockers, happy to merge.

pyquil/_parser/Quil.g4 Outdated Show resolved Hide resolved
pyquil/quilbase.py Outdated Show resolved Hide resolved
pyquil/paulis.py Outdated Show resolved Hide resolved
pyquil/quilbase.py Outdated Show resolved Hide resolved
Copy link
Contributor

@appleby appleby left a comment

Choose a reason for hiding this comment

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

if TYPE_CHECKING:
    import crazy_pills_amiright

Copy link
Contributor

@karalekas karalekas left a comment

Choose a reason for hiding this comment

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

will need to review again but just very small stuff so far

pyquil/quilatom.py Outdated Show resolved Hide resolved
Comment on lines +31 to +32
if TYPE_CHECKING:
from pyquil.paulis import PauliSum
Copy link
Contributor

Choose a reason for hiding this comment

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

what does this do?

Copy link
Contributor

Choose a reason for hiding this comment

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

magic. see previous comment here and/or mypy docs here.

tl;dr it's an escape hatch provided by mypy to allow you to import a module when you need the types only for type checking purposes, but importing the module at runtime would result in an import cycle.

pyquil/quilbase.py Outdated Show resolved Hide resolved
@karalekas karalekas changed the title add support for DEFGATE ... AS PAULI-SUM Add support for DEFGATE ... AS PAULI-SUM Dec 18, 2019
@karalekas karalekas added the enhancement ✨ A request for a new feature. label Dec 18, 2019
@karalekas karalekas added this to the v2.15 milestone Dec 18, 2019
@karalekas karalekas merged commit da87f82 into master Dec 18, 2019
@karalekas karalekas deleted the defexpi branch December 18, 2019 20:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ A request for a new feature.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants