Skip to content

Commit

Permalink
Loosen type restrictions
Browse files Browse the repository at this point in the history
  • Loading branch information
adrhill committed Nov 25, 2024
1 parent 435aa8f commit 14d2ba3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/parse_outputs_to_matrix.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
#= Parse tracers from function evaluation in `src/trace_functions.jl` into an output matrix. =#

_tracer_or_number(x::Real) = x
_tracer_or_number(d::Dual) = tracer(d)

#==========#
# Jacobian #
#==========#

function jacobian_tracers_to_matrix(
xt::AbstractArray{T}, yt::AbstractArray{<:Real}
xt::AbstractArray{T}, yt::AbstractArray
) where {T<:GradientTracer}
n, m = length(xt), length(yt)
I = Int[] # row indices
Expand All @@ -24,7 +27,7 @@ function jacobian_tracers_to_matrix(
end

function jacobian_tracers_to_matrix(
xt::AbstractArray{D}, yt::AbstractArray{<:Real}
xt::AbstractArray{D}, yt::AbstractArray
) where {P,T<:GradientTracer,D<:Dual{P,T}}
return jacobian_tracers_to_matrix(tracer.(xt), _tracer_or_number.(yt))
end
Expand Down
4 changes: 0 additions & 4 deletions src/trace_functions.jl
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ end
to_array(x::Real) = [x]
to_array(x::AbstractArray) = x

# Utilities
_tracer_or_number(x::Real) = x
_tracer_or_number(d::Dual) = tracer(d)

#==========#
# Jacobian #
#==========#
Expand Down

0 comments on commit 14d2ba3

Please sign in to comment.