Skip to content

Commit

Permalink
Merge pull request #18 from numericalEFT/dev
Browse files Browse the repository at this point in the history
add compat for JLD2 and FileIO; corrected deepequal for io test
  • Loading branch information
iintSjds authored Dec 30, 2021
2 parents 4c01537 + c386974 commit 19b4c04
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 8 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ FastGaussQuadrature = "0.4"
Quadmath = "0.5"
StaticArrays = "1"
julia = "1.4"
FileIO = "1.11.2"
JLD2 = "0.4.17"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"
Expand Down
50 changes: 42 additions & 8 deletions test/io.jl
Original file line number Diff line number Diff line change
@@ -1,23 +1,55 @@
@testset "IO" begin
@testset "JLD2" begin
function deepequal(a::Array, b::Array)
typeof(a) == typeof(b) || return false
N = length(a)
for i in 1:N
deepequal(a[i] , b[i]) || return false
end
return true
end

function deepequal(a, b)
typeof(a) == typeof(b) || return false
N = fieldcount(typeof(a))
if N==0
return a==b
end
for i in 1:N
deepequal(getfield(a, i) , getfield(b, i)) || return false
end
return true
end

function deeptest(a::Array, b::Array)
@test typeof(a) == typeof(b)
N = length(a)
for i in 1:N
deeptest(a[i] , b[i])
end
end

function deeptest(a, b)
@test typeof(a) == typeof(b)
N = fieldcount(typeof(a))
if N==0
@test a==b
end
for i in 1:N
deeptest(getfield(a, i) , getfield(b, i))
@test deepequal(a,b)
end
end

β = 10

tgrid = CompositeGrid.LogDensedGrid(
:gauss,# The top layer grid is :gauss, optimized for integration. For interpolation use :cheb
[0.0, β],# The grid is defined on [0.0, β]
[0.0, β],# and is densed at 0.0 and β, as given by 2nd and 3rd parameter.
5,# N of log grid
0.005, # niminum interval length of log grid
5 # N of bottom layer
:gauss,# The top layer grid is :gauss, optimized for integration. For interpolation use :cheb
[0.0, β],# The grid is defined on [0.0, β]
[0.0, β],# and is densed at 0.0 and β, as given by 2nd and 3rd parameter.
5,# N of log grid
0.005, # niminum interval length of log grid
5 # N of bottom layer
)

############# FileIO API #################
Expand All @@ -27,7 +59,8 @@
dg = d["grid"]
println(typeof(dg))
println(dg.grid)
@test deepequal(dg, tgrid)
deeptest(dg, tgrid)
@test deepequal(dg,tgrid)

############# naive API ##################
jldopen("example.jld2", "w") do file
Expand All @@ -38,7 +71,8 @@
g = file["test"]
println(typeof(g))
println(g.grid)
@test deepequal(g, tgrid)
deeptest(g, tgrid)
@test deepequal(g,tgrid)
end

# remove the file
Expand Down

2 comments on commit 19b4c04

@iintSjds
Copy link
Member Author

Choose a reason for hiding this comment

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

@JuliaRegistrator
Copy link

Choose a reason for hiding this comment

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

Registration pull request updated: JuliaRegistries/General/51406

After the above pull request is merged, it is recommended that a tag is created on this repository for the registered package version.

This will be done automatically if the Julia TagBot GitHub Action is installed, or can be done manually through the github interface, or via:

git tag -a v0.0.3 -m "<description of version>" 19b4c04ad714cc48a8d9ef0107a14cbf15ef0a97
git push origin v0.0.3

Please sign in to comment.