Skip to content

Commit

Permalink
fixed bug to ignore main elements of the XML file if not defined, e.g…
Browse files Browse the repository at this point in the history
…., impropers
  • Loading branch information
Christopher Iacovella authored and Christopher Iacovella committed Jan 12, 2023
1 parent 0823bf7 commit ffc06d7
Showing 1 changed file with 11 additions and 10 deletions.
21 changes: 11 additions & 10 deletions hoomdxml_reader/hoomdxml_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,16 +118,17 @@ def load(self, xml_file=None, identify_molecules=True, ignore_zero_bond_order=Fa
# takes the element as an argument and number of entries per line
def _parse_topology(self, element, length):
temp_element = self._config.find(element)
temp_text = temp_element.text
agg_array = []
entry_temp = temp_text.split()
for i in range(0, len(entry_temp), length):
temp_array = []
temp_array.append(entry_temp[i])
for j in range(1, length):
temp_array.append(int(entry_temp[i+j]))
agg_array.append(temp_array)
return agg_array
if temp_element is not None:
temp_text = temp_element.text
agg_array = []
entry_temp = temp_text.split()
for i in range(0, len(entry_temp), length):
temp_array = []
temp_array.append(entry_temp[i])
for j in range(1, length):
temp_array.append(int(entry_temp[i+j]))
agg_array.append(temp_array)
return agg_array

# a generic function to parse a list of floats defined in the text between opening/closing tags for a given element
def _parse_floats(self, element):
Expand Down

0 comments on commit ffc06d7

Please sign in to comment.