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

Test for DiscontinuousTestODE #368

Merged
merged 4 commits into from
Oct 26, 2023

Conversation

lisawim
Copy link
Collaborator

@lisawim lisawim commented Oct 25, 2023

Since hardcoded solutions do not say anything about the correctness of the problem class itself, I also added a small test for the DiscontinuousTestODE. It's only a small one whether the correct event time together with value of state function at event is tested. In the TIME-X test hackathon I also learnt that errors can be tested by capture them. Thus, ProblemError and logger.warning are also captured through this test when nan values arises.

The function get_switching_info is not tested here, because this is rather stuff of SwitchEstimator which I also started to test during the test hackathon. (Coming soon some time..)

Let me know if this is not enough.

@codecov
Copy link

codecov bot commented Oct 25, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (83415ca) 72.55% compared to head (3cda182) 72.56%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #368      +/-   ##
==========================================
+ Coverage   72.55%   72.56%   +0.01%     
==========================================
  Files         269      269              
  Lines       22330    22328       -2     
==========================================
+ Hits        16202    16203       +1     
+ Misses       6128     6125       -3     
Files Coverage Δ
...mentations/problem_classes/DiscontinuousTestODE.py 100.00% <100.00%> (+3.94%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

u_event = DODE.u_exact(DODE.t_switch_exact)
h = u_event[0] - 5

assert h < 1e-15, 'Value of state function at exact event time is not zero!'
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe you should test for the absolute value of h here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.


sol = DODE.solve_system(**args)
assert np.isclose(
sol[0], DODE.u_exact(t0 + dt)[0], atol=2e-3
Copy link
Contributor

Choose a reason for hiding this comment

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

Why don't you use np.allclose and test all of the values instead of just the first one?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Your are right, but in this case, the solution consists of only one value.

@pancetta
Copy link
Member

Ready to be merged?

@lisawim
Copy link
Collaborator Author

lisawim commented Oct 26, 2023

From my side, yes. Depends on @brownbaerchen

@brownbaerchen brownbaerchen merged commit f6f013e into Parallel-in-Time:master Oct 26, 2023
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.

3 participants