-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update citation-handling to work with nested step size controllers
- Loading branch information
1 parent
ff301da
commit 50c9ff1
Showing
2 changed files
with
68 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import diffrax as dfx | ||
|
||
|
||
def test_adaptive_sde(capfd, getkey): | ||
topline = "AUTOGENERATED REFERENCES PRODUCED USING `diffrax.citation(...)`" | ||
sde = "You are solving an SDE, and may wish to cite the textbook" | ||
adaptive = "The use of adaptive step size controllers for SDEs are from" | ||
reject_buffer = ( | ||
"You are adaptively solving an SDE whilst revisiting rejected time points" | ||
) | ||
|
||
bm = dfx.VirtualBrownianTree(0, 1, 1e-3, (), getkey()) | ||
terms = dfx.ControlTerm(lambda t, y, args: -y, bm) | ||
stepsize_controller = dfx.PIDController(rtol=1e-3, atol=1e-3) | ||
capfd.readouterr() | ||
dfx.citation(terms=terms, stepsize_controller=stepsize_controller) | ||
out = capfd.readouterr().out | ||
assert topline in out | ||
assert sde in out | ||
assert adaptive in out | ||
assert reject_buffer not in out | ||
|
||
capfd.readouterr() | ||
dfx.citation( | ||
terms=terms, | ||
stepsize_controller=dfx.ClipStepSizeController( | ||
stepsize_controller, store_rejected_steps=1 | ||
), | ||
) | ||
out = capfd.readouterr().out | ||
assert topline in out | ||
assert sde in out | ||
assert adaptive in out | ||
assert reject_buffer in out |