Skip to content

Commit

Permalink
Format black
Browse files Browse the repository at this point in the history
  • Loading branch information
pyiron-runner committed Dec 26, 2023
1 parent 7f7035b commit d40487e
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions pyiron_atomistics/vasp/vasprun.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def from_file(self, filename="vasprun.xml"):
"""
if not (os.path.isfile(filename)):
raise AssertionError()
self.filename=filename
self.filename = filename
try:
self.parse_root_to_dict(filename)
except ParseError:
Expand Down Expand Up @@ -537,7 +537,7 @@ def parse_structure_to_dict(self, node, d):

if leaf.tag == "varray" and leaf.attrib["name"] == "selective":
d["selective_dynamics"] = self._parse_2d_matrix(leaf, vec_type=bool)

def _parse_INCAR_generator_parameters(self, val_type, val):
"""
Helper function to convert a Vasprun parameter into the proper type.
Expand All @@ -555,8 +555,9 @@ def _parse_INCAR_generator_parameters(self, val_type, val):
return val.strip()
return float(val)


def _parse_INCAR_generator_vector_parameters(self, val_type, val, filename, param_name):
def _parse_INCAR_generator_vector_parameters(
self, val_type, val, filename, param_name
):
"""
Helper function to convert a Vasprun array-type parameter into the proper
type. Boolean, int and float types are converted.
Expand Down Expand Up @@ -615,9 +616,13 @@ def _parse_INCAR_and_generator(self, elem):
val = c.text.strip() if c.text else ""
try:
if c.tag == "i":
params[name] = self._parse_INCAR_generator_parameters(ptype, val)
params[name] = self._parse_INCAR_generator_parameters(
ptype, val
)
else:
params[name] = self._parse_INCAR_generator_vector_parameters(ptype, val, self.filename, name)
params[name] = self._parse_INCAR_generator_vector_parameters(
ptype, val, self.filename, name
)
except Exception as exc:
if name == "RANDOM_SEED":
# Handles the case where RANDOM SEED > 99999, which results in *****
Expand All @@ -626,11 +631,11 @@ def _parse_INCAR_and_generator(self, elem):
raise exc
elem.clear()
return params

@staticmethod
def parse_item_to_dict(node, d):
"""
Parses an XML element with the tag 'i' into a dictionary. The method handles different
Parses an XML element with the tag 'i' into a dictionary. The method handles different
data types specified in the 'type' attribute of the element (e.g., string, float, int, logical).
Args:
Expand All @@ -653,7 +658,7 @@ def parse_item_to_dict(node, d):

def _parse_from_incar(self, param_name, val_type, val):
"""
Placeholder method for reading and parsing parameter values from an INCAR file. This method is intended
Placeholder method for reading and parsing parameter values from an INCAR file. This method is intended
to be used for handling special cases where values in the VASP XML file are not correctly formatted.
Args:
Expand All @@ -671,7 +676,7 @@ def _parse_from_incar(self, param_name, val_type, val):
# Adapt this method based on specific handling logic for irregular values
# For example, read from an INCAR file or set to a default value
return None

def parse_parameters(self, node, d):
"""
Parses parameter data from a node to a dictionary
Expand Down

0 comments on commit d40487e

Please sign in to comment.