Fix ODE integrator default time and compatibility with jax>=0.9.0#813
Merged
chaoming0625 merged 2 commits intomasterfrom Jan 21, 2026
Merged
Fix ODE integrator default time and compatibility with jax>=0.9.0#813chaoming0625 merged 2 commits intomasterfrom
jax>=0.9.0#813chaoming0625 merged 2 commits intomasterfrom
Conversation
…format code in build method
Reviewer's guide (collapsed on small PRs)Reviewer's GuideEnsures the ODE integrator’s internal _call_integral method always passes a default t=0 keyword argument when none is provided, and applies minor formatting cleanups in the explicit Runge-Kutta integrator implementation. Sequence diagram for _call_integral with default t keyword argumentsequenceDiagram
participant Caller
participant IntegratorBase
participant JAX as jax
participant JAXCore as jax_core
Caller->>IntegratorBase: _call_integral(args, kwargs)
IntegratorBase->>IntegratorBase: copy kwargs to new dict
IntegratorBase->>IntegratorBase: t = kwargs.get(t, None)
alt t is None
IntegratorBase->>IntegratorBase: kwargs[t] = 0.0
else t is provided
IntegratorBase->>IntegratorBase: kwargs[t] = t
end
alt _during_compile is True
IntegratorBase->>JAX: make_jaxpr(integral, return_shape=True)(**kwargs)
JAX-->>IntegratorBase: jaxpr, out_shapes
IntegratorBase->>JAXCore: eval_jaxpr(jaxpr.jaxpr, jaxpr.consts, *leaves(kwargs))
JAXCore-->>IntegratorBase: outs
else _during_compile is False
IntegratorBase->>IntegratorBase: integral(**kwargs)
IntegratorBase-->>Caller: result
end
Updated class diagram for IntegratorBase and ExplicitRKIntegratorclassDiagram
class IntegratorBase {
<<abstract>>
+integral
+_call_integral(*args, **kwargs)
}
class ExplicitRKIntegrator {
+variables
+A
+B
+C
+code_lines
+parameters
+code_scope
+show_code
+func_name
+build()
}
IntegratorBase <|-- ExplicitRKIntegrator
class CommonModule {
+step(variables, dt, A, C, code_lines, parameters)
+update(variables, dt, B, code_lines)
}
class CodeGenerator {
+compile(var_dict, arg_names, return_args, fun_name, code_scope, code_lines, show_code, func_name)
}
ExplicitRKIntegrator ..> CommonModule : uses
ExplicitRKIntegrator ..> CodeGenerator : uses
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In
_call_integral, consider defaultingtat the call sites (or only when the target integral actually expects atkwarg) rather than unconditionally injectingtintokwargs, to avoid surprising failures for integrals that don’t accept atparameter.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `_call_integral`, consider defaulting `t` at the call sites (or only when the target integral actually expects a `t` kwarg) rather than unconditionally injecting `t` into `kwargs`, to avoid surprising failures for integrals that don’t accept a `t` parameter.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Member
Author
|
@sourcery-ai title |
jax>=0.9.0
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary by Sourcery
Ensure the ODE integrator always passes a default time argument and perform minor formatting cleanups.
Bug Fixes:
Enhancements: