Skip to content

Commit

Permalink
Make Arkane PEP8 compliant
Browse files Browse the repository at this point in the history
  • Loading branch information
alongd authored and mliu49 committed Sep 23, 2019
1 parent f94e417 commit 59d8060
Show file tree
Hide file tree
Showing 32 changed files with 662 additions and 702 deletions.
2 changes: 1 addition & 1 deletion Arkane.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
arkane = Arkane()

# Parse and validate the command-line arguments
arkane.parseCommandLineArguments()
arkane.parse_command_line_arguments()

# Execute the job
arkane.execute()
Expand Down
20 changes: 9 additions & 11 deletions arkane/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@

import rmgpy.constants as constants
from rmgpy import __version__
from rmgpy.molecule.element import element_list, get_element
from rmgpy.molecule.element import get_element
from rmgpy.molecule.translator import to_inchi, to_inchi_key
from rmgpy.pdep.collision import SingleExponentialDown
from rmgpy.quantity import ScalarQuantity, ArrayQuantity
Expand All @@ -58,8 +58,6 @@

from arkane.pdep import PressureDependenceJob

################################################################################


# Add a custom string representer to use block literals for multiline strings
def str_repr(dumper, data):
Expand Down Expand Up @@ -229,7 +227,7 @@ def save_yaml(self, path):
def load_yaml(self, path, label=None, pdep=False):
"""
Load the all statMech data from the .yml file in `path` into `species`
`pdep` is a boolean specifying whether or not jobList includes a pressureDependentJob.
`pdep` is a boolean specifying whether or not job_list includes a pressureDependentJob.
"""
yml_file = os.path.basename(path)
if label:
Expand Down Expand Up @@ -312,26 +310,26 @@ def load_yaml(self, path, label=None, pdep=False):
################################################################################


def is_pdep(jobList):
def is_pdep(job_list):
"""A helper function to determine whether a job is PressureDependenceJob or not"""
for job in jobList:
for job in job_list:
if isinstance(job, PressureDependenceJob):
return True
return False


def check_conformer_energy(Vlist, path):
def check_conformer_energy(energies, path):
"""
Check to see that the starting energy of the species in the potential energy scan calculation
is not 0.5 kcal/mol (or more) higher than any other energies in the scan. If so, print and
log a warning message.
"""
v_list = np.array(Vlist, np.float64)
v_diff = (v_list[0] - np.min(v_list)) * constants.E_h * constants.Na / 1000
if v_diff >= 2: # we choose 2 kJ/mol to be the critical energy
energies = np.array(energies, np.float64)
e_diff = (energies[0] - np.min(energies)) * constants.E_h * constants.Na / 1000
if e_diff >= 2: # we choose 2 kJ/mol to be the critical energy
logging.warning('the species corresponding to {path} is different in energy from the lowest energy conformer '
'by {diff} kJ/mol. This can cause significant errors in your computed rate constants.'
.format(path=os.path.basename(path), diff=v_diff))
.format(path=os.path.basename(path), diff=e_diff))


def get_element_mass(input_element, isotope=None):
Expand Down
28 changes: 14 additions & 14 deletions arkane/commonTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

from arkane import Arkane, input
from arkane.common import ArkaneSpecies, get_element_mass
from arkane.input import jobList
from arkane.input import job_list
from arkane.statmech import InputError, StatMechJob

################################################################################
Expand Down Expand Up @@ -81,11 +81,11 @@ class TestArkaneJob(unittest.TestCase):
def setUp(cls):
"""A method that is run before each unit test in this class"""
arkane = Arkane()
job_list = arkane.loadInputFile(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data', 'methoxy.py'))
job_list = arkane.load_input_file(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data', 'methoxy.py'))
pdepjob = job_list[-1]
cls.kineticsjob = job_list[0]
pdepjob.activeJRotor = True
pdepjob.active_j_rotor = True
network = pdepjob.network
cls.Nisom = len(network.isomers)
cls.Nreac = len(network.reactants)
Expand All @@ -99,9 +99,9 @@ def setUp(cls):
cls.PminValue = pdepjob.Pmin.value
cls.Pcount = pdepjob.Pcount
cls.Tcount = pdepjob.Tcount
cls.GenTlist = pdepjob.generateTemperatureList()
cls.GenTlist = pdepjob.generate_T_list()
cls.PlistValue = pdepjob.Plist.value
cls.maximumGrainSizeValue = pdepjob.maximumGrainSize.value
cls.maximum_grain_size_value = pdepjob.maximum_grain_size.value
cls.method = pdepjob.method
cls.rmgmode = pdepjob.rmgmode

Expand Down Expand Up @@ -189,7 +189,7 @@ def test_maximum_grain_size_value(self):
"""
Test the max grain size value.
"""
self.assertEqual(self.maximumGrainSizeValue, 0.5)
self.assertEqual(self.maximum_grain_size_value, 0.5)

def test_method(self):
"""
Expand Down Expand Up @@ -242,7 +242,7 @@ def test_species(self):

def test_species_statmech(self):
"""Test loading of statmech job from species input file."""
job = jobList[-1]
job = job_list[-1]
self.assertTrue(isinstance(job, StatMechJob))
job.modelChemistry = self.modelChemistry
job.frequencyScaleFactor = self.frequencyScaleFactor
Expand All @@ -256,7 +256,7 @@ def test_species_statmech(self):
def test_species_thermo(self):
"""Test thermo job execution for species from separate input file."""
input.thermo('C2H4', 'NASA')
job = jobList[-1]
job = job_list[-1]
filepath = os.path.join(self.directory, 'reactions', 'H+C2H4=C2H5')
job.execute(output_directory=filepath)
self.assertTrue(os.path.isfile(os.path.join(filepath, 'output.py')))
Expand All @@ -271,7 +271,7 @@ def test_transition_state(self):

def test_transition_state_statmech(self):
"""Test loading of statmech job from transition state input file."""
job = jobList[-1]
job = job_list[-1]
self.assertTrue(isinstance(job, StatMechJob))
job.modelChemistry = self.modelChemistry
job.frequencyScaleFactor = self.frequencyScaleFactor
Expand All @@ -289,8 +289,8 @@ class TestStatmech(unittest.TestCase):
def setUp(cls):
"""A method that is run before each unit test in this class"""
arkane = Arkane()
cls.job_list = arkane.loadInputFile(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data', 'Benzyl', 'input.py'))
cls.job_list = arkane.load_input_file(os.path.join(os.path.dirname(os.path.abspath(__file__)),
'data', 'Benzyl', 'input.py'))

def test_gaussian_log_file_error(self):
"""Test that the proper error is raised if gaussian geometry and frequency file paths are the same"""
Expand Down Expand Up @@ -330,7 +330,7 @@ def test_dump_yaml(self):
"""
Test properly dumping the ArkaneSpecies object and respective sub-objects
"""
job_list = self.arkane.loadInputFile(self.dump_input_path)
job_list = self.arkane.load_input_file(self.dump_input_path)
for job in job_list:
job.execute(output_directory=self.dump_path)
self.assertTrue(os.path.isfile(self.dump_output_file))
Expand All @@ -340,7 +340,7 @@ def test_create_and_load_yaml(self):
Test properly loading the ArkaneSpecies object and respective sub-objects
"""
# Create YAML file by running Arkane
job_list = self.arkane.loadInputFile(self.dump_input_path)
job_list = self.arkane.load_input_file(self.dump_input_path)
for job in job_list:
job.execute(output_directory=self.dump_path)

Expand Down
2 changes: 1 addition & 1 deletion arkane/data/methoxy.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@
minimumGrainCount=500,
method='modified strong collision',
# Other methods include: 'reservoir state', 'chemically-significant eigenvalues',
interpolationModel=('pdeparrhenius'),
interpolationModel='pdeparrhenius',
activeKRotor=True,
# active_j_rotor = False, # causes Arkane to crash
rmgmode=False,
Expand Down
2 changes: 1 addition & 1 deletion arkane/data/methoxy_explore.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@
maximumGrainSize=(0.5, 'kcal/mol'),
minimumGrainCount=500,
method='modified strong collision',
interpolationModel=('pdeparrhenius'),
interpolationModel='pdeparrhenius',
activeKRotor=True,
rmgmode=False,
)
Expand Down
2 changes: 0 additions & 2 deletions arkane/encorr/corr.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
import arkane.encorr.pbac as pbac
from arkane.exceptions import AtomEnergyCorrectionError, BondAdditivityCorrectionError

################################################################################


def get_energy_correction(model_chemistry, atoms, bonds, coords, nums, multiplicity=1,
atom_energies=None, apply_atom_corrections=True,
Expand Down
2 changes: 1 addition & 1 deletion arkane/encorr/mbac.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def get_bac(model_chemistry, coords, nums, multiplicity=1, mol_corr=0.0):

# Bond correction
bac_bond = 0.0
for bond in mol.getAllEdges():
for bond in mol.get_all_edges():
atom1 = bond.atom1
atom2 = bond.atom2
symbol1 = atom1.element.symbol
Expand Down
Loading

0 comments on commit 59d8060

Please sign in to comment.