Skip to content

Error cleanly on complex EnsembleSummary; fix SplitFunction ODEProblem cache - #1463

Merged
ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/ensemble-summary-complex-and-splitfunction-cache
Jul 24, 2026
Merged

ChrisRackauckas merged 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:fix/ensemble-summary-complex-and-splitfunction-cache

Conversation

@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member

Summary

Two small, independent fixes for long-standing footguns:

  1. EnsembleSummary on complex data (SciML/DifferentialEquations.jl#632): quantiles/medians need isless, which is undefined on Complex. Previously this failed deep inside Statistics.quantile with MethodError: no method matching isless(::ComplexF64, ::ComplexF64). Now detects complex eltypes up front and throws ComplexEnsembleSummaryError with workarounds (real/imag separately, magnitudes, or mean/var helpers). Semantics of "quantile on ℂ" are deliberately not invented — clean error matches SciML style (ComplexSupportError, etc.).

  2. ODEProblem(SplitFunction(f1!, f2!), u0, tspan) for iip: SplitODEProblem allocates _func_cache from u0, but bare ODEProblem(sf, u0, tspan) did not, so f(du,u,p,t) called get_tmp(nothing, du) → ndims(::Type{Nothing}). Mirror the SplitODEProblem cache allocation on the bare ODEProblem path, and throw a clear ArgumentError if an iip SplitFunction is evaluated without a cache.

This PR should be ignored until reviewed by @ChrisRackauckas.

Tests

  • test/ensemble_tests.jl: complex ensemble rejects with ComplexEnsembleSummaryError; mean/var still works
  • test/problem_building_test.jl: bare iip ODEProblem(SplitFunction, …) allocates cache and evaluates; bare call without cache errors; oop path unchanged
  • Local e2e with OrdinaryDiffEq: solve(ODEProblem(SplitFunction(f1!,f2!), u0, tspan), Tsit5()) → Success; complex EnsembleSummary throws the new error

Recommendation notes (not in this PR)

Co-Authored-By: Chris Rackauckas [email protected]

…m cache

- EnsembleSummary: detect complex state eltypes and throw
  ComplexEnsembleSummaryError instead of isless MethodError (DE SciML#632).
  Mean/var helpers remain available; quantiles/medians need a total order.
- ODEProblem(SplitFunction, u0, tspan): allocate `_func_cache` for iip,
  matching SplitODEProblem, so bare construction no longer fails with
  ndims(::Type{Nothing}) on solve.
- In-place SplitFunction call: throw a clear ArgumentError when
  `_func_cache` is still nothing.

Co-Authored-By: Chris Rackauckas <[email protected]>
@ChrisRackauckas-Claude

Copy link
Copy Markdown
Member Author

CI babysit note

Package-level checks (Runic/Docs/Downgrade/Spell) are green; tests/* still queued.

Downstream reds match the other SciMLBase drafts and master-side issues (Catalyst parent_sys, DiffEqDevTools QA, step_limiter allowlist → #1466, DEVerbosity, MTK inverse models). Not caused by this PR.

Local: test/ensemble_tests.jl (including complex EnsembleSummary rejection) passes.

@ChrisRackauckas
ChrisRackauckas marked this pull request as ready for review July 24, 2026 06:16
@ChrisRackauckas
ChrisRackauckas merged commit 415cab4 into SciML:master Jul 24, 2026
48 of 63 checks passed
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.

2 participants