How to use the cclib.parser.utils.float function in cclib

To help you get started, we’ve selected a few cclib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cclib / cclib / test / test_utils.py View on Github external
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)
github cclib / cclib / test / test_utils.py View on Github external
def test_float_stars(self):
        """Does the function return nan for stars?"""
        self.assertTrue(numpy.isnan(utils.float("*")))
        self.assertTrue(numpy.isnan(utils.float("*****")))
github cclib / cclib / test / test_utils.py View on Github external
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)
github cclib / cclib / test / test_utils.py View on Github external
def test_float_stars(self):
        """Does the function return nan for stars?"""
        self.assertTrue(numpy.isnan(utils.float("*")))
        self.assertTrue(numpy.isnan(utils.float("*****")))
github cclib / cclib / test / test_utils.py View on Github external
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)
github cclib / cclib / test / test_utils.py View on Github external
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)
github cclib / cclib / test / test_utils.py View on Github external
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)
github cclib / cclib / cclib / parser / orcaparser.py View on Github external
# -------------------------------------------------------------------
            # 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'])
github cclib / cclib / cclib / parser / orcaparser.py View on Github external
# 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)