Skip to content

Commit

Permalink
Fix numargs for ComposedFunction
Browse files Browse the repository at this point in the history
  • Loading branch information
Lilith Hafner authored and Lilith Hafner committed Sep 30, 2023
1 parent 16db0e3 commit ef270d9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/utils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ function numargs(f::RuntimeGeneratedFunctions.RuntimeGeneratedFunction{
(length(T),)
end

numargs(f::ComposedFunction) = numargs(f.inner)

Check warning on line 30 in src/utils.jl

View check run for this annotation

Codecov / codecov/patch

src/utils.jl#L30

Added line #L30 was not covered by tests

"""
$(SIGNATURES)
Expand Down
5 changes: 3 additions & 2 deletions test/function_building_error_messages.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ function test_num_args()
numpar = SciMLBase.numargs(f) # Should be [1,2]
g = (x, y) -> x^2
numpar2 = SciMLBase.numargs(g) # [2]
numpar3 = SciMLBase.numargs(sqrt g) # [2]
@show numpar, minimum(numpar) == 1, maximum(numpar) == 2
minimum(numpar) == 1 && maximum(numpar) == 2 &&
maximum(numpar2) == 2 &&
minimum(numpar2) == 2
only(numpar3) == 2
end

@test test_num_args()
Expand Down Expand Up @@ -614,7 +615,7 @@ bvjp(u, v, p, t) = [1.0]
@test_throws SciMLBase.NonconformingFunctionsError BVPFunction(bfoop, bciip, vjp = bvjp)
bvjp(du, u, v, p, t) = [1.0]
BVPFunction(bfiip, bciip, vjp = bvjp)

@test_throws SciMLBase.NonconformingFunctionsError BVPFunction(bfoop, bciip, vjp = bvjp)

# IntegralFunction
Expand Down

0 comments on commit ef270d9

Please sign in to comment.