Skip to content

Conversation

@nantonel
Copy link
Member

@nantonel nantonel commented Jan 29, 2019

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

The reason is that the notation compatibility between Tuples and ArrayPartitions isn't the best.
ArrayPartition employs a different redefinition of getindex: if typeof(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 in StruturedOptimization, it will possibly lead to many simplifications since ArrayPartion <: 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

@nantonel nantonel requested a review from lostella January 29, 2019 17:16
@lostella
Copy link
Member

I would take the occasion to remove Julia 0.7 from Travis, and putting 1.1 instead

Copy link
Member

@lostella lostella left a 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!

NonLinearOperator,
AbstractOperator
# from other packages
export ArrayPartition, mul!
Copy link
Member

Choose a reason for hiding this comment

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

Why these exports?

Copy link
Member Author

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.

Copy link
Member

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

Copy link
Member Author

Choose a reason for hiding this comment

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

👍

N, # number of AbstractOperator
L <: NTuple{N,AbstractOperator},
P <: NTuple{N,Union{Int,Tuple}},
C <: Union{NTuple{M,AbstractArray}, AbstractArray},
Copy link
Member

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?

Copy link
Member Author

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
Copy link
Member

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?

Copy link
Member Author

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.

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)
Copy link
Member

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

Copy link
Member Author

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

Copy link
Member

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

Copy link
Member Author

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!

@nantonel
Copy link
Member Author

I would take the occasion to remove Julia 0.7 from Travis, and putting 1.1 instead

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!

@lostella
Copy link
Member

Just remove 0.7 from .travis.yml, and add 1.1

@nantonel
Copy link
Member Author

Ah right! It's not in the REQUIRE! Anyway, before merging this PR we should fix the other packages as well.

@codecov-io
Copy link

Codecov Report

Merging #8 into master will decrease coverage by 2.83%.
The diff coverage is 83.41%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/AbstractOperators.jl 100% <ø> (ø) ⬆️
src/calculus/Sum.jl 89.13% <100%> (-1.78%) ⬇️
src/calculus/Reshape.jl 96.15% <100%> (+4.48%) ⬆️
src/properties.jl 88.88% <100%> (+1.08%) ⬆️
src/calculus/Hadamard.jl 93.1% <100%> (-0.23%) ⬇️
src/calculus/Jacobian.jl 75% <100%> (-8.34%) ⬇️
src/syntax.jl 91.48% <100%> (+0.58%) ⬆️
src/calculus/NonLinearCompose.jl 100% <100%> (+2.7%) ⬆️
src/calculus/VCAT.jl 56.19% <42%> (-0.45%) ⬇️
src/calculus/DCAT.jl 89.87% <71.42%> (ø) ⬆️
... and 6 more

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 087f8cc...c110542. Read the comment docs.

@codecov-io
Copy link

codecov-io commented Feb 13, 2019

Codecov Report

Merging #8 into master will decrease coverage by 2.76%.
The diff coverage is 83.41%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
src/AbstractOperators.jl 100% <ø> (ø) ⬆️
src/calculus/Sum.jl 89.13% <100%> (-1.78%) ⬇️
src/calculus/Reshape.jl 96.15% <100%> (+4.48%) ⬆️
src/properties.jl 88.88% <100%> (+1.08%) ⬆️
src/calculus/Hadamard.jl 93.1% <100%> (-0.23%) ⬇️
src/calculus/Jacobian.jl 75% <100%> (-8.34%) ⬇️
src/syntax.jl 91.48% <100%> (+0.58%) ⬆️
src/calculus/NonLinearCompose.jl 100% <100%> (+2.7%) ⬆️
src/calculus/VCAT.jl 56.19% <42%> (-0.45%) ⬇️
src/calculus/DCAT.jl 89.87% <71.42%> (ø) ⬆️
... and 6 more

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 087f8cc...a1b9736. Read the comment docs.

lostella and others added 3 commits February 19, 2019 08:41
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 and others added 5 commits February 27, 2019 09:58
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>
Copy link
Member

@lostella lostella left a comment

Choose a reason for hiding this comment

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

Good to go!

@nantonel nantonel merged commit 7cf2a82 into kul-optec:master Mar 6, 2019
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.

3 participants