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

Qutrit Rotations #2 (TRY) #2846

Merged
merged 646 commits into from
May 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
646 commits
Select commit Hold shift + click to select a range
058cbcf
Updated tests
mudit2812 Aug 19, 2022
dfd4e79
Merge branch 'master' into qutrit_nops#4
glassnotes Aug 23, 2022
883d8e3
Merge branch 'master' into qutrit_nops#4
glassnotes Aug 24, 2022
6b371fe
Apply suggestions from code review
glassnotes Aug 24, 2022
0f0c523
Partition device apply ops test case.
glassnotes Aug 24, 2022
21ff728
Run black
glassnotes Aug 24, 2022
33e1448
Fix pylint
glassnotes Aug 24, 2022
675da77
Merge branch 'master' into qutrit_nops#4
glassnotes Aug 29, 2022
a2ff8a3
Update pennylane/devices/default_qutrit.py
glassnotes Aug 29, 2022
012ebb8
black and pylint
glassnotes Aug 29, 2022
30ffc35
Merge branch 'master' into qutrit_nops#4
glassnotes Sep 6, 2022
648024d
Update pennylane/devices/default_qutrit.py
mudit2812 Sep 7, 2022
5dfdb14
Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py
mudit2812 Sep 8, 2022
1c8e2bb
Updated test_default_qutrit.py
mudit2812 Sep 8, 2022
93e0cd7
Merge branch 'qutrit_nops#4' of https://github.com/mudit2812/pennylan…
mudit2812 Sep 8, 2022
7c16942
Updated _apply_tadd documentation
mudit2812 Sep 8, 2022
9ff997b
Merge branch 'master' into qutrit_nops#4
mudit2812 Sep 8, 2022
1a4f7dc
Merge branch 'qutrit_nops#4' into qutrit_gm
mudit2812 Sep 8, 2022
c89551c
Merge branch 'master' into qutrit_nops#4
glassnotes Sep 8, 2022
1624c7b
Added eigvals method for TSWAP
mudit2812 Sep 8, 2022
fc2e71b
Reverted TSWAP eigval changes
mudit2812 Sep 8, 2022
25d374c
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 8, 2022
96ceb1d
Update pennylane/devices/default_qutrit.py
mudit2812 Sep 8, 2022
45a7227
Merge branch 'master' into qutrit_nops#4
mudit2812 Sep 8, 2022
5c4c34b
Added TSWAP eigvals
mudit2812 Sep 8, 2022
f6bf13b
Updated changelog-dev.md to include GellMannObs
mudit2812 Sep 8, 2022
4afc700
Removed empty file
mudit2812 Sep 8, 2022
9bb9412
Added linting comments
mudit2812 Sep 8, 2022
bf6159c
Updated tests to use gate_data
mudit2812 Sep 8, 2022
f516b83
Updated test parameter names to be more accurate
mudit2812 Sep 8, 2022
a6e9ae1
Remove unused file
mudit2812 Sep 8, 2022
bae5934
Updated GellMannObs doc-string
mudit2812 Sep 8, 2022
f411371
Merge branch 'master' into qutrit_gm
mudit2812 Sep 9, 2022
8d0f5e2
Merge branch 'qutrit_nops#4' into qutrit_gm
mudit2812 Sep 8, 2022
fa1db85
Merge branch 'master' into qutrit_gm
mudit2812 Sep 9, 2022
3a8cb6f
Merge branch 'qutrit_gm' of https://github.com/mudit2812/pennylane in…
mudit2812 Sep 8, 2022
78a07e1
Merge branch 'master' into qutrit_gm
mudit2812 Sep 9, 2022
80e5ea7
Merge branch 'master' into qutrit_gm
mudit2812 Sep 9, 2022
70f0bdb
Update changelog-dev.md
mudit2812 Sep 9, 2022
a80cbcb
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 13, 2022
84f18e7
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 13, 2022
86875fc
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 13, 2022
1b0a46f
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 13, 2022
229b78a
Merge branch 'master' into qutrit_gm
mudit2812 Sep 13, 2022
d8f3542
Added changes to GellMann to address PR comments
mudit2812 Sep 13, 2022
eaa70b0
Updated test
mudit2812 Sep 13, 2022
08087be
Reformatting
mudit2812 Sep 13, 2022
e140dca
Trying out changes to Gell-Mann docstring
mudit2812 Sep 13, 2022
0dfd2d2
Updated Changelog
mudit2812 Sep 13, 2022
419eb9e
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 13, 2022
8e89143
Testing LaTeX align
mudit2812 Sep 13, 2022
86ebaa7
Merge branch 'qutrit_gm' of https://github.com/mudit2812/pennylane in…
mudit2812 Sep 13, 2022
0bdfe91
Added non-diag tests
mudit2812 Sep 13, 2022
fa22080
Added diag, complex case for tensor sample
mudit2812 Sep 13, 2022
1fec3e1
Added example to doc string
mudit2812 Sep 13, 2022
aff0eea
Fixed label test
mudit2812 Sep 13, 2022
d5315b5
Merge branch 'master' into qutrit_gm
glassnotes Sep 14, 2022
93d0452
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 15, 2022
c769aad
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 15, 2022
3c58377
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 15, 2022
c104fb6
Update tests/devices/test_default_qutrit.py
mudit2812 Sep 15, 2022
26cad8f
Merge branch 'master' into qutrit_gm
mudit2812 Sep 16, 2022
18789f6
Merge branch 'master' into qutrit_gm
mudit2812 Sep 16, 2022
af44097
Merge branch 'qutrit_gm' into qutrit_param#1
mudit2812 Sep 18, 2022
1b490ec
Added tests for controlled qutrit unitary
mudit2812 Jul 4, 2022
ce3caf0
Fix broadcasting, finish tests for CQutritUnitary
mudit2812 Jul 5, 2022
cb64e56
Added TRX and created skeleton files
mudit2812 Jul 5, 2022
fdf1b82
Adding tests for TRX
mudit2812 Jul 6, 2022
eb6dfac
Fixed broadcasting issue in controlled qutrit unitary
mudit2812 Jul 6, 2022
13d3218
Fixed broadcasting issue with ControlledQutritUnitary
mudit2812 Jul 7, 2022
9f03bdb
Fixed broadcasting issue in TRX
mudit2812 Jul 7, 2022
d766d64
Updated TRX documentation
mudit2812 Jul 7, 2022
de3d993
Added tests
mudit2812 Jul 7, 2022
8595df3
Added tests for TRX
mudit2812 Jul 8, 2022
454d580
Removed unused imports
mudit2812 Jul 8, 2022
40c7d66
Removed unused imports, linting changes
mudit2812 Jul 8, 2022
c031f33
Added TRX parameter frequencies
mudit2812 Jul 8, 2022
eebeead
Updated matrix dtype for TRX generator
mudit2812 Jul 8, 2022
9a97636
Added test for param frequencies
mudit2812 Jul 8, 2022
14e6f63
Added param-shift capability for qutrit devices
mudit2812 Jul 20, 2022
9833aa0
Updated changelog
mudit2812 Jul 20, 2022
70b7ee3
Update changelog
mudit2812 Jul 20, 2022
1359afd
Added change for TRX generator
mudit2812 Aug 2, 2022
e02e6d6
Updated utils.py to support higher dimensions
mudit2812 Aug 2, 2022
7d195a5
Added tests for updated utils.sparse_hamiltonian
mudit2812 Aug 2, 2022
9f89219
Added Identity as supported obs
mudit2812 Aug 2, 2022
07952d8
Updated TRX docstring
mudit2812 Aug 17, 2022
c6fd83a
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
mudit2812 Sep 19, 2022
1899553
Merge branch 'master' into qutrit_gm
Jaybsoni Sep 19, 2022
e3e1cc3
Merge branch 'master' into qutrit_gm
Jaybsoni Sep 20, 2022
35ef806
Merge branch 'master' into qutrit_gm
glassnotes Sep 21, 2022
ff3960e
Update tests/ops/qutrit/test_qutrit_non_parametric_ops.py
mudit2812 Sep 21, 2022
0a75bc7
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 21, 2022
1faf8b4
Update pennylane/ops/qutrit/observables.py
mudit2812 Sep 21, 2022
642fe5f
Added ControlledQutritUnitary
mudit2812 Jul 4, 2022
bfffa43
Merge branch 'master' into qutrit_param#1
mudit2812 Sep 21, 2022
05b6da1
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Sep 18, 2022
aa6a63e
Update changelog-dev.md
mudit2812 Sep 22, 2022
a1277b3
Removed empty files
mudit2812 Sep 19, 2022
db99fea
Merge branch 'master' into qutrit_cqunitary
glassnotes Sep 23, 2022
35c39ab
Update tests/ops/qutrit/test_qutrit_matrix_ops.py
mudit2812 Sep 26, 2022
222a0e3
Update tests/ops/qutrit/test_qutrit_matrix_ops.py
mudit2812 Sep 26, 2022
ad49d42
Update tests/ops/qutrit/test_qutrit_matrix_ops.py
mudit2812 Sep 26, 2022
da54287
Update tests/ops/qutrit/test_qutrit_matrix_ops.py
mudit2812 Sep 26, 2022
2e8b9cf
Merge branch 'master' into qutrit_cqunitary
mudit2812 Sep 26, 2022
6202413
Updated to address PR
mudit2812 Sep 26, 2022
3538bc5
Fixed uncommented lines in test suite
mudit2812 Sep 27, 2022
24d8715
Added complex values to state
mudit2812 Sep 27, 2022
2d23b1f
Updated test_mixed_polarity_controls
mudit2812 Sep 27, 2022
52353a8
Fixed QutritUnitary._controlled
mudit2812 Sep 27, 2022
b88d8c1
Merge branch 'master' into qutrit_cqunitary
mudit2812 Sep 28, 2022
6470222
Updated test_controlled for matrix ops
mudit2812 Sep 27, 2022
8fc5370
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 4, 2022
358a57c
Updated ControlledQutritUnitary._controlled
mudit2812 Oct 5, 2022
8a96191
Reformatting
mudit2812 Oct 5, 2022
6008992
Merge branch 'master' into qutrit_cqunitary
glassnotes Oct 5, 2022
ee9767b
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 8, 2022
882f295
Update pennylane/ops/qutrit/matrix_ops.py
mudit2812 Oct 11, 2022
d947bfd
Merge branch 'qutrit_cqunitary' of https://github.com/mudit2812/penny…
mudit2812 Oct 5, 2022
7639c44
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 12, 2022
477cf1d
Merge branch 'qutrit_cqunitary' of https://github.com/mudit2812/penny…
mudit2812 Oct 5, 2022
9dfeb17
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 14, 2022
7fa41e2
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 15, 2022
e89ddf9
Merge branch 'master' into qutrit_cqunitary
mudit2812 Oct 17, 2022
6b2ddc9
Updated ControlledQutritUnitary and tests
mudit2812 Oct 17, 2022
f6ca20d
Merge branch 'qutrit_cqunitary' into qutrit_param#1
mudit2812 Oct 17, 2022
e22d0c4
Merge branch 'qutrit_param#1' into qutrit_param#2
mudit2812 Oct 17, 2022
f27fcf3
Merge branch 'master' into qutrit_param#1
glassnotes Oct 21, 2022
6a2fb64
Addressing PR review
mudit2812 Oct 23, 2022
c2c3441
Updated sparse_hamiltonian, fixed TRX docstring
mudit2812 Oct 23, 2022
3e65065
Addressing PR review
mudit2812 Oct 24, 2022
af6f1a4
Refactoring
mudit2812 Oct 24, 2022
a75feee
Merge branch 'master' into qutrit_param#1
mudit2812 Nov 2, 2022
e9f6636
Fixed changelog
mudit2812 Oct 23, 2022
0451905
Update pennylane/devices/default_qutrit.py
mudit2812 Nov 2, 2022
0ff235d
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Oct 23, 2022
20ee96a
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 Nov 2, 2022
610b78e
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 Nov 2, 2022
a0701d0
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 Nov 2, 2022
9e19bdb
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 Nov 2, 2022
ed6949f
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Nov 2, 2022
be9bdbe
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Nov 2, 2022
01b0e1d
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Nov 2, 2022
0e4a270
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Nov 2, 2022
f3b5d62
Update tests/test_qnode.py
mudit2812 Nov 2, 2022
0ce96aa
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Oct 23, 2022
ab318e9
Merge branch 'master' into qutrit_param#1
glassnotes Nov 2, 2022
d981cab
Merge branch 'master' into qutrit_param#1
mudit2812 Nov 10, 2022
4f6b725
Reverted changes to sparse_hamiltonian
mudit2812 Nov 10, 2022
0bd0ed5
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Nov 10, 2022
457091f
Fixed sparse_hamiltonian test
mudit2812 Nov 10, 2022
d92f25c
Updated changelog
mudit2812 Nov 10, 2022
9fa2b19
Updated TRX documentation
mudit2812 Nov 10, 2022
cbd01fa
Fixed generator
mudit2812 Nov 10, 2022
10e5c74
Adding levels to sparse_hamiltonian
mudit2812 Nov 10, 2022
bf252df
Updated test sparse hamiltonian
mudit2812 Nov 10, 2022
869b149
Fixed sparse hamiltonian test
mudit2812 Nov 10, 2022
a217fae
Fixed constant level kwarg
mudit2812 Nov 10, 2022
837e811
Updated changelog, added test coverage
mudit2812 Nov 11, 2022
e0815ef
Fixed coverage
mudit2812 Nov 11, 2022
27acac9
Updated test suite
mudit2812 Nov 11, 2022
846bb46
Updated files to address PR review
mudit2812 Nov 16, 2022
fdcbe61
Updated tests to include subspace error tests
mudit2812 Nov 16, 2022
19dbad1
Added TRX tests for parameter shift
mudit2812 Nov 18, 2022
f2bd7e6
Update doc/releases/changelog-dev.md
mudit2812 Nov 24, 2022
d59c349
Update pennylane/utils.py
mudit2812 Nov 24, 2022
8f9a1c6
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Nov 16, 2022
45f820f
Update utils.py to remove trailing whitespace
mudit2812 Nov 24, 2022
6bfe1aa
Merge branch 'master' into qutrit_param#1
mudit2812 Nov 24, 2022
45e201f
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Nov 18, 2022
52c3954
Merge branch 'master' into qutrit_param#1
mudit2812 Dec 7, 2022
0fbd82a
Merge branch 'master' into qutrit_param#1
Jaybsoni Dec 7, 2022
75f73c5
Merge branch 'master' into qutrit_param#1
glassnotes Dec 7, 2022
ab8910b
Merge branch 'master' into qutrit_param#1
mudit2812 Dec 19, 2022
0261221
Updated to address PR review
mudit2812 Dec 19, 2022
7ad26ac
Fixed class/object confusion bug
mudit2812 Dec 19, 2022
e2cdcf0
Testing changes to adjust lines changed in PR
mudit2812 Dec 19, 2022
f2bbe63
Fixing changes
mudit2812 Dec 19, 2022
76729b6
Fixing changes
mudit2812 Dec 19, 2022
6604244
Resetting problem files
mudit2812 Dec 19, 2022
d3aab82
Fixing changes
mudit2812 Dec 19, 2022
e8d71c3
updated TRX docs
mudit2812 Dec 19, 2022
794199f
Fixed TRX docs
mudit2812 Dec 19, 2022
5effc25
Updated TRX docs
mudit2812 Dec 19, 2022
70ac995
Fixed PR too many lines changed issue
mudit2812 Dec 19, 2022
945e2cc
Updated subspace error tests
mudit2812 Dec 19, 2022
720f034
Merge branch 'master' into qutrit_param#1
mudit2812 Dec 19, 2022
8d7cc4a
Tweaked THadamard docs to fix rendering
mudit2812 Dec 19, 2022
b5078d4
Test dos2unix
glassnotes Dec 19, 2022
7b6d7ad
Merging
mudit2812 Dec 19, 2022
af3d5e8
Fixed subspace testing
mudit2812 Dec 20, 2022
8a8a6de
Merge branch 'master' into qutrit_param#1
mudit2812 Dec 20, 2022
de2c397
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
mudit2812 Jan 27, 2023
0bdf4c2
Merge changes
mudit2812 Jan 27, 2023
3814e4f
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 9, 2023
5999506
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 9, 2023
befea7b
Started adding tests for grad
mudit2812 Feb 9, 2023
efd46f2
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 Feb 9, 2023
f6ba12c
Updated tests to parametrize diff-method
mudit2812 Feb 9, 2023
76ddbfd
Linted tests
mudit2812 Feb 9, 2023
58fd032
Fiex tests using in-place inversion
mudit2812 Feb 10, 2023
65b59bb
Added diff tests
mudit2812 Feb 10, 2023
50f6803
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 10, 2023
642edcd
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 10, 2023
96e092c
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 10, 2023
23cd768
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 13, 2023
1f9db6d
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 Feb 13, 2023
5191878
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
cc11975
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
2d29219
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
b9e8a0a
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
8694b8a
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
366c894
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
a982cd3
Update tests/ops/qutrit/test_qutrit_parametric_ops.py
mudit2812 Feb 13, 2023
aeab773
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 14, 2023
92b197c
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 14, 2023
4125153
Fixed formatting
mudit2812 Feb 14, 2023
7595acb
Merge branch 'master' into qutrit_param#1
mudit2812 Feb 14, 2023
ed63a33
Merge branch 'trx' into qutrit_param#1
mudit2812 Mar 27, 2023
fec5668
Update pennylane/utils.py
mudit2812 Mar 27, 2023
068c724
Merge branch 'qutrit_param#1' into qutrit_param#2
mudit2812 Mar 27, 2023
784fb0d
Updated TRY and tests
mudit2812 Mar 27, 2023
85922b6
Updated utils.py
mudit2812 Mar 27, 2023
6b59b47
Merge branch 'qutrit_param#1' into qutrit_param#2
mudit2812 Mar 27, 2023
50d3fed
Fixed TRX generator
mudit2812 Mar 27, 2023
51ee945
Merge branch 'qutrit_param#1' into qutrit_param#2
mudit2812 Mar 27, 2023
0fd99b9
Updated generator TRY
mudit2812 Mar 27, 2023
f0be02d
Updated subspace validation for TRY
mudit2812 Mar 29, 2023
c3caa3d
Merge branch 'master' of https://github.com/PennyLaneAI/pennylane int…
mudit2812 May 10, 2023
21b8acb
Updated subspace validation
mudit2812 May 15, 2023
c844df9
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 May 15, 2023
f144488
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 May 15, 2023
9440066
Update pennylane/ops/qutrit/parametric_ops.py
mudit2812 May 15, 2023
142715d
Reverted `validate_subspace` changes
mudit2812 May 16, 2023
05e4521
Updated test
mudit2812 May 16, 2023
0bc24bc
Merge branch 'master' into qutrit_param#1
mudit2812 May 16, 2023
0bb7bfc
Added parameter shift test
mudit2812 May 16, 2023
d5269af
Merge branch 'qutrit_param#1' of https://github.com/mudit2812/pennyla…
mudit2812 May 16, 2023
c35026f
Fixed test
mudit2812 May 16, 2023
fba6837
Merge branch 'qutrit_param#1' into qutrit_param#2
mudit2812 May 17, 2023
de6748a
Merge branch 'master' into qutrit_param#2
mudit2812 May 17, 2023
6d19ac1
Update doc/releases/changelog-dev.md
mudit2812 May 18, 2023
7b7a50a
Update changelog
mudit2812 May 18, 2023
39d88fd
Updated grad tests
mudit2812 May 19, 2023
7cbc9d7
Apply suggestions from code review
mudit2812 May 23, 2023
ca55061
Updated subspace docstring
mudit2812 May 23, 2023
2984146
Merge branch 'qutrit_param#2' of https://github.com/mudit2812/pennyla…
mudit2812 May 23, 2023
3043eba
Merge branch 'master' into qutrit_param#2
mudit2812 May 23, 2023
fb8bb9f
Pylint
mudit2812 May 23, 2023
545b859
Merge branch 'master' into qutrit_param#2
mudit2812 May 23, 2023
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
Adding tests for TRX
  • Loading branch information
mudit2812 committed Sep 18, 2022
commit fdf1b821451f7c44d97ea7c781e08a0172f56894
19 changes: 13 additions & 6 deletions pennylane/ops/qutrit/parametric_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,19 @@ class TRX(Operation):
"""tuple[int]: Number of dimensions per trainable parameter that the operator depends on."""

grad_method = "A"
# TODO: Add parameter frequency

def generator(self):
gen_mat = np.zeros((3, 3))
gen_mat[self.subspace] = 1
gen_mat[self.subspace[::-1]] = 1
return -0.5 * QutritUnitary(gen_mat, wires=self.wires)
return QutritUnitary(-0.5 * gen_mat, wires=self.wires)

def __init__(self, phi, wires, subspace=[0, 1], do_queue=True, id=None):
self._subspace = sorted(tuple(subspace))
self._subspace = subspace
self._hyperparameters = {
"subspace": self.subspace,
}
super().__init__(phi, wires=wires, do_queue=do_queue, id=id)

@property
Expand All @@ -103,7 +107,7 @@ def subspace(self):
Returns:
tuple[int]: subspace on which operator acts
"""
return self._subspace
return tuple(sorted(self._subspace))

@staticmethod
def compute_matrix(theta, subspace=[0, 1]): # pylint: disable=arguments-differ
Expand All @@ -128,7 +132,7 @@ def compute_matrix(theta, subspace=[0, 1]): # pylint: disable=arguments-differ
[0.0000+0.0000j, 1.0000+0.0000j, 0.0000+0.0000j],
[0.0000-0.2474j, 0.0000+0.0000j, 0.9689+0.0000j]])
"""
subspace = sorted(tuple(subspace))
subspace = tuple(sorted(subspace))
c = qml.math.cos(theta / 2)
s = qml.math.sin(theta / 2)

