Skip to content

MF=1 MT=458 reports ZA as a float where every other section reports an int #14

Description

@shimwell

Summary

parse_mf1_mt458 (src/endf/mf1.py) reads its opening record with get_cont_record rather than get_head_record:

https://github.com/shimwell/endf-python/blob/main/src/endf/mf1.py#L171

    ZA, AWR, _, LFC, _, NFC = get_cont_record(file_obj)

The two differ in exactly this: get_head_record converts the first field to an integer, get_cont_record leaves it a float.

def get_head_record(file_obj):
    line = file_obj.readline()
    ZA = int(float_endf(line[:11]))   # <-- int
    ...

def get_cont_record(file_obj, skip_c=False):
    ...
    C1 = float_endf(line[:11])        # <-- float

Effect

>>> m = endf.Material('n-095_Am_244.endf')
>>> type(m[1, 451]['ZA']), type(m[1, 458]['ZA'])
(<class 'int'>, <class 'float'>)

So material[1, 458]['ZA'] is 95244.0 while every other section reports 95244. Anything that uses ZA as a dict key, compares it across sections, or formats it for a filename gets a surprise in this one place.

MT=458's record is a HEAD record per ENDF-102 — it has ZA and AWR in the first two fields like the rest — so this looks like an oversight rather than a deliberate choice.

Suggested fix

    ZA, AWR, _, LFC, _, NFC = get_head_record(file_obj)

This changes the type of a value that is currently exposed, so it is worth a line in the changelog even though the numeric value is unchanged.

Notes

Found while porting the reader to Rust. The port reproduces the current behaviour — Mf1Mt458::za is an f64 where every other section's is an i64 — with a comment pointing here, so the two agree until this is settled.

Activity

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

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions