Skip to content

Commit

Permalink
Use type(obj).__name__ to determime logfile type
Browse files Browse the repository at this point in the history
Previously statmech.py used `isinstance(x, GaussianLog, QchemLog, MolproLog))`
when determining if the logfile has the proper methods implemented.
This may cause issues when adding more subclasses, if these lines
are not properly modified. This commit reduces that potential error
by replacing that command with

`isinstance(x, Log) and type(obj).__name__ != 'Log'`
  • Loading branch information
goldmanm committed Jul 27, 2019
1 parent 97c31e8 commit 841c8a0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions arkane/statmech.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,9 +307,9 @@ def load(self, pdep=False, plot=False):
'{1!r}.'.format(self.modelChemistry, path))
e0, e_electronic = None, None # E0 = e_electronic + ZPE
energyLog = None
if isinstance(energy, Log) and not isinstance(energy, (GaussianLog, QChemLog, MolproLog)):
if isinstance(energy, Log) and type(energy).__name__ == 'Log':
energyLog = determine_qm_software(os.path.join(directory, energy.path))
elif isinstance(energy, (GaussianLog, QChemLog, MolproLog)):
elif isinstance(energy, Log) and type(energy).__name__ != 'Log':
energyLog = energy
energyLog.path = os.path.join(directory, energyLog.path)
elif isinstance(energy, float):
Expand All @@ -333,13 +333,13 @@ def load(self, pdep=False, plot=False):
statmechLog = local_context['frequencies']
except KeyError:
raise InputError('Required attribute "frequencies" not found in species file {0!r}.'.format(path))
if isinstance(statmechLog, Log) and not isinstance(energy, (GaussianLog, QChemLog, MolproLog)):
if isinstance(statmechLog, Log) and type(statmechLog).__name__ == 'Log':
statmechLog = determine_qm_software(os.path.join(directory, statmechLog.path))
else:
statmechLog.path = os.path.join(directory, statmechLog.path)
try:
geomLog = local_context['geometry']
if isinstance(geomLog, Log) and not isinstance(energy, (GaussianLog, QChemLog, MolproLog)):
if isinstance(geomLog, Log) and type(geomLog).__name__ == 'Log':
geomLog = determine_qm_software(os.path.join(directory, geomLog.path))
else:
geomLog.path = os.path.join(directory, geomLog.path)
Expand Down Expand Up @@ -487,7 +487,7 @@ def load(self, pdep=False, plot=False):
# the symmetry number will be derived from the scan
scanLog, pivots, top, fit = q
# Load the hindered rotor scan energies
if isinstance(scanLog, Log) and not isinstance(energy, (GaussianLog, QChemLog, MolproLog)):
if isinstance(scanLog, Log) and type(scanLog).__name__ == 'Log':
scanLog = determine_qm_software(os.path.join(directory, scanLog.path))
scanLog.path = os.path.join(directory, scanLog.path)
if isinstance(scanLog, (GaussianLog, QChemLog)):
Expand Down

0 comments on commit 841c8a0

Please sign in to comment.