Skip to content
Snippets Groups Projects
Verified Commit 890e77db authored by Michiel Cottaar's avatar Michiel Cottaar
Browse files

Improve check if `get_gradient` should be called

parent 714d5d02
No related branches found
No related tags found
No related merge requests found
......@@ -291,7 +291,9 @@ end
for base_fn in [:qval, :gradient_strength, :slew_rate]
fn3 = Symbol(String(base_fn) * "3")
@eval function $fn3(bb::AbstractBlock, args...; kwargs...)
if hasproperty(bb, :orientation)
if hasmethod(get_gradient, (typeof(bb), ))
return $fn3(get_gradient(bb), args...; kwargs...)
else
value = $base_fn(bb, args...; kwargs...)
if value isa Number && iszero(value)
return zero(SVector{3, Float64})
......@@ -300,8 +302,6 @@ for base_fn in [:qval, :gradient_strength, :slew_rate]
else
return value .* bb.orientation
end
else
return $fn3(get_gradient(bb), args...; kwargs...)
end
end
@eval $fn3(nt::NamedTuple, args...; kwargs...) = map(v -> $fn3(v, args...; kwargs...), nt)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment