From 14d88828cd1f18f1e5358da1445355bde55322a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 27 Oct 2023 20:58:43 +0200 Subject: [PATCH] apply "ruff --fix check --select=C40 pyscf" --- pyscf/adc/radc.py | 4 ++-- pyscf/adc/radc_ea.py | 4 ++-- pyscf/adc/radc_ip.py | 4 ++-- pyscf/adc/radc_ip_cvs.py | 4 ++-- pyscf/adc/uadc.py | 4 ++-- pyscf/adc/uadc_ea.py | 4 ++-- pyscf/adc/uadc_ip.py | 4 ++-- pyscf/adc/uadc_ip_cvs.py | 4 ++-- pyscf/agf2/chempot.py | 4 ++-- pyscf/agf2/dfragf2.py | 8 ++++---- pyscf/agf2/dfuagf2.py | 8 ++++---- pyscf/agf2/ragf2.py | 10 +++++----- pyscf/agf2/ragf2_slow.py | 4 ++-- pyscf/agf2/uagf2.py | 6 +++--- pyscf/agf2/uagf2_slow.py | 4 ++-- pyscf/cc/ccsd.py | 4 ++-- pyscf/cc/dfccsd.py | 2 +- pyscf/cc/eom_rccsd.py | 4 ++-- pyscf/cc/momgfccsd.py | 4 ++-- pyscf/cc/rccsd_slow.py | 2 +- pyscf/cc/uccsd_slow.py | 2 +- pyscf/ci/cisd.py | 4 ++-- pyscf/data/elements.py | 4 ++-- pyscf/df/addons.py | 16 ++++++++-------- pyscf/df/df.py | 2 +- pyscf/df/df_jk.py | 2 +- pyscf/dft/gen_grid.py | 8 ++++---- pyscf/dft/libxc.py | 20 ++++++++++---------- pyscf/dft/rks.py | 2 +- pyscf/dft/xcfun.py | 6 +++--- pyscf/eph/rhf.py | 2 +- pyscf/eph/rks.py | 2 +- pyscf/eph/uhf.py | 4 ++-- pyscf/eph/uks.py | 4 ++-- pyscf/fci/addons.py | 2 +- pyscf/fci/cistring.py | 2 +- pyscf/fci/direct_spin1.py | 4 ++-- pyscf/fci/selected_ci.py | 4 ++-- pyscf/grad/dhf.py | 2 +- pyscf/grad/rks.py | 2 +- pyscf/grad/tdrhf.py | 2 +- pyscf/grad/uks.py | 2 +- pyscf/gto/mole.py | 10 +++++----- pyscf/gw/gw_ac.py | 4 ++-- pyscf/gw/gw_cd.py | 4 ++-- pyscf/gw/gw_exact.py | 4 ++-- pyscf/gw/rpa.py | 4 ++-- pyscf/gw/ugw_ac.py | 4 ++-- pyscf/hessian/rhf.py | 8 ++++---- pyscf/hessian/rks.py | 2 +- pyscf/hessian/uhf.py | 8 ++++---- pyscf/hessian/uks.py | 2 +- pyscf/lib/chkfile.py | 3 +-- pyscf/lib/misc.py | 2 +- pyscf/lib/numpy_helper.py | 4 ++-- pyscf/lib/test/test_misc.py | 4 ++-- pyscf/lo/pipek.py | 2 +- pyscf/mcscf/addons.py | 24 ++++++++++++------------ pyscf/mcscf/casci.py | 4 ++-- pyscf/mcscf/df.py | 4 ++-- pyscf/mcscf/mc1step.py | 4 ++-- pyscf/mcscf/umc1step.py | 4 ++-- pyscf/mp/dfmp2.py | 2 +- pyscf/mp/mp2.py | 4 ++-- pyscf/mp/ump2.py | 4 ++-- pyscf/mrpt/nevpt2.py | 4 ++-- pyscf/pbc/adc/kadc_rhf.py | 4 ++-- pyscf/pbc/adc/kadc_rhf_ea.py | 4 ++-- pyscf/pbc/adc/kadc_rhf_ip.py | 4 ++-- pyscf/pbc/cc/kccsd_rhf.py | 4 ++-- pyscf/pbc/cc/kccsd_rhf_ksymm.py | 2 +- pyscf/pbc/cc/kccsd_uhf.py | 2 +- pyscf/pbc/cc/kintermediates.py | 2 +- pyscf/pbc/df/aft.py | 4 ++-- pyscf/pbc/df/df.py | 4 ++-- pyscf/pbc/df/fft.py | 4 ++-- pyscf/pbc/df/incore.py | 4 ++-- pyscf/pbc/df/rsdf_helper.py | 2 +- pyscf/pbc/dft/krkspu.py | 2 +- pyscf/pbc/dft/kukspu.py | 2 +- pyscf/pbc/dft/multigrid.py | 2 +- pyscf/pbc/dft/rks.py | 2 +- pyscf/pbc/grad/krks.py | 2 +- pyscf/pbc/grad/kuks.py | 2 +- pyscf/pbc/gto/cell.py | 4 ++-- pyscf/pbc/gw/krgw_ac.py | 4 ++-- pyscf/pbc/gw/krgw_cd.py | 4 ++-- pyscf/pbc/gw/kugw_ac.py | 4 ++-- pyscf/pbc/lib/kpts_helper.py | 2 +- pyscf/pbc/mp/kmp2.py | 2 +- pyscf/pbc/scf/hf.py | 2 +- pyscf/pbc/scf/khf.py | 2 +- pyscf/pbc/scf/khf_ksymm.py | 2 +- pyscf/pbc/scf/kuhf.py | 2 +- pyscf/pbc/scf/rsjk.py | 4 ++-- pyscf/pbc/scf/uhf.py | 2 +- pyscf/pbc/tdscf/krhf.py | 2 +- pyscf/pbc/tdscf/rhf.py | 2 +- pyscf/pbc/tdscf/test/test_common.py | 2 +- pyscf/pbc/x2c/sfx2c1e.py | 2 +- pyscf/pbc/x2c/x2c1e.py | 2 +- pyscf/qmmm/itrf.py | 2 +- pyscf/scf/addons.py | 4 ++-- pyscf/scf/atom_hf.py | 2 +- pyscf/scf/atom_ks.py | 2 +- pyscf/scf/dhf.py | 4 ++-- pyscf/scf/ghf.py | 2 +- pyscf/scf/ghf_symm.py | 2 +- pyscf/scf/hf.py | 8 ++++---- pyscf/scf/hf_symm.py | 8 ++++---- pyscf/scf/uhf.py | 2 +- pyscf/scf/uhf_symm.py | 8 ++++---- pyscf/sgx/sgx.py | 8 ++++---- pyscf/solvent/_attach_solvent.py | 8 ++++---- pyscf/solvent/_ddcosmo_tdscf_grad.py | 2 +- pyscf/solvent/ddcosmo.py | 4 ++-- pyscf/solvent/ddcosmo_grad.py | 2 +- pyscf/solvent/pol_embed.py | 4 ++-- pyscf/soscf/newton_ah.py | 8 ++++---- pyscf/symm/basis.py | 2 +- pyscf/tdscf/common_slow.py | 4 ++-- pyscf/tdscf/rhf.py | 4 ++-- pyscf/x2c/sfx2c1e.py | 2 +- pyscf/x2c/x2c.py | 4 ++-- 124 files changed, 250 insertions(+), 251 deletions(-) diff --git a/pyscf/adc/radc.py b/pyscf/adc/radc.py index 2d30a95a0f..3137c30498 100644 --- a/pyscf/adc/radc.py +++ b/pyscf/adc/radc.py @@ -111,7 +111,7 @@ class RADC(lib.StreamObject): blkmin = getattr(__config__, 'adc_radc_RADC_blkmin', 4) memorymin = getattr(__config__, 'adc_radc_RADC_memorymin', 2000) - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mol', 'mo_energy', 'incore_complete', 'scf_energy', 'e_tot', 't1', 'frozen', 'chkfile', @@ -119,7 +119,7 @@ class RADC(lib.StreamObject): 'imds', 'method', 'method_type', 'with_df', 'compute_properties', 'approx_trans_moments', 'evec_print_tol', 'spec_factor_print_tol', 'ncvs', 'E', 'U', 'P', 'X', - )) + } def __init__(self, mf, frozen=0, mo_coeff=None, mo_occ=None): from pyscf import gto diff --git a/pyscf/adc/radc_ea.py b/pyscf/adc/radc_ea.py index 81c189996f..7627074f95 100644 --- a/pyscf/adc/radc_ea.py +++ b/pyscf/adc/radc_ea.py @@ -966,13 +966,13 @@ class RADCEA(radc.RADC): Spectroscopic amplitudes for each EA transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mo_energy', 't1', 'max_space', 't2', 'max_cycle', 'nmo', 'transform_integrals', 'with_df', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', 'evec_print_tol', 'spec_factor_print_tol', - )) + } def __init__(self, adc): self.mol = adc.mol diff --git a/pyscf/adc/radc_ip.py b/pyscf/adc/radc_ip.py index 2732991308..3b25c541c2 100644 --- a/pyscf/adc/radc_ip.py +++ b/pyscf/adc/radc_ip.py @@ -921,14 +921,14 @@ class RADCIP(radc.RADC): Spectroscopic amplitudes for each IP transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mo_energy_b', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', 'nmo', 'transform_integrals', 'with_df', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', 'evec_print_tol', 'spec_factor_print_tol', - )) + } def __init__(self, adc): self.mol = adc.mol diff --git a/pyscf/adc/radc_ip_cvs.py b/pyscf/adc/radc_ip_cvs.py index c2a38b65ad..9448a5a9a5 100644 --- a/pyscf/adc/radc_ip_cvs.py +++ b/pyscf/adc/radc_ip_cvs.py @@ -938,14 +938,14 @@ class RADCIPCVS(radc.RADC): Spectroscopic amplitudes for each IP transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mo_energy_b', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', 'nmo', 'transform_integrals', 'with_df', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', 'evec_print_tol', 'spec_factor_print_tol', 'ncvs', - )) + } def __init__(self, adc): self.mol = adc.mol diff --git a/pyscf/adc/uadc.py b/pyscf/adc/uadc.py index ab7295c9c5..be88732ef9 100644 --- a/pyscf/adc/uadc.py +++ b/pyscf/adc/uadc.py @@ -113,7 +113,7 @@ class UADC(lib.StreamObject): ''' incore_complete = getattr(__config__, 'adc_uadc_UADC_incore_complete', False) - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'method_type', 'mo_coeff', 'mol', 'mo_energy_b', 'scf_energy', 'e_tot', 't1', 'frozen', @@ -122,7 +122,7 @@ class UADC(lib.StreamObject): 'compute_mpn_energy', 'compute_spec', 'compute_properties', 'approx_trans_moments', 'evec_print_tol', 'spec_factor_print_tol', 'E', 'U', 'P', 'X', 'ncvs', - )) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): from pyscf import gto diff --git a/pyscf/adc/uadc_ea.py b/pyscf/adc/uadc_ea.py index 5969d19ffa..53e373704d 100644 --- a/pyscf/adc/uadc_ea.py +++ b/pyscf/adc/uadc_ea.py @@ -1960,7 +1960,7 @@ class UADCEA(uadc.UADC): Spectroscopic amplitudes for each EA transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', @@ -1968,7 +1968,7 @@ class UADCEA(uadc.UADC): 'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals', 'with_df', 'spec_factor_print_tol', 'evec_print_tol', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', - )) + } def __init__(self, adc): self.verbose = adc.verbose diff --git a/pyscf/adc/uadc_ip.py b/pyscf/adc/uadc_ip.py index bb0a5df5f5..b1ad5d4d42 100644 --- a/pyscf/adc/uadc_ip.py +++ b/pyscf/adc/uadc_ip.py @@ -1838,7 +1838,7 @@ class UADCIP(uadc.UADC): Spectroscopic amplitudes for each IP transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', @@ -1846,7 +1846,7 @@ class UADCIP(uadc.UADC): 'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals', 'with_df', 'spec_factor_print_tol', 'evec_print_tol', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', - )) + } def __init__(self, adc): self.verbose = adc.verbose diff --git a/pyscf/adc/uadc_ip_cvs.py b/pyscf/adc/uadc_ip_cvs.py index da3d600200..5a1a39c115 100644 --- a/pyscf/adc/uadc_ip_cvs.py +++ b/pyscf/adc/uadc_ip_cvs.py @@ -2035,7 +2035,7 @@ class UADCIPCVS(uadc.UADC): Spectroscopic amplitudes for each IP transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'method_type', 'mo_coeff', 'mo_energy_b', 'max_memory', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', @@ -2043,7 +2043,7 @@ class UADCIPCVS(uadc.UADC): 'mo_energy_b', 'nmo_a', 'nmo_b', 'mol', 'transform_integrals', 'with_df', 'spec_factor_print_tol', 'evec_print_tol', 'ncvs', 'compute_properties', 'approx_trans_moments', 'E', 'U', 'P', 'X', - )) + } def __init__(self, adc): self.verbose = adc.verbose diff --git a/pyscf/agf2/chempot.py b/pyscf/agf2/chempot.py index ddfdf41af0..40bac597dc 100644 --- a/pyscf/agf2/chempot.py +++ b/pyscf/agf2/chempot.py @@ -154,8 +154,8 @@ def minimize_chempot(se, fock, nelec, occupancy=2, x0=0.0, tol=1e-6, maxiter=200 buf = np.zeros((se.nphys+se.naux, se.nphys+se.naux), dtype=dtype) fargs = (se, fock, nelec, occupancy, buf) - options = dict(maxiter=maxiter, ftol=tol, xtol=tol, gtol=tol) - kwargs = dict(x0=x0, method='TNC', jac=jac, options=options) + options = {'maxiter': maxiter, 'ftol': tol, 'xtol': tol, 'gtol': tol} + kwargs = {'x0': x0, 'method': 'TNC', 'jac': jac, 'options': options} fun = _objective if not jac else _gradient opt = optimize.minimize(fun, args=fargs, **kwargs) diff --git a/pyscf/agf2/dfragf2.py b/pyscf/agf2/dfragf2.py index 09a3beb056..8d532beb86 100644 --- a/pyscf/agf2/dfragf2.py +++ b/pyscf/agf2/dfragf2.py @@ -67,7 +67,7 @@ def build_se_part(agf2, eri, gf_occ, gf_vir, os_factor=1.0, ss_factor=1.0): nocc, nvir = gf_occ.naux, gf_vir.naux naux = agf2.with_df.get_naoaux() tol = agf2.weight_tol - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} ei, ci = gf_occ.energy, gf_occ.coupling ea, ca = gf_vir.energy, gf_vir.coupling @@ -258,7 +258,7 @@ class DFRAGF2(ragf2.RAGF2): Auxiliaries of the Green's function ''' - _keys = set(['_with_df', 'allow_lowmem_build']) + _keys = {'_with_df', 'allow_lowmem_build'} def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): ragf2.RAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy, @@ -335,7 +335,7 @@ def _make_mo_eris_incore(agf2, mo_coeff=None): qxy = np.zeros((naux, npair)) mo = np.asarray(eris.mo_coeff, order='F') sij = (0, nmo, 0, nmo) - sym = dict(aosym='s2', mosym='s2') + sym = {'aosym': 's2', 'mosym': 's2'} for p0, p1 in with_df.prange(): eri0 = with_df._cderi[p0:p1] @@ -370,7 +370,7 @@ def _make_qmo_eris_incore(agf2, eri, coeffs): xisym, nxi, cxi, sxi = ao2mo.incore._conc_mos(cx, ci, compact=False) jasym, nja, cja, sja = ao2mo.incore._conc_mos(cj, ca, compact=False) - sym = dict(aosym='s2', mosym='s1') + sym = {'aosym': 's2', 'mosym': 's1'} qxi = np.zeros((naux, nxi)) qja = np.zeros((naux, nja)) diff --git a/pyscf/agf2/dfuagf2.py b/pyscf/agf2/dfuagf2.py index edb5a7aeb1..be9ff1f81b 100644 --- a/pyscf/agf2/dfuagf2.py +++ b/pyscf/agf2/dfuagf2.py @@ -70,7 +70,7 @@ def build_se_part(agf2, eri, gf_occ, gf_vir, os_factor=1.0, ss_factor=1.0): noccb, nvirb = gf_occ[1].naux, gf_vir[1].naux naux = agf2.with_df.get_naoaux() tol = agf2.weight_tol - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} ci_a, ei_a = gf_occ[0].coupling, gf_occ[0].energy ci_b, ei_b = gf_occ[1].coupling, gf_occ[1].energy @@ -209,7 +209,7 @@ class DFUAGF2(uagf2.UAGF2): Auxiliaries of the Green's function for each spin ''' - _keys = set(['_with_df', 'allow_lowmem_build']) + _keys = {'_with_df', 'allow_lowmem_build'} def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): uagf2.UAGF2.__init__(self, mf, frozen=frozen, mo_energy=mo_energy, @@ -277,7 +277,7 @@ def _make_mo_eris_incore(agf2, mo_coeff=None): mob = np.asarray(mob, order='F') sija = (0, nmoa, 0, nmoa) sijb = (0, nmob, 0, nmob) - sym = dict(aosym='s2', mosym='s2') + sym = {'aosym': 's2', 'mosym': 's2'} for p0, p1 in with_df.prange(): eri0 = with_df._cderi[p0:p1] @@ -324,7 +324,7 @@ def _make_qmo_eris_incore(agf2, eri, coeffs_a, coeffs_b): jasym_a, nja_a, cja_a, sja_a = ao2mo.incore._conc_mos(cja, caa, compact=False) xisym_b, nxi_b, cxi_b, sxi_b = ao2mo.incore._conc_mos(cxb, cib, compact=False) jasym_b, nja_b, cja_b, sja_b = ao2mo.incore._conc_mos(cjb, cab, compact=False) - sym = dict(aosym='s2', mosym='s1') + sym = {'aosym': 's2', 'mosym': 's1'} qxi_a = np.zeros((naux, nxi_a)) qxi_b = np.zeros((naux, nxi_b)) diff --git a/pyscf/agf2/ragf2.py b/pyscf/agf2/ragf2.py index 99c7c07102..b18e11c88a 100644 --- a/pyscf/agf2/ragf2.py +++ b/pyscf/agf2/ragf2.py @@ -150,7 +150,7 @@ def build_se_part(agf2, eri, gf_occ, gf_vir, os_factor=1.0, ss_factor=1.0): nmo = eri.nmo tol = agf2.weight_tol - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} ci, ei = gf_occ.coupling, gf_occ.energy ca, ea = gf_vir.coupling, gf_vir.energy @@ -304,7 +304,7 @@ def fock_loop(agf2, eri, gf, se): nqmo = nmo + naux buf = np.zeros((nqmo, nqmo)) converged = False - opts = dict(tol=agf2.conv_tol_nelec, maxiter=agf2.max_cycle_inner) + opts = {'tol': agf2.conv_tol_nelec, 'maxiter': agf2.max_cycle_inner} rdm1_prev = 0 for niter1 in range(1, agf2.max_cycle_outer+1): @@ -507,7 +507,7 @@ class RAGF2(lib.StreamObject): async_io = getattr(__config__, 'agf2_async_io', True) incore_complete = getattr(__config__, 'agf2_incore_complete', False) - _keys = set(( + _keys = { 'async_io', 'mol', 'incore_complete', 'conv_tol', 'conv_tol_rdm1', 'conv_tol_nelec', 'max_cycle', 'max_cycle_outer', 'max_cycle_inner', 'weight_tol', 'fock_diis_space', @@ -515,7 +515,7 @@ class RAGF2(lib.StreamObject): 'os_factor', 'ss_factor', 'damping', 'mo_energy', 'mo_coeff', 'mo_occ', 'se', 'gf', 'e_1b', 'e_2b', 'e_init', 'frozen', 'converged', 'chkfile', - )) + } def __init__(self, mf, frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): @@ -697,7 +697,7 @@ def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=No if os_factor is None: os_factor = self.os_factor if ss_factor is None: ss_factor = self.ss_factor - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} gf_occ = gf.get_occupied() gf_vir = gf.get_virtual() diff --git a/pyscf/agf2/ragf2_slow.py b/pyscf/agf2/ragf2_slow.py index 74cb206a39..f2d23610f3 100644 --- a/pyscf/agf2/ragf2_slow.py +++ b/pyscf/agf2/ragf2_slow.py @@ -177,7 +177,7 @@ class RAGF2(ragf2.RAGF2): Auxiliaries of the Green's function ''' - _keys = set(['nmom']) + _keys = {'nmom'} def __init__(self, mf, nmom=(None,0), frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): @@ -222,7 +222,7 @@ def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=No if os_factor is None: os_factor = self.os_factor if ss_factor is None: ss_factor = self.ss_factor - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} gf_occ = gf.get_occupied() gf_vir = gf.get_virtual() diff --git a/pyscf/agf2/uagf2.py b/pyscf/agf2/uagf2.py index e08cab67c8..8c478269f6 100644 --- a/pyscf/agf2/uagf2.py +++ b/pyscf/agf2/uagf2.py @@ -73,7 +73,7 @@ def build_se_part(agf2, eri, gf_occ, gf_vir, os_factor=1.0, ss_factor=1.0): noa, nob = gf_occ[0].naux, gf_occ[1].naux nva, nvb = gf_vir[0].naux, gf_vir[1].naux tol = agf2.weight_tol - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} ci_a, ei_a = gf_occ[0].coupling, gf_occ[0].energy ci_b, ei_b = gf_occ[1].coupling, gf_occ[1].energy @@ -206,7 +206,7 @@ def fock_loop(agf2, eri, gf, se): rdm1a_prev = 0 rdm1b_prev = 0 converged = False - opts = dict(tol=agf2.conv_tol_nelec, maxiter=agf2.max_cycle_inner) + opts = {'tol': agf2.conv_tol_nelec, 'maxiter': agf2.max_cycle_inner} for niter1 in range(1, agf2.max_cycle_outer+1): sea, opt = minimize_chempot(sea, focka, nalph, x0=sea.chempot, @@ -557,7 +557,7 @@ def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=No if os_factor is None: os_factor = self.os_factor if ss_factor is None: ss_factor = self.ss_factor - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} gf_occ = (gf[0].get_occupied(), gf[1].get_occupied()) gf_vir = (gf[0].get_virtual(), gf[1].get_virtual()) diff --git a/pyscf/agf2/uagf2_slow.py b/pyscf/agf2/uagf2_slow.py index 65f39b6cc4..a35a078337 100644 --- a/pyscf/agf2/uagf2_slow.py +++ b/pyscf/agf2/uagf2_slow.py @@ -205,7 +205,7 @@ class UAGF2(uagf2.UAGF2): Auxiliaries of the Green's function for each spin ''' - _keys = set(['nmom']) + _keys = {'nmom'} def __init__(self, mf, nmom=(None,0), frozen=None, mo_energy=None, mo_coeff=None, mo_occ=None): @@ -250,7 +250,7 @@ def build_se(self, eri=None, gf=None, os_factor=None, ss_factor=None, se_prev=No if os_factor is None: os_factor = self.os_factor if ss_factor is None: ss_factor = self.ss_factor - facs = dict(os_factor=os_factor, ss_factor=ss_factor) + facs = {'os_factor': os_factor, 'ss_factor': ss_factor} gf_occ = (gf[0].get_occupied(), gf[1].get_occupied()) gf_vir = (gf[0].get_virtual(), gf[1].get_virtual()) diff --git a/pyscf/cc/ccsd.py b/pyscf/cc/ccsd.py index 15df586dc4..82b3451d3e 100644 --- a/pyscf/cc/ccsd.py +++ b/pyscf/cc/ccsd.py @@ -923,7 +923,7 @@ class CCSDBase(lib.StreamObject): cc2 = getattr(__config__, 'cc_ccsd_CCSD_cc2', False) callback = None - _keys = set(( + _keys = { 'max_cycle', 'conv_tol', 'iterative_damping', 'conv_tol_normt', 'diis', 'diis_space', 'diis_file', 'diis_start_cycle', 'diis_start_energy_diff', 'direct', @@ -931,7 +931,7 @@ class CCSDBase(lib.StreamObject): 'mol', 'verbose', 'stdout', 'frozen', 'level_shift', 'mo_coeff', 'mo_occ', 'converged', 'converged_lambda', 'emp2', 'e_hf', 'e_corr', 't1', 't2', 'l1', 'l2', 'chkfile', - )) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): from pyscf.scf import hf diff --git a/pyscf/cc/dfccsd.py b/pyscf/cc/dfccsd.py index 6c7af7ebf3..6169fc64ad 100644 --- a/pyscf/cc/dfccsd.py +++ b/pyscf/cc/dfccsd.py @@ -27,7 +27,7 @@ MEMORYMIN = getattr(__config__, 'cc_ccsd_memorymin', 2000) class RCCSD(ccsd.CCSD): - _keys = set(['with_df']) + _keys = {'with_df'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): ccsd.CCSD.__init__(self, mf, frozen, mo_coeff, mo_occ) diff --git a/pyscf/cc/eom_rccsd.py b/pyscf/cc/eom_rccsd.py index 3955e39187..be7ac10a13 100644 --- a/pyscf/cc/eom_rccsd.py +++ b/pyscf/cc/eom_rccsd.py @@ -96,10 +96,10 @@ def pickeig(w, v, nroots, envs): class EOM(lib.StreamObject): - _keys = set(( + _keys = { 'mol', 'max_space', 'max_cycle', 'conv_tol', 'partition', 'e', 'v', 'nocc', 'nmo', - )) + } def __init__(self, cc): self.mol = cc.mol diff --git a/pyscf/cc/momgfccsd.py b/pyscf/cc/momgfccsd.py index 8ed1342c94..14dddd183d 100644 --- a/pyscf/cc/momgfccsd.py +++ b/pyscf/cc/momgfccsd.py @@ -607,10 +607,10 @@ class MomGFCCSD(lib.StreamObject): particle Green's function """ - _keys = set(( + _keys = { 'verbose', 'stdout', 'niter', 'weight_tol', 'hermi_moments', 'hermi_solver', 'eh', 'ep', 'vh', 'vp', 'chkfile', - )) + } def __init__(self, mycc, niter=(2, 2)): self._cc = mycc diff --git a/pyscf/cc/rccsd_slow.py b/pyscf/cc/rccsd_slow.py index a246d7b11a..a420da690c 100644 --- a/pyscf/cc/rccsd_slow.py +++ b/pyscf/cc/rccsd_slow.py @@ -148,7 +148,7 @@ def energy(cc, t1, t2, eris): class RCCSD(ccsd.CCSD): - _keys = set(['max_space']) + _keys = {'max_space'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): ccsd.CCSD.__init__(self, mf, frozen, mo_coeff, mo_occ) diff --git a/pyscf/cc/uccsd_slow.py b/pyscf/cc/uccsd_slow.py index a24bc91968..967a1d3451 100644 --- a/pyscf/cc/uccsd_slow.py +++ b/pyscf/cc/uccsd_slow.py @@ -610,7 +610,7 @@ def uspatial2spin(cc, moidx, mo_coeff): dm = cc._scf.make_rdm1(cc.mo_coeff, cc.mo_occ) fockao = cc._scf.get_hcore() + cc._scf.get_veff(cc.mol, dm) - fockab = list() + fockab = [] for a in range(2): fockab.append( reduce(numpy.dot, (mo_coeff[a].T, fockao[a], mo_coeff[a])) ) diff --git a/pyscf/ci/cisd.py b/pyscf/ci/cisd.py index ca788647ba..cbbab7859f 100644 --- a/pyscf/ci/cisd.py +++ b/pyscf/ci/cisd.py @@ -860,12 +860,12 @@ class CISD(lib.StreamObject): direct = getattr(__config__, 'ci_cisd_CISD_direct', False) async_io = getattr(__config__, 'ci_cisd_CISD_async_io', True) - _keys = set(( + _keys = { 'conv_tol', 'max_cycle', 'max_space', 'lindep', 'level_shift', 'direct', 'async_io', 'mol', 'max_memory', 'nroots', 'frozen', 'chkfile', 'converged', 'mo_coeff', 'mo_occ', 'e_hf', 'e_corr', 'emp2', 'ci', - )) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): from pyscf.scf import hf diff --git a/pyscf/data/elements.py b/pyscf/data/elements.py index cb401fdc58..88d81dd769 100644 --- a/pyscf/data/elements.py +++ b/pyscf/data/elements.py @@ -30,7 +30,7 @@ 'Md', 'No', 'Lr', 'Rf', 'Db', 'Sg', 'Bh', 'Hs', 'Mt', 'Ds', 'Rg', 'Cn', 'Nh', 'Fl', 'Mc', 'Lv', 'Ts', 'Og', ] -NUC = dict(((x,i) for i,x in enumerate(ELEMENTS))) +NUC = {x: i for i,x in enumerate(ELEMENTS)} NUC.update((x.upper(),i) for i,x in enumerate(ELEMENTS)) NUC['GHOST'] = 0 ELEMENTS_PROTON = NUC @@ -1130,7 +1130,7 @@ def _rm_digit(symb): else: return ''.join([i for i in symb if i.isalpha()]) -_ELEMENTS_UPPER = dict((x.upper(),x) for x in ELEMENTS) +_ELEMENTS_UPPER = {x.upper(): x for x in ELEMENTS} _ELEMENTS_UPPER['GHOST'] = 'Ghost' def charge(symb_or_chg): diff --git a/pyscf/df/addons.py b/pyscf/df/addons.py index 78639a0ada..5cd32e7eae 100644 --- a/pyscf/df/addons.py +++ b/pyscf/df/addons.py @@ -79,7 +79,7 @@ def aug_etb_for_dfbasis(mol, dfbasis=DFBASIS, beta=ETB_BETA, exps = alpha*beta^i for i = 1..N ''' nuc_start = gto.charge(start_at) - uniq_atoms = set([a[0] for a in mol._atom]) + uniq_atoms = {a[0] for a in mol._atom} newbasis = {} for symb in uniq_atoms: @@ -143,12 +143,12 @@ def make_auxbasis(mol, mp2fit=False): '''Depending on the orbital basis, generating even-tempered Gaussians or the optimized auxiliary basis defined in DEFAULT_AUXBASIS ''' - uniq_atoms = set([a[0] for a in mol._atom]) + uniq_atoms = {a[0] for a in mol._atom} if isinstance(mol.basis, str): - _basis = dict(((a, mol.basis) for a in uniq_atoms)) + _basis = {a: mol.basis for a in uniq_atoms} elif 'default' in mol.basis: default_basis = mol.basis['default'] - _basis = dict(((a, default_basis) for a in uniq_atoms)) + _basis = {a: default_basis for a in uniq_atoms} _basis.update(mol.basis) del (_basis['default']) else: @@ -209,11 +209,11 @@ def make_auxmol(mol, auxbasis=None): pmol.basis = auxbasis if isinstance(auxbasis, (str, list, tuple)): - uniq_atoms = set([a[0] for a in mol._atom]) - _basis = dict([(a, auxbasis) for a in uniq_atoms]) + uniq_atoms = {a[0] for a in mol._atom} + _basis = {a: auxbasis for a in uniq_atoms} elif 'default' in auxbasis: - uniq_atoms = set([a[0] for a in mol._atom]) - _basis = dict(((a, auxbasis['default']) for a in uniq_atoms)) + uniq_atoms = {a[0] for a in mol._atom} + _basis = {a: auxbasis['default'] for a in uniq_atoms} _basis.update(auxbasis) del (_basis['default']) else: diff --git a/pyscf/df/df.py b/pyscf/df/df.py index 2b2a6c8ea2..de99b5bd21 100644 --- a/pyscf/df/df.py +++ b/pyscf/df/df.py @@ -79,7 +79,7 @@ class DF(lib.StreamObject): _compatible_format = getattr(__config__, 'df_df_DF_compatible_format', False) _dataname = 'j3c' - _keys = set(('mol', 'auxmol')) + _keys = {'mol', 'auxmol'} def __init__(self, mol, auxbasis=None): self.mol = mol diff --git a/pyscf/df/df_jk.py b/pyscf/df/df_jk.py index a5e8f95de3..66ed265e38 100644 --- a/pyscf/df/df_jk.py +++ b/pyscf/df/df_jk.py @@ -108,7 +108,7 @@ class _DFHF: __name_mixin__ = 'DF' - _keys = set(['with_df', 'only_dfj']) + _keys = {'with_df', 'only_dfj'} def __init__(self, mf, df=None, only_dfj=None): self.__dict__.update(mf.__dict__) diff --git a/pyscf/dft/gen_grid.py b/pyscf/dft/gen_grid.py index dc2512d203..30cc96c195 100644 --- a/pyscf/dft/gen_grid.py +++ b/pyscf/dft/gen_grid.py @@ -228,8 +228,8 @@ def gen_atomic_grids(mol, atom_grid={}, radi_method=radi.gauss_chebyshev, atom center; the second is the volume of that grid. ''' if isinstance(atom_grid, (list, tuple)): - atom_grid = dict([(mol.atom_symbol(ia), atom_grid) - for ia in range(mol.natm)]) + atom_grid = {mol.atom_symbol(ia): atom_grid + for ia in range(mol.natm)} atom_grids_tab = {} for ia in range(mol.natm): symb = mol.atom_symbol(ia) @@ -495,11 +495,11 @@ class Grids(lib.StreamObject): alignment = ALIGNMENT_UNIT cutoff = CUTOFF - _keys = set(( + _keys = { 'atomic_radii', 'radii_adjust', 'radi_method', 'becke_scheme', 'prune', 'level', 'alignment', 'cutoff', 'mol', 'symmetry', 'atom_grid', 'non0tab', 'screen_index', 'coords', 'weights', - )) + } def __init__(self, mol): self.mol = mol diff --git a/pyscf/dft/libxc.py b/pyscf/dft/libxc.py index e65a5d2334..b5b4f781e2 100644 --- a/pyscf/dft/libxc.py +++ b/pyscf/dft/libxc.py @@ -89,7 +89,7 @@ def available_libxc_functionals(): return {_itrf.LIBXC_functional_name(x).decode("UTF-8").upper() : x for x in numbers} XC = XC_CODES = available_libxc_functionals() - PROBLEMATIC_XC = dict([]) + PROBLEMATIC_XC = {} else: # XC dict is generated by @@ -703,7 +703,7 @@ def available_libxc_functionals(): #PROBLEMATIC_XC = dict([(XC_CODES[x], x) for x in # ('GGA_C_SPBE', 'MGGA_X_REVTPSS')]) - PROBLEMATIC_XC = dict([]) + PROBLEMATIC_XC = {} def _xc_key_without_underscore(xc_keys): new_xc = [] @@ -1191,20 +1191,20 @@ def parse_token(token, ftype, search_xc_alias=False): else: fn_facs.append((x_id, fac)) def possible_x_for(key): - return set((key, + return {key, 'LDA_X_'+key, 'GGA_X_'+key, 'MGGA_X_'+key, - 'HYB_GGA_X_'+key, 'HYB_MGGA_X_'+key)) + 'HYB_GGA_X_'+key, 'HYB_MGGA_X_'+key} def possible_xc_for(key): - return set((key, 'LDA_XC_'+key, 'GGA_XC_'+key, 'MGGA_XC_'+key, - 'HYB_LDA_XC_'+key, 'HYB_GGA_XC_'+key, 'HYB_MGGA_XC_'+key)) + return {key, 'LDA_XC_'+key, 'GGA_XC_'+key, 'MGGA_XC_'+key, + 'HYB_LDA_XC_'+key, 'HYB_GGA_XC_'+key, 'HYB_MGGA_XC_'+key} def possible_k_for(key): - return set((key, - 'LDA_K_'+key, 'GGA_K_'+key,)) + return {key, + 'LDA_K_'+key, 'GGA_K_'+key,} def possible_x_k_for(key): return possible_x_for(key).union(possible_k_for(key)) def possible_c_for(key): - return set((key, - 'LDA_C_'+key, 'GGA_C_'+key, 'MGGA_C_'+key)) + return {key, + 'LDA_C_'+key, 'GGA_C_'+key, 'MGGA_C_'+key} fpossible_dic = {'X': possible_x_for, 'C': possible_c_for, 'compound XC': possible_xc_for, diff --git a/pyscf/dft/rks.py b/pyscf/dft/rks.py index 9f17a2acb0..66d9418a08 100644 --- a/pyscf/dft/rks.py +++ b/pyscf/dft/rks.py @@ -320,7 +320,7 @@ class KohnShamDFT: -76.415443079840458 ''' - _keys = set(['xc', 'nlc', 'grids', 'nlcgrids', 'small_rho_cutoff']) + _keys = {'xc', 'nlc', 'grids', 'nlcgrids', 'small_rho_cutoff'} def __init__(self, xc='LDA,VWN'): self.xc = xc diff --git a/pyscf/dft/xcfun.py b/pyscf/dft/xcfun.py index a5d88e7e26..20942094bf 100644 --- a/pyscf/dft/xcfun.py +++ b/pyscf/dft/xcfun.py @@ -245,11 +245,11 @@ MGGA_IDS =set([10, 11, 12, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 66, 70, 75]) ''' -HYB_XC = set(('PBE0' , 'PBE1PBE' , 'B3PW91' , 'B3P86' , 'B3LYP' , +HYB_XC = {'PBE0' , 'PBE1PBE' , 'B3PW91' , 'B3P86' , 'B3LYP' , 'B3PW91G' , 'B3P86G' , 'B3LYPG' , 'O3LYP' , 'CAMB3LYP', 'B97XC' , 'B97_1XC' , 'B97_2XC' , 'M05XC' , 'TPSSH' , - 'HFLYP')) -RSH_XC = set(('CAMB3LYP',)) + 'HFLYP'} +RSH_XC = {'CAMB3LYP'} MAX_DERIV_ORDER = 3 VV10_XC = { diff --git a/pyscf/eph/rhf.py b/pyscf/eph/rhf.py index c570fd23aa..c78e86b3fb 100644 --- a/pyscf/eph/rhf.py +++ b/pyscf/eph/rhf.py @@ -145,7 +145,7 @@ def _freq_mass_weighted_vec(vec, omega, mass): def get_eph(ephobj, mo1, omega, vec, mo_rep): if isinstance(mo1, str): mo1 = chkfile.load(mo1, 'scf_mo1') - mo1 = dict([(int(k), mo1[k]) for k in mo1]) + mo1 = {int(k): mo1[k] for k in mo1} mol = ephobj.mol mf = ephobj.base diff --git a/pyscf/eph/rks.py b/pyscf/eph/rks.py index 2cef97ebb6..997d649331 100644 --- a/pyscf/eph/rks.py +++ b/pyscf/eph/rks.py @@ -102,7 +102,7 @@ def _get_vxc_deriv1(hessobj, mo_coeff, mo_occ, max_memory): def get_eph(ephobj, mo1, omega, vec, mo_rep): if isinstance(mo1, str): mo1 = lib.chkfile.load(mo1, 'scf_mo1') - mo1 = dict([(int(k), mo1[k]) for k in mo1]) + mo1 = {int(k): mo1[k] for k in mo1} mol = ephobj.mol mf = ephobj.base diff --git a/pyscf/eph/uhf.py b/pyscf/eph/uhf.py index e1b8866345..ae4109a1a3 100644 --- a/pyscf/eph/uhf.py +++ b/pyscf/eph/uhf.py @@ -58,8 +58,8 @@ def get_eph(ephobj, mo1, omega, vec, mo_rep): mo1 = lib.chkfile.load(mo1, 'scf_mo1') mo1a = mo1['0'] mo1b = mo1['1'] - mo1a = dict([(int(k), mo1a[k]) for k in mo1a]) - mo1b = dict([(int(k), mo1b[k]) for k in mo1b]) + mo1a = {int(k): mo1a[k] for k in mo1a} + mo1b = {int(k): mo1b[k] for k in mo1b} mol = ephobj.mol mf = ephobj.base diff --git a/pyscf/eph/uks.py b/pyscf/eph/uks.py index 56867bf19c..6256432e19 100644 --- a/pyscf/eph/uks.py +++ b/pyscf/eph/uks.py @@ -128,8 +128,8 @@ def get_eph(ephobj, mo1, omega, vec, mo_rep): mo1 = lib.chkfile.load(mo1, 'scf_mo1') mo1a = mo1['0'] mo1b = mo1['1'] - mo1a = dict([(int(k), mo1a[k]) for k in mo1a]) - mo1b = dict([(int(k), mo1b[k]) for k in mo1b]) + mo1a = {int(k): mo1a[k] for k in mo1a} + mo1b = {int(k): mo1b[k] for k in mo1b} mol = ephobj.mol mf = ephobj.base diff --git a/pyscf/fci/addons.py b/pyscf/fci/addons.py index f43d11e13d..95fda3f6ce 100644 --- a/pyscf/fci/addons.py +++ b/pyscf/fci/addons.py @@ -512,7 +512,7 @@ def overlap(bra, ket, norb, nelec, s=None): class SpinPenaltyFCISolver: __name_mixin__ = 'SpinPenalty' - _keys = set(('ss_value', 'ss_penalty', 'base')) + _keys = {'ss_value', 'ss_penalty', 'base'} def __init__(self, fcibase, shift, ss_value): self.base = fcibase.copy() diff --git a/pyscf/fci/cistring.py b/pyscf/fci/cistring.py index 014ed6e829..fb074f23f6 100644 --- a/pyscf/fci/cistring.py +++ b/pyscf/fci/cistring.py @@ -151,7 +151,7 @@ def gen_linkstr_index_o1(orb_list, nelec, strs=None, tril=False): norb = len(orb_list) assert (numpy.all(numpy.arange(norb) == orb_list)) - strdic = dict((tuple(s), i) for i,s in enumerate(occslst)) + strdic = {tuple(s): i for i,s in enumerate(occslst)} nvir = norb - nelec def propgate1e(str0): addr0 = strdic[tuple(str0)] diff --git a/pyscf/fci/direct_spin1.py b/pyscf/fci/direct_spin1.py index 33f20a585c..4b5b5a4946 100644 --- a/pyscf/fci/direct_spin1.py +++ b/pyscf/fci/direct_spin1.py @@ -718,12 +718,12 @@ class FCIBase(lib.StreamObject): threads = getattr(__config__, 'fci_direct_spin1_FCI_threads', None) lessio = getattr(__config__, 'fci_direct_spin1_FCI_lessio', False) - _keys = set(( + _keys = { 'max_cycle', 'max_space', 'conv_tol', 'lindep', 'level_shift', 'davidson_only', 'pspace_size', 'threads', 'lessio', 'mol', 'nroots', 'spin', 'orbsym', 'wfnsym', 'converged', 'norb', 'nelec', 'eci', 'ci', - )) + } def __init__(self, mol=None): if mol is None: diff --git a/pyscf/fci/selected_ci.py b/pyscf/fci/selected_ci.py index a0594fcc14..cb9dd79339 100644 --- a/pyscf/fci/selected_ci.py +++ b/pyscf/fci/selected_ci.py @@ -731,10 +731,10 @@ class SelectedCI(direct_spin1.FCISolver): start_tol = getattr(__config__, 'fci_selected_ci_SCI_start_tol', 3e-4) tol_decay_rate = getattr(__config__, 'fci_selected_ci_SCI_tol_decay_rate', 0.3) - _keys = set(( + _keys = { 'ci_coeff_cutoff', 'select_cutoff', 'conv_tol', 'start_tol', 'tol_decay_rate', - )) + } def __init__(self, mol=None): direct_spin1.FCISolver.__init__(self, mol) diff --git a/pyscf/grad/dhf.py b/pyscf/grad/dhf.py index 86d3fba309..88913bf56b 100644 --- a/pyscf/grad/dhf.py +++ b/pyscf/grad/dhf.py @@ -161,7 +161,7 @@ def get_ovlp(self, mol=None): class Gradients(GradientsBase): '''Unrestricted Dirac-Hartree-Fock gradients''' - _keys = set(['level']) + _keys = {'level'} def __init__(self, scf_method): GradientsBase.__init__(self, scf_method) diff --git a/pyscf/grad/rks.py b/pyscf/grad/rks.py index 3dfd3a22ce..7aee5fadfc 100644 --- a/pyscf/grad/rks.py +++ b/pyscf/grad/rks.py @@ -585,7 +585,7 @@ class Gradients(rhf_grad.Gradients): # the kernel function can be reused in the DFT gradients code. grid_response = getattr(__config__, 'grad_rks_Gradients_grid_response', False) - _keys = set(['grid_response', 'grids', 'nlcgrids']) + _keys = {'grid_response', 'grids', 'nlcgrids'} def __init__(self, mf): rhf_grad.Gradients.__init__(self, mf) diff --git a/pyscf/grad/tdrhf.py b/pyscf/grad/tdrhf.py index fe07ecff35..bfb08aedba 100644 --- a/pyscf/grad/tdrhf.py +++ b/pyscf/grad/tdrhf.py @@ -199,7 +199,7 @@ def as_scanner(td_grad, state=1): (TDSCF_GradScanner, td_grad.__class__), name) class TDSCF_GradScanner(lib.GradScanner): - _keys = set(['e_tot']) + _keys = {'e_tot'} def __init__(self, g, state): lib.GradScanner.__init__(self, g) diff --git a/pyscf/grad/uks.py b/pyscf/grad/uks.py index c0df2777e9..644ab01584 100644 --- a/pyscf/grad/uks.py +++ b/pyscf/grad/uks.py @@ -244,7 +244,7 @@ class Gradients(uhf_grad.Gradients): grid_response = getattr(__config__, 'grad_uks_Gradients_grid_response', False) - _keys = set(['grid_response', 'grids', 'nlcgrids']) + _keys = {'grid_response', 'grids', 'nlcgrids'} def __init__(self, mf): uhf_grad.Gradients.__init__(self, mf) diff --git a/pyscf/gto/mole.py b/pyscf/gto/mole.py index 5c9e9d282e..49f7fe9f34 100644 --- a/pyscf/gto/mole.py +++ b/pyscf/gto/mole.py @@ -1240,12 +1240,12 @@ def unpack(moldic): def dumps(mol): '''Serialize Mole object to a JSON formatted str. ''' - exclude_keys = set(('output', 'stdout', '_keys', + exclude_keys = {'output', 'stdout', '_keys', # Constructing in function loads - 'symm_orb', 'irrep_id', 'irrep_name')) + 'symm_orb', 'irrep_id', 'irrep_name'} # FIXME: nparray and kpts for cell objects may need to be excluded - nparray_keys = set(('_atm', '_bas', '_env', '_ecpbas', - '_symm_orig', '_symm_axes')) + nparray_keys = {'_atm', '_bas', '_env', '_ecpbas', + '_symm_orig', '_symm_axes'} moldic = dict(mol.__dict__) for k in exclude_keys: @@ -2521,7 +2521,7 @@ def build(self, dump_input=True, parse_arg=ARGPARSE, self.check_sanity() self._atom = self.format_atom(self.atom, unit=self.unit) - uniq_atoms = set([a[0] for a in self._atom]) + uniq_atoms = {a[0] for a in self._atom} _basis = _parse_default_basis(self.basis, uniq_atoms) self._basis = self.format_basis(_basis) diff --git a/pyscf/gw/gw_ac.py b/pyscf/gw/gw_ac.py index 3c401fcf16..8efee5b7d6 100644 --- a/pyscf/gw/gw_ac.py +++ b/pyscf/gw/gw_ac.py @@ -334,10 +334,10 @@ class GWAC(lib.StreamObject): # Analytic continuation: pade or twopole ac = getattr(__config__, 'gw_gw_GW_ac', 'pade') - _keys = set(( + _keys = { 'linearized','ac', 'with_df', 'mol', 'frozen', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - )) + } def __init__(self, mf, frozen=None): self.mol = mf.mol diff --git a/pyscf/gw/gw_cd.py b/pyscf/gw/gw_cd.py index 636ea0001a..364330caaa 100644 --- a/pyscf/gw/gw_cd.py +++ b/pyscf/gw/gw_cd.py @@ -258,10 +258,10 @@ class GWCD(lib.StreamObject): eta = getattr(__config__, 'gw_gw_GW_eta', 1e-3) linearized = getattr(__config__, 'gw_gw_GW_linearized', False) - _keys = set(( + _keys = { 'eta', 'linearized', 'mol', 'frozen', 'with_df', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - )) + } def __init__(self, mf, frozen=None): self.mol = mf.mol diff --git a/pyscf/gw/gw_exact.py b/pyscf/gw/gw_exact.py index 6cf627872c..41ad154a5a 100644 --- a/pyscf/gw/gw_exact.py +++ b/pyscf/gw/gw_exact.py @@ -157,10 +157,10 @@ class GWExact(lib.StreamObject): eta = getattr(__config__, 'gw_gw_GW_eta', 1e-8) linearized = getattr(__config__, 'gw_gw_GW_linearized', False) - _keys = set(( + _keys = { 'eta', 'linearized', 'mol', 'frozen', 'mo_energy', 'mo_coeff', 'mo_occ', - )) + } def __init__(self, mf, frozen=None, tdmf=None): self.mol = mf.mol diff --git a/pyscf/gw/rpa.py b/pyscf/gw/rpa.py index 181bbd8d1e..8304432298 100755 --- a/pyscf/gw/rpa.py +++ b/pyscf/gw/rpa.py @@ -162,10 +162,10 @@ def _mo_without_core(rpa, mo): class RPA(lib.StreamObject): - _keys = set(( + _keys = { 'mol', 'frozen', 'with_df', 'mo_energy', 'mo_coeff', 'mo_occ', 'e_corr', 'e_hf', 'e_tot', - )) + } def __init__(self, mf, frozen=None, auxbasis=None): self.mol = mf.mol diff --git a/pyscf/gw/ugw_ac.py b/pyscf/gw/ugw_ac.py index 5f888dc3d3..b5fc6db9c5 100644 --- a/pyscf/gw/ugw_ac.py +++ b/pyscf/gw/ugw_ac.py @@ -385,10 +385,10 @@ class UGWAC(lib.StreamObject): # Analytic continuation: pade or twopole ac = getattr(__config__, 'gw_ugw_UGW_ac', 'pade') - _keys = set(( + _keys = { 'linearized','ac', 'mol', 'frozen', 'with_df', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - )) + } def __init__(self, mf, frozen=None): self.mol = mf.mol diff --git a/pyscf/hessian/rhf.py b/pyscf/hessian/rhf.py index 63f0547e6c..4b269d419c 100644 --- a/pyscf/hessian/rhf.py +++ b/pyscf/hessian/rhf.py @@ -62,10 +62,10 @@ def hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None, if isinstance(h1ao, str): h1ao = lib.chkfile.load(h1ao, 'scf_f1ao') - h1ao = dict([(int(k), h1ao[k]) for k in h1ao]) + h1ao = {int(k): h1ao[k] for k in h1ao} if isinstance(mo1, str): mo1 = lib.chkfile.load(mo1, 'scf_mo1') - mo1 = dict([(int(k), mo1[k]) for k in mo1]) + mo1 = {int(k): mo1[k] for k in mo1} nao, nmo = mo_coeff.shape mocc = mo_coeff[:,mo_occ>0] @@ -470,9 +470,9 @@ def h_op(x): class Hessian(lib.StreamObject): '''Non-relativistic restricted Hartree-Fock hessian''' - _keys = set(( + _keys = { 'mol', 'base', 'chkfile', 'atmlst', 'de', - )) + } def __init__(self, scf_method): self.verbose = scf_method.verbose diff --git a/pyscf/hessian/rks.py b/pyscf/hessian/rks.py index 90bb2b2bdc..b9ba2a4b7f 100644 --- a/pyscf/hessian/rks.py +++ b/pyscf/hessian/rks.py @@ -551,7 +551,7 @@ def _get_vxc_deriv1(hessobj, mo_coeff, mo_occ, max_memory): class Hessian(rhf_hess.Hessian): '''Non-relativistic RKS hessian''' - _keys = set(['grids', 'grid_response']) + _keys = {'grids', 'grid_response'} def __init__(self, mf): rhf_hess.Hessian.__init__(self, mf) diff --git a/pyscf/hessian/uhf.py b/pyscf/hessian/uhf.py index a114bdb680..47f1e8ee96 100644 --- a/pyscf/hessian/uhf.py +++ b/pyscf/hessian/uhf.py @@ -64,16 +64,16 @@ def hess_elec(hessobj, mo_energy=None, mo_coeff=None, mo_occ=None, h1ao = lib.chkfile.load(h1ao, 'scf_f1ao') h1aoa = h1ao['0'] h1aob = h1ao['1'] - h1aoa = dict([(int(k), h1aoa[k]) for k in h1aoa]) - h1aob = dict([(int(k), h1aob[k]) for k in h1aob]) + h1aoa = {int(k): h1aoa[k] for k in h1aoa} + h1aob = {int(k): h1aob[k] for k in h1aob} else: h1aoa, h1aob = h1ao if isinstance(mo1, str): mo1 = lib.chkfile.load(mo1, 'scf_mo1') mo1a = mo1['0'] mo1b = mo1['1'] - mo1a = dict([(int(k), mo1a[k]) for k in mo1a]) - mo1b = dict([(int(k), mo1b[k]) for k in mo1b]) + mo1a = {int(k): mo1a[k] for k in mo1a} + mo1b = {int(k): mo1b[k] for k in mo1b} else: mo1a, mo1b = mo1 mo_e1a, mo_e1b = mo_e1 diff --git a/pyscf/hessian/uks.py b/pyscf/hessian/uks.py index 300cdeec1a..9349fa964c 100644 --- a/pyscf/hessian/uks.py +++ b/pyscf/hessian/uks.py @@ -656,7 +656,7 @@ def _get_vxc_deriv1(hessobj, mo_coeff, mo_occ, max_memory): class Hessian(uhf_hess.Hessian): '''Non-relativistic UKS hessian''' - _keys = set(['grids', 'grid_response']) + _keys = {'grids', 'grid_response'} def __init__(self, mf): uhf_hess.Hessian.__init__(self, mf) diff --git a/pyscf/lib/chkfile.py b/pyscf/lib/chkfile.py index ed2b441a4f..dd79a50480 100644 --- a/pyscf/lib/chkfile.py +++ b/pyscf/lib/chkfile.py @@ -65,8 +65,7 @@ def load_as_dic(key, group): if key.endswith('__from_list__'): return [load_as_dic(k, val) for k in val] else: - return dict([(k.replace('__from_list__', ''), - load_as_dic(k, val)) for k in val]) + return {k.replace('__from_list__', ''): load_as_dic(k, val) for k in val} else: return val[()] diff --git a/pyscf/lib/misc.py b/pyscf/lib/misc.py index 74959f0e48..08199fd6cf 100644 --- a/pyscf/lib/misc.py +++ b/pyscf/lib/misc.py @@ -560,7 +560,7 @@ class StreamObject: verbose = 0 stdout = sys.stdout # Store the keys appeared in the module. It is used to check misinput attributes - _keys = set(['output', 'verbose', 'stdout', 'max_memory']) + _keys = {'output', 'verbose', 'stdout', 'max_memory'} def kernel(self, *args, **kwargs): ''' diff --git a/pyscf/lib/numpy_helper.py b/pyscf/lib/numpy_helper.py index 6b468130e4..406fa54e20 100644 --- a/pyscf/lib/numpy_helper.py +++ b/pyscf/lib/numpy_helper.py @@ -190,8 +190,8 @@ def _contract(subscripts, *tensors, **kwargs): print("Reshaping A as (-1,", inner_shape, ")") print("Reshaping B as (", inner_shape, ",-1)") - shapeCt = list() - idxCt = list() + shapeCt = [] + idxCt = [] for idx in idxAt: if idx in shared_idxAB: break diff --git a/pyscf/lib/test/test_misc.py b/pyscf/lib/test/test_misc.py index b22aa8d787..21a4a5cbf7 100644 --- a/pyscf/lib/test/test_misc.py +++ b/pyscf/lib/test/test_misc.py @@ -66,11 +66,11 @@ def test_issequence(self): self.assertTrue(issequence(numpy.array([1, 2, 3]))) self.assertTrue(issequence(range(5))) self.assertTrue(issequence('abcde')) - self.assertTrue(issequence(tuple())) + self.assertTrue(issequence(())) self.assertFalse(issequence(True)) self.assertFalse(issequence(2.0)) self.assertFalse(issequence(1)) - self.assertFalse(issequence(dict())) + self.assertFalse(issequence({})) self.assertFalse(issequence(set())) def test_isintsequence(self): diff --git a/pyscf/lo/pipek.py b/pyscf/lo/pipek.py index c5900db70a..7f24d752aa 100644 --- a/pyscf/lo/pipek.py +++ b/pyscf/lo/pipek.py @@ -186,7 +186,7 @@ class PipekMezey(boys.OrbitalLocalizer): conv_tol = getattr(__config__, 'lo_pipek_PM_conv_tol', 1e-6) exponent = getattr(__config__, 'lo_pipek_PM_exponent', 2) # should be 2 or 4 - _keys = set(['pop_method', 'conv_tol', 'exponent']) + _keys = {'pop_method', 'conv_tol', 'exponent'} def __init__(self, mol, mo_coeff=None, mf=None, pop_method=None): boys.OrbitalLocalizer.__init__(self, mol, mo_coeff) diff --git a/pyscf/mcscf/addons.py b/pyscf/mcscf/addons.py index 950c965717..0e7cca66fe 100644 --- a/pyscf/mcscf/addons.py +++ b/pyscf/mcscf/addons.py @@ -191,8 +191,8 @@ def caslst_by_irrep(casscf, mo_coeff, cas_irrep_nocc, for ir in irrep_ncore: mask[orbsym == ir] = False core_rest = orbsym[mask][:ncore_rest] - core_rest = dict([(ir, numpy.count_nonzero(core_rest==ir)) - for ir in set(core_rest)]) + core_rest = {ir: numpy.count_nonzero(core_rest==ir) + for ir in set(core_rest)} log.info('Given core space %s < casscf core size %d', cas_irrep_ncore, ncore) log.info('Add %s to core configuration', core_rest) @@ -201,12 +201,12 @@ def caslst_by_irrep(casscf, mo_coeff, cas_irrep_nocc, raise ValueError('Given core space %s > casscf core size %d' % (cas_irrep_ncore, ncore)) else: - irrep_ncore = dict([(ir, sum(orbsym[:ncore]==ir)) for ir in irreps]) + irrep_ncore = {ir: sum(orbsym[:ncore]==ir) for ir in irreps} if not isinstance(cas_irrep_nocc, dict): # list => dict - cas_irrep_nocc = dict([(ir, n) for ir,n in enumerate(cas_irrep_nocc) - if n > 0]) + cas_irrep_nocc = {ir: n for ir,n in enumerate(cas_irrep_nocc) + if n > 0} irrep_ncas = {} for k, v in cas_irrep_nocc.items(): @@ -226,8 +226,8 @@ def caslst_by_irrep(casscf, mo_coeff, cas_irrep_nocc, mask[idx[:ncore]] = False cas_rest = orbsym[mask][:ncas_rest] - cas_rest = dict([(ir, numpy.count_nonzero(cas_rest==ir)) - for ir in set(cas_rest)]) + cas_rest = {ir: numpy.count_nonzero(cas_rest==ir) + for ir in set(cas_rest)} log.info('Given active space %s < casscf active space size %d', cas_irrep_nocc, casscf.ncas) log.info('Add %s to active space', cas_rest) @@ -253,11 +253,11 @@ def caslst_by_irrep(casscf, mo_coeff, cas_irrep_nocc, if log.verbose >= logger.INFO: log.info('ncore for each irreps %s', - dict([(symm.irrep_id2name(mol.groupname, k), v) - for k,v in irrep_ncore.items()])) + {symm.irrep_id2name(mol.groupname, k): v + for k,v in irrep_ncore.items()}) log.info('ncas for each irreps %s', - dict([(symm.irrep_id2name(mol.groupname, k), v) - for k,v in irrep_ncas.items()])) + {symm.irrep_id2name(mol.groupname, k): v + for k,v in irrep_ncas.items()}) log.info('(%d-based) caslst = %s', base, caslst) return caslst @@ -1207,7 +1207,7 @@ class StateAverageMixFCISolver_state_args (StateAverageMixFCISolver_solver_args) class StateAverageMixFCISolver(StateAverageFCISolver): __name_mixin__ = 'StateAverageMix' - _keys = set (('weights','e_states','fcisolvers')) + _keys = {'weights','e_states','fcisolvers'} _solver_args = StateAverageMixFCISolver_solver_args _state_args = StateAverageMixFCISolver_state_args diff --git a/pyscf/mcscf/casci.py b/pyscf/mcscf/casci.py index 9cc01b2717..3f00365b48 100644 --- a/pyscf/mcscf/casci.py +++ b/pyscf/mcscf/casci.py @@ -764,11 +764,11 @@ class CASBase(lib.StreamObject): canonicalization = getattr(__config__, 'mcscf_casci_CASCI_canonicalization', True) sorting_mo_energy = getattr(__config__, 'mcscf_casci_CASCI_sorting_mo_energy', False) - _keys = set(( + _keys = { 'natorb', 'canonicalization', 'sorting_mo_energy', 'mol', 'max_memory', 'ncas', 'nelecas', 'ncore', 'fcisolver', 'frozen', 'extrasym', 'e_tot', 'e_cas', 'ci', 'mo_coeff', 'mo_energy', 'mo_occ', 'converged', - )) + } def __init__(self, mf_or_mol, ncas, nelecas, ncore=None): if isinstance(mf_or_mol, gto.Mole): diff --git a/pyscf/mcscf/df.py b/pyscf/mcscf/df.py index e4b8a06c38..00b5ec8b74 100644 --- a/pyscf/mcscf/df.py +++ b/pyscf/mcscf/df.py @@ -85,7 +85,7 @@ def density_fit(casscf, auxbasis=None, with_df=None): class _DFCAS: __name_mixin__ = 'DF' - _keys = set(['with_df']) + _keys = {'with_df'} def __init__(self, mc, with_df): self.__dict__.update(mc.__dict__) @@ -228,7 +228,7 @@ class _DFHessianCASSCF: __name_mixin__ = 'DFHessian' - _keys = set(['with_df']) + _keys = {'with_df'} def __init__(self, mc, with_df): self.__dict__.update(mc.__dict__) diff --git a/pyscf/mcscf/mc1step.py b/pyscf/mcscf/mc1step.py index 59040526dd..35249ce9a5 100644 --- a/pyscf/mcscf/mc1step.py +++ b/pyscf/mcscf/mc1step.py @@ -742,7 +742,7 @@ class CASSCF(casci.CASBase): extrasym = None callback = None - _keys = set(( + _keys = { 'max_stepsize', 'max_cycle_macro', 'max_cycle_micro', 'conv_tol', 'conv_tol_grad', 'ah_level_shift', 'ah_conv_tol', 'ah_max_cycle', 'ah_lindep', 'ah_start_tol', 'ah_start_cycle', 'ah_grad_trust_region', @@ -753,7 +753,7 @@ class CASSCF(casci.CASBase): 'small_rot_tol', 'extrasym', 'callback', 'frozen', 'chkfile', 'fcisolver', 'e_tot', 'e_cas', 'ci', 'mo_coeff', 'mo_energy', 'converged', - )) + } def __init__(self, mf_or_mol, ncas, nelecas, ncore=None, frozen=None): casci.CASBase.__init__(self, mf_or_mol, ncas, nelecas, ncore) diff --git a/pyscf/mcscf/umc1step.py b/pyscf/mcscf/umc1step.py index e6c8951968..53b7d1022a 100644 --- a/pyscf/mcscf/umc1step.py +++ b/pyscf/mcscf/umc1step.py @@ -370,14 +370,14 @@ class UCASSCF(ucasci.UCASBase): callback = None - _keys = set(( + _keys = { 'max_stepsize', 'max_cycle_macro', 'max_cycle_micro', 'conv_tol', 'conv_tol_grad', 'ah_level_shift', 'ah_conv_tol', 'ah_max_cycle', 'ah_lindep', 'ah_start_tol', 'ah_start_cycle', 'ah_grad_trust_region', 'internal_rotation', 'ci_response_space', 'with_dep4', 'chk_ci', 'kf_interval', 'kf_trust_region', 'natorb', 'callback', 'canonicalization', 'sorting_mo_energy', - )) + } def __init__(self, mf_or_mol, ncas, nelecas, ncore=None, frozen=None): ucasci.UCASBase.__init__(self, mf_or_mol, ncas, nelecas, ncore) diff --git a/pyscf/mp/dfmp2.py b/pyscf/mp/dfmp2.py index 5ca314c475..d8cffdd57a 100644 --- a/pyscf/mp/dfmp2.py +++ b/pyscf/mp/dfmp2.py @@ -81,7 +81,7 @@ def kernel(mp, mo_energy=None, mo_coeff=None, eris=None, with_t2=WITH_T2, class DFMP2(mp2.MP2): - _keys = set(['with_df']) + _keys = {'with_df'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): mp2.MP2.__init__(self, mf, frozen, mo_coeff, mo_occ) diff --git a/pyscf/mp/mp2.py b/pyscf/mp/mp2.py index a90548f1d2..afd191aa04 100644 --- a/pyscf/mp/mp2.py +++ b/pyscf/mp/mp2.py @@ -487,11 +487,11 @@ class MP2(lib.StreamObject): conv_tol = getattr(__config__, 'cc_ccsd_CCSD_conv_tol', 1e-7) conv_tol_normt = getattr(__config__, 'cc_ccsd_CCSD_conv_tol_normt', 1e-5) - _keys = set(( + _keys = { 'max_cycle', 'conv_tol', 'conv_tol_normt', 'mol', 'max_memory', 'frozen', 'level_shift', 'mo_coeff', 'mo_occ', 'e_hf', 'e_corr', 'e_corr_ss', 'e_corr_os', 't2', - )) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): diff --git a/pyscf/mp/ump2.py b/pyscf/mp/ump2.py index ac1a9c1c45..c0aed1b036 100644 --- a/pyscf/mp/ump2.py +++ b/pyscf/mp/ump2.py @@ -287,8 +287,8 @@ def make_fno(mp, thresh=1e-6, pct_occ=None, t2=None, eris=None): mf = mp._scf dmab = mp.make_rdm1(t2=t2) - frozen = list() - no_coeff = list() + frozen = [] + no_coeff = [] for s,dm in enumerate(dmab): nocc = mp.nocc[s] nmo = mp.nmo[s] diff --git a/pyscf/mrpt/nevpt2.py b/pyscf/mrpt/nevpt2.py index 484406c65e..228a8b497a 100644 --- a/pyscf/mrpt/nevpt2.py +++ b/pyscf/mrpt/nevpt2.py @@ -616,9 +616,9 @@ class NEVPT(lib.StreamObject): -0.14058324991532101 ''' - _keys = set(( + _keys = { 'ncore', 'root', 'compressed_mps', 'e_corr', 'canonicalized', 'onerdm', - )).union(casci.CASBase._keys, mc1step.CASSCF._keys) + }.union(casci.CASBase._keys, mc1step.CASSCF._keys) def __init__(self, mc, root=0): self.__dict__.update(mc.__dict__) diff --git a/pyscf/pbc/adc/kadc_rhf.py b/pyscf/pbc/adc/kadc_rhf.py index a408e9ad9c..9562f42f93 100644 --- a/pyscf/pbc/adc/kadc_rhf.py +++ b/pyscf/pbc/adc/kadc_rhf.py @@ -129,13 +129,13 @@ def kernel(adc, nroots=1, guess=None, eris=None, kptlist=None, verbose=None): class RADC(pyscf.adc.radc.RADC): - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mol', 'mo_energy', 'incore_complete', 'scf_energy', 'e_tot', 't1', 'frozen', 'chkfile', 'max_space', 't2', 'mo_occ', 'max_cycle','kpts', 'khelper', 'exxdiv', 'cell', 'nkop_chk', 'kop_npick', 'chnk_size', 'keep_exxdiv', - )) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): diff --git a/pyscf/pbc/adc/kadc_rhf_ea.py b/pyscf/pbc/adc/kadc_rhf_ea.py index 217430e3b7..439ffc95a0 100644 --- a/pyscf/pbc/adc/kadc_rhf_ea.py +++ b/pyscf/pbc/adc/kadc_rhf_ea.py @@ -1204,11 +1204,11 @@ class RADCEA(kadc_rhf.RADC): Spectroscopic amplitudes for each EA transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mo_energy_b', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', 'kpts', 'exxdiv', 'khelper', 'cell', 'nkop_chk', 'kop_npick', 'chnk_size', - )) + } def __init__(self, adc): self.verbose = adc.verbose diff --git a/pyscf/pbc/adc/kadc_rhf_ip.py b/pyscf/pbc/adc/kadc_rhf_ip.py index b762ddefe9..c6ba72abef 100644 --- a/pyscf/pbc/adc/kadc_rhf_ip.py +++ b/pyscf/pbc/adc/kadc_rhf_ip.py @@ -977,11 +977,11 @@ class RADCIP(kadc_rhf.RADC): Spectroscopic amplitudes for each IP transition. ''' - _keys = set(( + _keys = { 'tol_residual','conv_tol', 'e_corr', 'method', 'mo_coeff', 'mo_energy_b', 't1', 'mo_energy_a', 'max_space', 't2', 'max_cycle', 'kpts', 'exxdiv', 'khelper', 'cell', 'nkop_chk', 'kop_npick', 'chnk_size', - )) + } def __init__(self, adc): self.verbose = adc.verbose diff --git a/pyscf/pbc/cc/kccsd_rhf.py b/pyscf/pbc/cc/kccsd_rhf.py index b2e60dd84f..4d100bdd7d 100644 --- a/pyscf/pbc/cc/kccsd_rhf.py +++ b/pyscf/pbc/cc/kccsd_rhf.py @@ -498,10 +498,10 @@ def kconserve_pmatrix(nkpts, kconserv): class RCCSD(pyscf.cc.ccsd.CCSD): max_space = getattr(__config__, 'pbc_cc_kccsd_rhf_KRCCSD_max_space', 20) - _keys = set([ + _keys = { 'kpts', 'khelper', 'ip_partition', 'ea_partition', 'max_space', 'direct', 'keep_exxdiv', - ]) + } def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): assert (isinstance(mf, scf.khf.KSCF)) diff --git a/pyscf/pbc/cc/kccsd_rhf_ksymm.py b/pyscf/pbc/cc/kccsd_rhf_ksymm.py index b83f2bdfbc..a7688bbb11 100644 --- a/pyscf/pbc/cc/kccsd_rhf_ksymm.py +++ b/pyscf/pbc/cc/kccsd_rhf_ksymm.py @@ -378,7 +378,7 @@ def energy(cc, t1, t2, eris): class KsymAdaptedRCCSD(RCCSD): - _keys = set(['kqrts', 'rmat', 'ktensor_direct', 'eris_outcore']) + _keys = {'kqrts', 'rmat', 'ktensor_direct', 'eris_outcore'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): ''' diff --git a/pyscf/pbc/cc/kccsd_uhf.py b/pyscf/pbc/cc/kccsd_uhf.py index 1c6acb8a22..fbac93bf14 100644 --- a/pyscf/pbc/cc/kccsd_uhf.py +++ b/pyscf/pbc/cc/kccsd_uhf.py @@ -639,7 +639,7 @@ class KUCCSD(uccsd.UCCSD): max_space = getattr(__config__, 'pbc_cc_kccsd_uhf_KUCCSD_max_space', 20) - _keys = set(['kpts', 'mo_energy', 'khelper', 'max_space', 'direct']) + _keys = {'kpts', 'mo_energy', 'khelper', 'max_space', 'direct'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): assert (isinstance(mf, scf.khf.KSCF)) diff --git a/pyscf/pbc/cc/kintermediates.py b/pyscf/pbc/cc/kintermediates.py index d752e90519..240550c48e 100644 --- a/pyscf/pbc/cc/kintermediates.py +++ b/pyscf/pbc/cc/kintermediates.py @@ -140,7 +140,7 @@ def cc_Wvvvv(cc,t1,t2,eris,kconserv): km = numpy.arange(nkpts).tolist() kn = kconserv[ka,km,kb].tolist() - kmn = tuple([km,kn]) + kmn = (km,kn) Wabef[ka,kb] += 0.25*einsum('xmnab,xymnef->yabef',tau.transpose(2,0,1,3,4,5,6)[ka][kmn],eris.oovv[kmn]) for ke in range(nkpts): diff --git a/pyscf/pbc/df/aft.py b/pyscf/pbc/df/aft.py index b72861a43a..2bded6e73a 100644 --- a/pyscf/pbc/df/aft.py +++ b/pyscf/pbc/df/aft.py @@ -567,9 +567,9 @@ class AFTDF(lib.StreamObject, AFTDFMixin): '''Density expansion on plane waves ''' - _keys = set(( + _keys = { 'cell', 'mesh', 'kpts', 'time_reversal_symmetry', 'blockdim', - )) + } def __init__(self, cell, kpts=np.zeros((1,3))): self.cell = cell diff --git a/pyscf/pbc/df/df.py b/pyscf/pbc/df/df.py index 8123d6748b..a03d058109 100644 --- a/pyscf/pbc/df/df.py +++ b/pyscf/pbc/df/df.py @@ -135,10 +135,10 @@ class GDF(lib.StreamObject, aft.AFTDFMixin): # If True, force using denisty matrix-based K-build force_dm_kbuild = False - _keys = set(( + _keys = { 'blockdim', 'force_dm_kbuild', 'cell', 'kpts', 'kpts_band', 'eta', 'mesh', 'exp_to_discard', 'exxdiv', 'auxcell', 'linear_dep_threshold', - )) + } def __init__(self, cell, kpts=numpy.zeros((1,3))): self.cell = cell diff --git a/pyscf/pbc/df/fft.py b/pyscf/pbc/df/fft.py index 9c24059457..8a1b982239 100644 --- a/pyscf/pbc/df/fft.py +++ b/pyscf/pbc/df/fft.py @@ -156,9 +156,9 @@ class FFTDF(lib.StreamObject): '''Density expansion on plane waves ''' - _keys = set(( + _keys = { 'cell', 'kpts', 'grids', 'mesh', 'blockdim', 'exxdiv', - )) + } def __init__(self, cell, kpts=numpy.zeros((1,3))): from pyscf.pbc.dft import gen_grid diff --git a/pyscf/pbc/df/incore.py b/pyscf/pbc/df/incore.py index 016afca89d..253250a405 100644 --- a/pyscf/pbc/df/incore.py +++ b/pyscf/pbc/df/incore.py @@ -148,10 +148,10 @@ class Int3cBuilder(lib.StreamObject): '''helper functions to compute 3-center integral tensor with double-lattice sum ''' - _keys = set(( + _keys = { 'cell', 'auxcell', 'kpts', 'rs_cell', 'bvk_kmesh', 'supmol', 'ke_cutoff', 'direct_scf_tol', - )) + } def __init__(self, cell, auxcell, kpts=None): self.cell = cell diff --git a/pyscf/pbc/df/rsdf_helper.py b/pyscf/pbc/df/rsdf_helper.py index dac891ef3b..719235e171 100644 --- a/pyscf/pbc/df/rsdf_helper.py +++ b/pyscf/pbc/df/rsdf_helper.py @@ -103,7 +103,7 @@ def remove_exp_basis(basis, amin=None, amax=None): return basisnew def _binary_search(xlo, xhi, xtol, ret_bigger, fcheck, args=None, MAX_RESCALE=5, MAX_CYCLE=20, early_exit=True): - if args is None: args = tuple() + if args is None: args = () # rescale xlo/xhi if necessary first_time = True count = 0 diff --git a/pyscf/pbc/dft/krkspu.py b/pyscf/pbc/dft/krkspu.py index 5cb550ce76..bc39a58cb3 100644 --- a/pyscf/pbc/dft/krkspu.py +++ b/pyscf/pbc/dft/krkspu.py @@ -239,7 +239,7 @@ class KRKSpU(krks.KRKS): RKSpU class adapted for PBCs with k-point sampling. """ - _keys = set(["U_idx", "U_val", "C_ao_lo", "U_lab"]) + _keys = {"U_idx", "U_val", "C_ao_lo", "U_lab"} get_veff = get_veff energy_elec = energy_elec diff --git a/pyscf/pbc/dft/kukspu.py b/pyscf/pbc/dft/kukspu.py index 6deb27590d..42b9131413 100644 --- a/pyscf/pbc/dft/kukspu.py +++ b/pyscf/pbc/dft/kukspu.py @@ -125,7 +125,7 @@ class KUKSpU(kuks.KUKS): UKSpU class adapted for PBCs with k-point sampling. """ - _keys = set(["U_idx", "U_val", "C_ao_lo", "U_lab"]) + _keys = {"U_idx", "U_val", "C_ao_lo", "U_lab"} get_veff = get_veff energy_elec = energy_elec diff --git a/pyscf/pbc/dft/multigrid.py b/pyscf/pbc/dft/multigrid.py index 248db41f75..80e72e551b 100644 --- a/pyscf/pbc/dft/multigrid.py +++ b/pyscf/pbc/dft/multigrid.py @@ -1809,7 +1809,7 @@ def _primitive_gto_cutoff(cell, precision=None): class MultiGridFFTDF(fft.FFTDF): - _keys = set(['tasks']) + _keys = {'tasks'} def __init__(self, cell, kpts=numpy.zeros((1,3))): fft.FFTDF.__init__(self, cell, kpts) diff --git a/pyscf/pbc/dft/rks.py b/pyscf/pbc/dft/rks.py index 9d8bda957b..07980e4f4f 100644 --- a/pyscf/pbc/dft/rks.py +++ b/pyscf/pbc/dft/rks.py @@ -169,7 +169,7 @@ def get_rho(mf, dm=None, grids=None, kpt=None): class KohnShamDFT(mol_ks.KohnShamDFT): '''PBC-KS''' - _keys = set(['xc', 'nlc', 'grids', 'nlcgrids', 'small_rho_cutoff']) + _keys = {'xc', 'nlc', 'grids', 'nlcgrids', 'small_rho_cutoff'} get_rho = get_rho diff --git a/pyscf/pbc/grad/krks.py b/pyscf/pbc/grad/krks.py index 8e25e917aa..efbff36708 100644 --- a/pyscf/pbc/grad/krks.py +++ b/pyscf/pbc/grad/krks.py @@ -112,7 +112,7 @@ def get_vxc(ni, cell, grids, xc_code, dms, kpts, kpts_band=None, relativity=0, h return -vmat class Gradients(rhf_grad.Gradients): - _keys = set(['grid_response', 'grids']) + _keys = {'grid_response', 'grids'} def __init__(self, mf): rhf_grad.Gradients.__init__(self, mf) diff --git a/pyscf/pbc/grad/kuks.py b/pyscf/pbc/grad/kuks.py index a8f60c7255..f859473f16 100644 --- a/pyscf/pbc/grad/kuks.py +++ b/pyscf/pbc/grad/kuks.py @@ -117,7 +117,7 @@ def get_vxc(ni, cell, grids, xc_code, dms, kpts, kpts_band=None, relativity=0, h class Gradients(uhf_grad.Gradients): '''Non-relativistic restricted Hartree-Fock gradients''' - _keys = set(['grid_response', 'grids']) + _keys = {'grid_response', 'grids'} def __init__(self, mf): uhf_grad.Gradients.__init__(self, mf) diff --git a/pyscf/pbc/gto/cell.py b/pyscf/pbc/gto/cell.py index 1b35b041f0..33891fd6c7 100644 --- a/pyscf/pbc/gto/cell.py +++ b/pyscf/pbc/gto/cell.py @@ -84,8 +84,8 @@ def unpack(celldic): def dumps(cell): '''Serialize Cell object to a JSON formatted str. ''' - exclude_keys = set(('output', 'stdout', '_keys', 'symm_orb', 'irrep_id', - 'irrep_name', 'lattice_symmetry')) + exclude_keys = {'output', 'stdout', '_keys', 'symm_orb', 'irrep_id', + 'irrep_name', 'lattice_symmetry'} celldic = dict(cell.__dict__) for k in exclude_keys: diff --git a/pyscf/pbc/gw/krgw_ac.py b/pyscf/pbc/gw/krgw_ac.py index 42487058d9..56f9eb0c72 100644 --- a/pyscf/pbc/gw/krgw_ac.py +++ b/pyscf/pbc/gw/krgw_ac.py @@ -541,10 +541,10 @@ class KRGWAC(lib.StreamObject): # Whether applying finite size corrections fc = getattr(__config__, 'gw_gw_GW_fc', True) - _keys = set([ + _keys = { 'linearized', 'ac', 'fc', 'frozen', 'mol', 'with_df', 'kpts', 'nkpts', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - ]) + } def __init__(self, mf, frozen=0): self.mol = mf.mol diff --git a/pyscf/pbc/gw/krgw_cd.py b/pyscf/pbc/gw/krgw_cd.py index 47454471c6..45e991d29b 100644 --- a/pyscf/pbc/gw/krgw_cd.py +++ b/pyscf/pbc/gw/krgw_cd.py @@ -602,10 +602,10 @@ class KRGWCD(lib.StreamObject): eta = getattr(__config__, 'gw_gw_GW_eta', 1e-3) fc = getattr(__config__, 'gw_gw_GW_fc', True) - _keys = set([ + _keys = { 'linearized', 'eta', 'fc', 'frozen', 'mol', 'with_df', 'kpts', 'nkpts', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - ]) + } def __init__(self, mf, frozen=0): self.mol = mf.mol diff --git a/pyscf/pbc/gw/kugw_ac.py b/pyscf/pbc/gw/kugw_ac.py index 1ffd715986..8481b7a343 100644 --- a/pyscf/pbc/gw/kugw_ac.py +++ b/pyscf/pbc/gw/kugw_ac.py @@ -604,10 +604,10 @@ class KUGWAC(lib.StreamObject): # Whether applying finite size corrections fc = getattr(__config__, 'gw_gw_GW_fc', True) - _keys = set([ + _keys = { 'linearized', 'ac', 'fc', 'frozen', 'mol', 'with_df', 'kpts', 'nkpts', 'mo_energy', 'mo_coeff', 'mo_occ', 'sigma', - ]) + } def __init__(self, mf, frozen=0): self.mol = mf.mol diff --git a/pyscf/pbc/lib/kpts_helper.py b/pyscf/pbc/lib/kpts_helper.py index 257bcfb13e..9deb352ec8 100644 --- a/pyscf/pbc/lib/kpts_helper.py +++ b/pyscf/pbc/lib/kpts_helper.py @@ -548,7 +548,7 @@ def build_symm_map(self, kptlist=None): kpt = tuple(kpt) kp,kq,kr = kpt if not completed[kp,kq,kr]: - self.symm_map[kpt] = list() + self.symm_map[kpt] = [] ks = self.kconserv[kp,kq,kr] completed[kp,kq,kr] = True diff --git a/pyscf/pbc/mp/kmp2.py b/pyscf/pbc/mp/kmp2.py index 5a64effee9..9b7a53b2bb 100644 --- a/pyscf/pbc/mp/kmp2.py +++ b/pyscf/pbc/mp/kmp2.py @@ -690,7 +690,7 @@ def _gamma1_intermediates(mp, t2=None): class KMP2(mp2.MP2): - _keys = set(('kpts', 'nkpts', 'khelper')) + _keys = {'kpts', 'nkpts', 'khelper'} def __init__(self, mf, frozen=None, mo_coeff=None, mo_occ=None): diff --git a/pyscf/pbc/scf/hf.py b/pyscf/pbc/scf/hf.py index 1162479431..0e10cf8ab6 100644 --- a/pyscf/pbc/scf/hf.py +++ b/pyscf/pbc/scf/hf.py @@ -504,7 +504,7 @@ class SCF(mol_hf.SCF): MDF model is favored for better accuracy. See also :mod:`pyscf.pbc.df`. ''' - _keys = set(['cell', 'exxdiv', 'with_df', 'rsjk']) + _keys = {'cell', 'exxdiv', 'with_df', 'rsjk'} init_direct_scf = lib.invalid_method('init_direct_scf') get_bands = get_bands diff --git a/pyscf/pbc/scf/khf.py b/pyscf/pbc/scf/khf.py index f8e3310f75..8a1ffd4a99 100644 --- a/pyscf/pbc/scf/khf.py +++ b/pyscf/pbc/scf/khf.py @@ -419,7 +419,7 @@ class KSCF(pbchf.SCF): ''' conv_tol_grad = getattr(__config__, 'pbc_scf_KSCF_conv_tol_grad', None) - _keys = set(['cell', 'exx_built', 'exxdiv', 'with_df', 'rsjk']) + _keys = {'cell', 'exx_built', 'exxdiv', 'with_df', 'rsjk'} reset = pbchf.SCF.reset mol = pbchf.SCF.mol diff --git a/pyscf/pbc/scf/khf_ksymm.py b/pyscf/pbc/scf/khf_ksymm.py index cdefdea11f..baaf5543a6 100644 --- a/pyscf/pbc/scf/khf_ksymm.py +++ b/pyscf/pbc/scf/khf_ksymm.py @@ -134,7 +134,7 @@ class KsymAdaptedKSCF(khf.KSCF): KRHF with k-point symmetry """ - _keys = set(['use_ao_symmetry']) + _keys = {'use_ao_symmetry'} get_occ = get_occ get_rho = get_rho diff --git a/pyscf/pbc/scf/kuhf.py b/pyscf/pbc/scf/kuhf.py index c6774580b0..5ba1905d01 100644 --- a/pyscf/pbc/scf/kuhf.py +++ b/pyscf/pbc/scf/kuhf.py @@ -369,7 +369,7 @@ class KUHF(khf.KSCF, pbcuhf.UHF): ''' conv_tol_grad = getattr(__config__, 'pbc_scf_KSCF_conv_tol_grad', None) - _keys = set(["init_guess_breaksym"]) + _keys = {"init_guess_breaksym"} init_guess_by_1e = pbcuhf.UHF.init_guess_by_1e init_guess_by_minao = pbcuhf.UHF.init_guess_by_minao diff --git a/pyscf/pbc/scf/rsjk.py b/pyscf/pbc/scf/rsjk.py index ece2b86c98..604b941504 100644 --- a/pyscf/pbc/scf/rsjk.py +++ b/pyscf/pbc/scf/rsjk.py @@ -50,12 +50,12 @@ INDEX_MIN = rsdf_builder.INDEX_MIN class RangeSeparatedJKBuilder(lib.StreamObject): - _keys = set(( + _keys = { 'cell', 'mesh', 'kpts', 'purify', 'omega', 'rs_cell', 'cell_d', 'bvk_kmesh', 'supmol_sr', 'supmol_ft', 'supmol_d', 'cell0_basis_mask', 'ke_cutoff', 'direct_scf_tol', 'time_reversal_symmetry', 'exclude_dd_block', 'allow_drv_nodddd', 'approx_vk_lr_missing_mo', - )) + } def __init__(self, cell, kpts=np.zeros((1,3))): self.cell = cell diff --git a/pyscf/pbc/scf/uhf.py b/pyscf/pbc/scf/uhf.py index e1c3e7e00d..beb9bce956 100644 --- a/pyscf/pbc/scf/uhf.py +++ b/pyscf/pbc/scf/uhf.py @@ -107,7 +107,7 @@ def dip_moment(cell, dm, unit='Debye', verbose=logger.NOTE, class UHF(pbchf.SCF, mol_uhf.UHF): '''UHF class for PBCs. ''' - _keys = set(["init_guess_breaksym"]) + _keys = {"init_guess_breaksym"} init_guess_by_minao = mol_uhf.UHF.init_guess_by_minao init_guess_by_atom = mol_uhf.UHF.init_guess_by_atom diff --git a/pyscf/pbc/tdscf/krhf.py b/pyscf/pbc/tdscf/krhf.py index ceefbfd5de..efcbb968c7 100644 --- a/pyscf/pbc/tdscf/krhf.py +++ b/pyscf/pbc/tdscf/krhf.py @@ -38,7 +38,7 @@ REAL_EIG_THRESHOLD = getattr(__config__, 'pbc_tdscf_rhf_TDDFT_pick_eig_threshold', 1e-3) class KTDBase(TDBase): - _keys = set(['kconserv', 'kshift_lst']) + _keys = {'kconserv', 'kshift_lst'} def __init__(self, mf, kshift_lst=None): assert isinstance(mf, scf.khf.KSCF) diff --git a/pyscf/pbc/tdscf/rhf.py b/pyscf/pbc/tdscf/rhf.py index 4e3a39a3a5..9a311849b7 100644 --- a/pyscf/pbc/tdscf/rhf.py +++ b/pyscf/pbc/tdscf/rhf.py @@ -26,7 +26,7 @@ from pyscf import __config__ class TDBase(rhf.TDBase): - _keys = set(['cell']) + _keys = {'cell'} def __init__(self, mf): rhf.TDBase.__init__(self, mf) diff --git a/pyscf/pbc/tdscf/test/test_common.py b/pyscf/pbc/tdscf/test/test_common.py index 5485e82e2f..a55ac53662 100644 --- a/pyscf/pbc/tdscf/test/test_common.py +++ b/pyscf/pbc/tdscf/test/test_common.py @@ -206,7 +206,7 @@ def adjust_td_phase(model1, model2, threshold=1e-5): m1, m2 = m1[o1, :], m2[o2, :] if common_space is not None: - space = list(common_space[i] if i is not None else common_space for i in space) + space = [common_space[i] if i is not None else common_space for i in space] s1, s2 = space m1 = m1[:, s1] m2 = m2[:, s2] diff --git a/pyscf/pbc/x2c/sfx2c1e.py b/pyscf/pbc/x2c/sfx2c1e.py index cd1b1a26c2..6a9df7d910 100644 --- a/pyscf/pbc/x2c/sfx2c1e.py +++ b/pyscf/pbc/x2c/sfx2c1e.py @@ -82,7 +82,7 @@ class SFX2C1E_SCF(x2c._X2C_SCF): __name_mixin__ = 'sfX2C1e' - _keys = set(['with_x2c']) + _keys = {'with_x2c'} def __init__(self, mf): self.__dict__.update(mf.__dict__) diff --git a/pyscf/pbc/x2c/x2c1e.py b/pyscf/pbc/x2c/x2c1e.py index a255b93c53..69a8ca66f7 100644 --- a/pyscf/pbc/x2c/x2c1e.py +++ b/pyscf/pbc/x2c/x2c1e.py @@ -84,7 +84,7 @@ class X2C1E_GSCF(x2c._X2C_SCF): __name_mixin__ = 'X2C1e' - _keys = set(['with_x2c']) + _keys = {'with_x2c'} def __init__(self, mf): self.__dict__.update(mf.__dict__) diff --git a/pyscf/qmmm/itrf.py b/pyscf/qmmm/itrf.py index e11f10ae00..3bb79202fb 100644 --- a/pyscf/qmmm/itrf.py +++ b/pyscf/qmmm/itrf.py @@ -116,7 +116,7 @@ class QMMM: _QMMM = QMMM class QMMMSCF(QMMM): - _keys = set(['mm_mol']) + _keys = {'mm_mol'} def __init__(self, method, mm_mol=None): self.__dict__.update(method.__dict__) diff --git a/pyscf/scf/addons.py b/pyscf/scf/addons.py index 082d8662a2..9fc887db5d 100644 --- a/pyscf/scf/addons.py +++ b/pyscf/scf/addons.py @@ -89,9 +89,9 @@ class _SmearingSCF: __name_mixin__ = 'Smearing' - _keys = set([ + _keys = { 'sigma', 'smearing_method', 'mu0', 'fix_spin', 'entropy', 'e_free', 'e_zero' - ]) + } def __init__(self, mf, sigma, method, mu0, fix_spin): self.__dict__.update(mf.__dict__) diff --git a/pyscf/scf/atom_hf.py b/pyscf/scf/atom_hf.py index aac6e44316..58e0a585c3 100644 --- a/pyscf/scf/atom_hf.py +++ b/pyscf/scf/atom_hf.py @@ -25,7 +25,7 @@ def get_atm_nrhf(mol, atomic_configuration=elements.NRSRHF_CONFIGURATION): - elements = set([a[0] for a in mol._atom]) + elements = {a[0] for a in mol._atom} logger.info(mol, 'Spherically averaged atomic HF for %s', elements) atm_template = mol.copy(deep=False) diff --git a/pyscf/scf/atom_ks.py b/pyscf/scf/atom_ks.py index d259a0968d..dee2382f7e 100644 --- a/pyscf/scf/atom_ks.py +++ b/pyscf/scf/atom_ks.py @@ -25,7 +25,7 @@ from pyscf.dft import rks def get_atm_nrks(mol, atomic_configuration=elements.NRSRHFS_CONFIGURATION, xc='slater', grid=(100, 434)): - elements = set([a[0] for a in mol._atom]) + elements = {a[0] for a in mol._atom} logger.info(mol, 'Spherically averaged atomic KS for %s', elements) atm_template = mol.copy(deep=False) diff --git a/pyscf/scf/dhf.py b/pyscf/scf/dhf.py index a939973362..32d2d0f7f2 100644 --- a/pyscf/scf/dhf.py +++ b/pyscf/scf/dhf.py @@ -453,8 +453,8 @@ class DHF(hf.SCF): # corrections for small component when with_ssss is set to False ssss_approx = getattr(__config__, 'scf_dhf_SCF_ssss_approx', 'Visscher') - _keys = set(('conv_tol', 'with_ssss', 'with_gaunt', - 'with_breit', 'ssss_approx', 'opt')) + _keys = {'conv_tol', 'with_ssss', 'with_gaunt', + 'with_breit', 'ssss_approx', 'opt'} def __init__(self, mol): hf.SCF.__init__(self, mol) diff --git a/pyscf/scf/ghf.py b/pyscf/scf/ghf.py index 408cc058b1..de759ea0ca 100644 --- a/pyscf/scf/ghf.py +++ b/pyscf/scf/ghf.py @@ -382,7 +382,7 @@ class GHF(hf.SCF): mo_coeff[nao:nao*2] are the coefficients of AO with beta spin. ''' - _keys = set(['with_soc']) + _keys = {'with_soc'} get_init_guess = hf.RHF.get_init_guess get_occ = get_occ diff --git a/pyscf/scf/ghf_symm.py b/pyscf/scf/ghf_symm.py index 836854b808..26d7aed985 100644 --- a/pyscf/scf/ghf_symm.py +++ b/pyscf/scf/ghf_symm.py @@ -97,7 +97,7 @@ class SymAdaptedGHF(ghf.GHF): occupancy based on the orbital energies. ''' - _keys = set(['irrep_nelec']) + _keys = {'irrep_nelec'} def __init__(self, mol): ghf.GHF.__init__(self, mol) diff --git a/pyscf/scf/hf.py b/pyscf/scf/hf.py index 6526331ac1..9f6361b763 100644 --- a/pyscf/scf/hf.py +++ b/pyscf/scf/hf.py @@ -427,8 +427,8 @@ def minao_basis(symb, nelec_ecp): 'elements. "atom" initial guess is used.') return init_guess_by_atom(mol) - nelec_ecp_dic = dict([(mol.atom_symbol(ia), mol.atom_nelec_core(ia)) - for ia in range(mol.natm)]) + nelec_ecp_dic = {mol.atom_symbol(ia): mol.atom_nelec_core(ia) + for ia in range(mol.natm)} basis = {} occdic = {} @@ -1472,14 +1472,14 @@ class SCF(lib.StreamObject): callback = None - _keys = set(( + _keys = { 'conv_tol', 'conv_tol_grad', 'max_cycle', 'init_guess', 'DIIS', 'diis', 'diis_space', 'diis_start_cycle', 'diis_file', 'diis_space_rollback', 'damp', 'level_shift', 'direct_scf', 'direct_scf_tol', 'conv_check', 'callback', 'mol', 'chkfile', 'mo_energy', 'mo_coeff', 'mo_occ', 'e_tot', 'converged', 'scf_summary', 'opt', - )) + } def __init__(self, mol): if not mol._built: diff --git a/pyscf/scf/hf_symm.py b/pyscf/scf/hf_symm.py index 0e1c07e4a8..0567481779 100644 --- a/pyscf/scf/hf_symm.py +++ b/pyscf/scf/hf_symm.py @@ -140,8 +140,8 @@ def get_irrep_nelec(mol, mo_coeff, mo_occ, s=None): {'A1': 6, 'A2': 0, 'B1': 2, 'B2': 2} ''' orbsym = get_orbsym(mol, mo_coeff, s, False) - irrep_nelec = dict([(mol.irrep_name[k], int(sum(mo_occ[orbsym==ir]))) - for k, ir in enumerate(mol.irrep_id)]) + irrep_nelec = {mol.irrep_name[k]: int(sum(mo_occ[orbsym==ir])) + for k, ir in enumerate(mol.irrep_id)} return irrep_nelec def canonicalize(mf, mo_coeff, mo_occ, fock=None): @@ -435,7 +435,7 @@ class SymAdaptedRHF(hf.RHF): {'A1': 6, 'A2': 2, 'B1': 2, 'B2': 0} ''' - _keys = set(['irrep_nelec']) + _keys = {'irrep_nelec'} def __init__(self, mol): hf.RHF.__init__(self, mol) @@ -599,7 +599,7 @@ class SymAdaptedROHF(rohf.ROHF): {'A1': (3, 3), 'A2': (0, 0), 'B1': (1, 0), 'B2': (1, 1)} ''' - _keys = set(['irrep_nelec']) + _keys = {'irrep_nelec'} def __init__(self, mol): rohf.ROHF.__init__(self, mol) diff --git a/pyscf/scf/uhf.py b/pyscf/scf/uhf.py index b5a16fc943..b89758d229 100644 --- a/pyscf/scf/uhf.py +++ b/pyscf/scf/uhf.py @@ -768,7 +768,7 @@ class UHF(hf.SCF): S^2 = 0.7570150, 2S+1 = 2.0070027 ''' - _keys = set(["init_guess_breaksym"]) + _keys = {"init_guess_breaksym"} def __init__(self, mol): hf.SCF.__init__(self, mol) diff --git a/pyscf/scf/uhf_symm.py b/pyscf/scf/uhf_symm.py index 2ff31b271b..9f82861201 100644 --- a/pyscf/scf/uhf_symm.py +++ b/pyscf/scf/uhf_symm.py @@ -179,9 +179,9 @@ def get_irrep_nelec(mol, mo_coeff, mo_occ, s=None): mo_coeff[1], s, False) orbsyma = numpy.array(orbsyma) orbsymb = numpy.array(orbsymb) - irrep_nelec = dict([(mol.irrep_name[k], (int(sum(mo_occ[0][orbsyma==ir])), - int(sum(mo_occ[1][orbsymb==ir])))) - for k, ir in enumerate(mol.irrep_id)]) + irrep_nelec = {mol.irrep_name[k]: (int(sum(mo_occ[0][orbsyma==ir])), + int(sum(mo_occ[1][orbsymb==ir]))) + for k, ir in enumerate(mol.irrep_id)} return irrep_nelec def canonicalize(mf, mo_coeff, mo_occ, fock=None): @@ -309,7 +309,7 @@ class SymAdaptedUHF(uhf.UHF): {'A1': (3, 3), 'A2': (0, 0), 'B1': (1, 0), 'B2': (1, 1)} ''' - _keys = set(['irrep_nelec']) + _keys = {'irrep_nelec'} def __init__(self, mol): uhf.UHF.__init__(self, mol) diff --git a/pyscf/sgx/sgx.py b/pyscf/sgx/sgx.py index e8c84c0084..25f05e2e9e 100644 --- a/pyscf/sgx/sgx.py +++ b/pyscf/sgx/sgx.py @@ -94,9 +94,9 @@ class _SGXHF: __name_mixin__ = 'SGX' - _keys = set([ + _keys = { 'auxbasis', 'with_df', 'direct_scf_sgx', 'rebuild_nsteps' - ]) + } def __init__(self, mf, df=None, auxbasis=None): self.__dict__.update(mf.__dict__) @@ -247,11 +247,11 @@ def _make_opt(mol, pjs=False, class SGX(lib.StreamObject): - _keys = set(( + _keys = { 'mol', 'grids_thrd', 'grids_level_i', 'grids_level_f', 'grids_switch_thrd', 'dfj', 'direct_j', 'pjs', 'debug', 'grids', 'blockdim', 'auxmol', - )) + } def __init__(self, mol, auxbasis=None, pjs=False): self.mol = mol diff --git a/pyscf/solvent/_attach_solvent.py b/pyscf/solvent/_attach_solvent.py index 5cd357705d..aeda9da86c 100644 --- a/pyscf/solvent/_attach_solvent.py +++ b/pyscf/solvent/_attach_solvent.py @@ -51,7 +51,7 @@ class _Solvation: pass class SCFWithSolvent(_Solvation): - _keys = set(['with_solvent']) + _keys = {'with_solvent'} def __init__(self, mf, solvent): self.__dict__.update(mf.__dict__) @@ -166,7 +166,7 @@ def _for_casscf(mc, solvent_obj, dm=None): return lib.set_class(sol_cas, (CASSCFWithSolvent, mc.__class__), name) class CASSCFWithSolvent(_Solvation): - _keys = set(['with_solvent']) + _keys = {'with_solvent'} def __init__(self, mc, solvent): self.__dict__.update(mc.__dict__) @@ -304,7 +304,7 @@ def _for_casci(mc, solvent_obj, dm=None): return lib.set_class(sol_mc, (CASCIWithSolvent, mc.__class__), name) class CASCIWithSolvent(_Solvation): - _keys = set(['with_solvent']) + _keys = {'with_solvent'} def __init__(self, mc, solvent): self.__dict__.update(mc.__dict__) @@ -580,7 +580,7 @@ def _for_tdscf(method, solvent_obj, dm=None): return lib.set_class(sol_td, (TDSCFWithSolvent, method.__class__), name) class TDSCFWithSolvent(_Solvation): - _keys = set(['with_solvent']) + _keys = {'with_solvent'} def __init__(self, method, scf_with_solvent): self.__dict__.update(method.__dict__) diff --git a/pyscf/solvent/_ddcosmo_tdscf_grad.py b/pyscf/solvent/_ddcosmo_tdscf_grad.py index 95b09b534f..03a34cd097 100644 --- a/pyscf/solvent/_ddcosmo_tdscf_grad.py +++ b/pyscf/solvent/_ddcosmo_tdscf_grad.py @@ -59,7 +59,7 @@ def make_grad_object(grad_method): (WithSolventGrad, grad_method.__class__), name) class WithSolventGrad: - _keys = set(['de_solvent', 'de_solute']) + _keys = {'de_solvent', 'de_solute'} def __init__(self, grad_method): self.__dict__.update(grad_method.__dict__) diff --git a/pyscf/solvent/ddcosmo.py b/pyscf/solvent/ddcosmo.py index f3150e27f1..80a4a6d8de 100644 --- a/pyscf/solvent/ddcosmo.py +++ b/pyscf/solvent/ddcosmo.py @@ -619,11 +619,11 @@ def atoms_with_vdw_overlap(atm_id, atom_coords, r_vdw): return atoms_nearby class ddCOSMO(lib.StreamObject): - _keys = set(( + _keys = { 'mol', 'radii_table', 'atom_radii', 'lebedev_order', 'lmax', 'eta', 'eps', 'grids', 'max_cycle', 'conv_tol', 'state_id', 'frozen', 'equilibrium_solvation', 'e', 'v', - )) + } def __init__(self, mol): self.mol = mol diff --git a/pyscf/solvent/ddcosmo_grad.py b/pyscf/solvent/ddcosmo_grad.py index f692a5a013..289fae201d 100644 --- a/pyscf/solvent/ddcosmo_grad.py +++ b/pyscf/solvent/ddcosmo_grad.py @@ -63,7 +63,7 @@ def make_grad_object(grad_method): (WithSolventGrad, grad_method.__class__), name) class WithSolventGrad: - _keys = set(['de_solvent', 'de_solute']) + _keys = {'de_solvent', 'de_solute'} def __init__(self, grad_method): self.__dict__.update(grad_method.__dict__) diff --git a/pyscf/solvent/pol_embed.py b/pyscf/solvent/pol_embed.py index d8f397a0c9..3b3ec7652c 100644 --- a/pyscf/solvent/pol_embed.py +++ b/pyscf/solvent/pol_embed.py @@ -152,11 +152,11 @@ def _get_element_row(symbol): class PolEmbed(lib.StreamObject): - _keys = set(( + _keys = { 'mol', 'max_cycle', 'conv_tol', 'state_id', 'frozen', 'equilibrium_solvation', 'options', 'do_ecp', 'eef', 'cppe_state', 'potentials', 'V_es', 'ecpmol', 'e', 'v', - )) + } def __init__(self, mol, options_or_potfile): self.mol = mol diff --git a/pyscf/soscf/newton_ah.py b/pyscf/soscf/newton_ah.py index 45a8071d40..0347eb7517 100644 --- a/pyscf/soscf/newton_ah.py +++ b/pyscf/soscf/newton_ah.py @@ -286,7 +286,7 @@ def gen_g_hop_dhf(mf, mo_coeff, mo_occ, fock_ao=None, h1e=None, # Dual basis for gradients and hessian def project_mol(mol, dual_basis={}): from pyscf import df - uniq_atoms = set([a[0] for a in mol._atom]) + uniq_atoms = {a[0] for a in mol._atom} newbasis = {} for symb in uniq_atoms: if gto.charge(symb) <= 10: @@ -644,11 +644,11 @@ class _CIAH_SOSCF: kf_interval = getattr(__config__, 'soscf_newton_ah_SOSCF_kf_interval', 4) kf_trust_region = getattr(__config__, 'soscf_newton_ah_SOSCF_kf_trust_region', 5) - _keys = set(( + _keys = { 'max_cycle_inner', 'max_stepsize', 'canonicalization', 'ah_start_tol', 'ah_start_cycle', 'ah_level_shift', 'ah_conv_tol', 'ah_lindep', 'ah_max_cycle', 'ah_grad_trust_region', 'kf_interval', 'kf_trust_region', - )) + } def __init__(self, mf): self.__dict__.update(mf.__dict__) @@ -972,7 +972,7 @@ def _force_SO3_degeneracy_(dr, orbsym): def _force_Ex_Ey_degeneracy_(dr, orbsym): '''Force the Ex and Ey orbitals to use the same rotation matrix''' # 0,1,4,5 are 1D irreps - E_irrep_ids = set(orbsym).difference(set((0,1,4,5))) + E_irrep_ids = set(orbsym).difference({0,1,4,5}) orbsym = numpy.asarray(orbsym) for ir in E_irrep_ids: diff --git a/pyscf/symm/basis.py b/pyscf/symm/basis.py index 321fa5bbf9..1ad6bb34fc 100644 --- a/pyscf/symm/basis.py +++ b/pyscf/symm/basis.py @@ -300,7 +300,7 @@ def _num_contract(basis): 'i+5': 622, 'i+6': 630, } -_SO3_ID2SYMB = dict([(v, k) for k, v in _SO3_SYMB2ID.items()]) +_SO3_ID2SYMB = {v: k for k, v in _SO3_SYMB2ID.items()} _ANGULAR = 'spdfghiklmnortu' def so3_irrep_symb2id(symb): diff --git a/pyscf/tdscf/common_slow.py b/pyscf/tdscf/common_slow.py index 513d3eb9e0..6f509b4ca6 100644 --- a/pyscf/tdscf/common_slow.py +++ b/pyscf/tdscf/common_slow.py @@ -164,7 +164,7 @@ def __check_primary_form__(m): raise ValueError("Empty tuple returned by `tdhf_primary_form`") if not isinstance(m[0], (str, unicode)): raise ValueError("The first item returned by `tdhf_primary_form` must be a string") - forms = dict(ab=3, mk=3, full=2) + forms = {"ab": 3, "mk": 3, "full": 2} if m[0] in forms: if len(m) != forms[m[0]]: raise ValueError("The {} form returned by `tdhf_primary_form` must contain {:d} values".format( @@ -329,7 +329,7 @@ def eri_mknj(self, item, *args): def __getitem__(self, item): if isinstance(item, str): - spec, args = item, tuple() + spec, args = item, () else: spec, args = item[0], item[1:] if set(spec) == set("mknj"): diff --git a/pyscf/tdscf/rhf.py b/pyscf/tdscf/rhf.py index 9dc2230e80..265d37d110 100644 --- a/pyscf/tdscf/rhf.py +++ b/pyscf/tdscf/rhf.py @@ -652,10 +652,10 @@ class TDBase(lib.StreamObject): # Threshold to handle degeneracy in init guess deg_eia_thresh = getattr(__config__, 'tdscf_rhf_TDDFT_deg_eia_thresh', 1e-3) - _keys = set(( + _keys = { 'conv_tol', 'nstates', 'singlet', 'lindep', 'level_shift', 'max_space', 'max_cycle', 'mol', 'chkfile', 'wfnsym', 'converged', 'e', 'xy', - )) + } def __init__(self, mf): self.verbose = mf.verbose diff --git a/pyscf/x2c/sfx2c1e.py b/pyscf/x2c/sfx2c1e.py index c4d6cf8dc8..6b6d8f8334 100644 --- a/pyscf/x2c/sfx2c1e.py +++ b/pyscf/x2c/sfx2c1e.py @@ -76,7 +76,7 @@ class SFX2C1E_SCF(x2c._X2C_SCF): __name_mixin__ = 'sfX2C1e' - _keys = set(['with_x2c']) + _keys = {'with_x2c'} def __init__(self, mf): self.__dict__.update(mf.__dict__) diff --git a/pyscf/x2c/x2c.py b/pyscf/x2c/x2c.py index de9ba596bd..bd2eee5fed 100644 --- a/pyscf/x2c/x2c.py +++ b/pyscf/x2c/x2c.py @@ -453,7 +453,7 @@ def get_init_guess(mol, key='minao'): class SCF(hf.SCF): '''The full X2C problem (scaler + soc terms) in j-adapted spinor basis''' - _keys = set(['with_x2c']) + _keys = {'with_x2c'} def __init__(self, mol): hf.SCF.__init__(self, mol) @@ -733,7 +733,7 @@ class X2C1E_GSCF(_X2C_SCF): __name_mixin__ = 'X2C1e' - _keys = set(['with_x2c']) + _keys = {'with_x2c'} def __init__(self, mf): self.__dict__.update(mf.__dict__)