Skip to content

Commit

Permalink
Linting
Browse files Browse the repository at this point in the history
  • Loading branch information
obackhouse committed Sep 29, 2023
1 parent 41ca96f commit 7113108
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
14 changes: 10 additions & 4 deletions ebcc/cderis.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Cholesky decomposed ERI containers."""

import numpy as np

from pyscf import ao2mo

from ebcc import util
Expand Down Expand Up @@ -85,10 +84,17 @@ def __getattr__(self, key):
coeffs = []
for i, k in enumerate(key):
coeffs.append(self.mo_coeff[i][:, self.slices[i][k]])
ijslice = (0, coeffs[0].shape[-1], coeffs[0].shape[-1], coeffs[0].shape[-1] + coeffs[1].shape[-1])
ijslice = (
0,
coeffs[0].shape[-1],
coeffs[0].shape[-1],
coeffs[0].shape[-1] + coeffs[1].shape[-1],
)
coeffs = np.concatenate(coeffs, axis=1)
block = ao2mo._ao2mo.nr_e2(self.mf.with_df._cderi, coeffs, ijslice, aosym="s2", mosym="s1")
block = block.reshape(-1, ijslice[1]-ijslice[0], ijslice[3]-ijslice[2])
block = ao2mo._ao2mo.nr_e2(
self.mf.with_df._cderi, coeffs, ijslice, aosym="s2", mosym="s1"
)
block = block.reshape(-1, ijslice[1] - ijslice[0], ijslice[3] - ijslice[2])
self.__dict__[key] = block
return self.__dict__[key]
else:
Expand Down
10 changes: 7 additions & 3 deletions ebcc/rebcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
from ebcc import default_log, init_logging, reom, util
from ebcc.ansatz import Ansatz
from ebcc.brueckner import BruecknerREBCC
from ebcc.cderis import RCDERIs
from ebcc.dump import Dump
from ebcc.eris import RERIs
from ebcc.fock import RFock
from ebcc.cderis import RCDERIs
from ebcc.space import Space


Expand Down Expand Up @@ -271,7 +271,9 @@ def __init__(
if isinstance(ansatz, Ansatz):
self.ansatz = ansatz
else:
self.ansatz = Ansatz.from_string(ansatz, density_fitting=getattr(self.mf, "with_df", None) is not None)
self.ansatz = Ansatz.from_string(
ansatz, density_fitting=getattr(self.mf, "with_df", None) is not None
)
self._eqns = self.ansatz._get_eqns(self.spin_type)

# Space:
Expand Down Expand Up @@ -1944,7 +1946,9 @@ def get_eris(self, eris=None):
using `self.ERIs()`.
"""
if (eris is None) or isinstance(eris, np.ndarray):
if (isinstance(eris, np.ndarray) and eris.ndim == 3) or getattr(self.mf, "with_df", None):
if (isinstance(eris, np.ndarray) and eris.ndim == 3) or getattr(
self.mf, "with_df", None
):
return self.CDERIs(self, array=eris)
else:
return self.ERIs(self, array=eris)
Expand Down
6 changes: 4 additions & 2 deletions ebcc/uebcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

from ebcc import rebcc, ueom, util
from ebcc.brueckner import BruecknerUEBCC
from ebcc.cderis import UCDERIs
from ebcc.eris import UERIs
from ebcc.fock import UFock
from ebcc.cderis import UCDERIs
from ebcc.space import Space


Expand Down Expand Up @@ -475,7 +475,9 @@ def get_eris(self, eris=None):
using `self.ERIs()`.
"""
if (eris is None) or isinstance(eris, tuple):
if (isinstance(eris, tuple) and isinstance(eris[0], np.ndarray) and eris[0].ndim == 3) or getattr(self.mf, "with_df", None):
if (
isinstance(eris, tuple) and isinstance(eris[0], np.ndarray) and eris[0].ndim == 3
) or getattr(self.mf, "with_df", None):
return self.CDERIs(self, array=eris)
else:
return self.ERIs(self, array=eris)
Expand Down

0 comments on commit 7113108

Please sign in to comment.