-
Notifications
You must be signed in to change notification settings - Fork 154
Added furlongs test #758
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
base: master
Are you sure you want to change the base?
Added furlongs test #758
Conversation
5a38c38 to
d75ad63
Compare
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #758 +/- ##
=======================================
Coverage 90.73% 90.73%
=======================================
Files 11 11
Lines 1069 1069
=======================================
Hits 970 970
Misses 99 99 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
Seems fine, but is this expected to pass without #665 ? (I would add a big comment linking to Base to explain which code is copied, and which is new tests.) |
|
Not sure, just trying to get the ball rolling :-) @longemen3000 suggested to add this test as a separate PR. Thoughts, @devmotion? |
devmotion
left a comment
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.
test/DerivativeTest.jl
Outdated
| Base.exp(f::Furlongs.Furlong) = exp(f.val) | ||
| Base.cos(f::Furlongs.Furlong) = cos(f.val) | ||
| Base.sin(f::Furlongs.Furlong) = sin(f.val) |
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.
Similar to unitful quantities, shouldn't these only be defined for dimensionless furlongs?
| Base.exp(f::Furlongs.Furlong) = exp(f.val) | |
| Base.cos(f::Furlongs.Furlong) = cos(f.val) | |
| Base.sin(f::Furlongs.Furlong) = sin(f.val) | |
| Base.exp(f::Furlongs.Furlong{0}) = exp(f.val) | |
| Base.cos(f::Furlongs.Furlong{0}) = cos(f.val) | |
| Base.sin(f::Furlongs.Furlong{0}) = sin(f.val) |
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.
Undid this, as it made the tests fail
|
Bump 🙂 |
|
@devmotion I've added a test that demonstrates the issue outlined in https://github.com/JuliaPhysics/Measurements.jl/pull/178/files/2a41c0cd440def23343d2565ff407eb47916d854#diff-0fafde266294d0a69e0589d46875ecceac83951c1d9a1ae32c084753539ec319R10-R22 - which is fixed by #665 |
Co-authored-by: David Widmann <[email protected]>
…sionless Furlongs
d29dacf to
af8176e
Compare
|
|
||
| f(x) = exp(x) + 4*sin(x)*oneunit(x) | ||
|
|
||
| @test ForwardDiff.derivative(f, furlong) == exp(furlong) + 4*cos(furlong) |
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.
Would any of gradient etc fail for Furlongs? If construct_seeds errors, it should also be possible to provoke errors in user-facing functions, and testing the latter seems much more relevant and future-proof than testing an internal function.
| Base.exp(f::Furlongs.Furlong) = exp(f.val) | ||
| Base.cos(f::Furlongs.Furlong) = cos(f.val) | ||
| Base.sin(f::Furlongs.Furlong) = sin(f.val) |
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.
These still don't seem reasonable to me - IMO they only exist for dimensionless numbers (ie Furlong{0}). This is also how they're defined in Unitful IIRC.
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.
Cf. #758 (comment)
The test currently entails exp etc. being defined for ::Furlongs.Furlong{2, Float64}`:
https://github.com/JuliaDiff/ForwardDiff.jl/actions/runs/17889140228/job/50867233017#step:6:156
If my comment makes no sense, please elaborate on what is unreasonable - I'm quite sure I may not have understood what you mean.
Added furlongs test - with
Furlongs.jlcopied from test/testhelpers in julia - implementing suggestion described in #665 (comment)