MaterialView

class endf_parserpy.tape.MaterialView(endf_file, slot)[source]

A handle to one material of an EndfFile.

Sections are addressed by an (MF, MT) pair and parsed lazily on access. A section can be read, replaced, added or deleted:

section = material[3, 2]
material[3, 2] = edited_section
del material[3, 2]

Reading a section returns a view over the parsed section whose mutability follows the file’s check_edits mode – read-only under "eager" and a live write-through view under "deferred" (see endf_parserpy.tape.views). A section that failed to parse raises SectionParseError on access.

The view is bound to the underlying material, so it stays valid if the tape is reordered; it becomes invalid only if that material is deleted, after which every operation on it raises RuntimeError.

property awr

Atomic weight ratio of the material, or None if unknown.

property is_modified

Whether this material has been edited.

property mat

ENDF MAT number of the material.

property position

The material’s current zero-based position on the tape.

sections()[source]

Return the list of (MF, MT) section keys of this material.

to_tape_dict()[source]

Return this material as a complete single-material tape dict.

The result is a {MF: {MT: section}} mapping that, unlike the per-section access of this view, also carries an MF=0/ MT=0 tape-head (TPID) entry. It therefore forms a complete single-material tape and can be handed directly to the ordinary parser’s writeparser.write(view.to_tape_dict()) yields a tape the ordinary parser.parse round-trips.

Untouched sections appear as their raw ENDF-6 lines and edited or added ones as parsed mappings; the writer accepts both.

property za

ZA identifier of the material, or None if unknown.