Skip to content

Commit 81396e4

Browse files
authored
Merge pull request #1168 from ReactionMechanismGenerator/GetRidofUnusedCode
Remove unused code
2 parents c586870 + 0c4a4f1 commit 81396e4

35 files changed

Lines changed: 40 additions & 150 deletions

rmgpy/cantherm/gaussian.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,9 +260,7 @@ def loadEnergy(self,frequencyScaleFactor=1.):
260260
CBS-QB3 value.
261261
"""
262262

263-
modes = []
264263
E0 = None; E0_cbs = None; scaledZPE = None
265-
spinMultiplicity = 1
266264

267265
f = open(self.path, 'r')
268266
line = f.readline()
@@ -307,9 +305,7 @@ def loadZeroPointEnergy(self):
307305
Load the unscaled zero-point energy in J/mol from a Gaussian log file.
308306
"""
309307

310-
modes = []
311308
ZPE = None
312-
spinMultiplicity = 1
313309

314310
f = open(self.path, 'r')
315311
line = f.readline()

rmgpy/cantherm/gaussianTest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
import os
3434

3535
from rmgpy.cantherm.gaussian import GaussianLog
36-
from rmgpy.statmech import Conformer, IdealGasTranslation, LinearRotor, NonlinearRotor, HarmonicOscillator, HinderedRotor
36+
from rmgpy.statmech import IdealGasTranslation, LinearRotor, NonlinearRotor, HarmonicOscillator, HinderedRotor
3737
import rmgpy.constants as constants
3838
from external.wip import work_in_progress
3939
################################################################################

rmgpy/cantherm/qchem.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,8 @@ def loadGeometry(self):
114114
last is returned.
115115
"""
116116
atom = []; coord = []; number = [];
117-
try:
118-
f = open(self.path, 'r')
119-
except IndexError:
120-
print('File not found')
121-
f = open(self.path, 'r')
117+
118+
f = open(self.path, 'r')
122119
line = f.readline()
123120
while line != '':
124121
if 'Final energy is' in line:
@@ -202,8 +199,7 @@ def loadConformer(self, symmetry=None, spinMultiplicity=None, opticalIsomers=1):
202199
# The rest of the data we want is in the Thermochemistry section of the output
203200
elif 'VIBRATIONAL ANALYSIS' in line:
204201
modes = []
205-
206-
inPartitionFunctions = False
202+
207203
line = f.readline()
208204
while line != '':
209205

@@ -254,7 +250,6 @@ def loadConformer(self, symmetry=None, spinMultiplicity=None, opticalIsomers=1):
254250
else:
255251
for i in range(3):
256252
inertia[i] *= (constants.a0/1e-10)**2
257-
pass
258253
rotation = NonlinearRotor(inertia=(inertia,"amu*angstrom^2"), symmetry=symmetry)
259254
#modes.append(rotation)
260255
rot.append(rotation)
@@ -281,9 +276,7 @@ def loadEnergy(self,frequencyScaleFactor=1.):
281276
in the file is returned. The zero-point energy is *not* included in
282277
the returned value.
283278
"""
284-
modes = []
285-
E0 = None
286-
spinMultiplicity = 1
279+
E0 = None
287280

