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

[OpRefactor] decomposition and compute_decomposition methods in Operator base class #2024

Merged
merged 48 commits into from
Dec 23, 2021

Conversation

albi3ro
Copy link
Contributor

@albi3ro albi3ro commented Dec 14, 2021

Currently, PennyLane Operators have:

  • The decompose instance method that takes no parameters
  • The decomposition static method that takes parameters and wires.

After this change, Operators will have:

  • The decomposition instance method that takes no parameters
  • The compute_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 a compute_decomposition method at this point in time. This leads to bugs, as many of the custom expand methods do not take into account inversion. In a future PR, we should move all expand method functionality into the compute_decomposition method. This is not done in this PR for the sake of it's length and commplexity.

@github-actions
Copy link
Contributor

Hello. You may have forgotten to update the changelog!
Please edit doc/releases/changelog-dev.md with:

  • A one-to-two sentence description of the change. You may include a small working example for new features.
  • A link back to this PR.
  • Your name (or GitHub username) in the contributors section.

Copy link
Member

@josh146 josh146 left a 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!

if self.num_params == 0:
return self.decomposition(wires=self.wires)
return self.decomposition(*self.parameters, wires=self.wires)
raise NotImplementedError
Copy link
Member

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 Show resolved Hide resolved
Comment on lines 560 to 562
parameters (tuple[float, int, array])
wires (Iterable[Number, str], Number, str, Wires): Wires that the operator acts on.
hyperparameters (dict):
Copy link
Member

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!

@@ -60,6 +60,10 @@ def _heisenberg_rep(p):
def diagonalizing_gates(self):
return []

@staticmethod
def compute_decomposition(data, wires, hyperparameters):
Copy link
Member

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

Copy link
Contributor Author

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
Copy link
Member

Choose a reason for hiding this comment

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

this is much cleaner 🙌

Comment on lines 999 to 1004
self._hyperparameters = {
"target_wire": self._target_wire,
"work_wires": self._work_wires,
"control_wires" : self._control_wires,
"control_values": self.control_values
}
Copy link
Member

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)

Copy link
Contributor Author

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.

Copy link
Member

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

Comment on lines 1052 to 1053
# pylint: disable=unused-argument
def decomposition(self, *args, **kwargs):
def compute_decomposition(wires, **hyperparams):
Copy link
Member

Choose a reason for hiding this comment

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

should this be static?

Comment on lines 1061 to 1063
work_wires
control_values
target_wire
Copy link
Member

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!

Copy link
Contributor

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?

Comment on lines 1066 to 1069
control_wires = hyperparams['control_wires']
work_wires = hyperparams['work_wires']
control_values = hyperparams['control_values']
target_wire = hyperparams['target_wire']
Copy link
Member

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 🤔

Copy link
Member

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):
Copy link
Member

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?

@albi3ro albi3ro changed the base branch from master to op-refactor December 14, 2021 12:22
@@ -547,24 +547,18 @@ def hyperparameters(self):
def decomposition(*params, wires):
Copy link
Contributor

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?)

Copy link
Contributor Author

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]]),
]
)
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah thanks!

Copy link
Member

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):
Copy link
Contributor

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()
Copy link
Contributor

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?)

Copy link
Member

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?

Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Member

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

Copy link
Contributor

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])]
Copy link
Contributor

Choose a reason for hiding this comment

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

💯

Copy link
Member

Choose a reason for hiding this comment

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

nice!

Copy link
Member

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?

Copy link
Contributor Author

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.

Copy link
Contributor

@mariaschuld mariaschuld left a 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!

@@ -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 = {}
Copy link
Contributor Author

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.

Copy link
Contributor

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
Copy link

codecov bot commented Dec 15, 2021

Codecov Report

Merging #2024 (cfa1a45) into op-refactor (df5848e) will decrease coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               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              
Impacted Files Coverage Δ
pennylane/_qubit_device.py 98.70% <100.00%> (ø)
pennylane/measure.py 99.02% <100.00%> (ø)
pennylane/operation.py 95.78% <100.00%> (ø)
pennylane/ops/identity.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/arithmetic_ops.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/matrix_ops.py 99.07% <100.00%> (-0.04%) ⬇️
pennylane/ops/qubit/non_parametric_ops.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/parametric_ops.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/qchem_ops.py 100.00% <100.00%> (ø)
pennylane/ops/qubit/state_preparation.py 100.00% <100.00%> (ø)
... and 6 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update df5848e...cfa1a45. Read the comment docs.

* 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`
Copy link
Contributor

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
Copy link
Contributor

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 ❤️

Copy link
Member

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!

Copy link
Member

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`.
Copy link
Contributor

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.
Copy link
Contributor

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?

@mariaschuld mariaschuld self-requested a review December 21, 2021 13:01
@mariaschuld mariaschuld merged commit a486495 into op-refactor Dec 23, 2021
@mariaschuld mariaschuld deleted the op-decomposition branch December 23, 2021 09:21
mariaschuld added a commit that referenced this pull request Feb 16, 2022
* 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>
dwierichs added a commit that referenced this pull request Feb 17, 2022
* 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>
dwierichs added a commit that referenced this pull request Feb 17, 2022
* 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants