Skip to content

Commit

Permalink
minimize diff
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeeter committed Jul 19, 2024
1 parent 7c0ea98 commit 814b015
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
4 changes: 2 additions & 2 deletions fidget/src/core/context/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ impl Context {
/// # let mut ctx = fidget::context::Context::new();
/// let x = ctx.x();
/// let y = ctx.y();
/// let op = ctx.less_than(x, y).unwrap();
/// let op = ctx.less_than_or_equal(x, y).unwrap();
/// let v = ctx.eval_xyz(op, 0.0, 1.0, 0.0).unwrap();
/// assert_eq!(v, 1.0);
/// let v = ctx.eval_xyz(op, 1.0, 1.0, 0.0).unwrap();
Expand All @@ -751,7 +751,7 @@ impl Context {
let rhs = rhs.into_node(self)?;
let cmp = self.op_binary(rhs, lhs, BinaryOpcode::Compare)?;
let shift = self.add(cmp, 1.0)?;
self.div(shift, 2.0)
self.min(shift, 1.0)
}

/// Builds a node that takes the modulo (least non-negative remainder)
Expand Down
7 changes: 3 additions & 4 deletions fidget/src/core/eval/test/grad_slice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ impl<F: Function + MathFunction> TestGradSlice<F> {
let mut eval = F::new_grad_slice_eval();

for i in 0..3 {
let args_g = args
let args = args
.iter()
.map(|&v| match i {
0 => Grad::new(v, 1.0, 0.0, 0.0),
Expand All @@ -401,9 +401,8 @@ impl<F: Function + MathFunction> TestGradSlice<F> {
_ => unreachable!(),
})
.collect::<Vec<Grad>>();
let out = eval.eval(&tape, &[args_g.as_slice()]).unwrap();

for (a, &o) in args_g.iter().zip(out.iter()) {
let out = eval.eval(&tape, &[args.as_slice()]).unwrap();
for (a, &o) in args.iter().zip(out.iter()) {
let v = C::eval_f64(a.v as f64);
let err = (v as f32 - o.v).abs();
let err_frac = err / (v.abs() as f32).max(o.v.abs());
Expand Down

0 comments on commit 814b015

Please sign in to comment.