From 3a72148989d115c65b669dc0d1d4711bf7342469 Mon Sep 17 00:00:00 2001 From: Qiming Sun Date: Mon, 4 Nov 2024 07:59:10 -0800 Subject: [PATCH] Integer overflow due to the type casting issue in numpy-2.0 (fix #2481) --- pyscf/ao2mo/_ao2mo.py | 2 +- pyscf/df/incore.py | 2 +- pyscf/df/outcore.py | 4 ++-- pyscf/gto/moleintor.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/pyscf/ao2mo/_ao2mo.py b/pyscf/ao2mo/_ao2mo.py index d01ad14229..83a899eb16 100644 --- a/pyscf/ao2mo/_ao2mo.py +++ b/pyscf/ao2mo/_ao2mo.py @@ -73,7 +73,7 @@ def nr_e1fill(intor, sh_range, atm, bas, env, natm = ctypes.c_int(c_atm.shape[0]) nbas = ctypes.c_int(c_bas.shape[0]) ao_loc = make_loc(bas, intor) - nao = ao_loc[-1] + nao = int(ao_loc[-1]) klsh0, klsh1, nkl = sh_range diff --git a/pyscf/df/incore.py b/pyscf/df/incore.py index f1497fa5c6..8710b5ade3 100644 --- a/pyscf/df/incore.py +++ b/pyscf/df/incore.py @@ -155,7 +155,7 @@ def cholesky_eri(mol, auxbasis='weigend+etb', auxmol=None, atm, bas, env = gto.mole.conc_env(mol._atm, mol._bas, mol._env, auxmol._atm, auxmol._bas, auxmol._env) ao_loc = gto.moleintor.make_loc(bas, int3c) - nao = ao_loc[mol.nbas] + nao = int(ao_loc[mol.nbas]) if aosym == 's1': nao_pair = nao * nao diff --git a/pyscf/df/outcore.py b/pyscf/df/outcore.py index 5872d61f9a..98c8f5be17 100644 --- a/pyscf/df/outcore.py +++ b/pyscf/df/outcore.py @@ -146,8 +146,8 @@ def cholesky_eri_b(mol, erifile, auxbasis='weigend+etb', dataname='j3c', atm, bas, env = gto.mole.conc_env(mol._atm, mol._bas, mol._env, auxmol._atm, auxmol._bas, auxmol._env) ao_loc = gto.moleintor.make_loc(bas, int3c) - nao = ao_loc[mol.nbas] - naoaux = ao_loc[-1] - nao + nao = int(ao_loc[mol.nbas]) + naoaux = int(ao_loc[-1] - nao) if aosym == 's1': nao_pair = nao * nao buflen = min(max(int(max_memory*.24e6/8/naoaux/comp), 1), nao_pair) diff --git a/pyscf/gto/moleintor.py b/pyscf/gto/moleintor.py index 4c6a4ce8cf..6072e89f0c 100644 --- a/pyscf/gto/moleintor.py +++ b/pyscf/gto/moleintor.py @@ -594,7 +594,7 @@ def getints4c(intor_name, atm, bas, env, shls_slice=None, comp=1, if aosym == 's8': assert (shls_slice is None) from pyscf.scf import _vhf - nao = ao_loc[-1] + nao = int(ao_loc[-1]) nao_pair = nao*(nao+1)//2 out = numpy.ndarray((nao_pair*(nao_pair+1)//2), buffer=out) if nao_pair == 0: