Skip to content

Commit

Permalink
Replace HasDomain with a dynamic call that supports multiple arguments
Browse files Browse the repository at this point in the history
This also allows reusing the same generator logic between logspace tests
and extensive tests, so comes with a nice bit of cleanup.

Changes:

* Make the generator part of `CheckCtx` since a `Generator` and
  `CheckCtx` are almost always passed together.
* Rename `domain_logspace` to `spaced` since this no longer only
  operates within a domain and we may want to handle integer spacing.
* Domain is now calculated at runtime rather than using traits, which is
  much easier to work with.
  • Loading branch information
tgross35 committed Jan 13, 2025
1 parent b8005ac commit fd76e4f
Show file tree
Hide file tree
Showing 12 changed files with 512 additions and 499 deletions.
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 fd76e4f

Please sign in to comment.