Skip to content

Commit 9efd021

Browse files
committed
Add tests to improve coverage
1 parent 5ca59cf commit 9efd021

File tree

4 files changed

+126
-76
lines changed

4 files changed

+126
-76
lines changed

test/csotests.jl

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
using Devito, PyCall, Test
2+
3+
# const numpy = PyNULL()
4+
# copy!(numpy, pyimport("numpy"))
5+
6+
function typedict()
7+
_typedict = Dict{DataType, PyCall.PyObject}()
8+
_typedict[Float32] = Devito.numpy.float32
9+
_typedict[Float64] = Devito.numpy.float64
10+
_typedict[Int8] = Devito.numpy.int8
11+
_typedict[UInt8] = Devito.numpy.uint8
12+
_typedict[Int16] = Devito.numpy.int16
13+
_typedict[UInt16] = Devito.numpy.uint16
14+
_typedict[Int32] = Devito.numpy.int32
15+
_typedict[Int64] = Devito.numpy.int64
16+
_typedict[ComplexF32] = Devito.numpy.complex64
17+
_typedict[ComplexF64] = Devito.numpy.complex128
18+
_typedict
19+
end
20+
21+
@testset "Exercise types" for T in (Float32, Float64, Int8, UInt8, Int16, UInt16, Int32, Int64, ComplexF32, ComplexF64)
22+
td = typedict()
23+
@test Devito.numpy.dtype(td[T]) == Devito.numpy.dtype(T)
24+
@test T == Devito._numpy_eltype(td[T])
25+
end
26+

test/devitoprotests.jl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,6 @@ compression = []
171171
(lowercase(devito_arch) in ["gcc", "clang"]) && (push!(compression, "cvxcompress"))
172172

173173
@testset "Serialization with compression=$(compression)" for compression in compression
174-
@info "testing compression with $(compression)"
175174
if compression == "bitcomp"
176175
configuration!("compiler", "nvc")
177176
else
@@ -214,6 +213,24 @@ compression = []
214213
end
215214
end
216215

216+
@testset "Serialization serial2str" begin
217+
nt = 11
218+
space_order = 8
219+
grid = Grid(shape=(21,21,21), dtype=Float32)
220+
f1 = TimeFunction(name="f1", grid=grid, space_order=space_order, time_order=1, save=Buffer(1))
221+
f2 = TimeFunction(name="f2", grid=grid, space_order=space_order, time_order=1, save=Buffer(1))
222+
z, y, x, t = dimensions(f1)
223+
ct = ConditionalDimension(name="ct", parent=time_dim(grid), factor=1)
224+
dumpdir = joinpath(tempdir(),"test-serial2str")
225+
isdir(dumpdir) && rm(dumpdir, force=true, recursive=true)
226+
mkdir(dumpdir)
227+
flazy = TimeFunction(name="flazy", lazy=false, grid=grid, time_order=0, space_order=space_order, time_dim=ct, save=nt, serialization=dumpdir)
228+
str = Devito.serial2str(flazy)
229+
ser = Devito.str2serial(str)
230+
pathlib = pyimport("pathlib")
231+
py_path = pathlib.Path(str)
232+
end
233+
217234
# JKW: removing for now, not sure what is even being tested here
218235
# @testset "Serialization with CCall T=$T" for T in (Float32,Float64)
219236
# space_order = 2

test/runtests.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ To change to a different implementation do (for example):
1212
MPIPreferences.use_jll_binary("MPICH_jll")
1313
"""
1414

15-
for testscript in ("serialtests.jl", "gencodetests.jl", "csymbolicstests.jl")
15+
for testscript in ("serialtests.jl", "gencodetests.jl", "csymbolicstests.jl", "csotests.jl")
1616
include(testscript)
1717
end
1818

0 commit comments

Comments
 (0)