Skip to content

Commit

Permalink
refactor + linting + updating dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ciaranra committed Feb 1, 2025
1 parent c0b6208 commit da4b5be
Show file tree
Hide file tree
Showing 35 changed files with 563 additions and 334 deletions.
71 changes: 43 additions & 28 deletions Cargo.lock

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

28 changes: 14 additions & 14 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,23 @@ keywords = ["scientific", "quantum", "QEC"]
categories = ["science", "simulation"]

[workspace.dependencies]
rand = "0.9"
rand_chacha = "0.9"
rand_xoshiro = "0.7"
uuid = { version = "1", features = ["v4"] }
pyo3 = "0.23"
rand = "0.8"
rayon = "1"
rand_chacha = "0.3"
rand_xoshiro = "0.6"
clap = { version = "4", features = ["derive"] }
log = "0.4"
env_logger = "0.11"
memmap2 = "0.9"
uuid = { version = "1", features = ["v4"] }
serde = { version = "1", features = ["derive"] }
os_pipe = "1"
lazy_static = "1.5.0"
parking_lot = "0.12.3"
serde_json = "1.0.137"
lazy_static = "1"
parking_lot = "0.12"
serde_json = "1"
num-complex = "0.4"
num-traits = "0.2"
tempfile = "3"
criterion = "0.5"

pecos-core = { version = "0.1.1", path = "crates/pecos-core" }
Expand All @@ -56,13 +55,14 @@ lto = "fat"

[workspace.lints.clippy]
# For more details see: https://doc.rust-lang.org/clippy/lints.html
suspicious = "warn"
complexity = "warn"
perf = "warn"
style = "warn"
pedantic = "warn"
suspicious = { level = "warn", priority = -1 }
complexity = { level = "warn", priority = -1 }
perf = { level = "warn", priority = -1 }
style = { level = "warn", priority = -1 }
pedantic = { level = "warn", priority = -1 }
# restriction = "warn"
cargo = "warn"
cargo = { level = "warn", priority = -1 }
multiple-crate-versions = "allow" # TODO: remove when possible

[workspace.metadata.commands]
test-py = ["./scripts/setup-env.sh", "cargo", "test", "-p", "pecos-python"]
31 changes: 16 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,24 +24,24 @@ installreqs: ## Install Python project requirements to root .venv
# ---------------------------------
.PHONY: build
build: installreqs ## Compile and install for development
cd python/pecos-rslib/ && uv run maturin develop --uv
cd python/quantum-pecos && uv pip install -e .[all]
@unset CONDA_PREFIX && cd python/pecos-rslib/ && uv run maturin develop --uv
@unset CONDA_PREFIX && cd python/quantum-pecos && uv pip install -e .[all]

.PHONY: build-basic
build-basic: installreqs ## Compile and install for development but do not include install extras
cd python/pecos-rslib/ && uv run maturin develop --uv
cd python/quantum-pecos && uv pip install -e .
@unset CONDA_PREFIX && cd python/pecos-rslib/ && uv run maturin develop --uv
@unset CONDA_PREFIX && cd python/quantum-pecos && uv pip install -e .

.PHONY: build-release
build-release: installreqs ## Build a faster version of binaries
cd python/pecos-rslib/ && uv run maturin develop --uv --release
cd python/quantum-pecos && uv pip install -e .[all]
@unset CONDA_PREFIX && cd python/pecos-rslib/ && uv run maturin develop --uv --release
@unset CONDA_PREFIX && cd python/quantum-pecos && uv pip install -e .[all]

.PHONY: build-native
build-native: installreqs ## Build a faster version of binaries with native CPU optimization
cd python/pecos-rslib/ && RUSTFLAGS='-C target-cpu=native' \
@unset CONDA_PREFIX && cd python/pecos-rslib/ && RUSTFLAGS='-C target-cpu=native' \
&& uv run maturin develop --uv --release
cd python/quantum-pecos && uv pip install -e .[all]
@unset CONDA_PREFIX && cd python/quantum-pecos && uv pip install -e .[all]

# Documentation
# -------------
Expand Down Expand Up @@ -79,14 +79,15 @@ rstest: ## Run Rust tests
.PHONY: pytest
pytest: ## Run tests on the Python package (not including optional dependencies). ASSUMES: previous build command
uv run pytest ./python/tests/ -m "not optional_dependency"
uv run pytest ./python/pecos-rslib/tests/

.PHONY: pytest-dep
pytest-dep: ## Run tests on the Python package only for optional dependencies. ASSUMES: previous build command
uv run pytest ./python/tests/ -m optional_dependency

.PHONY: pytest-all
pytest-all: ## Run all tests on the Python package ASSUMES: previous build command
uv run pytest ./python/tests/
pytest-all: pytest ## Run all tests on the Python package ASSUMES: previous build command
uv run pytest ./python/tests/ -m "optional_dependency"

# .PHONY: pytest-doc
# pydoctest: ## Run doctests with pytest. ASSUMES: A build command was ran previously. ASSUMES: previous build command
Expand All @@ -103,13 +104,13 @@ test: rstest pytest-all ## Run all tests. ASSUMES: previous build command
clean: ## Clean up caches and build artifacts
@rm -rf *.egg-info
@rm -rf dist
@rm -rf **/build/
@find . -type d -name "build" -exec rm -rf {} +
@rm -rf python/docs/_build
@rm -rf **/.pytest_cache/
@rm -rf **/.ipynb_checkpoints
@find . -type d -name ".pytest_cache" -exec rm -rf {} +
@find . -type d -name ".ipynb_checkpoints" -exec rm -rf {} +
@rm -rf .ruff_cache/
@rm -rf **/.hypothesis/
@rm -rf **/junit/
@find . -type d -name ".hypothesis" -exec rm -rf {} +
@find . -type d -name "junit" -exec rm -rf {} +
@cargo clean

.PHONY: pip-install-uv
Expand Down
1 change: 0 additions & 1 deletion crates/benchmarks/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ publish = false
[dev-dependencies]
criterion = { workspace = true }
pecos = { workspace = true }
pecos-core = { workspace = true }

[[bench]]
name = "benchmarks"
Expand Down
1 change: 1 addition & 0 deletions crates/pecos-cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ fn detect_program_type(path: &Path) -> Result<ProgramType, Box<dyn Error>> {
}
}

#[allow(clippy::upper_case_acronyms)]
enum ProgramType {
QIR,
PHIR,
Expand Down
1 change: 0 additions & 1 deletion crates/pecos-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ rand_chacha = { workspace = true }
rand_xoshiro = { workspace = true }
num-traits = { workspace = true }
num-complex = { workspace = true }
log = { workspace = true }
serde = { workspace = true, features = ["derive"] }

[lints]
Expand Down
18 changes: 9 additions & 9 deletions crates/pecos-core/src/angle.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,9 +975,9 @@ mod tests {

#[test]
fn test_randomized_values_u32_to_u64() {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
for _ in 0..1000 {
let random_u32: u32 = rng.gen();
let random_u32: u32 = rng.random();
let angle_u32 = Angle::<u32>::new(random_u32);
let converted: Angle<u64> = angle_u32.into();
let back: Angle<u32> = converted.try_into().expect("Lossless conversion failed");
Expand All @@ -987,9 +987,9 @@ mod tests {

#[test]
fn test_randomized_values_u64_to_u32() {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();
for _ in 0..1000 {
let random_u64: u64 = rng.gen();
let random_u64: u64 = rng.random();
let angle_u64 = Angle::<u64>::new(random_u64);
let result: Result<Angle<u32>, _> = angle_u64.try_into();
if u32::try_from(random_u64).is_ok() {
Expand Down Expand Up @@ -1314,28 +1314,28 @@ mod tests {

#[test]
fn test_randomized_conversions() {
let mut rng = rand::thread_rng();
let mut rng = rand::rng();

for _ in 0..1000 {
let val_u8: u8 = rng.gen();
let val_u8: u8 = rng.random();
let angle = Angle::<u8>::new(val_u8);
let up: Angle<u16> = angle.into();
let down: Angle<u8> = up.try_into().expect("Lossless downscaling failed");
assert_eq!(angle, down);

let val_u16: u16 = rng.gen();
let val_u16: u16 = rng.random();
let angle = Angle::<u16>::new(val_u16);
let up: Angle<u32> = angle.into();
let down: Angle<u16> = up.try_into().expect("Lossless downscaling failed");
assert_eq!(angle, down);

let val_u32: u32 = rng.gen();
let val_u32: u32 = rng.random();
let angle = Angle::<u32>::new(val_u32);
let up: Angle<u64> = angle.into();
let down: Angle<u32> = up.try_into().expect("Lossless downscaling failed");
assert_eq!(angle, down);

let val_u64: u64 = rng.gen();
let val_u64: u64 = rng.random();
let angle = Angle::<u64>::new(val_u64);
let up: Angle<u128> = angle.into();
let down: Angle<u64> = up.try_into().expect("Lossless downscaling failed");
Expand Down
1 change: 0 additions & 1 deletion crates/pecos-core/src/sims_rngs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,5 @@
pub mod chacha_rng;
pub mod choices;
pub mod cyclic_rng;
// pub mod mock_rng;
pub mod sim_rng;
pub mod xoshiro_rng;
Loading

0 comments on commit da4b5be

Please sign in to comment.