Skip to content

Commit

Permalink
Applied PEP-8 script...
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Ceriotti committed Dec 20, 2017
1 parent f2df411 commit 20e90fb
Show file tree
Hide file tree
Showing 117 changed files with 14,990 additions and 14,972 deletions.
18 changes: 9 additions & 9 deletions bin/i-pi
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import os

# Check that we have the import path for this i-PI set and if not, add it.
dir_root = os.path.realpath(
os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
os.path.join(os.path.dirname(os.path.realpath(__file__)), '..'))
if not dir_root in sys.path:
sys.path.insert(0, dir_root)

Expand All @@ -36,13 +36,13 @@ def main(fn_input, do_yappi=False):

# optionally profile this run - set up
#~ if do_yappi:
#~ try:
#~ import yappi
#~ yappi.start(builtins=True, profile_threads=True)
#~ except ImportError:
#~ print 'Profiling with yappi was enabled but could not be imported.'
#~ print "Profiling with yappi was enabled but could not be imported."
#~ sys.exit(1)
#~ try:
#~ import yappi
#~ yappi.start(builtins=True, profile_threads=True)
#~ except ImportError:
#~ print 'Profiling with yappi was enabled but could not be imported.'
#~ print "Profiling with yappi was enabled but could not be imported."
#~ sys.exit(1)

# construct simulation based on input file
simulation = Simulation.load_from_xml(fn_input, request_banner=True)
Expand Down Expand Up @@ -79,7 +79,7 @@ if __name__ == '__main__':
parser = OptionParser(usage='%prog [options] <input file>',
description='The main i-PI executable used to run '
'a simulation, given an XML input file.'
)
)

parser.add_option('-p', '--profile',
action='store_true', dest='do_yappi', default=False,
Expand Down
6 changes: 3 additions & 3 deletions doc/create_man.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@


if not os.path.exists("input_docs"):
os.mkdir("input_docs")
os.mkdir("input_docs")

help(xml=True, prefix="manual")
for opt in objects:
help(latex=True, levels=1, option=opt, prefix=("input_docs/" + opt), standalone=False)
help(latex=True, levels=1, option=opt, prefix=("input_docs/" + opt), standalone=False)
for opt in list_objects:
help_list(option=opt, prefix=("input_docs/" + opt), standalone=False)
help_list(option=opt, prefix=("input_docs/" + opt), standalone=False)
146 changes: 73 additions & 73 deletions doc/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,92 +31,92 @@
sys.path.append(src_dir)

from ipi.inputs import barostats, cell, simulation, paratemp, system, \
ensembles, thermostats, forcefields, forces, atoms, beads, \
prng, initializer, normalmodes, outputs, motion

ensembles, thermostats, forcefields, forces, atoms, beads, \
prng, initializer, normalmodes, outputs, motion


time.sleep(1)
__all__ = ['help', 'objects']

objects = { 'barostats': barostats.InputBaro(),
'cell': cell.InputCell(),
'simulation': simulation.InputSimulation(),
# 'paratemp': paratemp.InputParaTemp(),
'system': system.InputSystem(),
'ensembles': ensembles.InputEnsemble(),
'motion': motion.motion.InputMotion(),
'dynamics': motion.dynamics.InputDynamics(),
'thermostats': thermostats.InputThermo(),
'forcefield' : forcefields.InputForceField(),
'ffsocket': forcefields.InputFFSocket(),
'fflj': forcefields.InputFFLennardJones(),
'forcecomponent' : forces.InputForceComponent(),
'forces': forces.InputForces(),
'atoms': atoms.InputAtoms(),
'beads': beads.InputBeads(),
'prng': prng.InputRandom(),
'normal_modes': normalmodes.InputNormalModes(),
'init_file': initializer.InputInitFile(),
'init_pos': initializer.InputInitPositions(),
'init_mom': initializer.InputInitMomenta(),
'init_lab': initializer.InputInitLabels(),
'init_mass': initializer.InputInitMasses(),
'init_vel': initializer.InputInitVelocities(),
'init_cell': initializer.InputInitCell(),
'init_therm': initializer.InputInitThermo(),
'initializer': initializer.InputInitializer(),
'output': outputs.InputOutputs(),
'properties': outputs.InputProperties(),
'checkpoint': outputs.InputCheckpoint(),
'trajectory': outputs.InputTrajectory() }
objects = {'barostats': barostats.InputBaro(),
'cell': cell.InputCell(),
'simulation': simulation.InputSimulation(),
# 'paratemp': paratemp.InputParaTemp(),
'system': system.InputSystem(),
'ensembles': ensembles.InputEnsemble(),
'motion': motion.motion.InputMotion(),
'dynamics': motion.dynamics.InputDynamics(),
'thermostats': thermostats.InputThermo(),
'forcefield': forcefields.InputForceField(),
'ffsocket': forcefields.InputFFSocket(),
'fflj': forcefields.InputFFLennardJones(),
'forcecomponent': forces.InputForceComponent(),
'forces': forces.InputForces(),
'atoms': atoms.InputAtoms(),
'beads': beads.InputBeads(),
'prng': prng.InputRandom(),
'normal_modes': normalmodes.InputNormalModes(),
'init_file': initializer.InputInitFile(),
'init_pos': initializer.InputInitPositions(),
'init_mom': initializer.InputInitMomenta(),
'init_lab': initializer.InputInitLabels(),
'init_mass': initializer.InputInitMasses(),
'init_vel': initializer.InputInitVelocities(),
'init_cell': initializer.InputInitCell(),
'init_therm': initializer.InputInitThermo(),
'initializer': initializer.InputInitializer(),
'output': outputs.InputOutputs(),
'properties': outputs.InputProperties(),
'checkpoint': outputs.InputCheckpoint(),
'trajectory': outputs.InputTrajectory()}

usage = "usage: python %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-x", action="store_true", dest = "xml", default=False, help="write an xml help file")
parser.add_option("-l", action="store_true", dest = "latex", default=False, help="write a latex help file")
parser.add_option("-x", action="store_true", dest="xml", default=False, help="write an xml help file")
parser.add_option("-l", action="store_true", dest="latex", default=False, help="write a latex help file")
parser.add_option("-n", action="store", type="int", dest="levels", help="number of levels depth to which data is printed out")
parser.add_option("-o", action="store", dest="prefix", help="Prefix for the output files", default="help")
parser.add_option("-i", action="store", dest="opt", help="Root object for the help files. Options: ['barostats', 'cell', 'simulation', 'ensembles', 'thermostats', 'interface', 'forces', 'atoms', 'beads', 'prng', 'output', 'trajectory', 'properties', 'checkpoint']", default='simulation')
parser.add_option("-r", action="store_true", dest = "ref", default=False, help="add references to a latex help file. Ignored if -l is not present")
parser.add_option("-r", action="store_true", dest="ref", default=False, help="add references to a latex help file. Ignored if -l is not present")
(options, args) = parser.parse_args()

if options.opt not in objects:
raise ValueError("Option " + options.opt + " is not a viable tag name")

def help(latex=False, xml=False, levels = None, option='simulation', prefix="help", standalone=True):
"""Writes the help file.
Will write an xml file 'prefix.xml' if xml=True and a latex file 'prefix.tex'
if latex=True. Will write out tags to a depth equal to the value of levels,
if it is specified, and will print using a root tag as specified by
the value of option. The output will be given by prefix.tex and/or
prefix.xml, if latex and/or xml is True respectively. Can also print out
sections of latex documents with cross-references rather than entire
documents, so that we can input them into other latex documents, such as
the manual.
Args:
latex: Boolean specifying whether a latex file will be printed.
xml: Boolean specifying whether an xml file will be printed.
levels: An integer specifying how many layers of the hierarchy will be
printed. If not given, all layers will be printed.
option: A string specifying which object will be used as the root object
for the latex and xml files. Defaults to 'simulation'.
prefix: File prefix for the output files. Defaults to 'help'.
standalone: Boolean specifying whether the latex file will be a stand-alone
document, or will instead be intended to be used in a larger document
with cross references between the different objects.
"""

simrestart = objects[option]

if xml:
xml_output = open(prefix + ".xml","w")
xml_output.write(simrestart.help_xml(name=option, stop_level=levels))
if latex:
latex_output = open(prefix + ".tex","w")
latex_output.write(simrestart.help_latex(stop_level=levels, standalone=standalone))
raise ValueError("Option " + options.opt + " is not a viable tag name")


