Skip to content

Commit 04176ab

Browse files
authored
Merge pull request #1 from slimgroup/testing
re-enable most test
2 parents 7fa2e62 + 917145f commit 04176ab

15 files changed

+216
-144
lines changed

.github/workflows/cancel.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Cancel
2+
3+
on: [push]
4+
5+
jobs:
6+
cancel:
7+
name: 'Cancel Previous Runs'
8+
runs-on: ubuntu-latest
9+
timeout-minutes: 3
10+
steps:
11+
- uses: styfle/[email protected]
12+
with:
13+
# Ids to cancel op/judi
14+
# https://api.github.com/repos/slimgroup/JUDI.jl/actions/workflows
15+
workflow_id: 2306091
16+
access_token: ${{ github.token }}

.github/workflows/ci-test.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: CI-SetIntersectionProjection
2+
3+
on:
4+
# Trigger the workflow on push to master or pull request
5+
# to be merged in master
6+
push:
7+
branches:
8+
- master
9+
pull_request:
10+
branches:
11+
- master
12+
13+
jobs:
14+
test:
15+
name: Julia ${{ matrix.version }} - ${{ matrix.os }}
16+
runs-on: ${{ matrix.os }}
17+
18+
strategy:
19+
fail-fast: false
20+
21+
matrix:
22+
version: ['1.1', '1.2', '1.3', '1.4', '1.5', 'nightly']
23+
os: [ubuntu-latest]
24+
25+
include:
26+
- version: 1.3
27+
os: macos-latest
28+
29+
- version: 1.4
30+
os: macos-latest
31+
32+
steps:
33+
- name: Checkout SetIntersectionProjection
34+
uses: actions/checkout@v2
35+
36+
- name: Setup julia
37+
uses: julia-actions/setup-julia@v1
38+
with:
39+
version: ${{ matrix.version }}
40+
arch: x64
41+
42+
- name: Add SLIM registery
43+
run: |
44+
julia --color=yes --check-bounds=yes -e 'using Pkg;Pkg.update();Pkg.Registry.add(RegistrySpec(url="https://github.com/slimgroup/SLIMregistryJL.git"))'
45+
46+
- name: Build SetIntersectionProjection
47+
uses: julia-actions/julia-buildpkg@latest
48+
49+
- name: Run tests
50+
uses: julia-actions/julia-runtest@latest
51+
52+
- uses: julia-actions/julia-uploadcodecov@latest
53+
env:
54+
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

Project.toml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
21
name = "SetIntersectionProjection"
32
uuid = "335f7d24-6316-57dd-9c3a-df470f2b739e"
43
authors = ["Bas Peters <[email protected]>"]
5-
version = "0.0.0"
4+
version = "0.1.0"
65

76
[deps]
87
Distributed = "8ba89e20-285c-5b6f-9357-94700520ee1b"
8+
DistributedArrays = "aaf54ef3-cdf8-58ed-94cc-d582ad619b94"
9+
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
10+
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
11+
JOLI = "bb331ad6-a1cf-11e9-23da-9bcb53c69f6f"
912
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
13+
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
1014
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
1115
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
16+
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
1217
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"
1318
Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1419
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
15-
FFTW = "7a1cc6ca-52ef-59f5-83cd-3a7055c09341"
16-
JOLI = "bb331ad6-a1cf-11e9-23da-9bcb53c69f6f"
1720
Wavelets = "29a6e085-ba6d-5f35-a997-948ac2efa89a"
18-
SortingAlgorithms = "a2af1166-a08f-5f64-846c-94a0d3cef48c"
19-
Parameters = "d96e819e-fc66-5662-9728-84c9c7592b0a"
20-
Interpolations = "a98d9a8b-a2ab-59e6-89dd-64a1c18fca59"
21-
DistributedArrays = "aaf54ef3-cdf8-58ed-94cc-d582ad619b94"

src/cg.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ export cg
33

44
function cg(A::SparseMatrixCSC{T1,Int},b::Array{T2,1}; kwargs...) where {T1,T2}
55
x = zeros(promote_type(T1,T2),size(A,2)) # pre-allocate
6-
return cg(v -> At_mul_B!(1.0,A,v,0.0,x),b;kwargs...) # multiply with transpose of A for efficiency
6+
return cg(v -> mul!(x, transpose(A), v, 1.0, 0.0),b; kwargs...) # multiply with transpose of A for efficiency
77
end
88

99
cg(A,b::Vector;kwargs...) = cg(x -> A*x,b;kwargs...)

test/runtests.jl

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ end
1212
@assert nprocs() > 3
1313
@assert nworkers() >= 3
1414

15-
@everywhere using DistributedArrays
15+
@everywhere using DistributedArrays, SparseArrays
1616
@everywhere using JOLI
1717

1818
@everywhere using SetIntersectionProjection
@@ -23,32 +23,31 @@ end
2323
end
2424

2525

26-
2726
@testset "SetIntersectionProjection" begin
2827

29-
include("test_projectors.jl")
30-
include("test_setup_constraints.jl")
31-
32-
#still need to port the stuff below to Julia 1.1
33-
34-
# include("test_TD_OPs.jl")
35-
# include("test_prox_l2s!.jl")
36-
# include("test_argmin_x.jl")
37-
# include("test_update_y_l.jl")
38-
#
39-
# #parallel scripts
40-
# include("test_update_y_l_parallel.jl")
41-
# include("test_adapt_rho_gamma_parallel.jl")
42-
#
43-
# #linear algebra subroutines
44-
# include("test_cg.jl")
45-
# include("test_CDS_Mvp.jl")
46-
# include("test_CDS_scaled_add.jl")
47-
# include("test_Q_update.jl")
48-
#
49-
# #test full algorithms
50-
# include("test_PARSDMM.jl")
51-
# include("test_PARSDMM_parallel.jl")
52-
# include("test_PARSDMM_multilevel.jl")
28+
include("test_projectors.jl")
29+
include("test_setup_constraints.jl")
30+
31+
#still need to port the stuff below to Julia 1.1
32+
33+
include("test_TD_OPs.jl")
34+
include("test_prox_l2s!.jl")
35+
include("test_argmin_x.jl")
36+
include("test_update_y_l.jl")
37+
38+
#parallel scripts
39+
include("test_update_y_l_parallel.jl")
40+
include("test_adapt_rho_gamma_parallel.jl")
41+
42+
#linear algebra subroutines
43+
include("test_cg.jl")
44+
include("test_CDS_Mvp.jl")
45+
include("test_CDS_scaled_add.jl")
46+
include("test_Q_update.jl")
47+
48+
#test full algorithms
49+
# include("test_PARSDMM.jl")
50+
# include("test_PARSDMM_parallel.jl")
51+
# include("test_PARSDMM_multilevel.jl")
5352

5453
end

test/test_PARSDMM.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,10 @@ options=PARSDMM_options()
55
options.FL = Float64
66
options.parallel = false
77
options.zero_ini_guess = true
8-
options.linear_inv_prob_flag = false
98

109
x=randn(100,201)
1110

12-
comp_grid=compgrid((1.0, 1.0),(100, 201))
11+
comp_grid = compgrid((1.0, 1.0),(100, 201))
1312
x = vec(x)
1413
m2 = deepcopy(x)
1514
x_ini2 = deepcopy(x)
@@ -18,8 +17,8 @@ constraint= Dict()
1817
#check if input returns if the input satisfies the constraints
1918
#bound constraints
2019
constraint["use_bounds"]=true
21-
constraint["m_min"]=minimum(vec(x))
22-
constraint["m_max"]=maximum(vec(x))
20+
constraint["min"]=minimum(vec(x))
21+
constraint["max"]=maximum(vec(x))
2322

2423
(P_sub,TD_OP,TD_Prop) = setup_constraints(constraint,comp_grid,options.FL)
2524
(TD_OP,AtA,l,y) = PARSDMM_precompute_distribute(TD_OP,TD_Prop,comp_grid,options)
@@ -33,8 +32,8 @@ constraint= Dict()
3332
#add a few convex constraints. The projected model should satisfy these constraints
3433
#bound constraints
3534
constraint["use_bounds"]=true
36-
constraint["m_min"]=0.5*minimum(vec(x))
37-
constraint["m_max"]=0.5*maximum(vec(x))
35+
constraint["min"]=0.5*minimum(vec(x))
36+
constraint["max"]=0.5*maximum(vec(x))
3837

3938
#transform domain bounds
4039
(TD_OP, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"D_z",options.FL)
@@ -182,8 +181,8 @@ constraint= Dict()
182181
#add a few convex constraints which the model already satisfies
183182
#bound constraints
184183
constraint["use_bounds"]=false
185-
constraint["m_min"]=1.0*minimum(vec(c_l_solution))
186-
constraint["m_max"]=1.456*maximum(vec(c_l_solution))
184+
constraint["min"]=1.0*minimum(vec(c_l_solution))
185+
constraint["max"]=1.456*maximum(vec(c_l_solution))
187186

188187
#transform domain bounds
189188
(TD_OP, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"D_z",options.FL)
@@ -236,8 +235,8 @@ constraint["TD_nuclear_operator_1"]="identity"
236235
#add a few convex constraints which the model already satisfies
237236
#bound constraints
238237
constraint["use_bounds"]=true
239-
constraint["m_min"]=1.0*minimum(x)
240-
constraint["m_max"]=0.50*maximum(x)
238+
constraint["min"]=1.0*minimum(x)
239+
constraint["max"]=0.50*maximum(x)
241240

242241
#transform domain bounds
243242
(TD_OP, AtA_diag, dense, TD_n)=get_TD_operator(comp_grid,"D_z",options.FL)

test/test_Q_update.jl

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#sparse matrix
44
A=sprandn(100,100,0.1)
5-
B=Vector{SparseMatrixCSC{Float64,Int64}}(2)
5+
B=Vector{SparseMatrixCSC{Float64,Int64}}(undef, 2)
66
B[1]=sprandn(100,100,0.1)
77
B[2]=sprandn(100,100,0.1)
88
#make sure all nonzero diagonals in B are also in A, otherwise CDS doesnt work
@@ -14,15 +14,15 @@
1414
maxit=100;
1515
p=2
1616
log_PARSDMM = log_type_PARSDMM(zeros(maxit,p-1),zeros(maxit,p),zeros(maxit,p),zeros(maxit),zeros(maxit),zeros(maxit),zeros(maxit),zeros(maxit,p),zeros(maxit,p),zeros(maxit),zeros(maxit),0.00,0.00,0.00,0.00,0.00,0.00,0.00);
17-
rho=Vector{Float64}(2)
17+
rho=Vector{Float64}(undef, 2)
1818
rho[1]=1.0
1919
rho[2]=1.0
2020
log_PARSDMM.rho[1,1]=2.0
2121
log_PARSDMM.rho[1,2]=3.0
2222

2323
#add A = A+ 1.0*B[1] + 2.0*B[2]
2424
i=1
25-
ind_updated = find(rho .!= log_PARSDMM.rho[i,:]) #::Vector{Integer}# locate changed rho index
25+
ind_updated = findall(rho .!= log_PARSDMM.rho[i,:]) #::Vector{Integer}# locate changed rho index
2626
ind_updated = convert(Array{Int64,1},ind_updated)
2727
#use explicit solution:
2828
if isempty(ind_updated) == false
@@ -33,7 +33,11 @@
3333
#use Q_update:
3434
TI=Int64
3535
TF=Float64
36-
TD_Prop=set_properties(zeros(99),zeros(99),zeros(99),Vector{Tuple{TI,TI}}(99),Vector{Tuple{String,String}}(99),zeros(99),Vector{Vector{TI}}(99))
36+
TD_Prop=set_properties(zeros(Bool, 99), zeros(Bool, 99), zeros(Bool, 99),
37+
fill!(Vector{Tuple{TI,TI}}(undef, 99), (0, 0)),
38+
fill!(Vector{Tuple{String,String, String, String}}(undef, 99), ("", "", "", "")),
39+
zeros(Bool, 99),
40+
Vector{Vector{TI}}(undef,99))
3741
A2=Q_update!(A2,B2,TD_Prop,rho,ind_updated,log_PARSDMM,i,[])
3842

3943
x=randn(size(A,2))
@@ -43,7 +47,7 @@
4347
(R_A,offset_A)=mat2CDS(A3)
4448
(R_B1,offset_B1)=mat2CDS(B[1])
4549
(R_B2,offset_B2)=mat2CDS(B[2])
46-
R_B=Vector{Array{Float64,2}}(2)
50+
R_B=Vector{Array{Float64,2}}(undef, 2)
4751
R_B[1]=R_B1
4852
R_B[2]=R_B2
4953
TD_Prop.AtA_offsets[1]=offset_B1

test/test_TD_OPs.jl

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@
1111
D2z = get_discrete_Grad(n1,n2,h1,h2,"D_z")
1212

1313
x=zeros(n1,n2) #test on a 'cross' image
14-
x[:,3]=1.0
15-
x[4,:]=1.0
14+
x[:,3].=1.0
15+
x[4,:].=1.0
1616

1717
a1 = D2x*vec(x); a1=reshape(a1,n1-1,n2)
1818
a2 = D2z*vec(x); a2=reshape(a2,n1,n2-1)
@@ -21,17 +21,17 @@
2121
a3b = reshape(a3b,n1-1,n2)
2222

2323
#this test depends on the values of h1 and h2, as well as the type of derivative
24-
@test a1==diff(x,1)./h1
25-
@test a2==diff(x,2)./h2
24+
@test a1==diff(x, dims=1)./h1
25+
@test a2==diff(x, dims=2)./h2
2626

2727
#some more general tests:
28-
@test countnz(a1[:,3])==0
28+
@test count(!iszero, a1[:,3])==0
2929
for i in [1 2 4 5 6]
3030
@test a1[:,1]==a1[:,i]
3131
end
3232

3333
#some more general tests:
34-
@test countnz(a2[4,:])==0
34+
@test count(!iszero, a2[4,:])==0
3535
for i in [1 2 3 5 6 7 8 9]
3636
@test a2[1,:]==a2[i,:]
3737
end
@@ -52,32 +52,32 @@
5252
D3z = get_discrete_Grad(n1,n2,n3,h1,h2,h3,"D_z")
5353

5454
x=zeros(n1,n2,n3) #test on a 'cross' image
55-
x[2,:,:]=1.0
56-
x[:,4,:]=1.0
57-
x[:,:,3]=1.0
55+
x[2,:,:].=1.0
56+
x[:,4,:].=1.0
57+
x[:,:,3].=1.0
5858

5959
a1 = D3x*vec(x); a1=reshape(a1,n1-1,n2,n3)
6060
a2 = D3y*vec(x); a2=reshape(a2,n1,n2-1,n3)
6161
a3 = D3z*vec(x); a3=reshape(a3,n1,n2,n3-1)
6262
for i=1:n2
63-
@test a1[:,i,:]==diff(x[:,i,:],1)./h1
63+
@test a1[:,i,:]==diff(x[:,i,:], dims=1)./h1
6464
end
6565
for i=1:n3
66-
@test a1[:,:,i]==diff(x[:,:,i],1)./h1
66+
@test a1[:,:,i]==diff(x[:,:,i], dims=1)./h1
6767
end
6868

6969
for i=1:n1
70-
@test a2[i,:,:]==diff(x[i,:,:],1)./h2
70+
@test a2[i,:,:]==diff(x[i,:,:], dims=1)./h2
7171
end
7272
for i=1:n3
73-
@test a2[:,:,i]==diff(x[:,:,i],2)./h2
73+
@test a2[:,:,i]==diff(x[:,:,i], dims=2)./h2
7474
end
7575

7676
for i=1:n1
77-
@test a3[i,:,:]==diff(x[i,:,:],2)./h3
77+
@test a3[i,:,:]==diff(x[i,:,:], dims=2)./h3
7878
end
7979
for i=1:n2
80-
@test a3[:,i,:]==diff(x[:,i,:],2)./h3
80+
@test a3[:,i,:]==diff(x[:,i,:], dims=2)./h3
8181
end
8282

8383
end

0 commit comments

Comments
 (0)