288281
f = open(self.path, 'r')
289282
line = f.readline()
@@ -314,9 +307,7 @@ def loadZeroPointEnergy(self,frequencyScaleFactor=1.):
314307
Load the unscaled zero-point energy in J/mol from a Qchem output file.
315308
"""
316309

317-
modes = []
318310
ZPE = None
319-
spinMultiplicity = 1
320311

321312
f = open(self.path, 'r')
322313
line = f.readline()

rmgpy/constraints.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def failsSpeciesConstraints(species):
4343

4444
try:
4545
speciesConstraints = getInput('speciesConstraints')
46-
except Exception, e:
46+
except Exception:
4747
logging.debug('Species constraints could not be found.')
4848
speciesConstraints = {}
4949

rmgpy/data/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,7 @@ def load(self, path, local_context=None, global_context=None):
222222
f = open(path, 'r')
223223
try:
224224
exec f in global_context, local_context
225-
except Exception, e:
225+
except Exception:
226226
logging.error('Error while reading database {0!r}.'.format(path))
227227
raise
228228
f.close()

rmgpy/data/kinetics/family.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@
3636
import logging
3737
import codecs
3838
from copy import deepcopy
39-
import itertools
40-
import numpy as np
4139

4240
from rmgpy.constraints import failsSpeciesConstraints
4341
from rmgpy.data.base import Database, Entry, LogicNode, LogicOr, ForbiddenStructures,\
4442
getAllCombinations
4543
from rmgpy.reaction import Reaction
46-
from rmgpy.kinetics import Arrhenius, ArrheniusEP
44+
from rmgpy.kinetics import Arrhenius
4745
from rmgpy.molecule import Bond, GroupBond, Group, Molecule
4846
from rmgpy.species import Species
4947

rmgpy/data/kinetics/library.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,7 @@
4545

4646
from rmgpy.reaction import Reaction
4747
from rmgpy.kinetics import Arrhenius, ThirdBody, Lindemann, Troe, \
48-
PDepArrhenius, MultiArrhenius, MultiPDepArrhenius, \
49-
PDepKineticsModel
48+
PDepArrhenius, MultiArrhenius, MultiPDepArrhenius
5049
from rmgpy.molecule import Molecule
5150
from rmgpy.species import Species
5251
from .common import saveEntry
@@ -302,7 +301,7 @@ def load(self, path, local_context=None, global_context=None):
302301
f = open(path, 'r')
303302
try:
304303
exec f in global_context, local_context
305-
except Exception, e:
304+
except Exception:
306305
logging.error('Error while reading database {0!r}.'.format(path))
307306
raise
308307
f.close()

rmgpy/data/thermo.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,10 @@
4545

4646
import rmgpy.constants as constants
4747
from rmgpy.thermo import NASAPolynomial, NASA, ThermoData, Wilhoit
48-
from rmgpy.molecule import Molecule, Atom, Bond, Group
48+
from rmgpy.molecule import Molecule, Bond, Group
4949
import rmgpy.molecule
5050
from rmgpy.species import Species
5151

52-
from rmgpy.scoop_framework.util import get
53-
5452
#: This dictionary is used to add multiplicity to species label
5553
_multiplicity_labels = {1:'S',2:'D',3:'T',4:'Q',5:'V',}
5654

@@ -250,8 +248,7 @@ def averageThermoData(thermoDataList=None):
250248
"""
251249
if thermoDataList is None:
252250
thermoDataList = []
253-
254-
import copy
251+
255252
numValues = len(thermoDataList)
256253

257254
if numValues == 0:
@@ -260,10 +257,10 @@ def averageThermoData(thermoDataList=None):
260257
logging.debug('Averaging thermo data over {0} value(s).'.format(numValues))
261258

262259
if numValues == 1:
263-
return copy.deepcopy(thermoDataList[0])
260+
return deepcopy(thermoDataList[0])
264261

265262
else:
266-
averagedThermoData = copy.deepcopy(thermoDataList[0])
263+
averagedThermoData = deepcopy(thermoDataList[0])
267264
for thermoData in thermoDataList[1:]:
268265
averagedThermoData = addThermoData(averagedThermoData, thermoData)
269266

@@ -337,7 +334,6 @@ def convertRingToSubMolecule(ring):
337334
This function takes a ring structure (can either be monoring or polyring) to create a new
338335
submolecule with newly deep copied atoms
339336
"""
340-
from rmgpy.molecule.molecule import Molecule, Bond
341337

342338
atomsMapping = {}
343339
for atom in ring:
@@ -359,8 +355,6 @@ def combineTwoRingsIntoSubMolecule(ring1, ring2):
359355
submolecule with newly deep copied atoms
360356
"""
361357

362-
from rmgpy.molecule.molecule import Molecule, Bond
363-
364358
assert len(commonAtoms(ring1, ring2))>0, "The two input rings don't have common atoms."
365359

366360
atomsMapping = {}
@@ -680,7 +674,7 @@ def removeGroup(self, groupToRemove):
680674
parentR = groupToRemove.parent
681675

682676
#look for other pointers that point toward entry
683-
for entryName, entry in self.entries.iteritems():
677+
for entry in self.entries.itervalues():
684678
if isinstance(entry.data, basestring):
685679
if entry.data == groupToRemove.label:
686680
#if the entryToRemove.data is also a pointer, then copy
@@ -1051,7 +1045,7 @@ def getThermoData(self, species, trainingSet=None):
10511045

10521046
try:
10531047
quantumMechanics = getInput('quantumMechanics')
1054-
except Exception, e:
1048+
except Exception:
10551049
logging.debug('Quantum Mechanics DB could not be found.')
10561050
quantumMechanics = None
10571051

