Skip to content

uw.Params silently ignores negative CLI values (-uw_x -1 falls back to the default) #642

Description

@lmoresi

uw.Params reads CLI overrides from the PETSc options database, which treats a leading '-' token as an option name. So a negative value is never delivered: -uw_sense -1 registers 'sense' with an EMPTY value and '1' as an unrelated option; -uw_sense=-1 is not recognised at all. Params then falls back to the default silently.

Probe (uw.Params(sense=uw.Param(1.0, ...)); print float(p.sense), uw.options.getString('sense', '')):

argv p.sense raw PETSc string
-uw_sense 2 2.0 '2'
-uw_sense -2 1.0 ''
-uw_sense -0.5 1.0 ''
-uw_sense=-2 1.0

Consequence: half of a 26-run parameter ladder (sense = -1, the releasing-bend drive) ran at the default +1 and reported under the requested label — only caught because the partition numbers were identical to the +1 runs.

Suggested fix, two layers: (1) Params raises when an option is present with an empty value rather than using the default (the silent part is the dangerous part); (2) accept a quoting form for negatives (PETSc accepts -opt -1 when the next token parses as a number in some paths; if not, document -uw_x=-1 or a '--' style). Workaround used here: a boolean switch param (releasing=1) mapped to the sign in the script.

Underworld development team with AI support from Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions