mod architecture;
mod basis_changer;
mod compile;
pub mod language;
pub mod operation;
pub mod optimize;
pub mod small_angle;
use std::{error::Error, path::Path};
pub use architecture::PathArchitecture;
use bicycle_cliffords::CompleteMeasurementTable;
pub fn deserialize_table(cache_path: &Path) -> Result<CompleteMeasurementTable, Box<dyn Error>> {
let read = std::fs::read(cache_path)?;
Ok(bitcode::deserialize::<CompleteMeasurementTable>(&read)?)
}
#[cfg(test)]
mod test {
use std::error::Error;
use crate::language::{AnglePrecision, PbcOperation};
use super::*;
use bicycle_cliffords::{
MeasurementTableBuilder, TWOGROSS_MEASUREMENT, native_measurement::NativeMeasurement,
};
use operation::Operations;
#[test]
fn integration_test_rotation() -> Result<(), Box<dyn Error>> {
let program = r#"[
{
"Rotation": {
"basis": [
"X",
"X",
"I",
"I",
"I",
"I",
"I",
"I",
"I",
"I",
"I",
"Y"
],
"angle": "0.125"
}
}
]"#;
let parsed: Vec<PbcOperation> = serde_json::from_str(program)?;
dbg!(&parsed);
assert_eq!(1, parsed.len());
let mut builder =
MeasurementTableBuilder::new(NativeMeasurement::all(), TWOGROSS_MEASUREMENT);
builder.build();
let measurement_table = builder.complete()?;
let architecture = PathArchitecture { data_blocks: 2 };
let compiled: Vec<_> = parsed
.into_iter()
.flat_map(|op| {
op.compile(
&architecture,
&measurement_table,
AnglePrecision::lit("1e-16"),
)
})
.collect();
let ops = Operations(compiled);
println!("{ops}");
Ok(())
}
}