Skip to content

Commit

Permalink
final version for Julia 0.7
Browse files Browse the repository at this point in the history
  • Loading branch information
kdomino committed Sep 20, 2018
1 parent 4875849 commit 54a419a
Show file tree
Hide file tree
Showing 35 changed files with 32 additions and 28 deletions.
2 changes: 1 addition & 1 deletion src/CumulantsUpdates.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module CumulantsUpdates
using StatsBase
using FileIO
using JLD2
using Distributed
#using Distributed
import Cumulants: outerprodcum
import SymmetricTensors: pyramidindices, getblockunsafe
import LinearAlgebra: norm
Expand Down
11 changes: 5 additions & 6 deletions test/comptimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ using ArgParse
using CumulantsUpdates
using SymmetricTensors
using Combinatorics
using Distributed
import CumulantsUpdates: cumulants, moment

"""
cumspeedups(m::Int, n::Vector{Int}, t::Int, tup::Vector{Int}, b::Int)
Returns Vector, a computional speedup of m'th cumulant update of n[i] variate data
"""

function cumspeedups(m::Int, n::Vector{Int}, t::Int, u::Vector{Int}, b::Int, bc::Int = 2)
compt = zeros(length(u), length(n))
updt = copy(compt)
Expand All @@ -23,7 +23,7 @@ function cumspeedups(m::Int, n::Vector{Int}, t::Int, u::Vector{Int}, b::Int, bc:
X = randn(t, n[i])
t1 = Float64(time_ns())
cumulants(X, m, bc)
compt[:,i] = Float64(time_ns())-t1
compt[:,i] .= Float64(time_ns())-t1
dm = DataMoments(X, m, b)
for j in 1:length(u)
println("update u = ", u[j])
Expand Down Expand Up @@ -53,16 +53,15 @@ end
Saves comptime parameters into a .jld2 file
"""

function savecomptime(m::Int, n::Vector{Int}, t::Int, tup::Vector{Int}, b::Int, p::Int)
filename = replace("res/$(m)_$(t)_$(n)_$(tup)_$(p).jld2", "["=>"")
filename = replace(filename, "]", "")
filename = replace(filename, " ", "")
filename = replace(filename, "]"=>"")
filename = replace(filename, " "=>"")
compt = Dict{String, Any}()
cumtime = cumspeedups(m, n, t, tup, b)
push!(compt, "cumulants" => cumtime[1])
push!(compt, "cumulants updat" => cumtime[2])
push!(compt, "tm" => t./(2*tup+bellnum(m)))
push!(compt, "tm" => t./(2*tup.+bellnum(m)))
push!(compt, "t" => t)
push!(compt, "n" => n)
push!(compt, "m" => m)
Expand Down
4 changes: 3 additions & 1 deletion test/comptimesblocks.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using Cumulants
using SymmetricTensors
using CumulantsUpdates
using JLD
using JLD2
using FileIO
using ArgParse
using Distributed


function comptime(dm::DataMoments{Float64}, Xup::Matrix{Float64})
Expand Down
8 changes: 5 additions & 3 deletions test/comptimesprocs.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using Cumulants
using SymmetricTensors
using CumulantsUpdates
using JLD
using JLD2
using FileIO
using ArgParse
using Distributed

function comptime(dm::DataMoments{Float64}, Xup::Matrix{Float64})
t = time_ns()
Expand Down Expand Up @@ -37,8 +39,8 @@ function savect(u::Vector{Int}, p::Int, n::Int, m::Int, b::Int)
end
end
filename = replace("res/$(m)_$(u)_$(n)_$(b)_nprocs.jld2", "["=>"")
filename = replace(filename, "]", "")
filename = replace(filename, " ", "")
filename = replace(filename, "]"=>"")
filename = replace(filename, " "=>"")
compt = Dict{String, Any}("cumulants"=> comptimes)
push!(compt, "t" => u)
push!(compt, "n" => n)
Expand Down
8 changes: 5 additions & 3 deletions test/maxdatafreq.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
using Cumulants
using SymmetricTensors
using CumulantsUpdates
using JLD
using JLD2
using FileIO
using ArgParse
using Distributed
import CumulantsUpdates: cnorms

function cumnorms(c::Vector{SymmetricTensor{Float64}})
Expand Down Expand Up @@ -41,8 +43,8 @@ function savect(u::Vector{Int}, nvec::Vector{Int}, m::Int, p::Int, b::Int)
i += 1
end
filename = replace("res/$(m)_$(u)_$(nvec)_$(p)_$(b)_maxf.jld2", "["=>"")
filename = replace(filename, "]", "")
filename = replace(filename, " ", "")
filename = replace(filename, "]"=>"")
filename = replace(filename, " "=>"")
compt = Dict{String, Any}("cumulants"=> comptimes)
push!(compt, "t" => u)
push!(compt, "n" => nvec)
Expand Down
Binary file removed test/res/4_10000,20000_20,24,28_3_4_maxf.jld
Binary file not shown.
Binary file added test/res/4_10000,20000_20,24,28_3_4_maxf.jld2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test/res/4_25000,50000,70000_60_6_nblocks.jld
Binary file not shown.
Binary file added test/res/4_25000,50000,70000_60_6_nblocks.jld2
Binary file not shown.
Binary file removed test/res/4_25000,50000,75000_120_4_nprocs.jld
Binary file not shown.
Binary file added test/res/4_25000,50000,75000_120_4_nprocs.jld2
Binary file not shown.
Binary file removed test/res/4_25000,50000,75000_120_6_nblocks.jld
Binary file not shown.
Binary file added test/res/4_25000,50000,75000_120_6_nblocks.jld2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test/res/4_25000,50000,75000_60_6_nblocks.jld
Binary file not shown.
Binary file added test/res/4_25000,50000,75000_60_6_nblocks.jld2
Binary file not shown.
Binary file removed test/res/4_25000,50000_60,70,80,90,100_6_4_maxf.jld
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file removed test/res/5_120000,240000,360000_60_3_nprocs.jld
Binary file not shown.
Binary file added test/res/5_120000,240000,360000_60_3_nprocs.jld2
Binary file not shown.
Binary file removed test/res/5_120000,240000,360000_60_6_nblocks.jld
Binary file not shown.
Binary file added test/res/5_120000,240000,360000_60_6_nblocks.jld2
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
25 changes: 12 additions & 13 deletions test/res/plotcomptimes.jl
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@ mpl.rc("text", usetex=true)
mpl.use("Agg")
@pyimport matplotlib.ticker as mti
using PyPlot
using JLD
using JLD2
using FileIO
using ArgParse

o = 1
function singleplot(filename::String)
d = load(filename*".jld")
d = load(filename*".jld2")
x = d["x"]
t = d["t"]
n = d["n"]
Expand All @@ -22,13 +23,11 @@ function singleplot(filename::String)
col = ["red", "blue", "green", "gray", "brown", "orange"]
marker = [":s", ":o", ":v", ":<", ":>", ":d"]
for i in 1:size(d["cumulants"], 2)
if contains(filename, "nblocks") | contains(filename, "maxf")
str = replace(@sprintf("%.1e", t[i]), "0", "")
tt = "\$"*replace(str, "e+", "\\times 10^{")*"}\$"
if occursin("nblocks", filename) | occursin("maxf", filename)
tt = t[i]
ax[:plot](d[x], d["cumulants"][:,i], marker[i], label= "\$ t_{up} \$ = $tt", color = col[i], markersize=2.5, linewidth = 1)
elseif contains(filename, "nprocs")
str = replace(@sprintf("%.1e", t[i]), "0", "")
tt = "\$"*replace(str, "e+", "\\times 10^{")*"}\$"
elseif occursin("nprocs", filename)
tt = t[i]
y = d["cumulants"][:,i].\d["cumulants"][1,i]
ax[:plot](d[x][1:6], y[1:6], marker[i], label= "\$ t_{up} \$ = $tt", color = col[i], markersize=2.5, linewidth = 1)
else
Expand All @@ -42,19 +41,19 @@ function singleplot(filename::String)
fx = matplotlib[:ticker][:ScalarFormatter]()
fx[:set_powerlimits]((-1, 4))
ax[:xaxis][:set_major_formatter](fx)
if contains(filename, "nblocks")
if occursin("nblocks", filename)
subplots_adjust(left = 0.15)
PyPlot.ylabel("computational time [s]", labelpad = 0.6)
PyPlot.xlabel(x, labelpad = 0.6)
ax[:xaxis][:set_major_locator](mti.MaxNLocator(integer=true))
ax[:legend](fontsize = 5, loc = 9, ncol = 1)
elseif contains(filename, "nprocs")
elseif occursin("nprocs", filename)
subplots_adjust(left = 0.15)
PyPlot.ylabel("computational speedup", labelpad = 0)
PyPlot.xlabel(x, labelpad = 0.6)
ax[:xaxis][:set_major_locator](mti.MaxNLocator(integer=true))
ax[:legend](fontsize = 5, loc = 2, ncol = 1)
elseif contains(filename, "maxf")
elseif occursin("maxf", filename)
subplots_adjust(left = 0.18)
PyPlot.ylabel("frequency [Hz]", labelpad = 0.)
PyPlot.xlabel(x, labelpad = 0.6)
Expand All @@ -71,7 +70,7 @@ function singleplot(filename::String)
f = matplotlib[:ticker][:ScalarFormatter]()
f[:set_powerlimits]((-3, 2))
ax[:yaxis][:set_major_formatter](f)
fig[:savefig]("cumulants"*filename*".eps")
fig[:savefig]("cumulants"*filename*".pdf")
end


Expand All @@ -84,7 +83,7 @@ function main(args)
end
parsed_args = parse_args(s)
filename = parsed_args["file"]
singleplot(replace(filename, ".jld", ""))
singleplot(replace(filename, ".jld2"=>""))
end

main(ARGS)
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Test
using Cumulants
using Distributed
#using Distributed
using SymmetricTensors
using CumulantsUpdates
using FileIO
Expand Down

0 comments on commit 54a419a

Please sign in to comment.