Skip to content

[BUG] - Impossible to parse default xsdir #178

@alberto743

Description

@alberto743

Describe the bug
F4Enix is not able to load the xsdir file generated by the standard installation of MCNP 6.3

To Reproduce
After reading issue #61, I removed the comments present in the xsdir file generated by the MCNP 6.3 installation, but I am still unable to load it in a LibManager object

from f4enix.input.libmanager import LibManager
xsdir1 = open("xsdir",'r').read()
xsdir1_nocomments = '\n'.join([l for l in xsdir1.splitlines() if not l.startswith('#')]) + '\n'
open("xsdir_nocomments",'w').write(xsdir1_nocomments)
LibManager("xsdir_nocomments")

gives

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
Cell In[10], line 1
----> 1 LibManager("xsdir_nocomments")

File [... /python3.13/site-packages/f4enix/input/libmanager.py:158], in LibManager.__init__(self, xsdir_path, defaultlib, activationfile, isotopes_file, dosimetry_lib)
    156         xsdir = Xsdir(xs_file)
    157 else:
--> 158     xsdir = Xsdir(xsdir_path)
    159 available_libs = list(set(np.array(xsdir.tablenames)[:, 1]))
    160 df_rows = []

File [... /python3.13/site-packages/f4enix/input/xsdirpyne.py:92], in Xsdir.__init__(self, filename)
     89 self.awr = {}
     90 self.tables = []
---> 92 self.read()
     94 # It is useful to have a list of the available tables names to be
     95 # computed only once at initializations
     96 tablenames = []

File [... /python3.13/site-packages/f4enix/input/xsdirpyne.py:121], in Xsdir.read(self)
    119 line = self.f.readline()
    120 words = line.split()
--> 121 assert len(words) == 3
    122 assert words[0].lower() == "atomic"
    123 assert words[1].lower() == "weight"

AssertionError:

Expected behavior
Load of standard default xsdir file.

Screenshots
n/a

Desktop (please complete the following information):

  • OS: Linux
  • F4Enix: 0.17.0
  • Python: 3.13.9

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions