From 51db1469c74b397f1224931d82d3ae1477ba85cd Mon Sep 17 00:00:00 2001 From: Haadi Khan Date: Thu, 25 Jul 2024 11:54:49 -0400 Subject: [PATCH] Updated some accessor method names --- Cargo.lock | 62 ----------------------------------- src/circuit_instruction.rs | 10 +++--- src/quantum_circuit.rs | 13 +++++--- src/quantum_circuit/parser.rs | 2 ++ 4 files changed, 15 insertions(+), 72 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ecd6028..b7fc428 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2,15 +2,6 @@ # It is not intended for manual editing. version = 3 -[[package]] -name = "aho-corasick" -version = "1.1.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" -dependencies = [ - "memchr", -] - [[package]] name = "autocfg" version = "1.3.0" @@ -47,12 +38,6 @@ version = "0.2.155" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" -[[package]] -name = "list-any" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93d1d1b0528cc76bed22884ae4f56f5548d80643f848d6df0c652032f7ca6165" - [[package]] name = "lock_api" version = "0.4.12" @@ -73,21 +58,6 @@ dependencies = [ "rawpointer", ] -[[package]] -name = "memchr" -version = "2.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" - -[[package]] -name = "memmap2" -version = "0.9.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe751422e4a8caa417e13c3ea66452215d7d63e19e604f4980461212f3ae1322" -dependencies = [ - "libc", -] - [[package]] name = "memoffset" version = "0.9.1" @@ -272,13 +242,10 @@ dependencies = [ name = "qiskit-parser" version = "0.1.0" dependencies = [ - "list-any", - "memmap2", "ndarray", "numpy", "operation_macro", "pyo3", - "regex", ] [[package]] @@ -305,35 +272,6 @@ dependencies = [ "bitflags", ] -[[package]] -name = "regex" -version = "1.10.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" -dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", -] - -[[package]] -name = "regex-automata" -version = "0.4.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" -dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", -] - -[[package]] -name = "regex-syntax" -version = "0.8.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" - [[package]] name = "rustc-hash" version = "1.1.0" diff --git a/src/circuit_instruction.rs b/src/circuit_instruction.rs index 348a4f9..6f227b9 100644 --- a/src/circuit_instruction.rs +++ b/src/circuit_instruction.rs @@ -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 { + /// Get the qubit indices the CircuitInstruction acts on. + pub fn qubits(&self) -> &Vec { &self.qubits } - /// Get the classical bits of the CircuitInstruction. - pub fn get_clbits(&self) -> &Vec { + /// Get the clbit indices the CircuitInstruction acts on. + pub fn clbits(&self) -> &Vec { &self.clbits } } \ No newline at end of file diff --git a/src/quantum_circuit.rs b/src/quantum_circuit.rs index ef153a7..e103357 100644 --- a/src/quantum_circuit.rs +++ b/src/quantum_circuit.rs @@ -7,6 +7,7 @@ use crate::{ operations::{Gate, Operation}, }; +#[derive(Debug, PartialEq, Clone)] pub struct QuantumCircuit { instr: Vec, qubits: Vec, @@ -34,15 +35,17 @@ impl QuantumCircuit { } } - pub fn get_instructions(&self) -> &Vec { + pub fn instructions(&self) -> &Vec { &self.instr } - pub fn get_qubits(&self) -> &Vec { + /// Get the qubit objects for the circuit. + pub fn qubits(&self) -> &Vec { &self.qubits } - pub fn get_clbits(&self) -> &Vec { + /// Get the clbit objects for the circuit. + pub fn clbits(&self) -> &Vec { &self.clbits } @@ -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(); @@ -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(); diff --git a/src/quantum_circuit/parser.rs b/src/quantum_circuit/parser.rs index 2599e12..83c3eac 100644 --- a/src/quantum_circuit/parser.rs +++ b/src/quantum_circuit/parser.rs @@ -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,