def help(latex=False, xml=False, levels=None, option='simulation', prefix="help", standalone=True):
"""Writes the help file.
Will write an xml file 'prefix.xml' if xml=True and a latex file 'prefix.tex'
if latex=True. Will write out tags to a depth equal to the value of levels,
if it is specified, and will print using a root tag as specified by
the value of option. The output will be given by prefix.tex and/or
prefix.xml, if latex and/or xml is True respectively. Can also print out
sections of latex documents with cross-references rather than entire
documents, so that we can input them into other latex documents, such as
the manual.
Args:
latex: Boolean specifying whether a latex file will be printed.
xml: Boolean specifying whether an xml file will be printed.
levels: An integer specifying how many layers of the hierarchy will be
printed. If not given, all layers will be printed.
option: A string specifying which object will be used as the root object
for the latex and xml files. Defaults to 'simulation'.
prefix: File prefix for the output files. Defaults to 'help'.
standalone: Boolean specifying whether the latex file will be a stand-alone
document, or will instead be intended to be used in a larger document
with cross references between the different objects.
"""

simrestart = objects[option]

if xml:
xml_output = open(prefix + ".xml", "w")
xml_output.write(simrestart.help_xml(name=option, stop_level=levels))
if latex:
latex_output = open(prefix + ".tex", "w")
latex_output.write(simrestart.help_latex(stop_level=levels, standalone=standalone))

if __name__ == '__main__':
help(options.latex, options.xml, options.levels, options.opt, options.prefix, not options.ref)
help(options.latex, options.xml, options.levels, options.opt, options.prefix, not options.ref)
63 changes: 32 additions & 31 deletions doc/help_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,47 @@
__all__ = ['help_list', 'list_objects']


list_objects = { 'property_list': Properties(),
'trajectory_list': Trajectories()}
list_objects = {'property_list': Properties(),
'trajectory_list': Trajectories()}

usage = "usage: python %prog [options]"
parser = OptionParser(usage=usage)
parser.add_option("-o", action="store", dest="prefix", help="Prefix for the output files", default="help")
parser.add_option("-i", action="store", dest="opt", help="Root object for the help files. Options: ['property_list', 'trajectory_list']", default='property_list')
parser.add_option("-r", action="store_true", dest = "ref", default=False, help="If false, this creates a stand-alone document.")
parser.add_option("-r", action="store_true", dest="ref", default=False, help="If false, this creates a stand-alone document.")
(options, args) = parser.parse_args()

if options.opt not in list_objects:
raise ValueError("Option " + options.opt + " is not a viable tag name")
raise ValueError("Option " + options.opt + " is not a viable tag name")


def help_list(option='property_list', prefix="help", standalone=True):
"""Writes the help file.
Will write a latex file 'prefix.tex'. Can also print out
sections of latex documents rather than entire
documents, so that we can input them into other latex documents, such as
the manual.
Args:
option: A string specifying which object will be used as the root object
for the latex and xml files. Defaults to 'property_list'.
prefix: File prefix for the output files. Defaults to 'help'.
standalone: Boolean specifying whether the latex file will be a stand-alone
document, or will instead be intended to be used in a larger document
with cross references between the different objects.
"""

simrestart = list_objects[option]
if option == "property_list":
idict = simrestart.property_dict
elif option == "trajectory_list":
idict = simrestart.traj_dict
else:
raise ValueError("Incorrect option specified.")

latex_output = open(prefix + ".tex","w")
latex_output.write(help_latex(idict, standalone=standalone))
"""Writes the help file.
Will write a latex file 'prefix.tex'. Can also print out
sections of latex documents rather than entire
documents, so that we can input them into other latex documents, such as
the manual.
Args:
option: A string specifying which object will be used as the root object
for the latex and xml files. Defaults to 'property_list'.
prefix: File prefix for the output files. Defaults to 'help'.
standalone: Boolean specifying whether the latex file will be a stand-alone
document, or will instead be intended to be used in a larger document
with cross references between the different objects.
"""

simrestart = list_objects[option]
if option == "property_list":
idict = simrestart.property_dict
elif option == "trajectory_list":
idict = simrestart.traj_dict
else:
raise ValueError("Incorrect option specified.")

