Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add __mul__ dunder method #2891

Merged
merged 38 commits into from
Aug 5, 2022
Merged
Changes from 1 commit
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c162b1a
feat (Operator): :sparkles: __mul__ dunder method.
AlbertMitjans Aug 4, 2022
c3273af
test (Operator): :test_tube: Compare operators.
AlbertMitjans Aug 4, 2022
3e487be
test (Operator): :test_tube: Add __mul__ test.
AlbertMitjans Aug 4, 2022
358b858
chore (changelog): :pencil2: Add feature to changelog.
AlbertMitjans Aug 4, 2022
f48e700
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 4, 2022
4bb6d9f
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 4, 2022
b1ca393
chore (changelog): :pencil2: Add feature to changelog.
AlbertMitjans Aug 4, 2022
b9fd663
refactor (Operation): :recycle: Remove dead line.
AlbertMitjans Aug 4, 2022
06c488b
docs: :memo: Fix docs.
AlbertMitjans Aug 4, 2022
b550bc2
refactor (Operation): :recycle: Remove __rmul__.
AlbertMitjans Aug 4, 2022
cb16160
refactor (Hamiltonian): :recycle: Remove super call.
AlbertMitjans Aug 4, 2022
3decee5
feat (Operator): :sparkles: __matmul__ dunder method.
AlbertMitjans Aug 4, 2022
6bd9863
chore (changelog): :pencil2: Modify changelog.
AlbertMitjans Aug 4, 2022
1c6ec0e
test (Observable): :test_tube: Remove test.
AlbertMitjans Aug 4, 2022
5bbbc57
Update doc/releases/changelog-dev.md
AlbertMitjans Aug 4, 2022
0ab97db
fix (Operator): :bug: Use only one wire with Identity.
AlbertMitjans Aug 4, 2022
f79d73a
Merge branch 'mul_dunder_method' of https://github.com/PennyLaneAI/pe…
AlbertMitjans Aug 4, 2022
fd6e53e
test (Operator): :test_tube: Increase coverage.
AlbertMitjans Aug 4, 2022
4d0e710
test (Operator): :test_tube: Increase coverage.
AlbertMitjans Aug 4, 2022
3a6c2c7
Merge branch 'master' into mul_dunder_method
AlbertMitjans Aug 4, 2022
bd0f7b6
Update pennylane/operation.py
AlbertMitjans Aug 4, 2022
c8a487a
Update pennylane/operation.py
AlbertMitjans Aug 4, 2022
e92635a
Update tests/test_operation.py
AlbertMitjans Aug 4, 2022
1c900d6
test (Operator): :test_tube: Fix test.
AlbertMitjans Aug 4, 2022
e99d1b3
test (Operator): :test_tube: Support add for multiple wires.
AlbertMitjans Aug 4, 2022
7eb3914
test (Operator): :test_tube: Increase coverage.
AlbertMitjans Aug 4, 2022
4f85e5d
feat (s_prod): :sparkles: Add to init.
AlbertMitjans Aug 4, 2022
a66f6ed
Update pennylane/operation.py
AlbertMitjans Aug 4, 2022
b4f6395
Update pennylane/operation.py
AlbertMitjans Aug 4, 2022
3fcc60d
Merge branch 'master' into mul_dunder_method
AlbertMitjans Aug 4, 2022
b6bbf5a
fix: :bug: Fix small bug.
AlbertMitjans Aug 4, 2022
fec905d
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 4, 2022
ab5ade4
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 5, 2022
84bc335
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 5, 2022
39bb860
test (Operator): :test_tube: Add test.
AlbertMitjans Aug 5, 2022
624e23e
refactor (Operator): :recycle: Use wrappers.
AlbertMitjans Aug 5, 2022
bfe569d
refactor (Operator): :recycle: Use wrappers.
AlbertMitjans Aug 5, 2022
4d6f3cf
Update pennylane/operation.py
AlbertMitjans Aug 5, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test (Operator): 🧪 Increase coverage.
  • Loading branch information
AlbertMitjans committed Aug 4, 2022
commit 4d0e710820f2a05cba0fdb354a4cd83ff1b4dbf9
13 changes: 13 additions & 0 deletions tests/test_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -1169,6 +1169,19 @@ def test_multiply_tensor_in_place(self):
assert isinstance(t, Tensor)
assert t.obs == [X, Y, Z, H]

def test_operation_multiply_invalid(self):
"""Test that an exception is raised if an observable
is multiplied by an operation"""
X = qml.PauliX(0)
Y = qml.CNOT(wires=[0, 1])
Z = qml.PauliZ(0)

with pytest.raises(
ValueError, match="Can only perform tensor products between observables"
):
T = X @ Z
T @ Y

def test_eigvals(self):
"""Test that the correct eigenvalues are returned for the Tensor"""
X = qml.PauliX(0)
Expand Down