Skip to content

Commit

Permalink
test orthonormal bases
Browse files Browse the repository at this point in the history
  • Loading branch information
talonchandler committed Dec 21, 2024
1 parent 55ff94e commit ba45686
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
18 changes: 18 additions & 0 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,21 @@ def test_pad_zyx_large_padding(zyx_data):
assert result.shape == (13, 4, 5)
assert torch.all(result[:5] == 0)
assert torch.all(result[-5:] == 0)


def test_pauli_orthonormal():
s = util.pauli()
assert torch.allclose(
torch.abs(torch.einsum("kij,lji->kl", s, s)) - torch.eye(4),
torch.zeros((4, 4)),
atol=1e-5,
)


def test_gellmann_orthonormal():
Y = util.gellmann()
assert torch.allclose(
torch.abs(torch.einsum("kij,lji->kl", Y, Y)) - torch.eye(9),
torch.zeros((9, 9)),
atol=1e-5,
)
21 changes: 1 addition & 20 deletions waveorder/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -2258,17 +2258,6 @@ def pauli():
[[a, 0], [0, a]],
[[-a, 0], [0, a]],
[[0, a], [a, 0]],
[[0, 1j * a], [-1j * a, 0]],
]
)
return sigma


# torch.allclose(
# torch.abs(torch.einsum("kij,lji->kl", s, s) - torch.eye(4)),
# torch.zeros((4, 4)),
# atol=1e-5,
# )


def gellmann():
Expand Down Expand Up @@ -2297,12 +2286,4 @@ def gellmann():
[[0, 0, c], [0, 0, 0], [c, 0, 0]],
[[0, 0, 0], [0, -c, 0], [0, 0, c]], #
], dtype=torch.complex64
)

# torch.allclose(


# torch.abs(torch.einsum("kij,lji->kl", Y, Y) - torch.eye(9)),
# torch.zeros((9, 9)),
# atol=1e-5,
# )
)

0 comments on commit ba45686

Please sign in to comment.