Skip to content

Commit 1a2f340

Browse files
authored
Julia 1.0 update (#13)
* starting 1.0 update * test passing * fixing travis and appveyor * cleaned precomposeNonlinear mul! calls * updated installation in docs * fix to docs
1 parent 2771bb1 commit 1a2f340

28 files changed

+180
-152
lines changed

.travis.yml

+6-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,16 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
8+
- 1.0
89
- nightly
910
matrix:
1011
allow_failures:
1112
- julia: nightly
1213
notifications:
1314
email: false
1415
after_success:
15-
- julia -e 'cd(Pkg.dir("StructuredOptimization")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
16-
- julia -e 'cd(Pkg.dir("StructuredOptimization")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
17-
- julia -e 'Pkg.add("Documenter")'
18-
- julia -e 'cd(Pkg.dir("StructuredOptimization")); include(joinpath("docs", "make.jl"))'
16+
- julia -e 'using Pkg; cd(Pkg.dir("StructuredOptimization")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(process_folder())'
17+
- julia -e 'using Pkg; cd(Pkg.dir("StructuredOptimization")); Pkg.add("Coverage"); using Coverage; Codecov.submit(Codecov.process_folder())'
18+
- julia -e 'using Pkg; Pkg.add("Documenter")'
19+
- julia -e 'using Pkg; cd(Pkg.dir("StructuredOptimization")); include(joinpath("docs", "make.jl"))'

README.md

+5-2
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,11 @@ It supports complex variables as well.
2626

2727
## Installation
2828

29-
From the Julia command line hit `Pkg.clone("https://github.com/kul-forbes/StructuredOptimization.jl.git")`.
30-
Once the package is installed you can update it along with the others issuing `Pkg.update()` in the command line.
29+
To install the package, hit `]` from the Julia command line to enter the package manager, then
30+
31+
```julia
32+
pkg> add https://github.com/kul-forbes/StructuredOptimization.jl
33+
```
3134

3235
## Usage
3336

REQUIRE

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
julia 0.6
2-
AbstractOperators 0.0.5
3-
ProximalOperators 0.6.0
4-
ProximalAlgorithms 0.0.3
1+
julia 0.7
2+
FFTW 0.2.4
3+
DSP 0.5.1
4+
AbstractOperators 0.1.0
5+
ProximalOperators 0.8.0
6+
ProximalAlgorithms 0.1.0

appveyor.yml

+22-14
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
4-
# - JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
3+
- julia_version: 0.7
4+
- julia_version: 1
5+
- julia_version: nightly
6+
7+
platform:
8+
# - x86 # 32-bit
9+
- x64 # 64-bit
10+
11+
matrix:
12+
allow_failures:
13+
- julia_version: nightly
514

615
branches:
716
only:
@@ -15,19 +24,18 @@ notifications:
1524
on_build_status_changed: false
1625

1726
install:
18-
- ps: "[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12"
19-
# Download most recent Julia Windows binary
20-
- ps: (new-object net.webclient).DownloadFile(
21-
$env:JULIA_URL,
22-
"C:\projects\julia-binary.exe")
23-
# Run installer silently, output to C:\projects\julia
24-
- C:\projects\julia-binary.exe /S /D=C:\projects\julia
27+
- ps: iex ((new-object net.webclient).DownloadString("https://raw.githubusercontent.com/JuliaCI/Appveyor.jl/version-1/bin/install.ps1"))
2528

2629
build_script:
27-
# Need to convert from shallow to complete for Pkg.clone to work
28-
- IF EXIST .git\shallow (git fetch --unshallow)
29-
- C:\projects\julia\bin\julia -e "versioninfo();
30-
Pkg.clone(pwd(), \"StructuredOptimization\"); Pkg.build(\"StructuredOptimization\")"
30+
- echo "%JL_BUILD_SCRIPT%"
31+
- C:\julia\bin\julia -e "%JL_BUILD_SCRIPT%"
3132

3233
test_script:
33-
- C:\projects\julia\bin\julia --check-bounds=yes -e "Pkg.test(\"StructuredOptimization\")"
34+
- echo "%JL_TEST_SCRIPT%"
35+
- C:\julia\bin\julia -e "%JL_TEST_SCRIPT%"
36+
37+
# # Uncomment to support code coverage upload. Should only be enabled for packages
38+
# # which would have coverage gaps without running on Windows
39+
# on_success:
40+
# - echo "%JL_CODECOV_SCRIPT%"
41+
# - C:\julia\bin\julia -e "%JL_CODECOV_SCRIPT%"

docs/make.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using Documenter, StructuredOptimization
1+
using Documenter, StructuredOptimization, LinearAlgebra, DSP, AbstractFFTs, FFTW, AbstractOperators
22

33
makedocs(
44
modules = [StructuredOptimization],
@@ -17,7 +17,7 @@ makedocs(
1717

1818
deploydocs(
1919
repo = "github.com/kul-forbes/StructuredOptimization.jl.git",
20-
julia = "0.6",
20+
julia = "1.0",
2121
osname = "linux",
2222
target = "build",
2323
deps = nothing,

docs/src/index.md

+5-3
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,11 @@ StructuredOptimization.jl can handle large-scale convex and nonconvex problems w
1818

1919
## Installation
2020

21-
From the Julia command line hit `Pkg.clone("https://github.com/kul-forbes/StructuredOptimization.jl.git")`.
22-
Once the package is installed you can update it along with the others issuing
23-
`Pkg.update()` in the command line.
21+
To install the package, hit `]` from the Julia command line to enter the package manager, then
22+
23+
```julia
24+
pkg> add https://github.com/kul-forbes/StructuredOptimization.jl
25+
```
2426

2527
## Citing
2628

src/StructuredOptimization.jl

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ __precompile__()
22

33
module StructuredOptimization
44

5+
using LinearAlgebra
56
using AbstractOperators
67
using AbstractOperators.BlockArrays
78
using ProximalOperators

src/calculus/precomposeNonlinear.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@ function (f::PrecomposeNonlinear)(x)
2727
end
2828

2929
function gradient!(y::D, f::PrecomposeNonlinear{P,T,D,C}, x::D) where {P,T,D,C}
30-
A_mul_B!(f.bufC, f.G, x)
30+
mul!(f.bufC, f.G, x)
3131
v = gradient!(f.bufC2, f.g, f.bufC)
3232
J = Jacobian(f.G, x)
33-
y = Ac_mul_B!(y, J, f.bufC2)
33+
y = mul!(y, J', f.bufC2)
3434
return v
3535
end

src/solvers/solvers_options.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Creates an object `PG` containing the options of the Proximal Gradient solvers:
2222
2323
"""
2424
struct PG <: ForwardBackwardSolver
25-
kwargs::Array
25+
kwargs::Iterators.Pairs
2626
function PG(; kwargs...)
2727
new(kwargs)
2828
end
@@ -61,7 +61,7 @@ Creates an object `ZeroFPR` containing the options of the ZeroFPR solver:
6161
6262
"""
6363
struct ZeroFPR <: ForwardBackwardSolver
64-
kwargs::Array
64+
kwargs::Iterators.Pairs
6565
function ZeroFPR(; kwargs...)
6666
new(kwargs)
6767
end
@@ -90,7 +90,7 @@ Creates an object `PANOC` containing the options of the PANOC solver:
9090
9191
"""
9292
struct PANOC <: ForwardBackwardSolver
93-
kwargs::Array
93+
kwargs::Iterators.Pairs
9494
function PANOC(; kwargs...)
9595
new(kwargs)
9696
end

src/solvers/terms_extract.jl

+10-11
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# returns all variables of a cost function, in terms of appearance
22
extract_variables(t::Term) = variables(t)
33

4-
function extract_variables{N}(t::NTuple{N,Term})
4+
function extract_variables(t::NTuple{N,Term}) where {N}
55
x = variables.(t)
66
xAll = x[1]
77
for i = 2:length(x)
@@ -21,15 +21,15 @@ function extract_functions(t::Term)
2121
#TODO change this
2222
return f
2323
end
24-
extract_functions{N}(t::NTuple{N,Term}) = SeparableSum(extract_functions.(t))
24+
extract_functions(t::NTuple{N,Term}) where {N} = SeparableSum(extract_functions.(t))
2525
extract_functions(t::Tuple{Term}) = extract_functions(t[1])
2626

2727
# extract functions from terms without displacement
2828
function extract_functions_nodisp(t::Term)
2929
f = t.lambda == 1. ? t.f : Postcompose(t.f, t.lambda)
3030
return f
3131
end
32-
extract_functions_nodisp{N}(t::NTuple{N,Term}) = SeparableSum(extract_functions_nodisp.(t))
32+
extract_functions_nodisp(t::NTuple{N,Term}) where {N} = SeparableSum(extract_functions_nodisp.(t))
3333
extract_functions_nodisp(t::Tuple{Term}) = extract_functions_nodisp(t[1])
3434

3535
# extract operators from terms
@@ -39,10 +39,10 @@ extract_functions_nodisp(t::Tuple{Term}) = extract_functions_nodisp(t[1])
3939
#single term, single variable
4040
extract_operators(xAll::Tuple{Variable}, t::Term) = operator(t)
4141

42-
extract_operators{N}(xAll::NTuple{N,Variable}, t::Term) = extract_operators(xAll, (t,))
42+
extract_operators(xAll::NTuple{N,Variable}, t::Term) where {N} = extract_operators(xAll, (t,))
4343

4444
#multiple terms, multiple variables
45-
function extract_operators{N,M}(xAll::NTuple{N,Variable}, t::NTuple{M,Term})
45+
function extract_operators(xAll::NTuple{N,Variable}, t::NTuple{M,Term}) where {N,M}
4646
ops = ()
4747
for ti in t
4848
tex = expand(xAll,ti)
@@ -53,7 +53,7 @@ end
5353

5454
sort_and_extract_operators(xAll::Tuple{Variable}, t::Term) = operator(t)
5555

56-
function sort_and_extract_operators{N}(xAll::NTuple{N,Variable}, t::Term)
56+
function sort_and_extract_operators(xAll::NTuple{N,Variable}, t::Term) where {N}
5757
p = zeros(Int,N)
5858
xL = variables(t)
5959
for i in eachindex(xAll)
@@ -69,10 +69,10 @@ end
6969
#single term, single variable
7070
extract_affines(xAll::Tuple{Variable}, t::Term) = affine(t)
7171

72-
extract_affines{N}(xAll::NTuple{N,Variable}, t::Term) = extract_affines(xAll, (t,))
72+
extract_affines(xAll::NTuple{N,Variable}, t::Term) where {N} = extract_affines(xAll, (t,))
7373

7474
#multiple terms, multiple variables
75-
function extract_affines{N,M}(xAll::NTuple{N,Variable}, t::NTuple{M,Term})
75+
function extract_affines(xAll::NTuple{N,Variable}, t::NTuple{M,Term}) where {N,M}
7676
ops = ()
7777
for ti in t
7878
tex = expand(xAll,ti)
@@ -83,7 +83,7 @@ end
8383

8484
sort_and_extract_affines(xAll::Tuple{Variable}, t::Term) = affine(t)
8585

86-
function sort_and_extract_affines{N}(xAll::NTuple{N,Variable}, t::Term)
86+
function sort_and_extract_affines(xAll::NTuple{N,Variable}, t::Term) where {N}
8787
p = zeros(Int,N)
8888
xL = variables(t)
8989
for i in eachindex(xAll)
@@ -93,7 +93,7 @@ function sort_and_extract_affines{N}(xAll::NTuple{N,Variable}, t::Term)
9393
end
9494

9595
# expand term domain dimensions
96-
function expand{N,T1,T2,T3}(xAll::NTuple{N,Variable}, t::Term{T1,T2,T3})
96+
function expand(xAll::NTuple{N,Variable}, t::Term{T1,T2,T3}) where {N,T1,T2,T3}
9797
xt = variables(t)
9898
C = codomainType(operator(t))
9999
size_out = size(operator(t),1)
@@ -165,4 +165,3 @@ end
165165

166166
extract_proximable(xAll::Variable, t::Term) = extract_merge_functions(t)
167167
extract_proximable(xAll::NTuple{N,Variable}, t::Term) where {N} = extract_proximable(xAll,(t,))
168-

src/solvers/terms_splitting.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44
#
55
# Splits cost function into `SmoothFunction` and `NonSmoothFunction` terms.
66
# """
7-
# split_smooth(cf::Vararg{Term}) = cf[find(is_smooth(cf))],cf[find((!).(is_smooth(cf)))]
7+
# split_smooth(cf::Vararg{Term}) = cf[findall(is_smooth(cf))],cf[findall((!).(is_smooth(cf)))]
88
# split_smooth{N}(cf::NTuple{N,Term}) = split_smooth(cf...)
99
#
1010
# """
1111
# `split_AAc_diagonal(cf::Vararg{Term}) -> (proximable, non_proximable)`
1212
#
1313
# Splits cost function into terms with L'*L diagonal operator.
1414
# """
15-
# split_AAc_diagonal(cf::Vararg{Term}) = cf[find(is_AAc_diagonal(cf))],cf[find((!).(is_AAc_diagonal(cf)))]
15+
# split_AAc_diagonal(cf::Vararg{Term}) = cf[findall(is_AAc_diagonal(cf))],cf[findall((!).(is_AAc_diagonal(cf)))]
1616
# split_AAc_diagonal{N}(cf::NTuple{N,Term}) = split_AAc_diagonal(cf...)
1717
#
1818
# #""" TODO
@@ -22,10 +22,10 @@
2222
# #"""
2323

2424
split_smooth(terms::Tuple) =
25-
terms[find(is_smooth.(terms))], terms[find((!).(is_smooth.(terms)))]
25+
terms[findall(is_smooth.(terms))], terms[findall((!).(is_smooth.(terms)))]
2626

2727
split_quadratic(terms::Tuple) =
28-
terms[find(is_quadratic.(terms))], terms[find((!).(is_quadratic.(terms)))]
28+
terms[findall(is_quadratic.(terms))], terms[findall((!).(is_quadratic.(terms)))]
2929

3030
split_AAc_diagonal(terms::Tuple) =
31-
terms[find(is_AAc_diagonal.(terms))], terms[find((!).(is_AAc_diagonal.(terms)))]
31+
terms[findall(is_AAc_diagonal.(terms))], terms[findall((!).(is_AAc_diagonal.(terms)))]

src/syntax/expressions/abstractOperator_bind.jl

+29-9
Original file line numberDiff line numberDiff line change
@@ -24,24 +24,32 @@ function reshape(a::AbstractExpression, dims...)
2424
end
2525
#Reshape
2626

27-
imported = [:getindex :GetIndex;
28-
:fft :DFT;
27+
imported = [
28+
:getindex :GetIndex;
29+
:exp :Exp;
30+
:cos :Cos;
31+
:sin :Sin;
32+
:atan :Atan;
33+
:tanh :Tanh;
34+
]
35+
36+
importedFFTW = [
37+
:fft :(AbstractOperators.DFT);
2938
:rfft :RDFT;
3039
:irfft :IRDFT;
3140
:ifft :IDFT;
3241
:dct :DCT;
3342
:idct :IDCT;
43+
]
44+
45+
importedDSP = [
3446
:conv :Conv;
3547
:xcorr :Xcorr;
3648
:filt :Filt;
37-
:exp :Exp;
38-
:cos :Cos;
39-
:sin :Sin;
40-
:atan :Atan;
41-
:tanh :Tanh;
4249
]
4350

44-
exported = [:finitediff :FiniteDiff;
51+
exported = [
52+
:finitediff :FiniteDiff;
4553
:variation :Variation;
4654
:mimofilt :MIMOFilt;
4755
:zeropad :ZeroPad;
@@ -56,14 +64,26 @@ for f in imported[:,1]
5664
import Base: $f
5765
end
5866
end
67+
#importing functions from FFTW
68+
for f in importedFFTW[:,1]
69+
@eval begin
70+
import FFTW: $f
71+
end
72+
end
73+
#importing functions from DSP
74+
for f in importedDSP[:,1]
75+
@eval begin
76+
import DSP: $f
77+
end
78+
end
5979
#exporting functions
6080
for f in exported[:,1]
6181
@eval begin
6282
export $f
6383
end
6484
end
6585

66-
fun = [imported; exported]
86+
fun = [imported; importedFFTW; importedDSP; exported]
6787
for i = 1:size(fun,1)
6888
f,fAbsOp = fun[i,1],fun[i,2]
6989
@eval begin

src/syntax/expressions/addition.jl

+4-5
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ function Usum_op(xA::NTuple{N,Variable},
9595
A::L1,
9696
B::AbstractOperator,sign::Bool) where {N, M, L1<:HCAT{M,N}}
9797
if xB[1] in xA
98-
idx = findfirst(xA.==xB[1])
98+
idx = findfirst(xA.==Ref(xB[1]))
9999
S = sign ? A[idx]+B : A[idx]-B
100100
xNew = xA
101101
opNew = hcat(A[1:idx-1],S,A[idx+1:N] )
@@ -113,7 +113,7 @@ function Usum_op(xA::Tuple{Variable},
113113
A::AbstractOperator,
114114
B::L2,sign::Bool) where {N, M, L2<:HCAT{M,N}}
115115
if xA[1] in xB
116-
idx = findfirst(xA.==xB[1])
116+
idx = findfirst(xA.==Ref(xB[1]))
117117
S = sign ? A+B[idx] : B[idx]-A
118118
xNew = xB
119119
opNew = sign ? hcat(B[1:idx-1],S,B[idx+1:N] ) : -hcat(B[1:idx-1],S,B[idx+1:N] )
@@ -207,9 +207,8 @@ end
207207
# sum with array/scalar
208208

209209
#broadcasted + -
210-
import Base: broadcast
211210

212-
function broadcast(::typeof(+),a::AbstractExpression, b::AbstractExpression)
211+
function Broadcast.broadcasted(::typeof(+),a::AbstractExpression, b::AbstractExpression)
213212
A = convert(Expression,a)
214213
B = convert(Expression,b)
215214
if size(affine(A),1) != size(affine(B),1)
@@ -225,7 +224,7 @@ function broadcast(::typeof(+),a::AbstractExpression, b::AbstractExpression)
225224
return A+B
226225
end
227226

228-
function broadcast(::typeof(-),a::AbstractExpression, b::AbstractExpression)
227+
function Broadcast.broadcasted(::typeof(-),a::AbstractExpression, b::AbstractExpression)
229228
A = convert(Expression,a)
230229
B = convert(Expression,b)
231230
if size(affine(A),1) != size(affine(B),1)

0 commit comments

Comments
 (0)