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

Add tests of various features #2806

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

TorkelE
Copy link
Member

@TorkelE TorkelE commented Jun 15, 2024

Ok, I have tried to rewrite various tests in Catalyst to work within MTK (a bit more complicated since each system have to be generated directly, and cannot be generated from a single ReactionSystem model. These tests are primarily going through vaiours ways to interact with SciML structures, and giving input to problems, across various system types.

I have tried to go through all broken tests, and mark issues that are related. Unfortunately there are quite a few, so someone else would probably need to have a second look at each to check the issues are accurate.

@ChrisRackauckas
Copy link
Member

The tests fail?

@TorkelE
Copy link
Member Author

TorkelE commented Jun 15, 2024

Not too surprised. I will have a look locally (the test log is too large to actually see what is going on)

@TorkelE
Copy link
Member Author

TorkelE commented Jun 15, 2024

Ok, tests pass now (except for one downstream test)

Copy link
Member

@AayushSabharwal AayushSabharwal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the extremely comprehensive tests. Apart from the specific comments below, I have a couple of overarching requests.

Firstly, these tests don't belong in MTK. They are all testing features implemented in SciMLBase, and should go there alongside the other tests for similar functionality.

  • Anything to do with remake should be in SciMLBase's modelingtoolkit_remake.jl testset
  • All of the tests for symbolic indexing/interpolation of integrators/solutions/etc should be in a comprehensive_indexing.jl testset
  • Both of the above should be in the "SymbolicIndexingInterface" group

That way all of these will be run in MTK downstream, and are tested in the library that implements the features being tested. SciMLBase wants to run these tests because changes in SciMLBase are more likely to break them than ones in MTK. remake for example is almost entirely a SciMLBase feature, and the only places MTK is likely to break it is remake_buffer.

Testing save_idxs is also unnecessary in my opinion. It's not something that's broken, it's a feature we don't support yet.

I would also like to not merge these tests in a state where the broken ones are commented out/marked as @test_broken. That defeats the purpose of the tests. We should test everything, and merge when it's all fixed.

base_esol = solve(base_eprob, ImplicitEM(); seed, trajectories = 2, saveat = 1.0)

# Simulates problems for all input types, checking that identical solutions are found.
@test_broken false # first remake in subsequent test yields a `ERROR: type Nothing has no field portion`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the difference between this SDESystem and the one in https://github.com/SciML/SciMLBase.jl/blob/master/test/downstream/modelingtoolkit_remake.jl? remake passes there and fails here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this ones goes through a couple of additional cases (e.g. observables). not sure why this one errors though, probably something very niche.

base_esol = solve(base_eprob, SSAStepper(); seed, trajectories = 2, saveat = 1.0)

# Simulates problems for all input types, checking that identical solutions are found.
@test_broken false # first remake in subsequent test yields a `ERROR: type Nothing has no field portion`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for JumpSystems

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This on fails, but yes, let's investigate closer.

test/sciml_problem_inputs.jl Outdated Show resolved Hide resolved
test/sciml_problem_inputs.jl Outdated Show resolved Hide resolved
@test prob[X] == prob[sys.X] == prob[:X] == 4
@test prob[XY] == prob[sys.XY] == prob[:XY] == 9
@test prob[[XY, Y]] == prob[[sys.XY, sys.Y]] == prob[[:XY, :Y]] == [9, 5]
@test_broken prob[(XY, Y)] == prob[(sys.XY, sys.Y)] == prob[(:XY, :Y)] == (9, 5) # https://github.com/SciML/SciMLBase.jl/issues/709
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, indexing everywhere should just use getu.


# Test integrator indexing.
let
@test_broken false # NOTE: Multiple problems for `nint` (https://github.com/SciML/SciMLBase.jl/issues/662).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this still fail? The issue is closed.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issues got closed but then the conversation continued. But I see that there was a PR merged related. I checked fairly recently and this was still broken, but should check again.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checked, this still fails for nonlinear integrators

end

# Test solve's save_idxs argument.
# Currently, `save_idxs` is broken with symbolic stuff (https://github.com/SciML/ModelingToolkit.jl/issues/1761).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah this is a nontrivial change, requiring updates to integrators, solutions, and a generic reimplementation of SII's index provider interface in SciMLBase.


# Handles nonlinear and steady state solutions differently.
let
@test_broken false # Currently a problem for nonlinear solutions and steady state solutions (https://github.com/SciML/SciMLBase.jl/issues/720).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also a case of everything not using getu.

@AayushSabharwal
Copy link
Member

I should have mentioned: I'll move the tests when I PR to SciMLBase to fix the bugs

@TorkelE
Copy link
Member Author

TorkelE commented Jun 16, 2024

I should have mentioned: I'll move the tests when I PR to SciMLBase to fix the bugs

Thanks!

@TorkelE
Copy link
Member Author

TorkelE commented Jun 16, 2024

Yeah, I am a bit uncertain what actually goes where now when the MTK pipeline have been split up in so many different places. To me it is basically tests of the System types that MTK implements. But I agree that if possible it would make sense to move them as far internal as possible. If you point out what and where I could do it, but might be easier for you to do it yourself.

@TorkelE
Copy link
Member Author

TorkelE commented Jun 16, 2024

For the save_idx I think it is just that it has been broken since the very beginning. It is something that should be supported, so don't think it is bad to keep the tests in until it actually gets fixed, even if it might be a while.

@TorkelE
Copy link
Member Author

TorkelE commented Jul 2, 2024

Are we sure that the modified version of these that got ported to SciMLBase are actually exhaustive? I.e. regression that I caught with these tests in Catalyst still appear in the ecosystem: #2838

@TorkelE
Copy link
Member Author

TorkelE commented Jul 6, 2024

I have modified this one, removing the SciMLBase related stuff, and also adding tests that static vectors can be used as input across all problem types. @AayushSabharwal

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

Successfully merging this pull request may close these issues.

None yet

3 participants