Skip to content

[1.9.x] Drop trailing commas that made twelve argsDict values 1-tuples - #45

Merged
cekees merged 1 commit into
1.9.xfrom
fix-argsdict-tuples-1.9.x
Oct 13, 2026
Merged

cekees merged 1 commit into
1.9.xfrom
fix-argsdict-tuples-1.9.x

Conversation

@cekees

@cekees cekees commented Oct 12, 2026

Copy link
Copy Markdown
Owner

argsDict["k"] = arr, stores the 1-tuple (arr,). On 1.9.x this does not raise TypeError: the xt::pyarray caster converts the tuple instead (PyArray_FromAny with FORCECAST), and pybind11 tries the int overload of ArgumentsDict.__setitem__ first. I checked this against an installed 1.9.x build (proteus-arm64-verify): a["k"] = (np.zeros((4,2),'i'),) is stored as shape (1,4,2), and a["d"] = (np.array([0.5,1.7]),) lands in iarray as [[0,1]], so darray["d"] raises RuntimeError: key d not found.

Int arrays: silent copy, correct results. The kernels read through .data(), so they saw the right numbers.

site method key test that reaches it
mprans/PresInc.py:861 getResidual elementBoundaryLocalElementBoundariesArray test_clsvof_with_rans3pf
mprans/RANS3PF.py:2729, :2741 getJacobian sdInfo_u_w_rowptr, sdInfo_w_v_rowptr test_clsvof_with_rans3pf
richards/Richards.py:1599, :1962 getResidual, getJacobian elementMaterialTypes griffiths_lane_6
mprans/RANS3PSed.py:1998 getJacobian sdInfo_u_v_rowptr none
mprans/RANS2P_IB.py:1397 getJacobian sdInfo_u_w_rowptr none
m_comp_co2/m_comp_co2.py:3830, :4677 getResidual, getJacobian elementMaterialTypes none

Double arrays: hard failure. The value is truncated into the int dict, so the kernel's args.array<double>("elementDiameter") throws "key not found" on every call.

site method
mprans/RANS2P_IB.py:1343 getJacobian
mprans/RANS2P_IB.py:1574 beamStep
mprans/SW2D.py:825 getJacobian

All twelve sites run unconditionally; none depends on nSpace or a coefficient option. Tests "missed" them for two reasons: the conversion hides the int cases, and nothing runs RANS2P_IB, SW2D, RANS3PSed or m_comp_co2.

On main, these were fixed by 27c00b0 and #44. Only the comma removals are applied here. The delta_x_ij reordering in 27c00b0 isn't needed, because 1.9.x's Richards.getResidual already allocates it before building argsDict.

richards/ADR.py (:1160/:1341/:1587) is intentionally left alone for erdc#1285. The new test lists it in KNOWN and fails once it is fixed, which forces the exception to be removed.

Guard

test/test_argsdict_values.py is the same AST scan as #44, plus the KNOWN exemption. Both tests pass on this branch; the scan fails on unfixed origin/1.9.x (12 sites).

PresInc.py also appears in open #43, but in a different hunk.

🤖 Generated with Claude Code

`argsDict["k"] = arr,` stores (arr,). The xt::pyarray caster converts the
tuple instead of rejecting it (PyArray_FromAny with FORCECAST), and
pybind11 tries the int overload of ArgumentsDict.__setitem__ first. So:

- An int array became a (1, ...) copy with the same flat layout. Kernels
  read it through .data(), so the results were right, off a needless copy:
    PresInc.getResidual        elementBoundaryLocalElementBoundariesArray
    RANS2P_IB.getJacobian      sdInfo_u_w_rowptr
    RANS3PF.getJacobian        sdInfo_u_w_rowptr, sdInfo_w_v_rowptr
    RANS3PSed.getJacobian      sdInfo_u_v_rowptr
    Richards.getResidual/getJacobian      elementMaterialTypes
    m_comp_co2.getResidual/getJacobian    elementMaterialTypes
  All of these run unconditionally. test_clsvof_with_rans3pf (PresInc,
  RANS3PF) and griffiths_lane_6 (Richards) reach theirs and pass because
  of the conversion. RANS3PSed, RANS2P_IB and m_comp_co2 have no test.
- A double array was truncated into the *int* dict, so the kernel's
  args.array<double>("elementDiameter") threw "key elementDiameter not
  found". That happens on every call of RANS2P_IB.getJacobian,
  RANS2P_IB.beamStep and SW2D.getJacobian. No test runs either model.

On main, where proteus::pyarray rejects tuples, these were fixed by
27c00b0 and the companion main PR. This applies the same comma removals.
The Richards delta_x_ij reordering in 27c00b0 is not needed here, because
1.9.x already allocates it before building argsDict.

richards/ADR.py has three more. They are left for erdc#1285 (its
extension is not built). The new test lists ADR.py as a known exception and
fails once it is fixed, so the exception gets removed.

test/test_argsdict_values.py walks the installed proteus sources with ast
and rejects any tuple, list, set, dict, comprehension, None or string
assigned into an ArgumentsDict.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cekees
cekees merged commit 69ad61d into 1.9.x Oct 13, 2026
5 checks passed
@cekees
cekees deleted the fix-argsdict-tuples-1.9.x branch October 13, 2026 14:26
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.

1 participant