Skip to content

Commit

Permalink
bump devito version req to sympy 1.13
Browse files Browse the repository at this point in the history
  • Loading branch information
mloubout committed Jul 12, 2024
1 parent 328490f commit a446215
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 37 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-judi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ jobs:

- name: Set julia python
run: |
echo "PYTHON=$(which python3)" >> $GITHUB_ENV
PYTHON=$(which python3) julia -e 'using Pkg;Pkg.add("PyCall");Pkg.build("PyCall")'
- name: Build JUDI
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/ci-op.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ jobs:

- name: Set julia python
run: |
echo "PYTHON=$(which python3)" >> $GITHUB_ENV
PYTHON=$(which python3) julia -e 'using Pkg;Pkg.add("PyCall");Pkg.build("PyCall")'
- name: Build JUDI
Expand Down
22 changes: 11 additions & 11 deletions Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "JUDI"
uuid = "f3b833dc-6b2e-5b9c-b940-873ed6319979"
authors = ["Philipp Witte, Mathias Louboutin"]
version = "3.4.4"
version = "3.4.5"

[deps]
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"
Expand All @@ -17,16 +17,6 @@ Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Requires = "ae029012-a4dd-5104-9daa-d747884805df"
SegyIO = "157a0f19-4d44-4de5-a0d0-07e2f0ac4dfa"

[weakdeps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"

[extensions]
FluxJUDIExt = "Flux"
JLD2JUDIExt = "JLD2"
ZygoteJUDIExt = "Zygote"

[compat]
Aqua = "0.5"
ChainRulesCore = "1"
Expand All @@ -42,6 +32,11 @@ SegyIO = "0.7.7 - 0.8.5"
TimerOutputs = "0.5"
julia = "1.6"

[extensions]
FluxJUDIExt = "Flux"
JLD2JUDIExt = "JLD2"
ZygoteJUDIExt = "Zygote"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
Expand All @@ -52,3 +47,8 @@ TimerOutputs = "a759f4b9-e2f1-59dc-863e-4aeb61b1ea8f"

[targets]
test = ["Aqua", "JLD2", "Printf", "Test", "TimerOutputs", "Flux"]

[weakdeps]
Flux = "587475ba-b771-5e3f-ad9e-33799f191a9c"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
Zygote = "e88e6eb3-aa80-5325-afca-941959d7151f"
23 changes: 12 additions & 11 deletions deps/build.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,37 +5,38 @@ struct DevitoException <: Exception
msg::String
end

python = PyCall.pyprogramname
if PyCall.pyversion >= VersionNumber("3.12.0")
install = ["install", "--user"]
else
install = ["install"]
end

pk = try
pyimport("pkg_resources")
catch e
Cmd([python, "-m", "pip", "install", "--user", "setuptools"])
run(cmd)
run(PyCall.python_cmd(`-m pip install --user setuptools`))
pyimport("pkg_resources")
end

################## Devito ##################
# pip command
cmd = Cmd([python, "-m", "pip", "install", "-U", "--user", "devito[extras,tests]>=4.4"])
dvver = "4.8.10"
cmd = PyCall.python_cmd(`-m pip install --user devito\[extras,tests\]\>\=$(dvver)`)

try
dv_ver = split(pk.get_distribution("devito").version, "+")[1]
if cmp(dv_ver, "4.8.7") < 0
@info "Devito version too low, updating to >=4.8.7"
dv_ver = VersionNumber(split(pk.get_distribution("devito").version, "+")[1])
if dv_ver < VersionNumber(dvver)
@info "Devito version too low, updating to >=$(dvver)"
run(cmd)
end
catch e
@info "Devito not installed, installing with PyCall python"
run(cmd)
end


################## Matplotlib ##################
# pip command
cmd = Cmd([python, "-m", "pip", "install", "--user", "matplotlib"])
try
mpl = pyimport("matplotlib")
catch e
run(cmd)
run(PyCall.python_cmd(`-m pip install --user matplotlib`))
end
3 changes: 1 addition & 2 deletions src/JUDI.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ module JUDI
export JUDIPATH, set_verbosity, ftp_data, get_serial, set_serial, set_parallel
JUDIPATH = dirname(pathof(JUDI))


# Only needed if extension not available (julia < 1.9)
if !isdefined(Base, :get_extension)
using Requires
Expand Down Expand Up @@ -102,7 +101,7 @@ function _worker_pool()
return nothing
end
p = default_worker_pool()
pool = length(p) < 2 ? nothing : p
pool = length(workers()) < 2 ? nothing : p
return pool
end

Expand Down
23 changes: 12 additions & 11 deletions src/pysource/FD_utils.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
from sympy import rot_axis2, rot_axis3
from devito import TensorFunction, Differentiable, div, grad, cos, sin

from devito import TensorFunction, Differentiable, div, grad

trig_mapper = {cos.__sympy_class__: cos, sin.__sympy_class__: sin}
r2 = lambda x: rot_axis2(x).applyfunc(lambda i: trig_mapper.get(i.func, i.func)(*i.args))
r3 = lambda x: rot_axis3(x).applyfunc(lambda i: trig_mapper.get(i.func, i.func)(*i.args))


def laplacian(v, irho):
Expand All @@ -27,22 +31,19 @@ def R_mat(model):
"""
# Rotation matrix
try:
Rt = rot_axis2(model.theta)
Rt = r2(model.theta)
except AttributeError:
Rt = rot_axis2(0)
Rt = r2(0)
if model.dim == 3:
try:
Rt *= rot_axis3(model.phi)
Rt *= r3(model.phi)
except AttributeError:
Rt *= rot_axis3(0)
Rt *= r3(0)
else:
Rt = Rt[[0, 2], [0, 2]]
R = TensorFunction(name="R", grid=model.grid, components=Rt, symmetric=False)
try:
R.name == "R"
return R
except AttributeError:
return Rt
# Rebuild sin/cos

return TensorFunction(name="R", grid=model.grid, components=Rt, symmetric=False)


def thomsen_mat(model):
Expand Down
3 changes: 1 addition & 2 deletions src/pysource/kernels.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,6 @@ def SLS_2nd_order(model, p, fw=True, q=None, f0=0.015):
b * r.forward - q + (1 - damp) * p.dt
u_p = Eq(p.forward, solve(pde_p, p.forward))

return [u_r, u_p]
else:
# Attenuation Memory variable
pde_r = r.dt.T + b * p + (1 / t_s) * r
Expand All @@ -130,7 +129,7 @@ def SLS_2nd_order(model, p, fw=True, q=None, f0=0.015):

u_p = Eq(p.backward, solve(pde_p, p.backward))

return [u_r, u_p], []
return [u_r, u_p], []


def tti_kernel(model, u1, u2, fw=True, q=None):
Expand Down

0 comments on commit a446215

Please sign in to comment.