Skip to content

Commit

Permalink
Merge pull request #506 from LilithHafner/fix-numargs-composed
Browse files Browse the repository at this point in the history
Implement `numargs` for ComposedFunction
  • Loading branch information
ChrisRackauckas authored Oct 1, 2023
2 parents aaa55ad + 5e16982 commit 75b1925
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ jobs:
- Downstream
version:
- '1'
- '1.6'
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v1
Expand Down
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)

"""
$(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 75b1925

Please sign in to comment.