Skip to content

Commit

Permalink
Merge pull request #415 from tgross35/domain-multiple-dimensions
Browse files Browse the repository at this point in the history
Replace `HasDomain` to enable multi-argument edge case and domain tests
  • Loading branch information
tgross35 authored Jan 16, 2025
2 parents d0eb897 + 2fab7e0 commit 8ded576
Show file tree
Hide file tree
Showing 15 changed files with 669 additions and 520 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
jobs:
test:
name: Build and test
timeout-minutes: 25
timeout-minutes: 40
strategy:
fail-fast: false
matrix:
Expand Down
4 changes: 2 additions & 2 deletions crates/libm-test/benches/random.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::time::Duration;
use criterion::{Criterion, criterion_main};
use libm_test::gen::random;
use libm_test::gen::random::RandomInput;
use libm_test::{CheckBasis, CheckCtx, MathOp, TupleCall};
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, TupleCall};

/// Benchmark with this many items to get a variety
const BENCH_ITER_ITEMS: usize = if cfg!(feature = "short-benchmarks") { 50 } else { 500 };
Expand Down Expand Up @@ -52,7 +52,7 @@ where
{
let name = Op::NAME;

let ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Musl);
let ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Musl, GeneratorKind::Random);
let benchvec: Vec<_> =
random::get_test_cases::<Op::RustArgs>(&ctx).take(BENCH_ITER_ITEMS).collect();

Expand Down
28 changes: 9 additions & 19 deletions crates/libm-test/examples/plot_domains.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@ use std::path::Path;
use std::process::Command;
use std::{env, fs};

use libm_test::domain::HasDomain;
use libm_test::gen::{domain_logspace, edge_cases};
use libm_test::{CheckBasis, CheckCtx, MathOp, op};
use libm_test::gen::spaced::SpacedInput;
use libm_test::gen::{edge_cases, spaced};
use libm_test::{CheckBasis, CheckCtx, GeneratorKind, MathOp, op};

const JL_PLOT: &str = "examples/plot_file.jl";

Expand Down Expand Up @@ -52,23 +52,13 @@ fn main() {
/// Run multiple generators for a single operator.
fn plot_one_operator<Op>(out_dir: &Path, config: &mut String)
where
Op: MathOp<FTy = f32> + HasDomain<f32>,
Op: MathOp<FTy = f32, RustArgs = (f32,)>,
Op::RustArgs: SpacedInput<Op>,
{
let ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr);
plot_one_generator(
out_dir,
&ctx,
"logspace",
config,
domain_logspace::get_test_cases::<Op>(&ctx),
);
plot_one_generator(
out_dir,
&ctx,
"edge_cases",
config,
edge_cases::get_test_cases::<Op, _>(&ctx),
);
let mut ctx = CheckCtx::new(Op::IDENTIFIER, CheckBasis::Mpfr, GeneratorKind::QuickSpaced);
plot_one_generator(out_dir, &ctx, "logspace", config, spaced::get_test_cases::<Op>(&ctx).0);
ctx.gen_kind = GeneratorKind::EdgeCases;
plot_one_generator(out_dir, &ctx, "edge_cases", config, edge_cases::get_test_cases::<Op>(&ctx));
}

/// Plot the output of a single generator.
Expand Down
Loading

0 comments on commit 8ded576

Please sign in to comment.