Repository navigation
Conversation
UNFILED 35: a constitutive parameter took uw.quantity(1e-6, "m**2/s") but sent 1e-6 * uw.units.m**2 / uw.units.s, the form the units tutorial wrote, to sympify(float(q)), and pint raised a DimensionalityError naming neither fix; uw.expression and the body force did the same. A raw pint Quantity is now converted to a UWQuantity where a value enters: the parameter setter, UWexpression's constructor and .sym setter, and each body force component. non_dimensionalise and a field's .array already took the raw form. Underworld development team with AI support from Claude Code
This branch has not been deployed
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: a raw pint quantity, such as
1e-6 * uw.units.m**2 / uw.units.s(the form the units tutorial wrote), is taken wherever auw.quantityis: a constitutive parameter,uw.expression, and a body force component.UNFILED 35, by the units desk (a Claude session). Runs were on a 96-thread Linux workstation (single system image; Intel Xeon Gold 6240R, AVX-512; MPICH), on development 657d984.
The defect
A constitutive parameter took
uw.quantity(1e-6, "m**2/s"), but sent the raw pint form tosympy.sympify(float(q)). pint then raised "Cannot convert from 'meter ** 2 / second' to 'dimensionless'", which names neither fix.uw.expression("k", 3.0 * uw.units("W/(m*K)"))andstokes.bodyforce = (0 * uw.units("Pa/m"), -3e4 * uw.units("Pa/m"))failed the same way.The fix
A small helper,
function.quantities.from_raw_pint, turns a raw pint Quantity into a UWQuantity. It is called where a value enters:UWexpression's constructor and its.symsetter;From there the raw form takes the same path as a
uw.quantity. CLAUDE.md's rule is to accept the forms a user writes and store pint objects.uw.non_dimensionaliseand a field's.arrayalready took the raw form, and are tested here so that they stay that way. Boundary values took it already (#1264).Test
tests/test_0778_raw_pint_quantities.py, 5 tests. Each sets a value in the raw form and checks it against theuw.quantityform:non_dimensionalise;.array.On development the first three fail, with the DimensionalityError above.
Regression runs
test_00*andtest_05*totest_08*, on 75cb427, 6 xdist workers: 2390 passed, 0 failed.scripts/test.sh --parallel-only --p 2on 75cb427: all passed.Checklist (UW3 Style Charter)
level_*andtier_*markers (S8)Underworld development team with AI support from Claude Code