fix(ddt): Lagrangian.__init__ — uw.swarm.UWSwarm typo#184
Merged
Conversation
The Lagrangian DDt flavor has been unconstructible since commit 0778b7d (2025-07-07, "Fix uw.function.evaluate / eliminate evalf"), which typo'd uw.swarm.Swarm(mesh) as uw.swarm.UWSwarm(mesh) while editing nearby code. UWSwarm does not exist — never has — so direct construction of Lagrangian has died with AttributeError for ten months. Higher-level solver pathways that wrap Lagrangian were presumably also broken; consumers may have silently fallen back to Lagrangian_Swarm or another flavor. One-character fix. No other UWSwarm references exist in the tree. The bug surfaced during the in-memory snapshot toolkit work (feature/in-memory-checkpoint, PR 4: state-as-dataclass retrofit on all five DDt flavors). This commit is the bug fix only — cherry-picked from the feature branch onto development so consumers of Lagrangian don't have to wait for the snapshot feature to land. Underworld development team with AI support from Claude Code (https://claude.com/claude-code)
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a long-standing construction bug in the Lagrangian D/Dt implementation by correcting a non-existent swarm class reference, restoring the ability to instantiate uw.systems.ddt.Lagrangian directly.
Changes:
- Replace
uw.swarm.UWSwarm(mesh)(non-existent) withuw.swarm.Swarm(mesh)inLagrangian.__init__.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Summary
uw.swarm.UWSwarm(mesh)→uw.swarm.Swarm(mesh)inLagrangian.__init__.UWSwarmdoes not exist (and never has). The typo was introduced by0778b7d(2025-07-07, "Fix uw.function.evaluate / eliminate evalf") while editing nearby code, and has silently blocked direct construction ofLagrangianDDt for ten months.Context
Surfaced during the in-memory snapshot toolkit work on
feature/in-memory-checkpoint. The state-as-dataclass retrofit added a Lagrangian roundtrip test that couldn't run; investigation showed the class itself was the problem, not the retrofit. Cherry-picked here as a small standalone bugfix so consumers ofLagrangiandon't have to wait for the snapshot feature to land.No other
UWSwarmreferences exist in the tree.Test plan
pixi run -e amr-dev python -c "import underworld3 as uw; mesh = uw.meshing.UnstructuredSimplexBox(minCoords=(0,0), maxCoords=(1,1), cellSize=1/4); T = uw.discretisation.MeshVariable('T', mesh, 1, degree=1); V = uw.discretisation.MeshVariable('V', mesh, 2, degree=2); lg = uw.systems.ddt.Lagrangian(mesh=mesh, psi_fn=T.sym, V_fn=V.sym, vtype=uw.VarType.SCALAR, degree=1, continuous=True, order=2); print(lg)"— succeeds (previously raisedAttributeError).test_0000-test_0005,test_1052_ddt_set_initial_history) still passes.Underworld development team with AI support from Claude Code