Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some SciMLFunctions don't error for too few arguments #608

Closed
lxvm opened this issue Feb 2, 2024 · 1 comment
Closed

Some SciMLFunctions don't error for too few arguments #608

lxvm opened this issue Feb 2, 2024 · 1 comment

Comments

@lxvm
Copy link
Contributor

lxvm commented Feb 2, 2024

Is your feature request related to a problem? Please describe.

I find I often write a one-argument function to pass to an IntegralProblem but I only get an error at solve time. Here is a list of all SciMLFunctions and whether or not they throw a too-few argument error. Here is a test that confirms they all throw the expected error

using SciMLBase, Test

few(x) = x

@testset "too few argument error" begin
    @test_throws SciMLBase.TooFewArgumentsError ODEFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError DiscreteFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError ImplicitDiscreteFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError SplitFunction(few, few)
    @test_throws SciMLBase.TooFewArgumentsError DAEFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError DDEFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError SDEFunction(few, few)
    @test_throws SciMLBase.TooFewArgumentsError SplitSDEFunction(few, few, few)
    @test_throws SciMLBase.TooFewArgumentsError RODEFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError SDDEFunction(few, few)
    @test_throws SciMLBase.TooFewArgumentsError IncrementingODEFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError NonlinearFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError IntervalNonlinearFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError BVPFunction(few, few)
    @test_throws SciMLBase.TooFewArgumentsError IntegralFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError BatchIntegralFunction(few)
    @test_throws SciMLBase.TooFewArgumentsError OptimizationFunction(few)
end

Describe the solution you’d like

Ideally all SciMLFunctions should detect too few arguments and throw an error in that case.

Describe alternatives you’ve considered

Adding tests for these cases

Additional context

This would be a helpful usability and consistency feature

@lxvm
Copy link
Contributor Author

lxvm commented Feb 3, 2024

I had a bad MWE since sin has methods with more than one argument defined in Lazy.jl. The updated comment above tests the expected error messages.

@lxvm lxvm closed this as completed Feb 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant