Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't extend implicit eval method #274

Merged
merged 2 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/JLD2JUDIExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ JUDI.Geometry(x::JLD2.ReconstructedMutable{N, FN, NT}) where {N, FN, NT} = Geome
function JUDI.tof32(x::JLD2.ReconstructedStatic{N, FN, NT}) where {N, FN, NT}
# Drop "typed" signature
reconstructT = Symbol(split(string(N), "{")[1])
return JUDI.tof32(eval(reconstructT)([getproperty(x, f) for f in FN]...))
return JUDI.tof32(getproperty(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...))
Copy link

Choose a reason for hiding this comment

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

Suggested change
return JUDI.tof32(getproperty(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...))
return JUDI.tof32(getglobal(@__MODULE__, reconstructT)([getproperty(x, f) for f in FN]...))

(assuming you only support v1.9 or later)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe there's a 1.6 compat, which is why I used get property. But yes, getglobal is preferred for 1.9+

end

end
2 changes: 1 addition & 1 deletion src/TimeModeling/LinearOperators/lazy.jl
Original file line number Diff line number Diff line change
Expand Up @@ -215,4 +215,4 @@ _as_src(::judiNoopOperator, ::AbstractModel, q::judiMultiSourceVector) = q

############################################################################################################################
###### Evaluate lazy operation
eval(rhs::judiRHS) = rhs.d
eval_lazy(rhs::judiRHS) = rhs.d
7 changes: 4 additions & 3 deletions src/TimeModeling/Modeling/python_interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ function wrapcall_weights(func, args...;kw...)
return out
end

function wrapcall_wf(func, args...;kw...)
rtype = _outtype(get(kw, :illum, nothing), 1, Array{Float32})
out = rlock_pycall(func, rtype, args...;kw...)
function wrapcall_wf(func, modelPy, args...;kw...)
ndim = modelPy.dim + 1 # Add time dimension
rtype = _outtype(get(kw, :illum, nothing), 1, Array{Float32, ndim})
out = rlock_pycall(func, rtype, modelPy, args...;kw...)
return out
end

Expand Down
4 changes: 2 additions & 2 deletions src/TimeModeling/Types/GeometryStructure.jl
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ function getproperty(G::Geometry, s::Symbol)
end
# Legacy dt/nt/t
if s in [:dt, :t, :nt, :t0]
return eval(Symbol("get_$(s)"))(G)
return getproperty(@__MODULE__, Symbol("get_$(s)"))(G)
end

return getfield(G, s)
end

Expand Down
8 changes: 4 additions & 4 deletions src/TimeModeling/Types/lazy_msv.jl
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ end
getindex(la::LazyAdd{D}, i::RangeOrVec) where D = LazyAdd{D}(length(i), la.A[i], la.B[i], la.sign)


function eval(ls::LazyAdd{D}) where D
aloc = eval(ls.A)
bloc = eval(ls.B)
function eval_lazy(ls::LazyAdd{D}) where D
aloc = eval_lazy(ls.A)
bloc = eval_lazy(ls.B)
ga = aloc.geometry
gb = bloc.geometry
@assert (ga.nt == gb.nt && ga.dt == gb.dt && ga.t == gb.t)
Expand All @@ -49,7 +49,7 @@ function eval(ls::LazyAdd{D}) where D
end

function make_src(ls::LazyAdd{D}) where D
q = eval(ls)
q = eval_lazy(ls)
return q.geometry[1], q.data[1]
end

Expand Down
Loading