Skip to content

Writing a unit-aware array to SwarmVariable.array stores its magnitude as non-dimensional #993

Open

Description

@lmoresi

Writing a unit-aware array to SwarmVariable.array stores its magnitude as non-dimensional, so a round trip multiplies storage by the scale, with no error (p20_unit_array.py, p26_unitarray.py, np 1 and 2).

T in K, stored raw 0.5, .array reads 500 K:

  • v.array = UnitAwareArray(500 K): .data becomes 500, where 0.5 is right.
  • v.array = np.asarray(v.array): .data becomes 500.

Seen on scalar, vector, MATRIX, TENSOR and SYM_TENSOR swarm variables. #788 is a related store of dimensional magnitudes, in viscoelastic history.

Found in the third review of the #909 branch. Measured on eddab70 (development before #954 to #973, which do not touch these paths) unless stated; not rerun on f31edcb. Probes on hyperion in runs/2026-11-06/review909r3/probes/.

Part of the units bundle the hub is recording for one owner: #979, and the issues linked below.

Underworld development team with AI support from Claude Code

Activity

  1. lmoresi commented on Nov 10, 2026

    @lmoresi
    MemberAuthor

    Still live on development 8f0ed0a (H3 units re-verification). Scalar, vector, MATRIX, TENSOR and SYM_TENSOR swarm variables in K, stored 0.5: after v.array = UnitAwareArray(500 K) or v.array = np.asarray(v.array), .data reads 500, where 0.5 is right.

    The cause: SwarmVariable.array's setter (swarm.py) reshapes the value and writes it straight into .data, skipping the unit conversion that the view's __setitem__ performs. MeshVariable.array's setter routes through self.array[...] = value instead. The fix is to do the same.

    Scripts: runs/2026-11-10-h3/probes/p20_unit_array.py and p26_unitarray.py on hyperion.

    Underworld development team with AI support from Claude Code

  2. added
    fixed-in-PR
    and removed
    fixed-in-PR
    on Nov 16, 2026
  3. added a commit that references this issue on Nov 16, 2026
  4. added
    fixed-in-development
    on Nov 16, 2026
  5. lmoresi commented on Nov 16, 2026

    @lmoresi
    MemberAuthor

    Fixed in development by #1205 (units PR 2), merge commit 04d6f84. The PR body gives the change for this issue and the test that fails on development without it. H1 checked each reproducer, at np 1 to 4 where the issue is parallel. The issue stays open until the release.

    Underworld development team with AI support from Claude Code


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    fixed-in-development

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions