# Path: test/test_data.py
# def getdatafile(parser, subdir, files, stream=None, loglevel=logging.ERROR, datatype=None):
#     """Returns a parsed logfile.
# 
#     Inputs:
#         parser   - a logfile parser class (subclass of LogFile)
#         subdir   - subdirectory containing data files (program version)
#         files    - data filename(s)
#         stream   - where to log to (sys.stdout by default)
#         loglevel - what level to log at
#         datatype - ccData or child class
# 
#     Outputs:
#         data - the resulting data object
#         logfile - the parser object used for parsing
#     """
# 
#     # Convert any string into the parser object we will be using.
#     if isinstance(parser, str):
#         parser = all_parsers[parser]
# 
#     datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data"))
#     programdir = os.path.join(get_program_dir(parser.__name__), subdir)
#     inputs = [os.path.join(datadir, programdir, fn) for fn in files]
# 
#     # We should be able to pass a list of length one here, but for some reason
#     # this does not work with some parsers and we get errors.
#     if len(inputs) == 1:
#         inputs = inputs[0]
# 
#     stream = stream or sys.stdout
#     logfile = parser(inputs, logstream=stream, loglevel=loglevel,
#                      datatype=datatype or cclib.parser.data.ccData)
# 
#     data = logfile.parse()
#     return data, logfile


import unittest
import numpy
from cclib.bridge import cclib2pyquante
from ..test_data import getdatafile
from cclib.parser.utils import find_package
from numpy.testing import assert_array_almost_equal
        from PyQuante.hartree_fock import hf
        from PyQuante.Molecule import Molecule
        from pyquante2 import molecule, rhf, h2o, basisset
        super(PyquanteTest, self).setUp()
        if not find_package("PyQuante"):
            raise ImportError("Must install PyQuante to run this test")

        self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16", ["water_ccsd.log"])

    def test_makepyquante(self):
        """Test older PyQuante bridge."""

        reference = Molecule(
            "h2o",
            [(8, (0, 0, 0.119159)), (1, (0, 0.790649, -0.476637)), (1, (0, -0.790649, -0.476637)),],
            units="Angstroms",
        )
        refen, reforbe, reforbs = hf(reference)

        pyqmol = cclib2pyquante.makepyquante(self.data)
        en, orbe, orbs = hf(pyqmol)

        self.assertAlmostEqual(en, refen, delta=1.0e-6)


class pyquante2Test(unittest.TestCase):
    """Tests for the cclib2pyquante bridge in cclib."""

    def setUp(self):
        super(pyquante2Test, self).setUp()
        if not find_package("pyquante2"):
            raise ImportError("Must install pyquante2 to run this test")
            

# Path: test/test_data.py
# def getdatafile(parser, subdir, files, stream=None, loglevel=logging.ERROR, datatype=None):
#     """Returns a parsed logfile.
# 
#     Inputs:
#         parser   - a logfile parser class (subclass of LogFile)
#         subdir   - subdirectory containing data files (program version)
#         files    - data filename(s)
#         stream   - where to log to (sys.stdout by default)
#         loglevel - what level to log at
#         datatype - ccData or child class
# 
#     Outputs:
#         data - the resulting data object
#         logfile - the parser object used for parsing
#     """
# 
#     # Convert any string into the parser object we will be using.
#     if isinstance(parser, str):
#         parser = all_parsers[parser]
# 
#     datadir = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", "data"))
#     programdir = os.path.join(get_program_dir(parser.__name__), subdir)
#     inputs = [os.path.join(datadir, programdir, fn) for fn in files]
# 
#     # We should be able to pass a list of length one here, but for some reason
#     # this does not work with some parsers and we get errors.
#     if len(inputs) == 1:
#         inputs = inputs[0]
# 
#     stream = stream or sys.stdout
#     logfile = parser(inputs, logstream=stream, loglevel=loglevel,
#                      datatype=datatype or cclib.parser.data.ccData)
# 
#     data = logfile.parse()
#     return data, logfile


# Path: test/bridge/testpyquante.py
import unittest
import numpy
from cclib.bridge import cclib2pyquante
from ..test_data import getdatafile
from cclib.parser.utils import find_package
from numpy.testing import assert_array_almost_equal
        from PyQuante.hartree_fock import hf
        from PyQuante.Molecule import Molecule
        from pyquante2 import molecule, rhf, h2o, basisset

        super(PyquanteTest, self).setUp()
        if not find_package("PyQuante"):
            raise ImportError("Must install PyQuante to run this test")

        self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16", ["water_ccsd.log"])

    def test_makepyquante(self):
        """Test older PyQuante bridge."""

        reference = Molecule(
            "h2o",
            [(8, (0, 0, 0.119159)), (1, (0, 0.790649, -0.476637)), (1, (0, -0.790649, -0.476637)),],
            units="Angstroms",
        )
        refen, reforbe, reforbs = hf(reference)

        pyqmol = cclib2pyquante.makepyquante(self.data)
        en, orbe, orbs = hf(pyqmol)

        self.assertAlmostEqual(en, refen, delta=1.0e-6)


class pyquante2Test(unittest.TestCase):
    """Tests for the cclib2pyquante bridge in cclib."""

    def setUp(self):
        super(pyquante2Test, self).setUp()
        if not find_package("pyquante2"):
            raise ImportError("Must install pyquante2 to run this test")
            

        self.data, self.logfile = getdatafile("Gaussian", "basicGaussian16", ["water_ccsd.log"])