latex_output = open(prefix + ".tex", "w")
latex_output.write(help_latex(idict, standalone=standalone))

if __name__ == '__main__':
help_list(options.opt, options.prefix, not options.ref)
help_list(options.opt, options.prefix, not options.ref)
8 changes: 4 additions & 4 deletions examples/ASE/W2-PIMD-MP2/run-ase.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
atoms = ase.io.read('init.xyz')
atoms.set_calculator(
Gaussian(
method = 'MP2',
method='MP2',
# Note that 6-31G is for faster testing only, not a good basis set
# for gas-phase W2. Use the bigger one instead.
basis = '6-31G',
basis='6-31G',
#basis = '6-311++G**',
nproc = nthreads,
label = dir_calc + '/calculator'
nproc=nthreads,
label=dir_calc + '/calculator'
)
)

Expand Down
10 changes: 5 additions & 5 deletions examples/cp2k/nvt-cl/idtau_plot.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from pylab import *

idtdata = []
#output is a standard output from i-pi
# output is a standard output from i-pi
for line in open("output"):
llist = line.split()
if llist:
Expand All @@ -10,10 +10,10 @@

nsteps = len(idtdata)
maxt = nsteps * 0.1
print("Mean IDTAU for " + str(maxt*0.5) + "<t<" + str(maxt) + " fs: "+str(mean(idtdata[nsteps//2:nsteps])))
print("Mean IDTAU for " + str(maxt * 0.5) + "<t<" + str(maxt) + " fs: " + str(mean(idtdata[nsteps // 2:nsteps])))

fig = figure()
ax = fig.add_subplot(111)
ax.plot(linspace(0,maxt,num=nsteps), idtdata)
ax.set(title="Automatic IDTAU Parameter Adjustment",xlabel="Time [fs]", ylabel="IDTAU [a.u.]",xlim=(0,maxt))
ax.plot(linspace(0, maxt, num=nsteps), idtdata)
ax.set(title="Automatic IDTAU Parameter Adjustment", xlabel="Time [fs]", ylabel="IDTAU [a.u.]", xlim=(0, maxt))
show()
8 changes: 4 additions & 4 deletions examples/hswfqmc/FixWF_1Bead/intau_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

nsteps = len(invdata)
maxt = nsteps * 0.1
print("Mean INTAU for " + str(maxt*0.5) + "<t<" + str(maxt) + " fs: "+str(mean(invdata[nsteps//2:nsteps])))
print("Mean INTAU for " + str(maxt * 0.5) + "<t<" + str(maxt) + " fs: " + str(mean(invdata[nsteps // 2:nsteps])))

fig = figure()
ax = fig.add_subplot(111)
ax.plot(linspace(0,maxt,num=nsteps), invdata)
ax.set(title="Automatic INTAU Parameter Adjustment",xlabel="Time [fs]", ylabel="INTAU [a.u.]",xlim=(0,maxt))
ax.plot(linspace(0, maxt, num=nsteps), invdata)
ax.set(title="Automatic INTAU Parameter Adjustment", xlabel="Time [fs]", ylabel="INTAU [a.u.]", xlim=(0, maxt))
show()
8 changes: 4 additions & 4 deletions examples/hswfqmc/WFOpt_2Bead/intau_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

nsteps = len(invdata)
maxt = nsteps * 0.1
print("Mean INTAU for " + str(maxt*0.5) + "<t<" + str(maxt) + " fs: "+str(mean(invdata[nsteps//2:nsteps])))
print("Mean INTAU for " + str(maxt * 0.5) + "<t<" + str(maxt) + " fs: " + str(mean(invdata[nsteps // 2:nsteps])))

fig = figure()
ax = fig.add_subplot(111)
ax.plot(linspace(0,maxt,num=nsteps), invdata)
ax.set(title="Automatic INTAU Parameter Adjustment",xlabel="Time [fs]", ylabel="INTAU [a.u.]",xlim=(0,maxt))
ax.plot(linspace(0, maxt, num=nsteps), invdata)
ax.set(title="Automatic INTAU Parameter Adjustment", xlabel="Time [fs]", ylabel="INTAU [a.u.]", xlim=(0, maxt))
show()
Loading

0 comments on commit 20e90fb

Please sign in to comment.