Skip to content

Commit

Permalink
Fixed pairs_to_indices & added test
Browse files Browse the repository at this point in the history
  • Loading branch information
rbyrne299 committed Jun 29, 2024
1 parent eb78356 commit 3efb7cc
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/anyon_braiding_simulator/Simulator.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ def pairs_to_indices(self, anyon_pairs: list) -> list:
index_1 = self.get_anyon_index(anyon_A)
index_2 = self.get_anyon_index(anyon_B)
anyon_indices.append((index_1, index_2))
return anyon_indices
except ValueError:
raise
return anyon_indices

def get_anyon_index(self, anyon_name: str) -> int:
"""
Expand Down
16 changes: 16 additions & 0 deletions python/tests/test_simulator.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import pytest
from Simulator import Simulator
from anyon_braiding_simulator import Anyon, TopoCharge, IsingTopoCharge

@pytest.mark.simulator
def test_pairs_to_indices():
simulator = Simulator()
anyon1 = Anyon("anyon1", TopoCharge(IsingTopoCharge.Sigma), (1, 2))
anyon2 = Anyon("anyon2", TopoCharge(IsingTopoCharge.Psi), (3, 4))
anyon3 = Anyon("anyon3", TopoCharge(IsingTopoCharge.Vacuum), (5, 6))
simulator.update_anyons(True, [anyon1, anyon2, anyon3])

pairs = [("anyon1", "anyon2"), ("anyon2", "anyon3")]
indices = simulator.pairs_to_indices(pairs)

assert indices == [(0, 1), (1, 2)]

0 comments on commit 3efb7cc

Please sign in to comment.