Skip to content

BUG: localize function does not work with SVD method #190

Description

@kzsigmond

Describe the problem:

Localizing the orbitals with fanpy.interface.pyscf_tools.localize and providing method=svd results in an error.

Code that reproduces the bug:

from fanpy.interface.pyscf_tools import localize

name = "data/data_h2.xyz"
# method options: None, SVD, iao, boys, pm, er
result = localize(name, "sto-6g", method='svd')
print(result["t_ab_mo"])

The xyz file is from tests/data

Traceback error:

converged SCF energy = -0.900206370773928
converged SCF energy = -0.900206370773927
pyscf mo energies: [-0.75482456  1.19029906]
computed mo energies: [-0.75482456  1.19029906]
pyscf hf electronic energy: -2.2479152656526336
computed hf electronic energy: -2.2479152656526336
Traceback (most recent call last):
  File "/home/quintana/Documents/code/Fanpy/tests/test_calc.py", line 5, in <module>
    result = localize(name, "sto-6g", method='svd')
  File "/home/quintana/Documents/code/Fanpy/fanpy/interface/pyscf_tools.py", line 427, in localize
    minao_inds = np.array([system_inds[int(re.search(r'^(\d+)\s+', label).group(1))] for label in minao_labels])
  File "/home/quintana/Documents/code/Fanpy/fanpy/interface/pyscf_tools.py", line 427, in <listcomp>
    minao_inds = np.array([system_inds[int(re.search(r'^(\d+)\s+', label).group(1))] for label in minao_labels])
TypeError: 'NoneType' object is not subscriptable

Package versions:

python: 3.10
fanpy: N/A
numpy: 1.26.4

Additonal comments

The other methods have a similar issue. If one of the inputs is required (e.g. system inds, etc.), localize should raise an error sooner.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions