Skip to content

Commit

Permalink
Updated some accessor method names
Browse files Browse the repository at this point in the history
  • Loading branch information
Haadi-Khan committed Jul 25, 2024
1 parent 359b36b commit 51db146
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 72 deletions.
62 changes: 0 additions & 62 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions src/circuit_instruction.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ impl CircuitInstruction {
}

/// Get the operation of the CircuitInstruction.
pub fn get_operation(&self) -> &Operation {
pub fn operation(&self) -> &Operation {
&self.operation
}

/// Get the qubits of the CircuitInstruction.
pub fn get_qubits(&self) -> &Vec<usize> {
/// Get the qubit indices the CircuitInstruction acts on.
pub fn qubits(&self) -> &Vec<usize> {
&self.qubits
}

/// Get the classical bits of the CircuitInstruction.
pub fn get_clbits(&self) -> &Vec<usize> {
/// Get the clbit indices the CircuitInstruction acts on.
pub fn clbits(&self) -> &Vec<usize> {
&self.clbits
}
}
13 changes: 8 additions & 5 deletions src/quantum_circuit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ use crate::{
operations::{Gate, Operation},
};

#[derive(Debug, PartialEq, Clone)]
pub struct QuantumCircuit {
instr: Vec<CircuitInstruction>,
qubits: Vec<Qubit>,
Expand Down Expand Up @@ -34,15 +35,17 @@ impl QuantumCircuit {
}
}

pub fn get_instructions(&self) -> &Vec<CircuitInstruction> {
pub fn instructions(&self) -> &Vec<CircuitInstruction> {
&self.instr
}

pub fn get_qubits(&self) -> &Vec<Qubit> {
/// Get the qubit objects for the circuit.
pub fn qubits(&self) -> &Vec<Qubit> {
&self.qubits
}

pub fn get_clbits(&self) -> &Vec<Clbit> {
/// Get the clbit objects for the circuit.
pub fn clbits(&self) -> &Vec<Clbit> {
&self.clbits
}

Expand Down Expand Up @@ -74,7 +77,7 @@ mod tests {

let qc = QuantumCircuit::new(input.to_string(), None);

let instructions = qc.get_instructions();
let instructions = qc.instructions();
assert_eq!(instructions.len(), 1);

let instr = instructions.get(0).unwrap();
Expand All @@ -92,7 +95,7 @@ mod tests {

let qc = QuantumCircuit::new(input.to_string(), None);

let instructions = qc.get_instructions();
let instructions = qc.instructions();
assert_eq!(instructions.len(), 2);

let instr = instructions.get(0).unwrap();
Expand Down
2 changes: 2 additions & 0 deletions src/quantum_circuit/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::collections::HashMap;
use ndarray::Array2;
use numpy::Complex64;

/// TODO: Migrate to a standard parser library instead of a custom one (didn't realized these existed before lol)
use crate::{
bit::{AncillaQubit, Bit, BitOps, Clbit, Qubit},
circuit_instruction::CircuitInstruction,
Expand Down

0 comments on commit 51db146

Please sign in to comment.