Skip to content

fix(ddt): Lagrangian.__init__ — uw.swarm.UWSwarm typo#184

Merged
lmoresi merged 1 commit into
developmentfrom
bugfix/lagrangian-uwswarm-typo
May 14, 2026
Merged

fix(ddt): Lagrangian.__init__ — uw.swarm.UWSwarm typo#184
lmoresi merged 1 commit into
developmentfrom
bugfix/lagrangian-uwswarm-typo

Conversation

@lmoresi
Copy link
Copy Markdown
Member

@lmoresi lmoresi commented May 12, 2026

Summary

  • One-line fix: uw.swarm.UWSwarm(mesh)uw.swarm.Swarm(mesh) in Lagrangian.__init__.
  • UWSwarm does not exist (and never has). The typo was introduced by 0778b7d (2025-07-07, "Fix uw.function.evaluate / eliminate evalf") while editing nearby code, and has silently blocked direct construction of Lagrangian DDt 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 of Lagrangian don't have to wait for the snapshot feature to land.

No other UWSwarm references 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 raised AttributeError).
  • Existing core test suite (test_0000-test_0005, test_1052_ddt_set_initial_history) still passes.

Underworld development team with AI support from Claude Code

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)
Copilot AI review requested due to automatic review settings May 12, 2026 00:06
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

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) with uw.swarm.Swarm(mesh) in Lagrangian.__init__.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@lmoresi lmoresi merged commit 4e29e0e into development May 14, 2026
5 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.

2 participants