-
Notifications
You must be signed in to change notification settings - Fork 5
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
Limit Dual to Real primals, replace all Number with Real #95
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #95 +/- ##
=======================================
Coverage 79.62% 79.62%
=======================================
Files 17 17
Lines 702 702
=======================================
Hits 559 559
Misses 143 143 ☔ View full report in Codecov by Sentry. |
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.
I'm not sure we actually need the other changes besides the one I commented on. Would be interested in discussing this.
struct Dual{P<:Number,T<:Union{ConnectivityTracer,GradientTracer,HessianTracer}} <: | ||
struct Dual{P<:Real,T<:Union{ConnectivityTracer,GradientTracer,HessianTracer}} <: |
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.
This is all we need.
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.
I thought so too. But then I ran the tests and found that leaving the ::Number
dispatches led to some method ambiguities, typically between
<=(::Real, ::Real)
<=(::SCT.Dual, ::Number)
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.
I would even argue that it would be more informative to have MethodError
s due to type restrictions occur here rather than in Base.promote_rule
.
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.
See the discussion below, we shouldn't promise complex number support anyway. Tracers are real numbers, and if people want to go beyond they can do Complex{Tracer}
The original motivation for this PR is that #92 introduced a weird edge case:
This PR however removes a lot of functionality from connectivity_pattern(x -> x^(2im), 1) |
Point taken for If we wanted to promise that a complex derivative is zero, derivative would that be anyway? The holomorphic derivative |
However, I note that ForwardDiff doesn't constrain the primal and partial values inside their Still, based on what I understand from previous discussion, the right way to proceed is to make a Related: |
I think however that we should be able to support functions that do |
This I like. I guess this requires adding some new |
The test I added back failed and that's probably the reason, will investigate |
Here's an argument for only supporting real inputs (nevermind the output type):
|
I agree with all of this. My suggestion was that a
|
This would require additional |
But all of this is not something that has to be done in this PR (or has to be done in general until the need for it arises). |
Fix #91 for good