Closed alexjaffray closed 2 years ago
looping in @tknopp
Merging #231 (7e0ad26) into main (1341c7c) will decrease coverage by
0.10%
. The diff coverage is50.00%
.
@@ Coverage Diff @@
## main #231 +/- ##
==========================================
- Coverage 97.71% 97.61% -0.11%
==========================================
Files 13 13
Lines 964 965 +1
==========================================
Hits 942 942
- Misses 22 23 +1
Impacted Files | Coverage Δ | |
---|---|---|
src/abstract.jl | 98.76% <50.00%> (-1.24%) |
:arrow_down: |
Continue to review full report at Codecov.
Legend - Click here to learn more
Δ = absolute <relative> (impact)
,ø = not affected
,? = missing data
Powered by Codecov. Last update 1341c7c...7e0ad26. Read the comment docs.
Hi, I wrote storage_type(op::LinearOperator) = typeof(op.Mv5)
because if you want to create a new type such as NewLinearOperator <: AbstractLinearOperator
which does not have a field Mv5
, it leads to an error.
With your solution the tests passed because I wrote a storage_type
method for the other LinearOperators types defined in this package (such as AdjointLinearOperator
etc...).
I see three solutions here:
Mv5
(or write a new storage_type
method in case it does not),storage_type
method,storage_type(op::AbstractLinearOperator{T}) where T = Vector{T}
so that when storage_type
is not defined for a NewLinearOperator <: AbstractLinearOperator
it defaults to CPU vectors.@dpo which one do you prefer? For info I think that the storage_type
function is only useful when using the 5-args mul!
with 3-args mul!
defined operators (requires also at least a Mv5
field to work), and when creating operators with BlockDiagonalOperator
For info I think that the
storage_type
function is only useful when using the 5-argsmul!
with 3-argsmul!
defined operators (requires also at least aMv5
field to work), and when creating operators withBlockDiagonalOperator
As far as I can tell in src/operations.jl, the storage_type function is called whenever two operators are multiplied together, requiring the Mv5 field regardless.
Oh yes sorry I forgot about these calls in operations.jl. However I think operations between operators could still work if they did not have the Mv5
field (at least if they are defined with the 5-args mul!
) as long as storage_type
is implemented. I've only used the types created in this package until now, but I can try to create a new operator type and see what works and what does not.
I can try to create a new operator type and see what works and what does not.
@geoffroyleconte That sounds like a good plan until a way forward is determined. The main thing to test is that any operator without a Mv5 field never gets accidentally queried for it (i.e, the base storage_type
doesn't get called on it).
I think the easiest thing (as you proposed earlier) would be to require a storage_type
method definition as part of the interface, and just document the interface requirements for people who rely on the package.
@geoffroyleconte did you get a chance to try a new operator type yet and play around.
If you didn't, I'm thinking probably the best thing to do is just to require that one defines a storage_type method for their custom operator types, and document the interface. If you agree with this, then feel free to close this PR.
How about something like
storage_type(op::AbstractLinearOperator) = error("please implement storage_type for $(typeof(op))")
storage_type(op::LinearOperator) = typeof(op.Mv5)
Yes I think that's a good idea
I agree @geoffroyleconte , @dpo , I have added it in to the commit
Thank you!
For externally defined operator types (i.e NFFTOp in MRIReco.jl) the following error is encountered:
The proposed change seems to fix the issue, but I was wondering if the function argument being the base LinearOperator type was a design decision (since we can also fix the issue by locally overloading the LinearOperator.storage_type function for each external operator).