Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_float_numeric_format(self):
"""Does numeric formatting get converted correctly?"""
self.assertEqual(utils.float("1.2345E+02"), 123.45)
self.assertEqual(utils.float("1.2345D+02"), 123.45)
def test_float_stars(self):
"""Does the function return nan for stars?"""
self.assertTrue(numpy.isnan(utils.float("*")))
self.assertTrue(numpy.isnan(utils.float("*****")))
def test_float_basic(self):
"""Are floats converted from strings correctly?"""
self.assertEqual(utils.float("0.0"), 0.0)
self.assertEqual(utils.float("1.0"), 1.0)
self.assertEqual(utils.float("-1.0"), -1.0)
def test_float_stars(self):
"""Does the function return nan for stars?"""
self.assertTrue(numpy.isnan(utils.float("*")))
self.assertTrue(numpy.isnan(utils.float("*****")))
def test_float_basic(self):
"""Are floats converted from strings correctly?"""
self.assertEqual(utils.float("0.0"), 0.0)
self.assertEqual(utils.float("1.0"), 1.0)
self.assertEqual(utils.float("-1.0"), -1.0)
def test_float_basic(self):
"""Are floats converted from strings correctly?"""
self.assertEqual(utils.float("0.0"), 0.0)
self.assertEqual(utils.float("1.0"), 1.0)
self.assertEqual(utils.float("-1.0"), -1.0)
def test_float_numeric_format(self):
"""Does numeric formatting get converted correctly?"""
self.assertEqual(utils.float("1.2345E+02"), 123.45)
self.assertEqual(utils.float("1.2345D+02"), 123.45)
# -------------------------------------------------------------------
# State Energy Wavelength R MX MY MZ
# (cm-1) (nm) (1e40*cgs) (au) (au) (au)
# -------------------------------------------------------------------
# 1 43167.6 231.7 0.00000 0.00000 -0.00000 0.00000
#
etenergies = []
etrotats = []
self.skip_lines(inputfile, ["d", "State Energy Wavelength", "(cm-1) (nm)", "d"])
line = next(inputfile)
while line.strip():
tokens = line.split()
if "spin forbidden" in line:
etrotat, mx, my, mz = 0.0, 0.0, 0.0, 0.0
else:
etrotat, mx, my, mz = [utils.float(t) for t in tokens[3:]]
etenergies.append(utils.float(tokens[1]))
etrotats.append(etrotat)
line = next(inputfile)
self.set_attribute("etrotats", etrotats)
if not hasattr(self, "etenergies"):
self.logger.warning("etenergies not parsed before ECD section, "
"the output file may be malformed")
self.set_attribute("etenergies", etenergies)
if line[:23] == "VIBRATIONAL FREQUENCIES":
self.skip_lines(inputfile, ['d', 'b'])
# Starting with 4.1, a scaling factor for frequencies is printed
if float(self.metadata["package_version"][:3]) > 4.0:
self.skip_lines(inputfile, ['Scaling factor for frequencies', 'b'])
# State Energy Wavelength R MX MY MZ
# (cm-1) (nm) (1e40*cgs) (au) (au) (au)
# -------------------------------------------------------------------
# 1 43167.6 231.7 0.00000 0.00000 -0.00000 0.00000
#
etenergies = []
etrotats = []
self.skip_lines(inputfile, ["d", "State Energy Wavelength", "(cm-1) (nm)", "d"])
line = next(inputfile)
while line.strip():
tokens = line.split()
if "spin forbidden" in line:
etrotat, mx, my, mz = 0.0, 0.0, 0.0, 0.0
else:
etrotat, mx, my, mz = [utils.float(t) for t in tokens[3:]]
etenergies.append(utils.float(tokens[1]))
etrotats.append(etrotat)
line = next(inputfile)
self.set_attribute("etrotats", etrotats)
if not hasattr(self, "etenergies"):
self.logger.warning("etenergies not parsed before ECD section, "
"the output file may be malformed")
self.set_attribute("etenergies", etenergies)
if line[:23] == "VIBRATIONAL FREQUENCIES":
self.skip_lines(inputfile, ['d', 'b'])
# Starting with 4.1, a scaling factor for frequencies is printed
if float(self.metadata["package_version"][:3]) > 4.0:
self.skip_lines(inputfile, ['Scaling factor for frequencies', 'b'])
vibfreqs = numpy.zeros(3 * self.natom)