When an Xarray pseudoinverse changes shape but keeps the old coordinates
A pseudoinverse changes axis roles. Reconcile each output axis with its coordinates before relying on the total element count.
Axes need a new contract
A pseudoinverse swaps the roles of the last two axes. Reconcile each output-axis length with its coordinates by name and role before approving a new coordinate contract. Square fixtures can conceal this mismatch because their lengths stay equal; retain the business role of each axis. The Truthound check begins with a separately prepared table of these axis-specific lengths. [1, 2, 3]
The asymmetric matrix in the report
Xarray #11396 reports a 3×4 DataArray becoming 4×3 after pinv while retaining coordinate lengths 3 and 4. Contributors discussed a generic wrapper that may not understand linear-algebra axis changes. That is a proposed explanation, not an independent test of every array function. [1]
Join by name and role
Record the original matrix axis roles, then compare each pinv output axis with its attached coordinate length. Hold mismatching objects before storage and explicitly construct new names and coordinates for the result. Preserve the input roles and extract lengths independently from the actual axes and coordinates. [1, 3]
A reference from 4 features
The illustrative source matrix has 3 observations and 4 features. The pseudoinverse feature axis therefore requires 4 feature coordinates; this reference comes from the input definition. An actual coordinate length of 4 passes. A retained length of 3 fails against 4, even if the total element count is unchanged. [1, 3]
Core checks the prepared audit table
ColumnPairValidator in Truthound Python SDK 3.3.2 compares nonmissing actual_coordinate_length and required_axis_length values extracted by the operator. Check absent axes and coordinates separately. Matching lengths do not establish coordinate values or numerical correctness; Core neither executes pinv nor reattaches coordinates. [1, 2, 3]
Rebuild from the value array
One alternative is to apply pinv to the value array, explicitly construct a new DataArray by axis role, and check numerical residuals separately. If that explicit construction is already the normal path, the risk from passing through the original coordinate wrapper is smaller. [1, 3]
Application conditions
Extract the input axis roles and actual output-axis and coordinate lengths separately, then join by name.
Alternatives
Compute from the value array and explicitly construct the new axis roles and coordinates.
Limitations
Equal lengths do not establish coordinate values or numerical correctness of the pseudoinverse.
Evidence
- Event checked
- Subject checked
- Modified
