From 35878dc4a99fd6e8b96222867b997cab38fe41c4 Mon Sep 17 00:00:00 2001 From: juli6nne Date: Sat, 22 Jun 2024 11:47:23 -0400 Subject: [PATCH] fixed topocharge --- python/anyon_braiding_simulator/Braiding.py | 10 +++++----- python/tests/test_braiding.py | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/python/anyon_braiding_simulator/Braiding.py b/python/anyon_braiding_simulator/Braiding.py index 6388ad0..b92edbd 100644 --- a/python/anyon_braiding_simulator/Braiding.py +++ b/python/anyon_braiding_simulator/Braiding.py @@ -1,12 +1,12 @@ import numpy as np -from anyon_braiding_simulator import State, Fusion, AnyonModel, Model +from anyon_braiding_simulator import State, Fusion, Model, AnyonModel class Braid: def __init__(self, state: State, model: Model): """ Parameters: - state (State): The state of the system containing anyons and fusion operations - - model_type (AnyonModel): Model to use for the braid simulation + - model (Model): Model to use for the braid simulation """ self.state = state self.anyons = state.anyons @@ -74,7 +74,7 @@ def swap_to_qubit(self, time: int, swap_index: int) -> int: index_A, index_B = swap[swap_index] # Iterate through the qubit encoding to find the matching qubit - for qubit_index, fusion_pair in enumerate(self.fusion.qubit_enc()): + for qubit_index, fusion_pair in enumerate(self.fusion.qubit_enc(self.model.model_type)): if {index_A, index_B} == {fusion_pair.anyon_1, fusion_pair.anyon_2}: return qubit_index @@ -112,11 +112,11 @@ def generate_swap_matrix(self, time: int, swap_index: int) -> np.ndarray: return swap_matrix def generate_overall_unitary(self, time: int, swap_index: int) -> np.ndarray: - qubit_encoding = self.fusion.qubit_enc() + qubit_encoding = self.fusion.qubit_enc(self.model.model_type) if qubit_encoding is None: raise ValueError("Fusion qubit encoding returned None") - num_qubits = len(self.fusion.qubit_enc()) + num_qubits = len(self.fusion.qubit_enc(self.model.model_type)) unitary = np.eye(2**num_qubits) # Start with identity matrix of appropriate size for i in range(num_qubits): diff --git a/python/tests/test_braiding.py b/python/tests/test_braiding.py index bf54217..84c6e27 100644 --- a/python/tests/test_braiding.py +++ b/python/tests/test_braiding.py @@ -149,17 +149,17 @@ def setup_state(): state.add_operation(3, FusionPair(0, 2)) # Initialize the braid with the given state and model type - braid = Braid(state, AnyonModel.Ising) + braid = Braid(state, Model(AnyonModel.Ising)) return braid def test_qubit_enc(setup_state): braid = setup_state - correct = [FusionPair(0, 1), FusionPair(2, 3), FusionPair(2, 4)] + correct = [FusionPair(0, 1), FusionPair(2, 4), FusionPair(2, 3)] # Confirm qubit_enc is working as expected - assert set(map(str, braid.fusion.qubit_enc())) == set(map(str, correct)) + assert set(map(str, braid.fusion.qubit_enc(braid.model.model_type))) == set(map(str, correct)) def test_swap_to_qubit(setup_state): braid = setup_state