From 6294c673587cfcb4f4229a64781c1b8b1139a4a1 Mon Sep 17 00:00:00 2001 From: Brent Westbrook <36778786+ntBre@users.noreply.github.com> Date: Sat, 30 Nov 2024 15:32:28 -0500 Subject: [PATCH] Remove nightly requirement (#147) * bump tensor * move benchmarks to benches to avoid nightly requirement * fix imports * remove toolchain * lint * bench needs nightly * remove allow(dead_code) --- Cargo.lock | 4 ++-- Makefile | 2 +- spectro/{src/tests/bench.rs => benches/main.rs} | 9 ++++++++- spectro/rust-toolchain.toml | 2 -- spectro/src/consts.rs | 3 +-- spectro/src/lib.rs | 1 - spectro/src/tests.rs | 1 - spectro/src/utils.rs | 7 +++++-- 8 files changed, 17 insertions(+), 12 deletions(-) rename spectro/{src/tests/bench.rs => benches/main.rs} (92%) delete mode 100644 spectro/rust-toolchain.toml diff --git a/Cargo.lock b/Cargo.lock index 1e89a8f..112a53d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1,6 +1,6 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. -version = 3 +version = 4 [[package]] name = "anstream" @@ -354,7 +354,7 @@ dependencies = [ [[package]] name = "tensor" version = "0.1.0" -source = "git+https://github.com/ntBre/tensor#c58afe5b120636db285bfc41787123d4cfef0130" +source = "git+https://github.com/ntBre/tensor#b7331cbf697d51ce7fbf8d41de55229f0cfeaa77" dependencies = [ "approx", ] diff --git a/Makefile b/Makefile index 28f35c5..06722e8 100644 --- a/Makefile +++ b/Makefile @@ -8,7 +8,7 @@ test: cargo test --workspace ${TESTFLAGS} ${ARGS} bench: - cargo bench ${TESTFLAGS} ${ARGS} + cargo +nightly bench ${TESTFLAGS} ${ARGS} clippy: cargo clippy --workspace --tests diff --git a/spectro/src/tests/bench.rs b/spectro/benches/main.rs similarity index 92% rename from spectro/src/tests/bench.rs rename to spectro/benches/main.rs index 7491c41..5e08ac2 100644 --- a/spectro/src/tests/bench.rs +++ b/spectro/benches/main.rs @@ -1,4 +1,11 @@ -use super::*; +#![feature(test)] + +use spectro::{ + consts::FACT2, + load_fc2, load_fc3, load_fc4, + utils::{self, force3, force4, load_vec, to_wavenumbers}, + Spectro, +}; extern crate test; diff --git a/spectro/rust-toolchain.toml b/spectro/rust-toolchain.toml deleted file mode 100644 index 271800c..0000000 --- a/spectro/rust-toolchain.toml +++ /dev/null @@ -1,2 +0,0 @@ -[toolchain] -channel = "nightly" \ No newline at end of file diff --git a/spectro/src/consts.rs b/spectro/src/consts.rs index cb63ce3..5f5b11b 100644 --- a/spectro/src/consts.rs +++ b/spectro/src/consts.rs @@ -10,7 +10,7 @@ pub(crate) const _A0: f64 = 0.52917706; /// says, the base energy unit is mdyne·Å, which is equal to an attojoule. A /// first derivative would be in units mdyne·Å/Å or mdyne, so a second /// derivative is mdyne/Å, and so on. -pub(crate) const FACT2: f64 = 4.359813653 / (0.52917706 * 0.52917706); +pub const FACT2: f64 = 4.359813653 / (0.52917706 * 0.52917706); pub(crate) const FUNIT3: f64 = 4.359813653 / (0.52917706 * 0.52917706 * 0.52917706); @@ -31,7 +31,6 @@ pub(crate) const ALAM: f64 = 4.0e-2 * (PI * PI * CL) / (PH * AVN); pub(crate) const CONST: f64 = 1.0e+02 * (PH * AVN) / (8.0e+00 * PI * PI * CL); /// planck's constant in atomic units? - pub(crate) const PH: f64 = 6.626176; /// pre-computed sqrt of ALAM diff --git a/spectro/src/lib.rs b/spectro/src/lib.rs index 2fbba42..a2bef95 100644 --- a/spectro/src/lib.rs +++ b/spectro/src/lib.rs @@ -1,4 +1,3 @@ -#![cfg_attr(test, feature(test))] #![allow(clippy::too_many_arguments, clippy::needless_range_loop)] use std::{ diff --git a/spectro/src/tests.rs b/spectro/src/tests.rs index c66d73e..b4909be 100644 --- a/spectro/src/tests.rs +++ b/spectro/src/tests.rs @@ -14,7 +14,6 @@ use std::ops::Sub; mod alphaa; mod alphas; -mod bench; mod enrgy; mod force3; mod force4; diff --git a/spectro/src/utils.rs b/spectro/src/utils.rs index 0a8c9d7..d1caec0 100644 --- a/spectro/src/utils.rs +++ b/spectro/src/utils.rs @@ -144,7 +144,11 @@ pub fn to_wavenumbers(freqs: &Dvec) -> Dvec { ) } -pub(crate) fn load_vec

(infile: P) -> Vec +/// Load a whitespace-separated vector from `infile`. +/// +/// Panics if there is an error reading the file or parsing any of the entries +/// as `f64`. +pub fn load_vec

(infile: P) -> Vec where P: AsRef + std::fmt::Debug, { @@ -337,7 +341,6 @@ pub fn make_funds(freq: &Dvec, nvib: usize, xcnst: &Dmat) -> Vec { } /// take a vec of energy: state pairs and print them in SPECTRO's format -#[allow(dead_code)] pub(crate) fn print_vib_states(reng: &[f64], i1sts: &Vec) { println!( "{:^10}{:^20}{:^20}{:>21}",