Skip to content

Clarify ConstantStepSize finite-interval step semantics#764

Open
Whning0513 wants to merge 1 commit into
patrick-kidger:mainfrom
Whning0513:clarify-constant-stepsize-docs-757
Open

Clarify ConstantStepSize finite-interval step semantics#764
Whning0513 wants to merge 1 commit into
patrick-kidger:mainfrom
Whning0513:clarify-constant-stepsize-docs-757

Conversation

@Whning0513

Copy link
Copy Markdown

Fixes #757.

This updates the finite-interval documentation for ConstantStepSize and diffeqsolve(dt0=...) to match the current implementation:

  • dt0 determines the number of fixed steps via ceil((t1 - t0) / dt0)
  • the remaining fixed steps are rescaled so the solve lands exactly on t1

It also adds a regression test that locks in the current step locations for a representative finite-interval solve, plus a docstring test for the clarified wording.

Tested with:

  • uv run python -m pytest -q test/test_saveat_solution.py

Copilot AI review requested due to automatic review settings July 1, 2026 09:28

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses #757 by aligning Diffrax’s documentation with the current ConstantStepSize behavior on finite intervals, and adds tests to lock in both the observed step locations and the clarified wording.

Changes:

  • Updates ConstantStepSize and diffeqsolve(dt0=...) documentation to describe finite-interval step placement that lands exactly on t1.
  • Updates the getting-started guide to describe ConstantStepSize as fixed-step behavior on finite intervals.
  • Adds a regression test asserting the step timestamps for a representative finite-interval ConstantStepSize solve, plus a docstring-content test.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
test/test_saveat_solution.py Adds a regression test for finite-interval step locations and a docstring wording test.
docs/usage/getting-started.md Adjusts tutorial wording to describe finite-interval fixed-step semantics.
diffrax/_step_size_controller/constant.py Updates ConstantStepSize docstring to describe finite-interval behavior.
diffrax/_integrate.py Updates diffeqsolve’s dt0 docstring text to match finite-interval fixed-step behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +23 to 28
"""Use a fixed number of constant steps determined by the `dt0` argument of
[`diffrax.diffeqsolve`][].

On finite intervals this chooses `ceil((t1 - t0) / dt0)` steps and rescales the
later fixed steps to hit `t1` exactly.
"""
Comment thread diffrax/_integrate.py
Comment on lines +932 to +936
- `dt0`: The step size to use for the first step. If using
[`diffrax.ConstantStepSize`][] on a finite interval then this determines the
number of fixed steps via `ceil((t1 - t0) / dt0)`, and rescales the remaining
fixed steps to land exactly on `t1`. If set as `None` then the initial step
size will be determined automatically.
- Step sizes and locations can be changed.
- The initial step size can be selected adaptively by setting `dt0=None`.
- A constant step size can be used by setting `stepsize_controller = ConstantStepSize()`. (This is also the default choice for `stepsize_controller` if you do not pass one at all.)
- Fixed steps can be used by setting `stepsize_controller = ConstantStepSize()`. On finite intervals this uses `dt0` to determine how many steps to take, then spaces those steps so the solve lands exactly on `t1`. (This is also the default choice for `stepsize_controller` if you do not pass one at all.)
Comment on lines +265 to +267
expected_ts = jnp.concatenate(
[jnp.array([0.0, 0.1]), jnp.linspace(2 * 1.05 / 11, 1.05, 10)]
)
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.

Documentation and implementation of ConstantStepSize do not quite align

2 participants