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

Model #53

Merged
merged 3 commits into from
Jun 19, 2024
Merged
Changes from all commits
Commits
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
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()