Skip to content

uw.unwrap: the docstring and tutorials 3 and 13 say what the parameters do (#824) - #1266

Merged
lmoresi merged 1 commit into
developmentfrom
docs/unwrap-parameters
Nov 20, 2026
Merged

lmoresi merged 1 commit into
developmentfrom
docs/unwrap-parameters

Conversation

@lmoresi

@lmoresi lmoresi commented Nov 20, 2026 •

Copy link
Copy Markdown
Member

What changes for users: the uw.unwrap docstring, and tutorials 3 and 13, now say what its parameters do. The behaviour does not change.

The remainder of #824, after #1209 fixed the argument forwarding. Docs only, plus one docstring. Found and checked by H3 (the units desk, a Claude session) on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on development 7c4e1df.

What the parameters do

uw.unwrap expands every named expression, and replaces every constant by a number, in both forms. For a viscosity of 1e22 Pa s against a 1e21 Pa s reference:

call result meaning
uw.unwrap(eta * v) 1.0e+22 * v each constant in its own units (the display form)
uw.unwrap(eta * v, keep_constants=False) 10.0 * v each constant in model units (the solver's form)
uw.unwrap(eta * v, return_self=False) 10.0 * v the same switch
uw.unwrap(eta * v, apply_scaling=True) 1.0e+22 * v no effect

What the docs said instead:

  • the docstring: keep_constants "keeps constants", and apply_scaling "applies scale factors";
  • tutorial 3: a constant "is only replaced if keep_constants is set to False";
  • tutorial 13: it called apply_scaling=True in its section without reference quantities.

Docs, not behaviour

uw.unwrap forwards to function.expressions.unwrap, which the JIT (_jitextension.py) and fault_contact.py call with these meanings. Changing the public meanings would make the two disagree. So the docs now describe the behaviour:

  • the docstring gives each form with an example;
  • it says that apply_scaling has no effect;
  • it points to unwrap_expression(fn, mode="symbolic_keep_constants") to keep constants as symbols. That mode stops at every named expression with no field or coordinate in it.
  • Tutorial 3's text and code comment describe the two forms.
  • Tutorial 13's call drops the two arguments that did nothing there.

Checked

The table above and the docstring's example were run on a build whose unwrap code is the same as development's (the #1197 branch, which does not touch it). The symbolic_keep_constants claim was run on a nested expression. Without reference quantities the two forms agree (15.0*x both), as tutorial 3 now says. The notebooks were edited as text, so only the changed lines differ.

Underworld development team with AI support from Claude Code

…rs do

The remainder of #824. uw.unwrap expands every named expression and replaces
every constant by a number in both forms. keep_constants=True (the default)
gives each constant's value in its own units, the display form;
keep_constants=False, or return_self=False, its value in model units, the
solver's form. apply_scaling has no effect on the result. The docstring said
keep_constants keeps constants and apply_scaling applies scale factors;
tutorial 3 said a constant is replaced only with keep_constants=False, and
tutorial 13 passed apply_scaling=True to a model with no reference
quantities. The docs are fixed and the behaviour kept: the solver's JIT path
and the library's own callers depend on it.

Underworld development team with AI support from Claude Code
Copilot AI balanced review requested due to automatic review settings November 20, 2026 06:09

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

@lmoresi
lmoresi merged commit c20d352 into development Nov 20, 2026
10 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.

3 participants