Expand All @@ -139,8 +143,11 @@ def compute_matrix(theta, subspace=[0, 1]): # pylint: disable=arguments-differ
# The following avoids casting an imaginary quantity to reals when backpropagating
c = (1 + 0j) * c
js = -1j * s

mat = qml.math.eye(3)
mat = (
qml.math.tensordot([1] * qml.math.shape(theta)[0], qml.math.eye(3), axes=0)
if len(qml.math.shape(theta)) != 0 and qml.math.shape(theta)[0] > 1
else qml.math.eye(3)
)
mat = qml.math.cast_like(mat, js)
slices = tuple(itertools.product(subspace, subspace))

Expand Down
131 changes: 131 additions & 0 deletions tests/ops/qutrit/test_qutrit_parametric_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,141 @@
"""
Unit tests for the available built-in parametric qutrit operations.
"""
from functools import reduce
import pytest
import copy
import numpy as np
from pennylane import numpy as npp

import pennylane as qml
from pennylane.wires import Wires
from tests.ops.qubit.test_parametric_ops import NON_PARAMETRIZED_OPERATIONS

from gate_data import TSHIFT, TCLOCK

PARAMETRIZED_OPERATIONS = [
qml.TRX(0.123, wires=0, subspace=[1, 2]),
qml.QutritUnitary(TSHIFT, wires=0),
qml.ControlledQutritUnitary(TCLOCK, wires=[0], control_wires=[2]),
]

BROADCASTED_OPERATIONS = [
qml.TRX([0.142, -0.61, 2.3], wires=0, subspace=[1, 2]),
qml.QutritUnitary(np.array([TSHIFT, TCLOCK]), wires=0),
qml.ControlledQutritUnitary(np.array([TSHIFT, TCLOCK]), wires=[0], control_wires=[2]),
]

NON_PARAMETRIZED_OPERATIONS = [
qml.TShift(wires=0),
qml.TClock(wires=0),
qml.TAdd(wires=[0, 1]),
qml.TSWAP(wires=[0, 1]),
]


ALL_OPERATIONS = NON_PARAMETRIZED_OPERATIONS + PARAMETRIZED_OPERATIONS

dot_broadcasted = lambda a, b: np.einsum("...ij,...jk->...ik", a, b)
multi_dot_broadcasted = lambda matrices: reduce(dot_broadcasted, matrices)


class TestOperations:
@pytest.mark.parametrize("op", ALL_OPERATIONS + BROADCASTED_OPERATIONS)
def test_parametrized_op_copy(self, op, tol):
"""Tests that copied parametrized ops function as expected"""
copied_op = copy.copy(op)
assert np.allclose(op.matrix(), copied_op.matrix(), atol=tol)

op.inv()
copied_op2 = copy.copy(op)
assert np.allclose(op.matrix(), copied_op2.matrix(), atol=tol)
op.inv()

@pytest.mark.parametrize("op", PARAMETRIZED_OPERATIONS)
def test_adjoint_unitaries(self, op, tol):
op_d = op.adjoint()
res1 = np.dot(op.matrix(), op_d.matrix())
res2 = np.dot(op_d.matrix(), op.matrix())
assert np.allclose(res1, np.eye(3 ** len(op.wires)), atol=tol)
assert np.allclose(res2, np.eye(3 ** len(op.wires)), atol=tol)
assert op.wires == op_d.wires

@pytest.mark.parametrize("op", BROADCASTED_OPERATIONS)
def test_adjoint_unitaries_broadcasted(self, op, tol):
op_d = op.adjoint()
res1 = dot_broadcasted(op.matrix(), op_d.matrix())
res2 = dot_broadcasted(op_d.matrix(), op.matrix())
I = [np.eye(3 ** len(op.wires))] * op.batch_size
assert np.allclose(res1, I, atol=tol)
assert np.allclose(res2, I, atol=tol)
assert op.wires == op_d.wires


# TODO: Add tests for parameter frequencies
# TODO: Add tests for decompositions


class TestMatrix:
def test_trx(self, tol):
"""Test x rotation is correct"""

# test identity for theta = 0
expected = np.eye(3)
assert np.allclose(qml.TRX.compute_matrix(0, subspace=[0, 1]), expected, atol=tol, rtol=0)
assert np.allclose(qml.TRX.compute_matrix(0, subspace=[1, 2]), expected, atol=tol, rtol=0)
assert np.allclose(qml.TRX.compute_matrix(0, subspace=[0, 2]), expected, atol=tol, rtol=0)

# test identity for theta=pi/2
expected = np.array([[1, -1j, 0], [-1j, 1, 0], [0, 0, np.sqrt(2)]]) / np.sqrt(2)
assert np.allclose(
qml.TRX.compute_matrix(np.pi / 2, subspace=[0, 1]), expected, atol=tol, rtol=0
)

expected = np.array([[np.sqrt(2), 0, 0], [0, 1, -1j], [0, -1j, 1]]) / np.sqrt(2)
assert np.allclose(
qml.TRX.compute_matrix(np.pi / 2, subspace=[1, 2]), expected, atol=tol, rtol=0
)

expected = np.array([[1, 0, -1j], [0, np.sqrt(2), 0], [-1j, 0, 1]]) / np.sqrt(2)
assert np.allclose(
qml.TRX.compute_matrix(np.pi / 2, subspace=[0, 2]), expected, atol=tol, rtol=0
)

# test identity for broadcasted theta=pi/2
pi_half = np.array([np.pi / 2] * 2)
expected = np.tensordot(
[1, 1], np.array([[1, -1j, 0], [-1j, 1, 0], [0, 0, np.sqrt(2)]]) / np.sqrt(2), axes=0
)
assert np.allclose(
qml.TRX.compute_matrix(pi_half, subspace=[0, 1]), expected, atol=tol, rtol=0
)

