-
Notifications
You must be signed in to change notification settings - Fork 97
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix #283: add possibility to include num-traits/libm for sin and cos … #309
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR! I kicked off the build. I expect we'll see a couple errors come up from that.
597a19e
to
f82bc45
Compare
Fixed yet another bug, now it could work |
Probably this is still not ready, I got some errors (even so the test suite runs through flawlesly:
|
What command did you run to get that error? |
I got this from running cargo build from a project where I use |
Anyway, I replaced the three offending instances of freestanding calls to the float functions with explicit mentioning of the |
8c95444
to
d874465
Compare
@iliekturtles Ok, now I could use your help. Never worked with |
diff --git a/.github/workflows/ci-full-test-suite.yml b/.github/workflows/ci-full-test-suite.yml
index 8d6c70f..2d70e0f 100644
--- a/.github/workflows/ci-full-test-suite.yml
+++ b/.github/workflows/ci-full-test-suite.yml
@@ -48,7 +48,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
- args: --verbose --no-default-features --features "autoconvert f32 si use_serde"
+ args: --verbose --no-default-features --features "autoconvert f32 si use_serde libm"
- name: Test si with underlying storage types
uses: actions-rs/cargo@v1
diff --git a/src/system.rs b/src/system.rs
index 05ac4ef..e68bc37 100644
--- a/src/system.rs
+++ b/src/system.rs
@@ -841,7 +841,7 @@ macro_rules! system {
Quantity {
dimension: $crate::lib::marker::PhantomData,
units: $crate::lib::marker::PhantomData,
- value: $crate::num_traits::Float::cbrt(self.value),
+ value: self.value.cbrt(),
}
}
@@ -907,7 +907,7 @@ macro_rules! system {
Quantity {
dimension: $crate::lib::marker::PhantomData,
units: $crate::lib::marker::PhantomData,
- value: $crate::num_traits::Float::powi(self.value, E::to_i32()),
+ value: self.value.powi(E::to_i32()),
}
}
@@ -945,7 +945,7 @@ macro_rules! system {
Quantity {
dimension: $crate::lib::marker::PhantomData,
units: $crate::lib::marker::PhantomData,
- value: $crate::num_traits::Float::sqrt(self.value),
+ value: self.value.sqrt(),
}
}}
}
diff --git a/src/tests/quantity.rs b/src/tests/quantity.rs
index 00ceced..159d8ce 100644
--- a/src/tests/quantity.rs
+++ b/src/tests/quantity.rs
@@ -468,7 +468,7 @@ mod float {
Test::assert_eq(&3.3.fract(), &m1.fract::<kilogram>().get::<kilogram>());
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
quickcheck! {
#[allow(trivial_casts)]
fn hypot_same(l: V, r: V) -> bool {
@@ -477,7 +477,7 @@ mod float {
}
}
- #[cfg(all(feature = "std", feature = "autoconvert"))]
+ #[cfg(all(any(feature = "std", feature = "libm"), feature = "autoconvert"))]
quickcheck! {
#[allow(trivial_casts)]
fn hypot_mixed(l: V, r: V) -> bool {
diff --git a/src/tests/system.rs b/src/tests/system.rs
index 1b5399f..46aa6dc 100644
--- a/src/tests/system.rs
+++ b/src/tests/system.rs
@@ -286,7 +286,7 @@ mod float {
v.classify() == Length::new::<meter>(*v).classify()
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn cbrt(v: A<V>) -> bool {
let l: Quantity<Q<P1, Z0, Z0>, U<V>, V> = Quantity::<Q<P3, Z0, Z0>, U<V>, V> {
@@ -298,7 +298,7 @@ mod float {
Test::eq(&v.cbrt(), &l.value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn hypot(l: A<V>, r: A<V>) -> bool {
Test::eq(&Length::new::<meter>(l.hypot(*r)),
@@ -315,7 +315,7 @@ mod float {
v.is_sign_negative() == Length::new::<meter>(*v).is_sign_negative()
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn mul_add(s: A<V>, a: A<V>, b: A<V>) -> bool {
let r: Quantity<Q<P2, Z0, Z0>, U<V>, V> = Length::new::<meter>(*s).mul_add(
@@ -340,13 +340,13 @@ mod float {
Test::eq(&v.recip(), &a.value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn powi(v: A<V>) -> bool {
Test::eq(&v.powi(3), &Length::new::<meter>(*v).powi(P3::new()).value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn sqrt(v: A<V>) -> TestResult {
if *v < V::zero() {
@@ -647,7 +647,7 @@ mod complex {
v.is_normal() == Length::new::<meter>(*v).is_normal()
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn cbrt(v: A<V>) -> bool {
let l: Quantity<Q<P1, Z0, Z0>, U<V>, V> = Quantity::<Q<P3, Z0, Z0>, U<V>, V> {
@@ -659,7 +659,7 @@ mod complex {
Test::eq(&v.cbrt(), &l.value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn mul_add(s: A<V>, a: A<V>, b: A<V>) -> bool {
#[allow(unused_imports)]
@@ -676,13 +676,13 @@ mod complex {
Test::eq(&s.mul_add(*a, *b), &r.value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn powi(v: A<V>) -> bool {
Test::eq(&v.powi(3), &Length::new::<meter>(*v).powi(P3::new()).value)
}
- #[cfg(feature = "std")]
+ #[cfg(any(feature = "std", feature = "libm"))]
#[allow(trivial_casts)]
fn sqrt(v: A<V>) -> TestResult {
let l: Quantity<Q<P1, Z0, Z0>, U<V>, V> = Quantity::<Q<P2, Z0, Z0>, U<V>, V> { |
e5db28d
to
92834dc
Compare
@iliekturtles I applied the (unfortunately broken) patch, and rebased. Unfortunately some test still fail, now due to stack-overflows. It's not obvious to me what causes the stack-overflow. Possibly a recursion for the proxied functions, such as |
Sounds like the proxy is calling itself instead of proxying the underlying function. Turbofish, like shown below, or explicitly using the full namespace to the function should resolve. I kicked off the builds to see which functions are having an issue. Lines 544 to 546 in 7c4b27b
|
Codecov Report
@@ Coverage Diff @@
## master #309 +/- ##
==========================================
+ Coverage 97.52% 97.75% +0.22%
==========================================
Files 67 89 +22
Lines 3035 3338 +303
==========================================
+ Hits 2960 3263 +303
Misses 75 75
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
But why do some tests succeeed without having the expicit Edit: So havin this, it still stack-overflows: Angle::new::<radian>(<V as crate::num::Float>::atan2(self.value, other.value)) To pinpoint which test caused the overflow, I disabled threading for tests:
yields
|
I tried running with |
I tried letting the run sit for a while with |
I let an instance of Edit: Edit 2: quickcheck::tester::{impl#13}::result::shrink_failure<bool, f32, f32> (g=0x7fffffffaa80, self_=0x5555564226a0 <uom::si::angle::tests::trig::f32::atan2::prop>, a=...) takes forever. Edit 3: |
@iliekturtles I now understand the issue, I believe. Our problem is twofold. For one, quickcheck does weird things, when a test fails. But why do tests fail? We are checking the outputs of rusts std lib and |
@wucke13 Sorry for the delay in responding. I've had the tab open for a while never quite get to it. Yes, if |
Yes, I believe that is just BurntSushi/quickcheck#295 I guess.f
I'll try to implement it. Edit: |
7dce87a
to
80c05d4
Compare
80c05d4
to
dde1217
Compare
fix in rust-lang/libm#275 |
dde1217
to
b43eed6
Compare
Thanks for the latest update. Some errors in the build. I have a busy weekend coming up but will see if I can track down where they're coming from. |
129b9f6
to
14ba2c2
Compare
@iliekturtles Do you see any chance we get this merged in the closer future? |
…in no_std builds