endf-python icon indicating copy to clipboard operation
endf-python copied to clipboard

KeyError when accessing `section_text` for certain sections

Open ahnaf-tahmid-chowdhury opened this issue 4 months ago • 8 comments

Description

I encountered a KeyError while trying to access specific sections of an ENDF material. Below is a summary of the issue:

Steps to Reproduce:

  1. Load a material using endf.Material(), for example:

    import endf
    mat = endf.Material('n-092_U_235.endf')
    
  2. The following warnings appear:

    /path/to/venv/lib/python3.12/site-packages/endf/material.py:228: UserWarning: MF=31, MT=452 ignored
      warn(f"{MF=}, {MT=} ignored")
    /path/to/venv/lib/python3.12/site-packages/endf/material.py:228: UserWarning: MF=31, MT=456 ignored
      warn(f"{MF=}, {MT=} ignored")
    /path/to/venv/lib/python3.12/site-packages/endf/material.py:228: UserWarning: MF=35, MT=18 ignored
      warn(f"{MF=}, {MT=} ignored")
    
  3. Attempt to access a specific section:

    print(mat.section_text[12, 75])
    

    This raises the following error:

    KeyError: (12, 75)
    
  4. Attempting to access other sections like:

    mat.section_data[3, 16]
    

    works as expected and returns data.

Expected Behavior:

mat.section_text[12, 75] should return the corresponding section data, or provide a clearer error if this section is not available.

Actual Behavior:

A KeyError is raised when trying to access section_text for certain sections.

System Information:

  • Python version: 3.12
  • endf version: 0.1.4 through pip
  • ENDF file used: n-092_U_235.endf

Additional Context:

The warnings related to MF=31 and MF=35 might be linked to the issue, but it's unclear if this is the cause.

ahnaf-tahmid-chowdhury avatar Oct 10 '24 12:10 ahnaf-tahmid-chowdhury