-
Notifications
You must be signed in to change notification settings - Fork 603
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
Collect expand_fn
s and stopping criteria into central file
#1734
Conversation
…nnylane into restructure-metric_tensor
…nnylane into restructure-metric_tensor
Co-authored-by: Josh Izaac <josh146@gmail.com>
…nnylane into restructure-metric_tensor
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.
@dwierichs 🎉 The new naming and structure now feels 💯!
All my comments and suggestions are minor, and mainly wrt documentation 🙂
Co-authored-by: Josh Izaac <josh146@gmail.com>
… into collect-expand_fns
… into collect-expand_fns
Hi @josh146 I think everything should be addressed now :)
|
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.
This is such a nice addition @dwierichs 😍
Happy to approve, conditional on my suggestions below. Don't forget to add the tape_expand
functions to the transforms/__init__.py
module docstring, and check that they render correctly in the PR documentation build!
@qml.BooleanFn | ||
def is_measurement(obj): | ||
"""Returns ``True`` if an operator is a ``MeasurementProcess`` instance.""" | ||
return isinstance(obj, qml.measure.MeasurementProcess) |
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.
docstring renders nicely!
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.
Very nice that you caught this one! :)
Co-authored-by: Josh Izaac <josh146@gmail.com>
Context:
tape expansion functions are scattered across PL, this PR collects them, introducing a handy wrapping class that enables logical conjunction of callables.
Description of the Change:
Introduce
StoppingCriterion
, a new wrapper class, as well as a convenience functionget_expand_fn
to create anexpand_fn
from a stopping criterion.Benefits:
Centralized expansion functions and convenient composition of stopping criteria.
Possible Drawbacks:
Likely a bit less performant that explicitly writing out the logical functions locally in the corresponding files.
Related GitHub Issues:
#1732