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_parse_check_values(self):
"""Are custom checks performed after parsing finishes?
The purpose of this test is not to comprehensively cover all the checks,
but rather to make sure the call and logging works. The unit tests
for the data class should have comprehensive coverage.
"""
_, path = tempfile.mkstemp()
logfileclass = cclib.parser.logfileparser.Logfile
logfileclass.__abstractmethods__ = set()
parser = logfileclass(path)
parser.extract = lambda self, inputfile, line: None
parser.logger = mock.Mock()
parser.etenergies = [1, -1]
parser.parse()
try:
parser.logger.error.assert_called_once()
except AttributeError: # assert_called_once is not availible until python 3.6
self.assertEqual(parser.logger.error.call_count, 1, "Expected mock to have been called once. Called {} times.".format(parser.logger.error.call_count))
(nbasis_text, symm)=line.split()
self.symmetries.append(symm)
nbasis=int(nbasis_text)
coeff_arr=numpy.zeros((nbasis, 2), float)
for j in range(0, nbasis, 1):
line=inputfile.next()
(e1_text, e2_text)=line.split()
coeff_arr[j][0]=float(e1_text)
coeff_arr[j][1]=float(e2_text)
self.coefficients.append(coeff_arr)
line=inputfile.next()
class Turbomole(logfileparser.Logfile):
"""A Turbomole log file."""
def __init__(self, *args, **kwargs):
super(Turbomole, self).__init__(logname="Turbomole", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "Turbomole output file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'Turbomole("%s")' % (self.filename)
def normalisesym(self, label):
"""Normalise the symmetries used by Turbomole."""
raise NotImplementedError('Now yet implemented for Turbomole.')
# the terms of the BSD 3-Clause License.
"""Parser for Molcas output files"""
from __future__ import print_function
import re
import string
import numpy
from cclib.parser import logfileparser
from cclib.parser import utils
class Molcas(logfileparser.Logfile):
"""A Molcas log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(Molcas, self).__init__(logname="Molcas", *args, **kwargs)
def __str__(self):
"""Return a string repeesentation of the object."""
return "Molcas log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'Molcas("%s")' % (self.filename)
#These are yet to be implemented.
"""Parser for ORCA output files"""
from __future__ import print_function
import re
import numpy
from packaging.version import parse as parse_version
from cclib.parser import logfileparser
from cclib.parser import utils
class ORCA(logfileparser.Logfile):
"""An ORCA log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(ORCA, self).__init__(logname="ORCA", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "ORCA log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'ORCA("%s")' % (self.filename)
# the terms of the BSD 3-Clause License.
"""Parser for DALTON output files"""
from __future__ import print_function
import re
import numpy
from cclib.parser import logfileparser
from cclib.parser import utils
class DALTON(logfileparser.Logfile):
"""A DALTON log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(DALTON, self).__init__(logname="DALTON", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "DALTON log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'DALTON("%s")' % (self.filename)
def normalisesym(self, label):
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
"""Parser for Psi4 output files."""
from collections import namedtuple
import numpy
from cclib.parser import data
from cclib.parser import logfileparser
from cclib.parser import utils
class Psi4(logfileparser.Logfile):
"""A Psi4 log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(Psi4, self).__init__(logname="Psi4", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "Psi4 log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'Psi4("%s")' % (self.filename)
def before_parsing(self):
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
"""Parser for NWChem output files"""
import itertools
import re
import numpy
from cclib.parser import logfileparser
from cclib.parser import utils
class NWChem(logfileparser.Logfile):
"""An NWChem log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(NWChem, self).__init__(logname="NWChem", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "NWChem log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'NWChem("%s")' % (self.filename)
def normalisesym(self, label):
import re
import math
import numpy
from cclib.parser import data
from cclib.parser import logfileparser
from cclib.parser import utils
def symbol2int(symbol):
t = utils.PeriodicTable()
return t.number[symbol]
class MOPAC(logfileparser.Logfile):
"""A MOPAC20XX output file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(MOPAC, self).__init__(logname="MOPAC", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "MOPAC log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'MOPAC("%s")' % (self.filename)
def normalisesym(self, label):
from __future__ import print_function
import re
import numpy
# CJS changed . to cclib.parser
from cclib.parser import logfileparser
from cclib.parser import utils
from chemlab.db import ChemlabDB
cdb = ChemlabDB()
symbols = cdb.get('data', 'symbols')
class Gausscom(logfileparser.Logfile):
"""A Gaussian 98/03 com file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(Gausscom, self).__init__(logname="Gausscom", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "Gaussian com file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'Gausscom("%s")' % (self.filename)
# -*- coding: utf-8 -*-
#
# Copyright (c) 2017, the cclib development team
#
# This file is part of cclib (http://cclib.github.io) and is distributed under
# the terms of the BSD 3-Clause License.
"""Parser for Psi3 output files."""
import numpy
from cclib.parser import logfileparser
from cclib.parser import utils
class Psi3(logfileparser.Logfile):
"""A Psi3 log file."""
def __init__(self, *args, **kwargs):
# Call the __init__ method of the superclass
super(Psi3, self).__init__(logname="Psi3", *args, **kwargs)
def __str__(self):
"""Return a string representation of the object."""
return "Psi3 log file %s" % (self.filename)
def __repr__(self):
"""Return a representation of the object."""
return 'Psi3("%s")' % (self.filename)
def normalisesym(self, label):