-
Notifications
You must be signed in to change notification settings - Fork 575
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
[OpRefactor] decomposition
and compute_decomposition
methods in Operator
base class
#2024
Conversation
Hello. You may have forgotten to update the changelog!
|
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.
Thanks @albi3ro, have left some preliminary comments!
pennylane/operation.py
Outdated
if self.num_params == 0: | ||
return self.decomposition(wires=self.wires) | ||
return self.decomposition(*self.parameters, wires=self.wires) | ||
raise NotImplementedError |
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.
Should this return None
like compute_matrix
?
pennylane/operation.py
Outdated
parameters (tuple[float, int, array]) | ||
wires (Iterable[Number, str], Number, str, Wires): Wires that the operator acts on. | ||
hyperparameters (dict): |
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.
parameters and hyperparameters are both missing a description!
pennylane/ops/identity.py
Outdated
@@ -60,6 +60,10 @@ def _heisenberg_rep(p): | |||
def diagonalizing_gates(self): | |||
return [] | |||
|
|||
@staticmethod | |||
def compute_decomposition(data, wires, hyperparameters): |
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.
woah that is a lot of pylint warnings
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.
That was my first pass signature. Updating it to unpacked version now.
for i in range(len(wires) - 1): | ||
qml.CNOT(wires=[wires[i + 1], wires[i]]) | ||
return rec.queue | ||
return ops |
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 much cleaner 🙌
self._hyperparameters = { | ||
"target_wire": self._target_wire, | ||
"work_wires": self._work_wires, | ||
"control_wires" : self._control_wires, | ||
"control_values": self.control_values | ||
} |
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.
It still feels wrong to me that this has to be private. I think this is almost an argument for implementing a very simple setter for self.hyperparameters
, so that you can do
self.hyperparameters = {...}
We could also add some basic validation (check that the input is a dict, etc)
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.
We are setting it privately within the class.
Once we create the dictionary during initialization, we can use self.hyperparameters
instead.
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.
Right, but we shouldn't have to set a private attribute to set up an operation --- all developer facing APIs for creating an operator should be public, documented, and include validation where it makes sense
# pylint: disable=unused-argument | ||
def decomposition(self, *args, **kwargs): | ||
def compute_decomposition(wires, **hyperparams): |
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.
should this be static?
work_wires | ||
control_values | ||
target_wire |
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.
these are missing types and descriptions!
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.
And the return statement...
I was wondering, I thought our convention is to not distinguish args/kwargs in the docstirng?
control_wires = hyperparams['control_wires'] | ||
work_wires = hyperparams['work_wires'] | ||
control_values = hyperparams['control_values'] | ||
target_wire = hyperparams['target_wire'] |
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.
I wonder if there is 'dictionary unpacking' in Python 🤔
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 probably solved by pattern matching in Python 3.10
# pylint: disable=unused-argument | ||
def decomposition(self, wires): | ||
# pylint: disable=unused-argument | ||
def compute_decomposition(parameters, wires, hyperparmeters): |
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.
should this be static as well?
…nylane into op-decomposition
pennylane/operation.py
Outdated
@@ -547,24 +547,18 @@ def hyperparameters(self): | |||
def decomposition(*params, wires): |
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.
It's getting late, but should this not be an instance method that only takes self
? In fact, I wonder how you can call self
below? (Is maybe my github view corrupted?)
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.
I think that was a problem with github merging things. I've cleaned that up locally
qml.Toffoli(wires=wires[1:]), | ||
qml.CNOT(wires=[wires[1], wires[2]]), | ||
qml.Toffoli(wires=[wires[0], wires[2], wires[3]]), | ||
] | ||
) |
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.
It seems a good choice, but is there any deeper reason for a tuple over a list here?
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.
Prevents modification of it later, so it's a little safer if we don't intend for the object to be modified.
If the iterable isn't going to be modified down the line, tuples are slightly more efficient, because they don't need to support the overhead of resizing.
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.
Ah thanks!
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 may be a breaking change all by itself 😆 I worry that this might cause issues for developers in that all Sequence[Operations]
in the codebase (I believe) are currently lists?
def decomposition(self, *args, **kwargs): | ||
@staticmethod | ||
def compute_decomposition(wires=None, control_wires=None, work_wires=None, control_values=None, | ||
target_wire=None, **kwargs): |
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.
Nice, I like this with the explicit signature!
return [] | ||
@staticmethod | ||
def compute_decomposition(wires, **kwargs): | ||
return tuple() |
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.
Same question as above (and reminds me, you should return a tuple for identity decomposition too?)
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.
@albi3ro I think I am still quite wary about adding this change in this PR, since it is so different to our other methods (e.g., diagonalizing_gates
, post-refactor, still returns a list).
Should we revert to a list here, and change everything to a tuple
in a separate PR, if that is the convention we want to set?
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.
Although I would argue this change is probably not high priority, and high effort to low impact.
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.
@josh146 I'm willing to revert this change for this PR, but I do think we should start using more tuples if we aren't needing to resize and edit them in most cases. Tuples are more efficient in both memory and time.
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.
In this case, I would probably prefer the change is reverted, to avoid introducing an inconsistency with the other methods that have already been refactored
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.
Agree both to using tuples in future, but not using them here to keep things simple!
def compute_decomposition(theta, wires): | ||
ops = [qml.CNOT(wires=(w0, w1)) for w0, w1 in zip(wires[~0:0:-1], wires[~1::-1])] | ||
ops.append(RZ(theta, wires=wires[0])) | ||
ops += [qml.CNOT(wires=(w0, w1)) for w0, w1 in zip(wires[1:], wires[:~0])] |
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.
💯
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.
nice!
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.
re-reading this though, I find it a bit harder to read/parse compared to the left 🤔
How come you use ~0
instead of -1, and ~1
instead of -2?
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.
I learned about using ~
recently and personally prefer it. It's more symmetric. a[~0]
is just a[0]
read from the end. But again, this can just use -1
and -2
since that's what is more common.
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 cool! I am so stunned that one does never have to overwrite decomposition
, since the default call always works...
Just the few minor comments. Thanks very much for the PR!
pennylane/operation.py
Outdated
@@ -464,7 +464,6 @@ def __init__(self, *params, wires=None, do_queue=True, id=None): | |||
self._name = self.__class__.__name__ #: str: name of the operator | |||
self._id = id | |||
self.queue_idx = None #: int, None: index of the Operator in the circuit queue, or None if not in a queue | |||
self._hyperparameters = {} |
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.
Now that _hyperparameters
is created the first time hyperparameters
is called, we don't need to initialize here.
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.
True, this was bugging me too!
Codecov Report
@@ Coverage Diff @@
## op-refactor #2024 +/- ##
===============================================
- Coverage 99.24% 99.24% -0.01%
===============================================
Files 225 225
Lines 17243 17240 -3
===============================================
- Hits 17112 17109 -3
Misses 131 131
Continue to review full report at Codecov.
|
* The static `compute_decomposition` method defines the decomposition | ||
of an operator into a product of simpler operators, and the instance method | ||
`decomposition()` computes this for a given instance. When a custom | ||
decomposition does not exist, the code now raises a custom `NoDecompositionError` |
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.
I still like DecompositonUndefined
more, because it states more what happened? Happy to be overruled though!
class NoDecompositionError(Exception): | ||
"""Raised when an Operator does not have a decomposition defined.""" | ||
|
||
pass |
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.
Is this how you define exceptions? So simple ❤️
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.
We should have been doing this from the beginning!
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.
(we started off well with QuantumFunctionError
and DeviceError
, but at some point we all just started using ValueError
😆 )
``compute_decomposition`` is a static method and can provide the decomposition of an | ||
operator without a specific instance. | ||
|
||
See also :meth:`~.operation.Operator.decomposition`. |
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.
Nice!
See also :meth:`~.Identity.decomposition`. | ||
|
||
Args: | ||
wires (Any, Wires): A single wire that the operator acts on. |
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.
There is still the strange type?
…nylane into op-decomposition
* remove string_for_inverse * fix accidental push * [OpRefractor] remove `string_for_inverse` (#2021) * remove string_for_inverse * remove string_for_inverse for device * black * Update doc/releases/changelog-dev.md * [OpRefactor] add temporary hyperparameter attribute (#2017) * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Move diagonalizing_gates method to Operator (#1985) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * polish * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * Update the `Operation.generator` property (#2030) * more * more * more * more * fixes * fixes * all tests passing * fix * more * Apply suggestions from code review * add to changelog * [OpRefactor] Add static compute_diagonalizing_gates method (#1993) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * add compute_diag_gates method * backup * add test and attribute * black * polish * polish signatures * black * fix docstring * fix signature * polish * make wires an arg * fix coverage * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * change signatures * improve docstring * small fix * Apply suggestions from code review * better docstrings * add examples everywhere * more docstring polish * add docstring for identity * hermitian better example * black * suggestions code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Fix dev branch after merging master (#2047) * use get_generator func * add a lot of pylints * fix failing test * move pylints * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Upgrade matrix methods (#1996) * change matrix methods * clean up basic methods * changed matrix to matrix() * black * fix test * fix Hadamard gate * changelog * fix some more small issues * some more fixes * make (almost) all _matrix methods static * backup * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * blackup * wrote up new usage * correct changelog * add some tests for expand-matrix * black * fix some tests * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * replace expand logic in get_unitary * fix multirz inverse * fix minor pauli_eigs error * fix qft error * resolve conflict * fix all test but the BIG ISSUE * change signature, part 1 * finish dosctrings * black * all minor problems cleared again * polish * more polish and black * fix docstrings, fix ControlledQubitUNitary * changelog polish * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * implement suggestions josh * black * redesigned ControlledQubitUnitary * backup * revert to NotImplementedErrors * typo * black * delete superfluous matrix methods * delete superfluous arg * fix tests * black * hopefully fix failing test * fix codecoverage * fix last coverage issue * backup * add hyperparameters and pylints * black * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Add terms and compute_terms (#2036) * black and changelog * fix typo * fixed fermionic terms * black * backup * fix * simpler implementation * minor updates * fix some tests * fix tests * polishing * add test * fix docstring formatting * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions josh * Update pennylane/ops/qubit/hamiltonian.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * add pylints (#2052) * [OpRefactor] Rename wires as wire_order in heisenberg ops (#2051) * rename * update changelog * [OpRefactor] Update eigenvalue representations (#2048) * fix tests * black * increase codecov * black * josh suggestions * move default to eigvals() and make everything static * apply suggestions josh * Apply suggestions from code review * [OpRefactor] Add sparse_matrix and compute_sparse_matrix methods (#2050) * basic changes * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * josh suggestions Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Update kraus representations (#2055) * rename * dicstrings * fix docstring * minor fix to test * Update doc/releases/changelog-dev.md * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] `decomposition` and `compute_decomposition` methods in `Operator` base class (#2024) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * remove unused import * black, fix multicontrolledx * fix tests, black * fixing more tests * hopefully the last breaking tests * enhance code coverage * fix some problems from merging * pin sphinx Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * [OpRefactor] Update the generator to raise an exception if not defined (#2061) * Update the generator to raise an exception if not defined * fixes * fixes * fixes * fix * [OpRefactor] Add custom errors when representations are undefined (#2064) * add errors and tests, use errors * small fix * change one more None to Error * delete obsolete line * fix tests * black * update changelog * [OpRefactor] fix codefactor (#2067) * fix codefactor * restore lines * delete again * `Tensor.matrix`: Warnings for partial wires overlaps and unsorted wire repetition (#2013) * implement sorting before grouping and check partial wires overlaps. * changelog * black * tests * tiny * reduce PR to warnings * lint * old python sum * black * code review * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * restructure warning logic * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * changes applied * Apply suggestions from code review * black * one more test fixed * [OpRefactor] Update dev guide to explain the new operator abstraction (#2066) * add previous changes * add graphic * rewrite architecture overview * rewrite op guide * add differentiation * fomatting * polish * polish * polish * black * formatting * fix sphinx? * some dashes * josh comments * major polish * minor details * minor improvement * more polishing * fix link * fix qasm precision * changing qasm tests back * Update doc/development/adding_operators.rst Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions Josh 1 * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * minor improvements * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update doc/development/guide/architecture.rst * Update doc/development/adding_operators.rst * change images, fix link Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update Operation call signatures to match doc string (#1976) * Updated parameteric_ops to match docs call signature * finished updating all of the ops * Added wires arg to SparseHamiltonian * updating some of cv ops * updating call signature for more ops * updated callsigns * updated changelog * disable too many args error for code factor * replaced lam with delta * Removed Sphinx Override * fixed bug with TensorN observable * Update doc/releases/changelog-dev.md Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> * [OpRefactor] Use decomposition in templates (#2053) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * embeddings started to refactor * embeddings done * backup * layers done * statepreps done * backup * done subroutines * backup * fix tests except grover, timeevol, commuting * black * fix last three tests * black * black * fix tests * mottonnen fixed * update changelog * fixes, including sphinx * backup * Fix tape expand tests (#2065) * fixes * more * more * more * more * more * more * black * delete faulty import * improve codecoverage * improve coverage by one line * port one bug fix from other branch * backup * suggestions Josh 1 * redo changes in reset files * rewrite op_list extension * black * fix tests * change ttn * make pylint happy * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> * black * black * revert * adapt isingzz eval function * backup * fix all tests except from the batch one * upgraded version of black and blackened again * [OpRefactor] Final clean-up of operator subclasses (#2131) * dummy change to open pr * clean docstrings * backup * port some changes from operation.py PR * clean docstrings of classes * black * minor sphinx fix * make docstrings similar * more cleaning, and revert BasisStatePrep for test passing * black * upgraded version of black and blackened again * fix * fix * fix bug * merge master * linting * remove print label * [WIP] Renaming (#2189) * more * more * more * more * more * more * more * rename eigvals to get_eigvals() * black * update eigvals in tests * tensor eigvals * fix * more * Update pennylane/operation.py Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * update deprecation warning * more * add deprecation tests Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * coverage Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: David Wierichs <davidwierichs@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com>
* remove string_for_inverse * fix accidental push * [OpRefractor] remove `string_for_inverse` (#2021) * remove string_for_inverse * remove string_for_inverse for device * black * Update doc/releases/changelog-dev.md * [OpRefactor] add temporary hyperparameter attribute (#2017) * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Move diagonalizing_gates method to Operator (#1985) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * polish * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * Update the `Operation.generator` property (#2030) * more * more * more * more * fixes * fixes * all tests passing * fix * more * Apply suggestions from code review * add to changelog * [OpRefactor] Add static compute_diagonalizing_gates method (#1993) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * add compute_diag_gates method * backup * add test and attribute * black * polish * polish signatures * black * fix docstring * fix signature * polish * make wires an arg * fix coverage * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * change signatures * improve docstring * small fix * Apply suggestions from code review * better docstrings * add examples everywhere * more docstring polish * add docstring for identity * hermitian better example * black * suggestions code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Fix dev branch after merging master (#2047) * use get_generator func * add a lot of pylints * fix failing test * move pylints * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Upgrade matrix methods (#1996) * change matrix methods * clean up basic methods * changed matrix to matrix() * black * fix test * fix Hadamard gate * changelog * fix some more small issues * some more fixes * make (almost) all _matrix methods static * backup * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * blackup * wrote up new usage * correct changelog * add some tests for expand-matrix * black * fix some tests * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * replace expand logic in get_unitary * fix multirz inverse * fix minor pauli_eigs error * fix qft error * resolve conflict * fix all test but the BIG ISSUE * change signature, part 1 * finish dosctrings * black * all minor problems cleared again * polish * more polish and black * fix docstrings, fix ControlledQubitUNitary * changelog polish * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * implement suggestions josh * black * redesigned ControlledQubitUnitary * backup * revert to NotImplementedErrors * typo * black * delete superfluous matrix methods * delete superfluous arg * fix tests * black * hopefully fix failing test * fix codecoverage * fix last coverage issue * backup * add hyperparameters and pylints * black * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Add terms and compute_terms (#2036) * black and changelog * fix typo * fixed fermionic terms * black * backup * fix * simpler implementation * minor updates * fix some tests * fix tests * polishing * add test * fix docstring formatting * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions josh * Update pennylane/ops/qubit/hamiltonian.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * add pylints (#2052) * [OpRefactor] Rename wires as wire_order in heisenberg ops (#2051) * rename * update changelog * [OpRefactor] Update eigenvalue representations (#2048) * fix tests * black * increase codecov * black * josh suggestions * move default to eigvals() and make everything static * apply suggestions josh * Apply suggestions from code review * [OpRefactor] Add sparse_matrix and compute_sparse_matrix methods (#2050) * basic changes * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * josh suggestions Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Update kraus representations (#2055) * rename * dicstrings * fix docstring * minor fix to test * Update doc/releases/changelog-dev.md * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] `decomposition` and `compute_decomposition` methods in `Operator` base class (#2024) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * remove unused import * black, fix multicontrolledx * fix tests, black * fixing more tests * hopefully the last breaking tests * enhance code coverage * fix some problems from merging * pin sphinx Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * [OpRefactor] Update the generator to raise an exception if not defined (#2061) * Update the generator to raise an exception if not defined * fixes * fixes * fixes * fix * [OpRefactor] Add custom errors when representations are undefined (#2064) * add errors and tests, use errors * small fix * change one more None to Error * delete obsolete line * fix tests * black * update changelog * [OpRefactor] fix codefactor (#2067) * fix codefactor * restore lines * delete again * `Tensor.matrix`: Warnings for partial wires overlaps and unsorted wire repetition (#2013) * implement sorting before grouping and check partial wires overlaps. * changelog * black * tests * tiny * reduce PR to warnings * lint * old python sum * black * code review * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * restructure warning logic * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * changes applied * Apply suggestions from code review * black * one more test fixed * [OpRefactor] Update dev guide to explain the new operator abstraction (#2066) * add previous changes * add graphic * rewrite architecture overview * rewrite op guide * add differentiation * fomatting * polish * polish * polish * black * formatting * fix sphinx? * some dashes * josh comments * major polish * minor details * minor improvement * more polishing * fix link * fix qasm precision * changing qasm tests back * Update doc/development/adding_operators.rst Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions Josh 1 * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * minor improvements * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update doc/development/guide/architecture.rst * Update doc/development/adding_operators.rst * change images, fix link Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update Operation call signatures to match doc string (#1976) * Updated parameteric_ops to match docs call signature * finished updating all of the ops * Added wires arg to SparseHamiltonian * updating some of cv ops * updating call signature for more ops * updated callsigns * updated changelog * disable too many args error for code factor * replaced lam with delta * Removed Sphinx Override * fixed bug with TensorN observable * Update doc/releases/changelog-dev.md Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> * [OpRefactor] Use decomposition in templates (#2053) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * embeddings started to refactor * embeddings done * backup * layers done * statepreps done * backup * done subroutines * backup * fix tests except grover, timeevol, commuting * black * fix last three tests * black * black * fix tests * mottonnen fixed * update changelog * fixes, including sphinx * backup * Fix tape expand tests (#2065) * fixes * more * more * more * more * more * more * black * delete faulty import * improve codecoverage * improve coverage by one line * port one bug fix from other branch * backup * suggestions Josh 1 * redo changes in reset files * rewrite op_list extension * black * fix tests * change ttn * make pylint happy * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> * black * black * revert * adapt isingzz eval function * backup * fix all tests except from the batch one * upgraded version of black and blackened again * [OpRefactor] Final clean-up of operator subclasses (#2131) * dummy change to open pr * clean docstrings * backup * port some changes from operation.py PR * clean docstrings of classes * black * minor sphinx fix * make docstrings similar * more cleaning, and revert BasisStatePrep for test passing * black * upgraded version of black and blackened again * first step * reduce step * undo has_gen * tests * changelog * restore grad_recipe * black * fix orbitalrotation gradient * docstring * lint * add gradient bug fix for OrbitalRotaiton to changelog * fix * tests for parameter frequencies * test coverage * copy JacobianTape methods to parameter_shift.py * fix * Revert "copy JacobianTape methods to parameter_shift.py" This reverts commit 3be9806. * use parameter_frequencies for shift rule. adapt tests. add parameter_frequencies to operation.grad_method * black * changelog * whitespace * debugging * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * add eight-term rule to OrbitalRotation * formatting of frequencies * orbital * doc * make frequencies a property * test * adapt tests to frequencies being property * adapt to parameter_frequencies as property * adapt more tests * more * more * simplify util functions a bit * fix bug * merge master * linting * remove print label * [WIP] Renaming (#2189) * more * more * more * more * more * more * more * rename eigvals to get_eigvals() * black * update eigvals in tests * tensor eigvals * fix * more * Update pennylane/operation.py Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * update deprecation warning * more * add deprecation tests Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * test coverage * lint * lint abstractmethod * coverage * tests for default grad_method * remove old prints * test coverage * black * undo move of JacobianTape methods * pointless statement is not pointless * black * some linting * print reintroduce * wrong local pylint * more fiddling with pylint * docstring shifts * test_draw * test_draw_1 * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * drawing tests * make _process_shifts public * rename no_duplicates to check_duplicates * remove unnecessary lint disable * black * merge master Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com>
* remove string_for_inverse * fix accidental push * [OpRefractor] remove `string_for_inverse` (#2021) * remove string_for_inverse * remove string_for_inverse for device * black * Update doc/releases/changelog-dev.md * [OpRefactor] add temporary hyperparameter attribute (#2017) * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Move diagonalizing_gates method to Operator (#1985) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * polish * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * Update the `Operation.generator` property (#2030) * more * more * more * more * fixes * fixes * all tests passing * fix * more * Apply suggestions from code review * add to changelog * [OpRefactor] Add static compute_diagonalizing_gates method (#1993) * move method and update docstrings in evals * black * revert to NotImplementedError * fix queuing issue * add compute_diag_gates method * backup * add test and attribute * black * polish * polish signatures * black * fix docstring * fix signature * polish * make wires an arg * fix coverage * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * change signatures * improve docstring * small fix * Apply suggestions from code review * better docstrings * add examples everywhere * more docstring polish * add docstring for identity * hermitian better example * black * suggestions code review Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Fix dev branch after merging master (#2047) * use get_generator func * add a lot of pylints * fix failing test * move pylints * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Upgrade matrix methods (#1996) * change matrix methods * clean up basic methods * changed matrix to matrix() * black * fix test * fix Hadamard gate * changelog * fix some more small issues * some more fixes * make (almost) all _matrix methods static * backup * add test and attribute * black * fix coverage * polish * changelog * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * blackup * wrote up new usage * correct changelog * add some tests for expand-matrix * black * fix some tests * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * replace expand logic in get_unitary * fix multirz inverse * fix minor pauli_eigs error * fix qft error * resolve conflict * fix all test but the BIG ISSUE * change signature, part 1 * finish dosctrings * black * all minor problems cleared again * polish * more polish and black * fix docstrings, fix ControlledQubitUNitary * changelog polish * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * implement suggestions josh * black * redesigned ControlledQubitUnitary * backup * revert to NotImplementedErrors * typo * black * delete superfluous matrix methods * delete superfluous arg * fix tests * black * hopefully fix failing test * fix codecoverage * fix last coverage issue * backup * add hyperparameters and pylints * black * Update pennylane/operation.py Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> * [OpRefactor] Add terms and compute_terms (#2036) * black and changelog * fix typo * fixed fermionic terms * black * backup * fix * simpler implementation * minor updates * fix some tests * fix tests * polishing * add test * fix docstring formatting * Update pennylane/operation.py Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions josh * Update pennylane/ops/qubit/hamiltonian.py Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * add pylints (#2052) * [OpRefactor] Rename wires as wire_order in heisenberg ops (#2051) * rename * update changelog * [OpRefactor] Update eigenvalue representations (#2048) * fix tests * black * increase codecov * black * josh suggestions * move default to eigvals() and make everything static * apply suggestions josh * Apply suggestions from code review * [OpRefactor] Add sparse_matrix and compute_sparse_matrix methods (#2050) * basic changes * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * josh suggestions Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] Update kraus representations (#2055) * rename * dicstrings * fix docstring * minor fix to test * Update doc/releases/changelog-dev.md * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * black Co-authored-by: Josh Izaac <josh146@gmail.com> * [OpRefactor] `decomposition` and `compute_decomposition` methods in `Operator` base class (#2024) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * remove unused import * black, fix multicontrolledx * fix tests, black * fixing more tests * hopefully the last breaking tests * enhance code coverage * fix some problems from merging * pin sphinx Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * [OpRefactor] Update the generator to raise an exception if not defined (#2061) * Update the generator to raise an exception if not defined * fixes * fixes * fixes * fix * [OpRefactor] Add custom errors when representations are undefined (#2064) * add errors and tests, use errors * small fix * change one more None to Error * delete obsolete line * fix tests * black * update changelog * [OpRefactor] fix codefactor (#2067) * fix codefactor * restore lines * delete again * `Tensor.matrix`: Warnings for partial wires overlaps and unsorted wire repetition (#2013) * implement sorting before grouping and check partial wires overlaps. * changelog * black * tests * tiny * reduce PR to warnings * lint * old python sum * black * code review * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * restructure warning logic * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Josh Izaac <josh146@gmail.com> * changes applied * Apply suggestions from code review * black * one more test fixed * [OpRefactor] Update dev guide to explain the new operator abstraction (#2066) * add previous changes * add graphic * rewrite architecture overview * rewrite op guide * add differentiation * fomatting * polish * polish * polish * black * formatting * fix sphinx? * some dashes * josh comments * major polish * minor details * minor improvement * more polishing * fix link * fix qasm precision * changing qasm tests back * Update doc/development/adding_operators.rst Co-authored-by: Josh Izaac <josh146@gmail.com> * suggestions Josh 1 * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * backup * minor improvements * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update doc/development/guide/architecture.rst * Update doc/development/adding_operators.rst * change images, fix link Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> * Update Operation call signatures to match doc string (#1976) * Updated parameteric_ops to match docs call signature * finished updating all of the ops * Added wires arg to SparseHamiltonian * updating some of cv ops * updating call signature for more ops * updated callsigns * updated changelog * disable too many args error for code factor * replaced lam with delta * Removed Sphinx Override * fixed bug with TensorN observable * Update doc/releases/changelog-dev.md Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com> Co-authored-by: David Ittah <dime10@users.noreply.github.com> * [OpRefactor] Use decomposition in templates (#2053) * decomposition and compute decomposition methods * adding some more ops * more consistent across qubit ops, return as tuple * start adding templates * move hyperparameters defintions * update templates in a later PR * tests * fixing tests * more test fixes * final test fix! * docstrings, interface device tests * black, tests for coverage * changelog and docstrings * docstrings * more child class docstrings * Update doc/releases/changelog-dev.md Co-authored-by: Josh Izaac <josh146@gmail.com> * nodecompositionerror, test new docstrings * docstring fixes * merge conflict * docstring fixes and minor updates * barrier doc change * test fixing, parametric op docstrings * final docstrings, black * qft docstring * black, fix test * embeddings started to refactor * embeddings done * backup * layers done * statepreps done * backup * done subroutines * backup * fix tests except grover, timeevol, commuting * black * fix last three tests * black * black * fix tests * mottonnen fixed * update changelog * fixes, including sphinx * backup * Fix tape expand tests (#2065) * fixes * more * more * more * more * more * more * black * delete faulty import * improve codecoverage * improve coverage by one line * port one bug fix from other branch * backup * suggestions Josh 1 * redo changes in reset files * rewrite op_list extension * black * fix tests * change ttn * make pylint happy * black * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> * black * black * revert * adapt isingzz eval function * backup * fix all tests except from the batch one * upgraded version of black and blackened again * [OpRefactor] Final clean-up of operator subclasses (#2131) * dummy change to open pr * clean docstrings * backup * port some changes from operation.py PR * clean docstrings of classes * black * minor sphinx fix * make docstrings similar * more cleaning, and revert BasisStatePrep for test passing * black * upgraded version of black and blackened again * first step * reduce step * undo has_gen * tests * changelog * restore grad_recipe * black * fix orbitalrotation gradient * docstring * lint * add gradient bug fix for OrbitalRotaiton to changelog * fix * tests for parameter frequencies * test coverage * copy JacobianTape methods to parameter_shift.py * fix * Revert "copy JacobianTape methods to parameter_shift.py" This reverts commit 3be9806. * use parameter_frequencies for shift rule. adapt tests. add parameter_frequencies to operation.grad_method * black * changelog * whitespace * debugging * Apply suggestions from code review Co-authored-by: Josh Izaac <josh146@gmail.com> * add eight-term rule to OrbitalRotation * formatting of frequencies * orbital * doc * make frequencies a property * test * adapt tests to frequencies being property * adapt to parameter_frequencies as property * adapt more tests * more * more * simplify util functions a bit * fix bug * merge master * linting * remove print label * [WIP] Renaming (#2189) * more * more * more * more * more * more * more * rename eigvals to get_eigvals() * black * update eigvals in tests * tensor eigvals * fix * more * Update pennylane/operation.py Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * update deprecation warning * more * add deprecation tests Co-authored-by: Maria Schuld <mariaschuld@gmail.com> * test coverage * lint * lint abstractmethod * coverage * tests for default grad_method * remove old prints * test coverage * black * undo move of JacobianTape methods * pointless statement is not pointless * black * some linting * print reintroduce * wrong local pylint * more fiddling with pylint * docstring shifts * move methods away from JacobianTape to gradients module * black * also use moved methods for finite diff * remove old print * make methods public Co-authored-by: albi3ro <chrissie.c.l@gmail.com> Co-authored-by: Christina Lee <christina@xanadu.ai> Co-authored-by: Josh Izaac <josh146@gmail.com> Co-authored-by: Maria Schuld <mariaschuld@gmail.com> Co-authored-by: Jay Soni <jbsoni@uwaterloo.ca> Co-authored-by: David Ittah <dime10@users.noreply.github.com> Co-authored-by: DSGuala <67476785+DSGuala@users.noreply.github.com> Co-authored-by: antalszava <antalszava@gmail.com>
Currently, PennyLane Operators have:
decompose
instance method that takes no parametersdecomposition
static method that takes parameters and wires.After this change, Operators will have:
decomposition
instance method that takes no parameterscompute_decomposition
static method that takes parameters, wires, and hyperparameters.Parameters and hyperparameters are accepted unpacked via
*
and**
. This way inheriting methods can redefine the signature with the parameters and hyperparameters relevant to that operation.Most templates define an
expand
method instead of acompute_decomposition
method at this point in time. This leads to bugs, as many of the customexpand
methods do not take into account inversion. In a future PR, we should move all expand method functionality into thecompute_decomposition
method. This is not done in this PR for the sake of it's length and commplexity.