Skip to content

NonlinearSolveBase: accept verbose=nothing as default NonlinearVerbosity()#920

Closed
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:accept-nothing-verbose-as-default
Closed

NonlinearSolveBase: accept verbose=nothing as default NonlinearVerbosity()#920
ChrisRackauckas-Claude wants to merge 1 commit into
SciML:masterfrom
ChrisRackauckas-Claude:accept-nothing-verbose-as-default

Conversation

@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor

Summary

Three solve entry points in lib/NonlinearSolveBase/src/solve.jl (top-level solve at lines 50, 194, 495) already normalize Bool and AbstractVerbosityPreset values of the verbose kwarg into a NonlinearVerbosity. Extend the branch set to also accept nothing, normalizing it to NonlinearVerbosity() (the default).

Why

Wrapping solves that forward a caller's verbose kwarg through to NonlinearSolve without owning the default may pass nothing to mean "inherit the default". Concrete call sites:

Prior to this, a caller-forwarded verbose = nothing would skip both normalizing branches (Bool, AbstractVerbosityPreset), land in downstream verbose.display_level / verbose.convergence_failure field accesses, and fail with:

MethodError: no method matching getfield(::Nothing, …)

Fix

One new elseif verbose === nothing branch per solve entry point, converting to NonlinearVerbosity().

Version

Bumps NonlinearSolveBase to 2.25.1 (patch — additive, non-breaking).

Three `solve` entry points (top-level `solve` at lines 50, 194, 495)
already normalize `Bool` and `AbstractVerbosityPreset` values of the
`verbose` kwarg into a `NonlinearVerbosity`. Extend the branch set to
also accept `nothing`, normalizing it to `NonlinearVerbosity()` (the
default).

Motivation: wrapping `solve`s that forward a caller's `verbose` kwarg
through to `NonlinearSolve` without owning the default — e.g.
`DiffEqBase` ↔ `NonlinearSolve` bridges and `SteadyStateDiffEq`'s
`SSRootfind` — may pass `nothing` to mean "inherit the default". Prior
to this, `nothing` would skip both normalizing branches, land in
downstream `verbose.display_level` / `verbose.convergence_failure`
field accesses, and fail with `getfield(::Nothing, …)`.

Bumps `NonlinearSolveBase` to 2.25.1.

Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com>
@ChrisRackauckas-Claude
Copy link
Copy Markdown
Contributor Author

Closing — making NonlinearSolveBase tolerant of verbose = nothing just hides the upstream bug (a caller forwarding an unset verbose as nothing when it should be passing an actual NonlinearVerbosity / DEVerbosity / Bool). Fix goes at the caller layer instead.

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