Summary
In get_intg_record (src/endf/records.py), the inner loop reads successive matrix elements across a row but assigns all of them to the same column jj, instead of advancing to jj + j.
https://github.com/shimwell/endf-python/blob/main/src/endf/records.py#L259-L271
for j in range(nrow):
if jj+j >= ii:
break
element = int_endf(line[11+(ndigit+1)*j:11+(ndigit+1)*(j+1)])
if element > 0:
corr[ii, jj] = (element+0.5)/factor # <-- jj, not jj + j
elif element < 0:
corr[ii, jj] = (element-0.5)/factor # <-- same
The field offset 11+(ndigit+1)*j advances with j, and the loop guard is if jj+j >= ii: break — both of which say the column being filled is jj + j. Only the assignment does not follow.
Effect
For an INTG line covering more than one column, every element is written on top of the previous one at column jj. The result is that:
- only the last in-range element of each line survives, and it lands in the wrong column;
- every other column the line was meant to fill stays at its initialised value (0, or 1 on the diagonal).
The correlation matrix returned for LCOMP=2 compact covariances is therefore wrong wherever a line carries more than one element. Since the guard jj+j >= ii stops at the diagonal, single-element lines (jj == ii-1) happen to come out right, which is probably why this has gone unnoticed.
Suggested fix
if element > 0:
corr[ii, jj+j] = (element+0.5)/factor
elif element < 0:
corr[ii, jj+j] = (element-0.5)/factor
Notes
get_intg_record currently has no caller in the package — MF32 (LCOMP=2) is not parsed yet — so this is latent rather than user-visible today.
- The symmetrisation at the end is fine:
np.diag(corr.diagonal()) is evaluated against the pre-addition matrix, so the diagonal correctly stays at 1.
- Found while porting the reader to Rust. The port reproduces the current behaviour deliberately, with a comment pointing here, so the two agree until this is settled.
Summary
In
get_intg_record(src/endf/records.py), the inner loop reads successive matrix elements across a row but assigns all of them to the same columnjj, instead of advancing tojj + j.https://github.com/shimwell/endf-python/blob/main/src/endf/records.py#L259-L271
The field offset
11+(ndigit+1)*jadvances withj, and the loop guard isif jj+j >= ii: break— both of which say the column being filled isjj + j. Only the assignment does not follow.Effect
For an INTG line covering more than one column, every element is written on top of the previous one at column
jj. The result is that:The correlation matrix returned for
LCOMP=2compact covariances is therefore wrong wherever a line carries more than one element. Since the guardjj+j >= iistops at the diagonal, single-element lines (jj == ii-1) happen to come out right, which is probably why this has gone unnoticed.Suggested fix
Notes
get_intg_recordcurrently has no caller in the package — MF32 (LCOMP=2) is not parsed yet — so this is latent rather than user-visible today.np.diag(corr.diagonal())is evaluated against the pre-addition matrix, so the diagonal correctly stays at 1.