Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _parse_mosyms_moenergies(self, inputfile, spinidx):
"""Parse molecular orbital symmetries and energies from the
'Post-Iterations' section.
"""
line = next(inputfile)
while line.strip():
for i in range(len(line.split()) // 2):
self.mosyms[spinidx].append(line.split()[i*2][-2:])
moenergy = utils.convertor(float(line.split()[i*2+1]), "hartree", "eV")
self.moenergies[spinidx].append(moenergy)
line = next(inputfile)
return
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
xyz = cclib.io.xyzwriter.XYZ(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(xyz.ccdata, data)
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
xyz = cclib.io.xyzwriter.XYZ(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(xyz.ccdata, data)
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
cjson = cclib.io.cjsonwriter.CJSON(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(cjson.ccdata, data)
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
xyz = cclib.io.xyzwriter.XYZ(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(xyz.ccdata, data)
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
writer = cclib.io.filewriter.Writer(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(writer.ccdata, data)
fname_norm = normalisefilename(fname.replace(__regression_dir__, ''))
funcname = "test" + fname_norm
test_this = funcname in globals()
funcname_noparse = "testnoparse" + fname_norm
test_noparse = not test_this and funcname_noparse in globals()
if not test_noparse:
datatype = parser_class.datatype if hasattr(parser_class, 'datatype') else ccData
job_filenames = glob.glob(fname)
try:
if len(job_filenames) == 1:
logfile = ccopen(job_filenames[0], datatype=datatype, loglevel=loglevel)
else:
logfile = ccopen(job_filenames, datatype=datatype, loglevel=loglevel)
except Exception as e:
errors += 1
print("ccopen error: ", e)
if opt_traceback:
print(traceback.format_exc())
else:
if type(logfile) == parser_class:
try:
logfile.data = logfile.parse()
except KeyboardInterrupt:
sys.exit(1)
except Exception as e:
print("parse error:", e)
errors += 1
if opt_traceback:
print(traceback.format_exc())
# to be additionaly prepended with 'testnoparse'.
test_this = test_noparse = False
fname_norm = normalisefilename(fname.replace(__regression_dir__, ''))
funcname = "test" + fname_norm
test_this = funcname in globals()
funcname_noparse = "testnoparse" + fname_norm
test_noparse = not test_this and funcname_noparse in globals()
if not test_noparse:
datatype = parser_class.datatype if hasattr(parser_class, 'datatype') else ccData
job_filenames = glob.glob(fname)
try:
if len(job_filenames) == 1:
logfile = ccopen(job_filenames[0], datatype=datatype, loglevel=loglevel)
else:
logfile = ccopen(job_filenames, datatype=datatype, loglevel=loglevel)
except Exception as e:
errors += 1
print("ccopen error: ", e)
if opt_traceback:
print(traceback.format_exc())
else:
if type(logfile) == parser_class:
try:
logfile.data = logfile.parse()
except KeyboardInterrupt:
sys.exit(1)
except Exception as e:
print("parse error:", e)
errors += 1
def test_init(self):
"""Does the class initialize correctly?"""
fpath = os.path.join(__datadir__, "data/ADF/basicADF2007.01/dvb_gopt.adfout")
data = cclib.io.ccread(fpath)
xyz = cclib.io.xyzwriter.XYZ(data)
# The object should keep the ccData instance passed to its constructor.
self.assertEqual(xyz.ccdata, data)
def testQChem_QChem5_0_argon_out(logfile):
"""This job has unit specifications at the end of 'Total energy for
state' lines.
"""
assert logfile.data.metadata["package_version"] == "5.0.1"
nroots = 12
assert len(logfile.data.etenergies) == nroots
state_0_energy = -526.6323968555
state_1_energy = -526.14663738
assert logfile.data.scfenergies[0] == convertor(state_0_energy, 'hartree', 'eV')
assert abs(logfile.data.etenergies[0] - convertor(state_1_energy - state_0_energy, 'hartree', 'wavenumber')) < 1.0e-1