Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit b9c35dd

Browse files
committed
Add an xfail for recent ynf failures
This failed a couple of times recently in CI, once on i686 and once on aarch64-apple: thread 'main' panicked at crates/libm-test/benches/random.rs:76:65: called `Result::unwrap()` on an `Err` value: ynf Caused by: 0: input: (681, 509.90924) (0x000002a9, 0x43fef462) expected: -3.2161271e38 0xff71f45b actual: -inf 0xff800000 1: mismatched infinities thread 'main' panicked at crates/libm-test/benches/random.rs:76:65: called `Result::unwrap()` on an `Err` value: ynf Caused by: 0: input: (132, 50.46604) (0x00000084, 0x4249dd3a) expected: -3.3364996e38 0xff7b02a5 actual: -inf 0xff800000 1: mismatched infinities Add a new override to account for this.
1 parent 1b89158 commit b9c35dd

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

libm/crates/libm-test/src/precision.rs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
use core::f32;
55

66
use CheckBasis::{Mpfr, Musl};
7+
use libm::support::CastFrom;
78
use {BaseName as Bn, Identifier as Id};
89

910
use crate::{BaseName, CheckBasis, CheckCtx, Float, Identifier, Int, TestResult};
@@ -524,7 +525,7 @@ impl MaybeOverride<(i32, f32)> for SpecialCase {
524525
ctx: &CheckCtx,
525526
) -> Option<TestResult> {
526527
match (&ctx.basis, ctx.base_name) {
527-
(Musl, _) => bessel_prec_dropoff(input, ulp, ctx),
528+
(Musl, _) => bessel_prec_dropoff(input, actual, expected, ulp, ctx),
528529

529530
// We return +0.0, MPFR returns -0.0
530531
(Mpfr, BaseName::Jn | BaseName::Yn)
@@ -554,7 +555,7 @@ impl MaybeOverride<(i32, f64)> for SpecialCase {
554555
ctx: &CheckCtx,
555556
) -> Option<TestResult> {
556557
match (&ctx.basis, ctx.base_name) {
557-
(Musl, _) => bessel_prec_dropoff(input, ulp, ctx),
558+
(Musl, _) => bessel_prec_dropoff(input, actual, expected, ulp, ctx),
558559

559560
// We return +0.0, MPFR returns -0.0
560561
(Mpfr, BaseName::Jn | BaseName::Yn)
@@ -569,8 +570,10 @@ impl MaybeOverride<(i32, f64)> for SpecialCase {
569570
}
570571

571572
/// Our bessel functions blow up with large N values
572-
fn bessel_prec_dropoff<F: Float>(
573-
input: (i32, F),
573+
fn bessel_prec_dropoff<F1: Float, F2: Float>(
574+
input: (i32, F1),
575+
actual: F2,
576+
expected: F2,
574577
ulp: &mut u32,
575578
ctx: &CheckCtx,
576579
) -> Option<TestResult> {
@@ -585,6 +588,17 @@ fn bessel_prec_dropoff<F: Float>(
585588
}
586589
}
587590

591+
// Values near infinity sometimes get cut off for us. `ynf(681, 509.90924) = -inf` but should
592+
// be -3.2161271e38.
593+
if ctx.fn_ident == Identifier::Ynf
594+
&& !expected.is_infinite()
595+
&& actual.is_infinite()
596+
&& (expected.abs().to_bits().abs_diff(actual.abs().to_bits())
597+
< F2::Int::cast_from(1_000_000u32))
598+
{
599+
return XFAIL;
600+
}
601+
588602
None
589603
}
590604

0 commit comments

Comments
 (0)