expected = np.tensordot(
[1, 1], np.array([[1, 0, -1j], [0, np.sqrt(2), 0], [-1j, 0, 1]]) / np.sqrt(2), axes=0
)
assert np.allclose(
qml.TRX.compute_matrix(pi_half, subspace=[0, 2]), expected, atol=tol, rtol=0
)

expected = np.tensordot(
[1, 1], np.array([[np.sqrt(2), 0, 0], [0, 1, -1j], [0, -1j, 1]]) / np.sqrt(2), axes=0
)
assert np.allclose(
qml.TRX.compute_matrix(pi_half, subspace=[1, 2]), expected, atol=tol, rtol=0
)

# test identity for theta=pi
expected = -1j * np.array([[0, 1, 0], [1, 0, 0], [0, 0, 1j]])
assert np.allclose(
qml.TRX.compute_matrix(np.pi, subspace=[0, 1]), expected, atol=tol, rtol=0
)

expected = -1j * np.array([[1j, 0, 0], [0, 0, 1], [0, 1, 0]])
assert np.allclose(
qml.TRX.compute_matrix(np.pi, subspace=[1, 2]), expected, atol=tol, rtol=0
)

expected = -1j * np.array([[0, 0, 1], [0, 1j, 0], [1, 0, 0]])
assert np.allclose(
qml.TRX.compute_matrix(np.pi, subspace=[0, 2]), expected, atol=tol, rtol=0
)