Skip to content

Commit

Permalink
Fix merge conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
rishi763 committed Jun 29, 2024
1 parent 957452a commit c1034dc
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 6 deletions.
6 changes: 3 additions & 3 deletions python/anyon_braiding_simulator/Braiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(self.model.model_type)):
for qubit_index, fusion_pair in enumerate(self.fusion.qubit_enc()):
if {index_A, index_B} == {fusion_pair.anyon_1, fusion_pair.anyon_2}:
return qubit_index

Expand Down Expand Up @@ -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(self.model.model_type)
qubit_encoding = self.fusion.qubit_enc()
if qubit_encoding is None:
raise ValueError("Fusion qubit encoding returned None")

num_qubits = len(self.fusion.qubit_enc(self.model.model_type))
num_qubits = len(self.fusion.qubit_enc())
unitary = np.eye(2**num_qubits) # Start with identity matrix of appropriate size

for i in range(num_qubits):
Expand Down
4 changes: 2 additions & 2 deletions python/tests/test_braiding.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

from Braiding import Braid
from Model import Model
from anyon_braiding_simulator import Anyon, AnyonModel, IsingTopoCharge, TopoCharge, State, FusionPair
from anyon_braiding_simulator import Anyon, AnyonModel, IsingTopoCharge, FibonacciTopoCharge, TopoCharge, State, FusionPair


@pytest.fixture
Expand Down Expand Up @@ -159,7 +159,7 @@ def test_qubit_enc(setup_state):
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(braid.model.model_type))) == set(map(str, correct))
assert set(map(str, braid.fusion.qubit_enc())) == set(map(str, correct))

def test_swap_to_qubit(setup_state):
braid = setup_state
Expand Down
1 change: 1 addition & 0 deletions python/tests/test_fusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
Fusion,
FusionPair,
IsingTopoCharge,
FibonacciTopoCharge,
State,
TopoCharge,
)
Expand Down
20 changes: 20 additions & 0 deletions src/model/model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,24 @@ impl AnyonModel {
AnyonModel::Ising
}
}
// Commenting out Model for now because it has no use atm We might port the
// python stuff to rust later, but for now we have no use

/// The parameters accompanying a model
/// More docs later when we impl stuff from python
#[pyclass]
pub struct Model {
model_type: AnyonModel,
// more fields which we'll impl later
}

#[pymethods]
impl Model {
#[new]
fn new() -> Self {
// Model { model_type }
Model {
model_type: AnyonModel::Ising,
}
}
}
2 changes: 1 addition & 1 deletion src/util/statevec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use numpy::{Complex64, PyArray1, PyReadonlyArray1, ToPyArray};
use pyo3::prelude::*;

#[pyclass]
#[derive(Clone, Debug)]
#[derive(Clone, Debug, PartialEq)]
/// State Vector for the system
pub struct StateVec {
vec: Array1<Complex64>,
Expand Down

0 comments on commit c1034dc

Please sign in to comment.