IAEA-NDS / endf-parserpy

Python package for reading, writing, verifying and translating ENDF-6 formatted files
Other
9 stars 4 forks source link

parser include single MF #1

Closed Teancum-Q closed 6 months ago

Teancum-Q commented 6 months ago

When only wanting to pull a single MF parsefile throws an error. Works when calling 3 and 4 though.

parser.parsefile('n-008_O_017.endf', include=(3))
Traceback (most recent call last):

  File ~\AppData\Local\miniconda3\envs\endf\Lib\site-packages\spyder_kernels\py3compat.py:356 in compat_exec
    exec(code, globals, locals)

  File c:\users\quiste\onedrive - idaho national laboratory\desktop\projects\python\nuclear data\test.py:29
    endf_dict = parser.parsefile('n-008_O_017.endf', include=(3))

  File ~\AppData\Local\miniconda3\envs\endf\Lib\site-packages\endf_parserpy\endf_parser.py:1041 in parsefile
    return self.parse(lines, exclude, include, nofail=nofail)

  File ~\AppData\Local\miniconda3\envs\endf\Lib\site-packages\endf_parserpy\endf_parser.py:823 in parse
    should_skip = self.should_skip_section(mf, mt, exclude, include)

  File ~\AppData\Local\miniconda3\envs\endf\Lib\site-packages\endf_parserpy\endf_parser.py:781 in should_skip_section
    if mf not in include and (mf, mt) not in include:

TypeError: argument of type 'int' is not iterable
gschnabel commented 6 months ago

The include argument used to expect a tuple so include=(3,) or include=tuple([3]) should work.

The new version 0.9.1, now available on PyPI, is more flexible and will also accept a single integer for the include and exclude argument. In addition, any iterable object, such as list, is now accepted as well.