Repository navigation
uw.unwrap: the docstring and tutorials 3 and 13 say what the parameters do (#824) - #1266
Merged
Merged
Conversation
…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
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.
What changes for users: the
uw.unwrapdocstring, 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.unwrapexpands 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:uw.unwrap(eta * v)1.0e+22 * vuw.unwrap(eta * v, keep_constants=False)10.0 * vuw.unwrap(eta * v, return_self=False)10.0 * vuw.unwrap(eta * v, apply_scaling=True)1.0e+22 * vWhat the docs said instead:
keep_constants"keeps constants", andapply_scaling"applies scale factors";keep_constantsis set toFalse";apply_scaling=Truein its section without reference quantities.Docs, not behaviour
uw.unwrapforwards tofunction.expressions.unwrap, which the JIT (_jitextension.py) andfault_contact.pycall with these meanings. Changing the public meanings would make the two disagree. So the docs now describe the behaviour:apply_scalinghas no effect;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.Checked
The table above and the docstring's example were run on a build whose
unwrapcode is the same as development's (the #1197 branch, which does not touch it). Thesymbolic_keep_constantsclaim was run on a nested expression. Without reference quantities the two forms agree (15.0*xboth), 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