<commit_before># This file is part of cclib (http://cclib.sf.net), a library for parsing
# and interpreting the results of computational chemistry packages.
#
# Copyright (C) 2007-2014, the cclib development team
#
# The library is free software, distributed under the terms of
# the GNU Lesser General Public version 2.1 or later. You should have
# received a copy of the license along with cclib. You can also access
# the full license online at http://www.gnu.org/copyleft/lgpl.html.

import numpy

import bettertest


class GenericTDTest(bettertest.TestCase):
    """Time-dependent HF/DFT unittest."""

    def testenergies(self):
        """Is the l_max reasonable?"""
        self.assertEqual(len(self.data.etenergies), self.number)
        idx_lambdamax = [i for i, x in enumerate(self.data.etoscs)
                         if x==max(self.data.etoscs)][0]
        self.assertInside(self.data.etenergies[idx_lambdamax], 41000, 5000)
    
    def testoscs(self):
        """Is the maximum of eotscs in the right range?"""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertInside(max(self.data.etoscs), 0.67, 0.1)

    def testsecs(self):
        """Is the sum of etsecs close to 1?"""
        self.assertEqual(len(self.data.etsecs), self.number)
        lowestEtrans = self.data.etsecs[1]
        sumofsec = sum([z*z for (x, y, z) in lowestEtrans])
        self.assertInside(sumofsec, 1.0, 0.16)

    def testsecs_transition(self):
        """Is the lowest E transition from the HOMO or to the LUMO?"""
        idx_minenergy = [i for i, x in enumerate(self.data.etenergies)
                         if x==min(self.data.etenergies)][0]
        sec = self.data.etsecs[idx_minenergy]
        t = [(c*c, s, e) for (s, e, c) in sec]
        t.sort()
        t.reverse()        
        self.assert_(t[0][1][0]==self.data.homos[0] or
                    t[0][2][0]==self.data.homos[0]+1, t[0])
        
    def testsymsnumber(self):
        """Is the length of etsyms correct?"""
        self.assertEqual(len(self.data.etsyms), self.number)


class ADFTDDFTTest(GenericTDTest):
    """ADF time-dependent DFT unittest."""
    number = 5

    def testsecs(self):
        """Is the sum of etsecs close to 1?"""
        self.assertEqual(len(self.data.etsecs), self.number)
        lowestEtrans = self.data.etsecs[1]

        #ADF squares the etsecs
        sumofsec = sum([z for (x, y, z) in lowestEtrans])
        self.assertInside(sumofsec, 1.0, 0.16)


class GaussianTDDFTTest(GenericTDTest):
    """Gaussian time-dependent HF/DFT unittest."""
    number = 5

    def testrotatsnumber(self):
        """Is the length of etrotats correct?"""
        self.assertEqual(len(self.data.etrotats), self.number)


class GAMESSUSTDDFTTest(GenericTDTest):
    """GAMESS time-dependent HF/DFT unittest."""

    number = 10

    old_tests = ["GAMESS/WinGAMESS/dvb_td_2007.03.24.r1.out.gz"]


class PCGamessTDDFTTest(GenericTDTest):
    """PC-GAMESS time-dependent HF/DFT unittest."""
    number = 5

    
class OrcaTDDFTTest(GenericTDTest):
    """ORCA time-dependent HF/DFT unittest."""
    number = 10
    def testoscs(self):
        """Is the maximum of eotscs in the right range?"""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertInside(max(self.data.etoscs), 1.1, 0.1)


class GenericTDTesttrp(GenericTDTest):
    """Time-dependent HF/DFT (triplet) unittest."""

    def testenergies(self):
        """Is the l_max reasonable?"""
        self.assertEqual(len(self.data.etenergies), self.number)<commit_msg>TD unit test: update ORCA class to match values from output files<commit_after># This file is part of cclib (http://cclib.sf.net), a library for parsing
# and interpreting the results of computational chemistry packages.
#
# Copyright (C) 2007-2014, the cclib development team
#
# The library is free software, distributed under the terms of
# the GNU Lesser General Public version 2.1 or later. You should have
# received a copy of the license along with cclib. You can also access
# the full license online at http://www.gnu.org/copyleft/lgpl.html.

import numpy

import bettertest


class GenericTDTest(bettertest.TestCase):
    """Time-dependent HF/DFT unittest."""

    def testenergies(self):
        """Is the l_max reasonable?"""
        self.assertEqual(len(self.data.etenergies), self.number)
        idx_lambdamax = [i for i, x in enumerate(self.data.etoscs)
                         if x==max(self.data.etoscs)][0]
        self.assertInside(self.data.etenergies[idx_lambdamax], 41000, 5000)
    
    def testoscs(self):
        """Is the maximum of eotscs in the right range?"""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertInside(max(self.data.etoscs), 0.67, 0.1)

    def testsecs(self):
        """Is the sum of etsecs close to 1?"""
        self.assertEqual(len(self.data.etsecs), self.number)
        lowestEtrans = self.data.etsecs[1]
        sumofsec = sum([z*z for (x, y, z) in lowestEtrans])
        self.assertInside(sumofsec, 1.0, 0.16)

    def testsecs_transition(self):
        """Is the lowest E transition from the HOMO or to the LUMO?"""
        idx_minenergy = [i for i, x in enumerate(self.data.etenergies)
                         if x==min(self.data.etenergies)][0]
        sec = self.data.etsecs[idx_minenergy]
        t = [(c*c, s, e) for (s, e, c) in sec]
        t.sort()
        t.reverse()        
        self.assert_(t[0][1][0]==self.data.homos[0] or
                    t[0][2][0]==self.data.homos[0]+1, t[0])
        
    def testsymsnumber(self):
        """Is the length of etsyms correct?"""
        self.assertEqual(len(self.data.etsyms), self.number)


class ADFTDDFTTest(GenericTDTest):
    """ADF time-dependent DFT unittest."""
    number = 5

    def testsecs(self):
        """Is the sum of etsecs close to 1?"""
        self.assertEqual(len(self.data.etsecs), self.number)
        lowestEtrans = self.data.etsecs[1]

        #ADF squares the etsecs
        sumofsec = sum([z for (x, y, z) in lowestEtrans])
        self.assertInside(sumofsec, 1.0, 0.16)


class GaussianTDDFTTest(GenericTDTest):
    """Gaussian time-dependent HF/DFT unittest."""
    number = 5

    def testrotatsnumber(self):
        """Is the length of etrotats correct?"""
        self.assertEqual(len(self.data.etrotats), self.number)


class GAMESSUSTDDFTTest(GenericTDTest):
    """GAMESS time-dependent HF/DFT unittest."""

    number = 10

    old_tests = ["GAMESS/WinGAMESS/dvb_td_2007.03.24.r1.out.gz"]


class PCGamessTDDFTTest(GenericTDTest):
    """PC-GAMESS time-dependent HF/DFT unittest."""
    number = 5

    
class OrcaTDDFTTest(GenericTDTest):
    """ORCA time-dependent HF/DFT unittest."""
    number = 10

    def testenergies(self):
        """Is the l_max reasonable?"""
        self.assertEqual(len(self.data.etenergies), self.number)
        idx_lambdamax = [i for i, x in enumerate(self.data.etoscs)
                         if x==max(self.data.etoscs)][0]
        self.assertInside(self.data.etenergies[idx_lambdamax], 48000, 5000)

    def testoscs(self):
        """Is the maximum of eotscs in the right range?"""
        self.assertEqual(len(self.data.etoscs), self.number)
        self.assertInside(max(self.data.etoscs), 1.0, 0.1)


class GenericTDTesttrp(GenericTDTest):
    """Time-dependent HF/DFT (triplet) unittest."""

    def testenergies(self):
        """Is the l_max reasonable?"""
        self.assertEqual(len(self.data.etenergies), self.number)
{'fraction_non_alphanumeric': 0.1298960831334932, 'fraction_numerical': 0.019984012789768184, 'mean_word_length': 2.8556753980482794, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3253706', 'n_tokens_mistral': 2679, 'n_tokens_neox': 2496, 'n_words': 630}