Skip to content

Commit

Permalink
Update Mole and Cell for the hasattr error in to_gpu and to_cpu methods
Browse files Browse the repository at this point in the history
  • Loading branch information
sunqm committed Dec 16, 2023
1 parent 37be001 commit e3ea7d1
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 7 deletions.
1 change: 0 additions & 1 deletion pyscf/dft/rks.py
Original file line number Diff line number Diff line change
Expand Up @@ -539,5 +539,4 @@ def to_gpu(self):
obj = lib.to_gpu(hf.SCF.reset(self.view(RKS)))
# Attributes only defined in gpu4pyscf.RKS
obj.screen_tol = 1e-14
obj.disp = None
return obj
1 change: 0 additions & 1 deletion pyscf/dft/uks.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,4 @@ def to_gpu(self):
obj = lib.to_gpu(SCF.reset(self.view(UKS)))
# Attributes only defined in gpu4pyscf.RKS
obj.screen_tol = 1e-14
obj.disp = None
return obj
6 changes: 4 additions & 2 deletions pyscf/gto/mole.py
Original file line number Diff line number Diff line change
Expand Up @@ -3700,7 +3700,7 @@ def __getattr__(self, key):
'_repr_mimebundle_'):
# https://github.com/mewwts/addict/issues/26
# https://github.com/jupyter/notebook/issues/2014
raise AttributeError
raise AttributeError(f'Mole object has no attribute {key}')

# Import all available modules. Some methods are registered to other
# classes/modules when importing modules in __all__.
Expand All @@ -3721,8 +3721,10 @@ def __getattr__(self, key):
if xc in dft.XC:
mf.xc = xc
key = 'TDDFT'
else:
elif 'CI' in key or 'CC' in key or 'CAS' in key or 'MP' in key:
mf = scf.HF(self)
else:
raise AttributeError(f'Mole object has no attribute {key}')

method = getattr(mf, key)

Expand Down
10 changes: 7 additions & 3 deletions pyscf/pbc/gto/cell.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,7 +971,7 @@ def __getattr__(self, key):
'_repr_mimebundle_'):
# https://github.com/mewwts/addict/issues/26
# https://github.com/jupyter/notebook/issues/2014
raise AttributeError
raise AttributeError(f'Cell object has no attribute {key}')

# Import all available modules. Some methods are registered to other
# classes/modules when importing modules in __all__.
Expand All @@ -994,8 +994,10 @@ def __getattr__(self, key):
if xc in XC:
mf.xc = xc
key = 'KTDDFT'
else:
elif 'CI' in key or 'CC' in key or 'MP' in key:
mf = scf.KHF(self)
else:
raise AttributeError(f'Cell object has no attribute {key}')
# Remove prefix 'K' because methods are registered without the leading 'K'
key = key[1:]
else:
Expand All @@ -1008,8 +1010,10 @@ def __getattr__(self, key):
if xc in XC:
mf.xc = xc
key = 'TDDFT'
else:
elif 'CI' in key or 'CC' in key or 'MP' in key:
mf = scf.HF(self)
else:
raise AttributeError(f'Cell object has no attribute {key}')

method = getattr(mf, key)

Expand Down

0 comments on commit e3ea7d1

Please sign in to comment.