Skip to content

FastDifferentiation v0.4.3 and newer break usage of make_Expr #110

@duetosymmetry

Description

@duetosymmetry

Installing with FastDifferentiation v0.4.2 works. When installing with v0.4.3 or v0.4.4, I get the following error when precompiling:

ERROR: LoadError: MethodError: no method matching make_Expr(::StaticArraysCore.SVector{1, FastDifferentiation.Node}, ::Vector{FastDifferentiation.Node}, ::Bool, ::Bool)
The function `make_Expr` exists, but no method is defined for this combination of argument types.

Closest candidates are:
  make_Expr(::AbstractArray{T}, ::AbstractVector...; in_place, init_with_zeros) where T<:FastDifferentiation.Node
   @ FastDifferentiation ~/.julia/packages/FastDifferentiation/7my9Z/src/CodeGeneration.jl:221
  make_Expr(::SparseArrays.SparseMatrixCSC{T, Ti}, ::AbstractVector...; in_place, init_with_zeros) where {T<:FastDifferentiation.Node, Ti}
   @ FastDifferentiation ~/.julia/packages/FastDifferentiation/7my9Z/src/CodeGeneration.jl:306

The code in question is this block:

fdpnsystem = FDPNSystem(FloatType, PNOrder)
# FD expects a single vector of variables, so we concatenate the state vector with the
# two tidal-coupling parameters
vars = FastDifferentiation.Node[fdpnsystem.state; Λ₁(fdpnsystem); Λ₂(fdpnsystem)]
# Now we evaluate 𝓔 using the FD variables. This will expand all derived variables in
# terms of the fundamental variables, but FD will take care of evaluating those
# efficiently via common subexpression elimination (CSE).
𝓔formula = 𝓔(fdpnsystem; pn_expansion_reducer=Val(PNExpansionReducer))
# Now we take the derivative of 𝓔 with respect to v.
𝓔′ = SVector(FastDifferentiation.derivative(𝓔formula, v(fdpnsystem)))
# Turn that into an Expr (FD insists on making it a function)
in_place = true
init_with_zeros = false
𝓔′expr = FastDifferentiation.make_Expr(𝓔′, vars, in_place, init_with_zeros)

I suspect the reason for this breakage was the following change on line 160 of src/CodeGeneration.jl in FD from v0.4.2...v0.4.3:

brianguenter/FastDifferentiation.jl@f5ae992#diff-b2b9a7d4664620d12817fc24b95f5532ea8a28744562bfce672174aba3ecb2b7R159-R161

which I quote here:

-function make_Expr(func_array::AbstractArray{T}, input_variables::AbstractVector{S}, in_place::Bool, init_with_zeros::Bool) where {T<:Node,S<:Node}
+function make_Expr(func_array::AbstractArray{T}, input_variables::AbstractVector...; in_place::Bool=false, init_with_zeros::Bool=true) where {T<:Node}

But I don't really know why this type signature isn't matching what's in binding_energy.jl (and separation.jl).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions