Skip to content

Commit

Permalink
version for Julia 1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Sep 19, 2018
1 parent bfeba99 commit f630fc4
Show file tree
Hide file tree
Showing 12 changed files with 44 additions and 33 deletions.
9 changes: 5 additions & 4 deletions test/comptime_leeuw_cums.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env julia

using Cumulants
using JLD
using JLD2
using FileIO
using ArgParse
#import Cumulants: mom2cums

Expand Down Expand Up @@ -43,12 +44,12 @@ end
"""
savecomptime(m::Int, T::Vector{Int}, n::Vector{Int}, cache::Bool)
Save a file in jld format of the computional times of moment, naivemoment, rawmoment
Save a file in jld2 format of the computional times of moment, naivemoment, rawmoment
"""
function savecomptime(m::Int, t::Vector{Int}, n::Vector{Int})
filename = replace("res/"*string(m)*string(t)*string(n)*"leeuw_cums.jld", "[", "_")
filename = replace(filename, "]", "")
filename = replace("res/"*string(m)*string(t)*string(n)*"leeuw_cums.jld2", "["=>"_")
filename = replace(filename, "]"=>"")
fs = [cumulants_upto_p, cumulants]
compt = Dict{String, Any}()
for f in fs
Expand Down
7 changes: 4 additions & 3 deletions test/comptimeblocks.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env julia

using Cumulants
using JLD
using JLD2
using FileIO
using ArgParse


Expand All @@ -25,8 +26,8 @@ function savect(t::Vector{Int}, n::Int, m::Int)
println("bloks size = ", b)
end
end
filename = replace("res/$(m)_$(t)_$(n)_nblocks.jld", "[", "")
filename = replace(filename, "]", "")
filename = replace("res/$(m)_$(t)_$(n)_nblocks.jld2", "["=>"")
filename = replace(filename, "]"=>"")
compt = Dict{String, Any}("cumulants"=> comptimes)
push!(compt, "t" => t)
push!(compt, "n" => n)
Expand Down
8 changes: 5 additions & 3 deletions test/comptimeproc.jl
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
#!/usr/bin/env julia

using Cumulants
using JLD
using JLD2
using FileIO
using ArgParse
using Distributed



Expand Down Expand Up @@ -32,8 +34,8 @@ function savect(t::Int, n::Int, m::Int, maxprocs::Int, b::Int)
comptimes = zeros(maxprocs)
comptimes = comptimesonprocs(t,n,m,maxprocs, b)
onec = fill(comptimes[1], maxprocs)
filename = replace("res/$(m)_$(t)_$(n)_$(b)_nprocs.jld", "[", "")
filename = replace(filename, "]", "")
filename = replace("res/$(m)_$(t)_$(n)_$(b)_nprocs.jld2", "["=>"")
filename = replace(filename, "]"=>"")
compt = Dict{String, Any}("cumulants"=> onec, "cumulantsnc"=> comptimes)
push!(compt, "t" => [t])
push!(compt, "n" => n)
Expand Down
9 changes: 5 additions & 4 deletions test/comptimes.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env julia

using Cumulants
using JLD
using JLD2
using FileIO
using ArgParse


Expand Down Expand Up @@ -41,12 +42,12 @@ end
"""
savecomptime(m::Int, T::Vector{Int}, n::Vector{Int}, cache::Bool)
Save a file in jld format of the computional times of moment, naivemoment, rawmoment
Save a file in jld2 format of the computional times of moment, naivemoment, rawmoment
"""
function savecomptime(m::Int, t::Vector{Int}, n::Vector{Int})
filename = replace("res/"*string(m)*string(t)*string(n)*".jld", "[", "_")
filename = replace(filename, "]", "")
filename = replace("res/"*string(m)*string(t)*string(n)*".jld2", "["=>"_")
filename = replace(filename, "]"=>"")
fs = [moment, naivemoment, cumulants, naivecumulant]
compt = Dict{String, Any}()
for f in fs
Expand Down
11 changes: 6 additions & 5 deletions test/data/plotsuperdiag.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env julia

using JLD
using JLD2
using FileIO
using SymmetricTensors
using PyCall
@pyimport matplotlib as mpl
Expand All @@ -15,12 +16,12 @@ mpl.rc("font", family="serif", size = 8)
Plots a chart of superdiagonal elements of cumulants of and its theoretical values
"""
function pltdiag()
tdiag = try load("datafortests.jld")["theoretical diag"]
tdiag = try load("datafortests.jld2")["theoretical diag"]
catch
println("please run test/gandata.jl and test/testondata.jl")
return ()
end
cum = try load("cumulants.jld")["cumulants"]
cum = try load("cumulants.jld2")["cumulants"]
catch
println("please run test/testondata.jl")
return ()
Expand All @@ -36,7 +37,7 @@ function pltdiag()
PyPlot.ylabel("superdiagonal elements", labelpad = -1)
PyPlot.xlabel("superdiagonal number", labelpad = -3)
ax[:legend](fontsize = 4.5, loc = 5)
fig[:savefig]("diagcumels.eps")
fig[:savefig]("diagcumels.pdf")
end


Expand All @@ -45,4 +46,4 @@ function main()
pltdiag()
end

main()
main()
11 changes: 7 additions & 4 deletions test/gendata.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
#!/usr/bin/env julia

using Distributions
using JLD
using FileIO
using JLD2
using Random
using SpecialFunctions

"""
gendat(nu::Int, t::Int)
Expand All @@ -13,7 +16,7 @@ with nu degress of freedom
function gendat(nu::Int, t::Int = 150000000)
cm = [[1. 0.7 0.7 0.7];[0.7 1. 0.7 0.7]; [0.7 0.7 1. 0.7]; [0.7 0.7 0.7 1]]
p = MvTDist(nu, [0., 0., 0., 0.],cm)
return transpose(rand(p, t))
return Array(transpose(rand(p, t)))
end


Expand Down Expand Up @@ -44,11 +47,11 @@ end

function main()
nu = 14
srand(42)
Random.seed!(42)
data = gendat(nu::Int)
d = Dict{String, Any}("theoretical diag" => Float64[tcum(14, k) for k in 1:6])
push!(d, "data" => data)
save("data/datafortests.jld", d)
save("data/datafortests.jld2", d)
end

main()
Binary file removed test/res/4_100000, 200000, 500000_60_nblocks.jld
Binary file not shown.
Binary file removed test/res/4_100000_30, 40leeuw_cums.jld
Binary file not shown.
Binary file removed test/res/4_100000_60_nblocks.jld
Binary file not shown.
Binary file removed test/res/5_100000_60_nblocks.jld
Binary file not shown.
13 changes: 7 additions & 6 deletions test/res/plotcomptimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ using PyCall
mpl.rc("text", usetex=true)
mpl.use("Agg")
using PyPlot
using JLD
using JLD2
using FileIO
using ArgParse

function singleplot(filename::String, name::String, compare::String = "")
d = load(filename*".jld")
d = load(filename*".jld2")
if compare == ""
comptimes = d[name]
ylab = "computional time [s]"
Expand Down Expand Up @@ -39,20 +40,20 @@ function singleplot(filename::String, name::String, compare::String = "")
ax[:yaxis][:set_major_formatter](f)
ax[:legend](fontsize = 6, loc = 2, ncol = 1)
subplots_adjust(bottom = 0.12,top=0.92)
fig[:savefig](name*filename*".eps")
fig[:savefig](name*filename*".pdf")
end


"""
pltspeedup(comptimes::Array{Float}, m::Int, n::Vector{Int}, T::Vector{Int}, label::String)
Returns a figure in .eps format of the computional speedup of cumulants function
Returns a figure in .pdf format of the computional speedup of cumulants function
"""

function pltspeedup(filename::String)
d = load(filename)
filename = replace(filename, ".jld", "")
filename = replace(filename, ".jld2"=>"")
for f in d["functions"]
singleplot(filename::String, f...)
end
Expand All @@ -70,4 +71,4 @@ function main(args)
pltspeedup(parsed_args["file"])
end

main(ARGS)
main(ARGS)
9 changes: 5 additions & 4 deletions test/testondata.jl
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
#!/usr/bin/env julia

using JLD
using JLD2
using FileIO
using Cumulants

function main()
d = try load("data/datafortests.jld")
d = try load("data/datafortests.jld2")
catch
println("please run gendata.jl")
return ()
end
c = cumulants(d["data"], 6)
save("data/cumulants.jld", Dict("cumulants" => c))
save("data/cumulants.jld2", Dict("cumulants" => c))
end

main()
main()

0 comments on commit f630fc4

Please sign in to comment.