-
Notifications
You must be signed in to change notification settings - Fork 33
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
Correct inverse plan logic #69
Conversation
Codecov Report
@@ Coverage Diff @@
## master #69 +/- ##
=======================================
Coverage 83.09% 83.09%
=======================================
Files 2 2
Lines 207 207
=======================================
Hits 172 172
Misses 35 35
Continue to review full report at Codecov.
|
Can you explain this? |
It seems like the |
Ah, I see now that those lines were pre-caching Nevertheless, given how the caching is implemented in Fundamentlaly, the issue is that We can either remove the caching or edit the |
In AbstractFFTs.jl/src/definitions.jl Lines 237 to 238 in 3e7d412
I think the whole caching approach is a bit suboptimal as it's not done in a type stable way and hence requires hacks such as the type annotation in 238 it seems. However, if we really think that this is the only valid type for the inverse plan then struct Plan{...,P}
...
pinv::Union{Nothing,P}
end and compute type parameter Additionally, I think it would be reasonable for |
I agree that ideally that hack shouldn't be necessary. But shouldn't that be left to a separate PR? i.e. this discussion seems to be more appropriate for #20 All this PR is doing is getting the test plans to conform to whatever the current design of |
I don't see where the API and implementation of |
Okay. Tonight (or time zone agnostically, in 10 hours) I'll take a stab at modifying things so that |
As you suggested, there was a correctness issue with the plan caching, and fixing that without removing the caching works. I've updated the PR description accordingly. |
@@ -278,7 +278,7 @@ plan_ifft(x::AbstractArray, region; kws...) = | |||
plan_ifft!(x::AbstractArray, region; kws...) = | |||
ScaledPlan(plan_bfft!(x, region; kws...), normalization(x, region)) | |||
|
|||
plan_inv(p::ScaledPlan) = ScaledPlan(plan_inv(p.p), inv(p.scale)) | |||
plan_inv(p::ScaledPlan) = ScaledPlan(inv(p.p), inv(p.scale)) |
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.
So to understand this correctly: that was a bug in the package and when fixing it tests would fail currently (without the changes in test/testplans.jl)?
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.
That's right: changing this without making changes to the test plans caused tests to fail.
I'm not sure to what extent I'd call the original version a bug in the package, but it did lead to ignoring the pinv
field of any plan inside a scaled plan: so for example given a plan P
a new inverse plan would be made for 2 * P
, 3 * P
, 4 * P
, etc., which is why the caches made by the test plans were just ignored.
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.
OK. I just wanted to make sure that this change is covered by the tests, ie that reverting it would cause errors.
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.
LGTM, thank you!
This PR fixes some incorrect caching logic in the test plans. The reason this escaped notice is because
ScaledPlan
usesplan_inv
rather thaninv
. That has been changed too.(Old Description)
There is no need to do the caching in
plan_inv
as it should be handled byAbstractFFTs
. The current logic leads to the following error which is now fixed.