@@ -1239,12 +1233,12 @@ def getThermoDataFromDepository(self, species):
12391233
Returns: a list of tuples (thermoData, depository, entry) without any Cp0 or CpInf data.
12401234
"""
12411235
items = []
1242-
for label, entry in self.depository['stable'].entries.iteritems():
1236+
for entry in self.depository['stable'].entries.itervalues():
12431237
for molecule in species.molecule:
12441238
if molecule.isIsomorphic(entry.item):
12451239
items.append((deepcopy(entry.data), self.depository['stable'], entry))
12461240
break
1247-
for label, entry in self.depository['radical'].entries.iteritems():
1241+
for entry in self.depository['radical'].entries.itervalues():
12481242
for molecule in species.molecule:
12491243
if molecule.isIsomorphic(entry.item):
12501244
items.append((deepcopy(entry.data), self.depository['radical'], entry))
@@ -1263,7 +1257,7 @@ def getThermoDataFromLibrary(self, species, library):
12631257
Returns a tuple: (ThermoData, library, entry) or None.
12641258
"""
12651259
match = None
1266-
for label, entry in library.entries.iteritems():
1260+
for entry in library.entries.itervalues():
12671261
for molecule in species.molecule:
12681262
if molecule.isIsomorphic(entry.item) and entry.data is not None:
12691263
thermoData = deepcopy(entry.data)
@@ -1685,8 +1679,7 @@ def __addRingCorrectionThermoDataFromTree(self, thermoData, ring_database, molec
16851679
if thermoData is None:
16861680
return data, node, isPartialMatch
16871681
else:
1688-
return addThermoData(thermoData, data, groupAdditivity=True, verbose = True), node, isPartialMatch
1689-
return addThermoData(thermoData, data, groupAdditivity=True, verbose=True), node
1682+
return addThermoData(thermoData, data, groupAdditivity=True, verbose=True), node, isPartialMatch
16901683
# By setting verbose=True, we turn on the comments of ring correction to pass the unittest.
16911684
# Typically this comment is very short and also very helpful to check if the ring correction is calculated correctly.
16921685

rmgpy/kinetics/modelTest.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@
3636

3737
from rmgpy.kinetics.model import getReactionOrderFromRateCoefficientUnits, \
3838
getRateCoefficientUnitsFromReactionOrder
39-
import rmgpy.constants as constants
4039

4140
################################################################################
4241

rmgpy/molecule/group.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,6 @@ def __loseRadical(self, radical):
209209
or 3 radical electrons.
210210
"""
211211
radicalElectrons = []
212-
pairs = set()
213212
if any([len(atomType.decrementRadical) == 0 for atomType in self.atomType]):
214213
raise ActionError('Unable to update GroupAtom due to LOSE_RADICAL action: Unknown atom type produced from set "{0}".'.format(self.atomType))
215214

@@ -1282,7 +1281,7 @@ def standardizeAtomType(self):
12821281

12831282
#list of :class:AtomType which are elements with more sub-divided atomtypes beneath them
12841283
specifics= [elementLabel for elementLabel in allElements if elementLabel not in nonSpecifics]
1285-
for index, atom in enumerate(self.atoms):
1284+
for atom in self.atoms:
12861285
claimedAtomType = atom.atomType[0]
12871286
newAtomType = None
12881287
element = None
@@ -1366,7 +1365,7 @@ def addExplicitLigands(self):
13661365
#Do not perform is this atom has wildCards
13671366
if atom.hasWildCards: continue
13681367
elif claimedAtomType is atomTypes['CO'] or claimedAtomType is atomTypes['CS']:
1369-
for atom2, bond12 in atom.bonds.iteritems():
1368+
for bond12 in atom.bonds.itervalues():
13701369
if bond12.isDouble():
13711370
break
13721371
else: atomsToAddTo.append(index)
@@ -1392,9 +1391,7 @@ def standardizeGroup(self):
13921391
Returns a 'True' if the group was modified otherwise returns 'False'
13931392
"""
13941393

1395-
modified = False
1396-
1397-
#If viable then we apply current conventions:
1394+
# If viable then we apply current conventions:
13981395
checkList=[]
13991396
checkList.append(self.standardizeAtomType())
14001397
checkList.append(self.addExplicitLigands())

0 commit comments

Comments
 (0)