From 06580381570d037e3031ba2ba93ae8f56e90c7fd Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Thu, 30 Jan 2025 09:57:08 -0600 Subject: [PATCH 1/3] feat: const for ERFC_HALF --- src/consts.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/consts.rs b/src/consts.rs index 32e83a64..21cae7b9 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -26,3 +26,6 @@ pub const EULER_MASCHERONI: f64 = /// Targeted accuracy instantiated over `f64` pub const ACC: f64 = 10e-11; + +/// Constant representing erf_inv(0.5) = erfc_inv(0.5) +pub const ERFC_HALF: f64 = 0.4769362762044698733814183536431305598089697490594706447038826959193; From dded4e92c56368119765844f0de5b63b1256d6cc Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Thu, 30 Jan 2025 09:57:54 -0600 Subject: [PATCH 2/3] feat: use const instead of literal evaluation in Levy --- src/distribution/levy.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/distribution/levy.rs b/src/distribution/levy.rs index 88208e8b..7b62d2b1 100644 --- a/src/distribution/levy.rs +++ b/src/distribution/levy.rs @@ -1,7 +1,7 @@ use crate::distribution::{Continuous, ContinuousCDF}; use crate::function::erf::{erf, erfc, erfc_inv}; -use crate::statistics::*; +use crate::{consts, statistics::*}; use core::f64; /// Implements the [Levy](https://en.wikipedia.org/wiki/L%C3%A9vy_distribution) distribution. @@ -273,7 +273,7 @@ impl Median for Levy { /// where `μ` is the mean, `c` is the dispersion and `erfc_inv` is /// the inverse of the complementary error function. fn median(&self) -> f64 { - self.mu + self.c * 0.5 * erfc_inv(0.5).powf(-2.0) + self.mu + self.c * 0.5 * consts::ERFC_HALF.powf(-2.0) } } From cd2f98e492e0b1a0daa676f4e506db69eddf96ee Mon Sep 17 00:00:00 2001 From: Orion Yeung <11580988+orionyeung001@users.noreply.github.com> Date: Tue, 1 Apr 2025 15:56:02 -0500 Subject: [PATCH 3/3] ci: allow tests to run even if cannot build benches --- .github/workflows/test.yml | 38 ++++++++++++++++++++++++++++++++++++-- 1 file changed, 36 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 65d901eb..7ec612c1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -47,19 +47,53 @@ jobs: - name: Build (lib only) run: cargo hack check --rust-version --locked - test: + build-unit: needs: [clippy, fmt, msrv] runs-on: ${{ matrix.os }} strategy: matrix: os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + - name: Build unit tests + run: cargo test --lib --bins --no-run + + build-integration: + needs: [clippy, fmt, msrv] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + - name: Build integration tests + run: cargo test --tests --no-run + build-benches: + needs: [clippy, fmt, msrv] + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Install Rust stable uses: dtolnay/rust-toolchain@stable + - name: Build benchmarks + run: cargo test --benches --no-run - - name: Test default features + run-tests: + needs: [build-unit, build-integration] + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v4 + - name: Install Rust stable + uses: dtolnay/rust-toolchain@stable + - name: Run all tests run: cargo test features: