Best Python code snippet using avocado_python
test_basis.py
Source:test_basis.py  
...18import unittest19import numpy20from pyscf import gto21from pyscf import symm22def get_so(atoms, basis, cart=False):23    atoms = gto.mole.format_atom(atoms)24    gpname, origin, axes = symm.detect_symm(atoms)25    gpname, axes = symm.subgroup(gpname, axes)26    atoms = gto.mole.format_atom(atoms, origin, axes)27    try:28        mol = gto.M(atom=atoms, basis=basis)29    except RuntimeError:30        mol = gto.M(atom=atoms, basis=basis, spin=1)31    mol.cart = cart32    so = symm.basis.symm_adapted_basis(mol, gpname)[0]33    n = 034    for c in so:35        if c.size > 0:36            n += c.shape[1]37    assert(n == mol.nao_nr())38    return n, so39class KnowValues(unittest.TestCase):40    def test_symm_orb_h2o(self):41        atoms = [['O' , (1. , 0.    , 0.   ,)],42                 [1   , (0. , -.757 , 0.587,)],43                 [1   , (0. , 0.757 , 0.587,)] ]44        basis = {'H': gto.basis.load('cc_pvqz', 'C'),45                 'O': gto.basis.load('cc_pvqz', 'C'),}46        self.assertEqual(get_so(atoms,basis  )[0], 165)47        self.assertEqual(get_so(atoms,basis,1)[0], 210)48    def test_symm_orb_d2h(self):49        atoms = [[1, (0., 0., 0.)],50                 [1, (1., 0., 0.)],51                 [1, (0., 1., 0.)],52                 [1, (0., 0., 1.)],53                 [1, (-1, 0., 0.)],54                 [1, (0.,-1., 0.)],55                 [1, (0., 0.,-1.)]]56        basis = {'H': gto.basis.load('cc_pvqz', 'C'),}57        self.assertEqual(get_so(atoms,basis  )[0], 385)58        self.assertEqual(get_so(atoms,basis,1)[0], 490)59    def test_symm_orb_c2v(self):60        atoms = [[1, (1., 0., 2.)],61                 [2, (0., 1., 0.)],62                 [1, (-2.,0.,-1.)],63                 [2, (0.,-1., 0.)]]64        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),65                 'He': gto.basis.load('cc_pvqz', 'C'),}66        self.assertEqual(get_so(atoms,basis)[0], 220)67    def test_symm_orb_c2h(self):68        atoms = [[1, (1., 0., 2.)],69                 [2, (0., 1., 0.)],70                 [1, (-1.,0.,-2.)],71                 [2, (0.,-1., 0.)]]72        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),73                 'He': gto.basis.load('cc_pvqz', 'C'),}74        self.assertEqual(get_so(atoms,basis  )[0], 220)75        self.assertEqual(get_so(atoms,basis,1)[0], 280)76        atoms = [[1, (1., 0., 1.)],77                 [1, (1., 0.,-1.)],78                 [2, (0., 0., 2.)],79                 [2, (2., 0.,-2.)],80                 [3, (1., 1., 0.)],81                 [3, (1.,-1., 0.)]]82        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),83                 'He': gto.basis.load('cc_pvqz', 'C'),84                 'Li': gto.basis.load('cc_pvqz', 'C'),}85        self.assertEqual(get_so(atoms,basis  )[0], 330)86        self.assertEqual(get_so(atoms,basis,1)[0], 420)87    def test_symm_orb_d2(self):88        atoms = [[1, (1., 0., 1.)],89                 [1, (1., 0.,-1.)],90                 [2, (0., 0., 2.)],91                 [2, (2., 0., 2.)],92                 [2, (1., 1.,-2.)],93                 [2, (1.,-1.,-2.)]]94        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),95                 'He': gto.basis.load('cc_pvqz', 'C'),}96        self.assertEqual(get_so(atoms,basis  )[0], 330)97        self.assertEqual(get_so(atoms,basis,1)[0], 420)98    def test_symm_orb_ci(self):99        atoms = [[1, ( 1., 0., 0.)],100                 [2, ( 0., 1., 0.)],101                 [3, ( 0., 0., 1.)],102                 [4, ( .5, .5, .5)],103                 [1, (-1., 0., 0.)],104                 [2, ( 0.,-1., 0.)],105                 [3, ( 0., 0.,-1.)],106                 [4, (-.5,-.5,-.5)]]107        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),108                 'He': gto.basis.load('cc_pvqz', 'C'),109                 'Li': gto.basis.load('cc_pvqz', 'C'),110                 'Be': gto.basis.load('cc_pvqz', 'C'),}111        self.assertEqual(get_so(atoms,basis)[0], 440)112    def test_symm_orb_cs(self):113        atoms = [[1, (1., 0., 2.)],114                 [2, (1., 0., 0.)],115                 [3, (2., 0.,-1.)],116                 [4, (0., 0., 1.)]]117        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),118                 'He': gto.basis.load('cc_pvqz', 'C'),119                 'Li': gto.basis.load('cc_pvqz', 'C'),120                 'Be': gto.basis.load('cc_pvqz', 'C'),}121        self.assertEqual(get_so(atoms,basis)[0], 220)122    def test_symm_orb_c1(self):123        atoms = [[1, ( 1., 0., 0.)],124                 [2, ( 0., 1., 0.)],125                 [3, ( 0., 0., 1.)],126                 [4, ( .5, .5, .5)]]127        basis = {'H' : gto.basis.load('cc_pvqz', 'C'),128                 'He': gto.basis.load('cc_pvqz', 'C'),129                 'Li': gto.basis.load('cc_pvqz', 'C'),130                 'Be': gto.basis.load('cc_pvqz', 'C'),}131        self.assertEqual(get_so(atoms,basis)[0], 220)132if __name__ == "__main__":133    print("Full Tests symm.basis")...native.py
Source:native.py  
...32    _e = sys.exc_info()[1]33    _native = None34    if setting.use_debug:35        raise36def get_so(safe=False):37    if not _native:38        if safe:39            return None40        raise Error(repr(_e))41    return _native42def is_enabled():43    return get_so(True) is not None44def get_blkdev_info(f):45    return get_so().get_blkdev_info(f)46def has_ptrace():47    return get_ptrace_word_size() > 048def ptrace_peektext(pid, addr):49    return get_so().ptrace_peektext(pid, addr)50def ptrace_peekdata(pid, addr):51    return get_so().ptrace_peekdata(pid, addr)52def ptrace_poketext(pid, addr, data):53    return get_so().ptrace_poketext(pid, addr, data)54def ptrace_pokedata(pid, addr, data):55    return get_so().ptrace_pokedata(pid, addr, data)56def ptrace_attach(pid):57    return get_so().ptrace_attach(pid)58def ptrace_detach(pid):59    return get_so().ptrace_detach(pid)60def get_ptrace_word_size():61    try:62        return get_so().get_ptrace_word_size()63    except Exception:...Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!
