Skip to content

Commit

Permalink
Merge pull request #53 from Cornell-QCA/model
Browse files Browse the repository at this point in the history
Model into main
  • Loading branch information
Haadi-Khan authored Jun 19, 2024
2 parents ffef954 + 9b3441b commit 4c8cdf8
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions python/tests/test_model.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,40 @@
import pytest
from anyon_braiding_simulator import AnyonModel, Model
# Standard Library
import cmath

"""
TODO: Write tests for the Model class
"""
import numpy as np
import pytest
from anyon_braiding_simulator import AnyonModel
from Model import Model


@pytest.fixture
def setup():
def initialize_ising():
return Model(AnyonModel.Ising)


@pytest.mark.model
def test_r_matrix(initialize_ising):
isingMat1 = initialize_ising._r_mtx
isingMat2 = cmath.exp(-1j * np.pi / 8) * np.array([[1, 0], [0, 1j]])
assert np.equal(isingMat1, isingMat2).all()


@pytest.mark.model
def test_f_matrix(initialize_ising):
ising = initialize_ising

# check F with all sigma subscripts yields the desired matrix
sigma4F1 = ising.getFMatrix('sigma', 'sigma', 'sigma', 'sigma')
sigma4F2 = 1 / np.sqrt(2) * np.array([[1, 1], [1, -1]])
assert np.equal(sigma4F1, sigma4F2).all()

# check other non identity matrices
assert np.equal(ising.getFMatrix('psi', 'sigma', 'sigma', 'vacuum'), -1 * np.identity(2)).all()
assert np.equal(ising.getFMatrix('psi', 'psi', 'sigma', 'sigma'), -1 * np.identity(2)).all()
assert np.equal(ising.getFMatrix('sigma', 'sigma', 'psi', 'psi'), -1 * np.identity(2)).all()
assert not np.equal(ising.getFMatrix('psi', 'sigma', 'psi', 'vacuum'), np.identity(2)).all()

# check identity matrices
assert np.equal(ising.getFMatrix('psi', 'psi', 'psi', 'vacuum'), np.identity(2)).all()
assert np.equal(ising.getFMatrix('psi', 'vacuum', 'psi', 'psi'), np.identity(2)).all()
assert np.equal(ising.getFMatrix('psi', 'psi', 'psi', 'psi'), np.identity(2)).all()

0 comments on commit 4c8cdf8

Please sign in to comment.