-
Notifications
You must be signed in to change notification settings - Fork 9
Using RecursiveArrayTools #8
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
Conversation
|
I would take the occasion to remove Julia 0.7 from Travis, and putting 1.1 instead |
lostella
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.
Looks like there are more occurrences of Tuple{AbstractArray} around to get rid of.
But in general adopting ArrayPartition seems to lead to much simpler code in many parts already!
src/AbstractOperators.jl
Outdated
| NonLinearOperator, | ||
| AbstractOperator | ||
| # from other packages | ||
| export ArrayPartition, mul! |
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.
Why these exports?
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.
they are not necessary, but quite practical when you load the package to test stuff.
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 remove exporting ArrayPartition for sure, I think the package should export what it defines. Maybe mul! could still be exported
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.
👍
src/calculus/HCAT.jl
Outdated
| N, # number of AbstractOperator | ||
| L <: NTuple{N,AbstractOperator}, | ||
| P <: NTuple{N,Union{Int,Tuple}}, | ||
| C <: Union{NTuple{M,AbstractArray}, AbstractArray}, |
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 think this one could be simplified? In the idea of moving to ArrayPartition to represent product spaces, here the arrival space can just be an AbstractArray, since ArrayPartition <: AbstractArray. Or am I missing something?
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.
yes I guess it can be simplified, was just lazy! 😄
| C <: Union{NTuple{M,AbstractArray}, AbstractArray}, | ||
| } <: AbstractOperator | ||
| A::L # tuple of AbstractOperators | ||
| idxs::P # indices |
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.
Also, I don’t remember what the advantage of storing these indices is, but I guess that storing the exact Tuple of operators to be horizontally concatenated could potentially simplify the code?
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.
The indices are due to eventual rearrangement of block of variables (I guess we should call them ArrayPartitions now). I suppose stuff can be simplified there as well, but it's out of the scope of this PR.
src/linearoperators/LBFGS.jl
Outdated
| s_M = [0 .*similar(x) for i = 1:M] | ||
| y_M = [0 .*similar(x) for i = 1:M] | ||
| s = 0 .*similar(x) | ||
| y = 0 .*similar(x) |
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.
You can just use zero(x) in all these here
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.
zero(x::AbstractArray) is no longer in use since Julia 1.0
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.
It’s there, and I think it was introduced in 0.7: https://docs.julialang.org/en/v1/base/numbers/#Base.zero
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.
ah right! in the past it was zeros now it's zero, that's why I got confused!
I did that in the REQUIRE, don't know why Travis still checked 0.7! I've put 1.0 should I put 1.1? I never remember this stuff! |
|
Just remove 0.7 from .travis.yml, and add 1.1 |
|
Ah right! It's not in the REQUIRE! Anyway, before merging this PR we should fix the other packages as well. |
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
=========================================
- Coverage 87.04% 84.2% -2.84%
=========================================
Files 45 45
Lines 1497 1475 -22
=========================================
- Hits 1303 1242 -61
- Misses 194 233 +39
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## master #8 +/- ##
==========================================
- Coverage 87.04% 84.27% -2.77%
==========================================
Files 45 45
Lines 1497 1475 -22
==========================================
- Hits 1303 1243 -60
- Misses 194 232 +38
Continue to review full report at Codecov.
|
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
Co-Authored-By: nantonel <nantonel@esat.kuleuven.be>
lostella
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.
Good to go!
Addressing #5 and #7 and #9
I'm convinced that removing completely operations with Tuples is the way to go, like these ones:
A*(x,y)->A*ArrayParition(x,y)mul!(y::Tuple, A::AbstractOperators, b::Tuple)->mul!(y::ArrayParition, A::AbstractOperators, b::ArrayParition)The reason is that the notation compatibility between
TuplesandArrayPartitionsisn't the best.ArrayPartitionemploys a different redefinition ofgetindex: iftypeof(x) <: ArrayParition,x[1]will not give you the first array of the collection but the first element of the first array. So to avoid confusion in the code I would avoid working with Tuples of Arrays at all.That being said, I'm quite in favor of using
ArrayParitions: although this will mean breaking changes inStruturedOptimization, it will possibly lead to many simplifications sinceArrayPartion <: AbstractArray. We can already see some in the LBFGS (where dots can now be employed) and in Sum.TODO: if we decide to completely remove multiplication with Tuples (which I think is the way to go), update docs accordingly