Skip to content

Conversation

@stemann
Copy link

@stemann stemann commented Jul 28, 2025

Added furlongs test - with Furlongs.jl copied from test/testhelpers in julia - implementing suggestion described in #665 (comment)

@stemann stemann force-pushed the feature/furlongs_test branch 2 times, most recently from 5a38c38 to d75ad63 Compare July 28, 2025 11:56
@codecov
Copy link

codecov bot commented Jul 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.73%. Comparing base (a7991dd) to head (af8176e).

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@mcabbott
Copy link
Member

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.)

@stemann
Copy link
Author

stemann commented Jul 30, 2025

Not sure, just trying to get the ball rolling :-) @longemen3000 suggested to add this test as a separate PR.

Thoughts, @devmotion?

Copy link
Member

@devmotion devmotion left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm surprised tests are passing without #665 - it seems the tests might not cover the problem addressed by #665? It would be good to add a broken test that demonstrates the issue that #665 is supposed to fix.

Comment on lines 118 to 120
Base.exp(f::Furlongs.Furlong) = exp(f.val)
Base.cos(f::Furlongs.Furlong) = cos(f.val)
Base.sin(f::Furlongs.Furlong) = sin(f.val)
Copy link
Member

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?

Suggested change
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)

Copy link
Author

@stemann stemann Sep 21, 2025

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

@giordano
Copy link

Bump 🙂

@stemann
Copy link
Author

stemann commented Sep 21, 2025

@stemann stemann requested a review from devmotion November 14, 2025 07:21
@stemann stemann force-pushed the feature/furlongs_test branch from d29dacf to af8176e Compare November 14, 2025 07:25

f(x) = exp(x) + 4*sin(x)*oneunit(x)

@test ForwardDiff.derivative(f, furlong) == exp(furlong) + 4*cos(furlong)
Copy link
Member

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.

Comment on lines +110 to +112
Base.exp(f::Furlongs.Furlong) = exp(f.val)
Base.cos(f::Furlongs.Furlong) = cos(f.val)
Base.sin(f::Furlongs.Furlong) = sin(f.val)
Copy link
Member

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.

Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants