Adding documentation to create_xml_subelement methods. Removing old, now unused, path variables from those methods as well.

This commit is contained in:
Patrick Shriwise 2019-03-05 13:22:50 -06:00
parent 177f3d1423
commit ec1a4b5d2b
3 changed files with 50 additions and 10 deletions

View file

@ -463,7 +463,23 @@ class Cell(IDManagerMixin):
return memo[self]
def create_xml_subelement(self, xml_element, memo=None):
"""Add the cell's xml representation to an incoming xml element
Parameters
----------
xml_element : xml.etree.ElementTree.Element
XML element to be added to
memo : dict or None
A dictionary containing sets of universe, lattice, cell, and surface
id sets already written to the xml_element. This parameter
is used internally and should not be specified by the user.
Returns
-------
None
"""
element = ET.Element("cell")
element.set("id", str(self.id))
@ -500,7 +516,6 @@ class Cell(IDManagerMixin):
# thus far.
def create_surface_elements(node, element, memo=None):
if isinstance(node, Halfspace):
path = "./surface[@id='{}']".format(node.surface.id)
if memo and node.surface.id in memo['surfaces']:
return
if memo is not None:

View file

@ -753,11 +753,24 @@ class RectLattice(Lattice):
0 <= idx[2] < self.shape[2])
def create_xml_subelement(self, xml_element, memo=None):
# Determine if XML element already contains subelement for this Lattice
path = './lattice[@id=\'{0}\']'.format(self._id)
test = xml_element.find(path)
"""Add the lattice xml representation to an incoming xml element
# If the element does contain the Lattice subelement, then return
Parameters
----------
xml_element : xml.etree.ElementTree.Element
XML element to be added to
memo : dict or None
A dictionary containing sets of universe, lattice, cell, and surface
id sets already written to the xml_element. This parameter
is used internally and should not be specified by the user.
Returns
-------
None
"""
# If the element already contains the Lattice subelement, then return
if memo and self._id in memo['lattices']:
return
if memo is not None:
@ -1275,10 +1288,6 @@ class HexLattice(Lattice):
return g < self.num_rings and 0 <= idx[2] < self.num_axial
def create_xml_subelement(self, xml_element, memo=None):
# Determine if XML element already contains subelement for this Lattice
path = './hex_lattice[@id=\'{0}\']'.format(self._id)
test = xml_element.find(path)
# If the element does contain the Lattice subelement, then return
if memo and self._id in memo['lattices']:
return

View file

@ -512,9 +512,25 @@ class Universe(IDManagerMixin):
return memo[self]
def create_xml_subelement(self, xml_element, memo=None):
"""Add the universe xml representation to an incoming xml element
Parameters
----------
xml_element : xml.etree.ElementTree.Element
XML element to be added to
memo : dict or None
A dictionary containing sets of universe, lattice, cell, and surface
id sets already written to the xml_element. This parameter
is used internally and should not be specified by the user.
Returns
-------
None
"""
# Iterate over all Cells
for cell_id, cell in self._cells.items():
path = "./cell[@id='{}']".format(cell_id)
# If the cell was not already written, write it
if memo and cell_id in memo['cells']: