Skip to content

Commit f2abbd5

Browse files
authored
Merge pull request #227 from ChevronETC/mbader/sympy-or
Add access to sympy Or
2 parents e56af7d + 8b950ab commit f2abbd5

File tree

4 files changed

+29
-2
lines changed

4 files changed

+29
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ jobs:
7777
- name: run tests
7878
run: |
7979
julia --color=yes --check-bounds=yes --inline=no --project -e 'using Pkg; Pkg.test(coverage=true)'
80+
env:
81+
DEVITO_BRANCH: ${{ matrix.devitoversion }}
8082

8183
- uses: julia-actions/julia-processcoverage@v1
8284

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "Devito"
22
uuid = "06ed14b1-0e40-4084-abdf-764a285f8c42"
33
authors = ["Sam Kaplan <Sam.Kaplan@chevron.com>"]
4-
version = "1.3.2"
4+
version = "1.4.0"
55

66
[deps]
77
PyCall = "438e738f-606a-5dbb-bf0a-cddfbfd45ab0"

src/Devito.jl

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@ Symbol defining the size of the Dimension
14891489
function symbolic_size end
14901490

14911491
# metaprograming for Devito functions taking variable number of arguments
1492-
for (M,F) in ((:devito,:Min), (:devito,:Max),(:sympy,:And))
1492+
for (M,F) in ((:devito,:Min), (:devito,:Max), (:sympy,:And))
14931493
@eval begin
14941494
$F(args...) = $M.$F((PyObject.(args))...)
14951495
export $F
@@ -1559,6 +1559,9 @@ Perform Modular division on a dimension
15591559
Mod(x::Union{AbstractDimension,PyObject},y::Int) = sympy.Mod(PyObject(x),PyObject(y))
15601560
export Mod
15611561

1562+
"""function to return the sympy Or"""
1563+
sympy_or() = sympy.Or
1564+
15621565
"""Get symbolic representation for function index object"""
15631566
function Base.getindex(x::Union{TimeFunction,Function},args...)
15641567
return utils."indexobj"(x,reverse(args)...)

test/serialtests.jl

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,28 @@ end
506506
end
507507
end
508508

509+
@testset "Conditional dimension with sympy_or" begin
510+
size, factr = 18, 4
511+
i = Devito.SpaceDimension(name="i")
512+
grd = Grid(shape=(size,),dimensions=(i,))
513+
ci = ConditionalDimension(name="ci", parent=i, factor=factr, relation=Devito.sympy_or())
514+
cend = ConditionalDimension(name="cend", parent=i, condition=CondEq(i, size-1), relation=Devito.sympy_or())
515+
@test parent(ci) == i
516+
@test parent(cend) == i
517+
g = Devito.Function(name="g", grid=grd, shape=(size,), dimensions=(i,))
518+
f = Devito.Function(name="f", grid=grd, shape=(div(size,factr)+2,), dimensions=(ci,))
519+
op = Operator([Eq(g, i), Eq(f, g), Eq(f[ci+1], g, implicit_dims=cend)], name="Conditional_and_Or")
520+
apply(op)
521+
for j in 1:div(size,factr)+1
522+
@test data(f)[j] == data(g)[(j-1)*factr+1]
523+
end
524+
if ENV["DEVITO_BRANCH"] in ("main", "devitopro")
525+
@test data(f)[end] == data(g)[end]
526+
else
527+
@test_broken data(f)[end] == data(g)[end]
528+
end
529+
end
530+
509531
@testset "PyObject(Dimension)" begin
510532
x = SpaceDimension(name="x")
511533
@test PyObject(x) === x.o

0 commit comments

Comments
 (0)