From 03e94077fba78e1d9121648d902595e1017248d7 Mon Sep 17 00:00:00 2001 From: Ollie Backhouse Date: Fri, 3 Mar 2023 12:07:14 +0000 Subject: [PATCH 01/23] Initialise mkdocs stuff --- mkdocs.yaml | 10 ++++++++++ pyproject.toml | 2 ++ 2 files changed, 12 insertions(+) create mode 100644 mkdocs.yaml diff --git a/mkdocs.yaml b/mkdocs.yaml new file mode 100644 index 00000000..4461935f --- /dev/null +++ b/mkdocs.yaml @@ -0,0 +1,10 @@ +site_name: ebcc + +plugins: +- mkdocstrings: + enabled: !ENV [ENABLE_MKDOCSTRINGS, true] + default_handler : python + handles: + python: + options: + show_source: false diff --git a/pyproject.toml b/pyproject.toml index d6859e64..4314936f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -48,6 +48,8 @@ dev = [ "coverage[toml]", "pytest", "pytest-cov", + "mkdocs", + "mkdocstrings", ] [tool.black] From db9ca6e482bce6f6fcbd18b9649c01820e628bee Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 14:52:38 +0000 Subject: [PATCH 02/23] Start on some documentation --- docs/gen_files.py | 28 ++++++++ docs/index.md | 3 + ebcc/ansatz.py | 2 +- ebcc/util.py | 166 ++++++++++++++++++++++++++++++++++++++++++---- mkdocs.yaml | 41 ++++++++++-- pyproject.toml | 7 ++ 6 files changed, 230 insertions(+), 17 deletions(-) create mode 100644 docs/gen_files.py create mode 100644 docs/index.md diff --git a/docs/gen_files.py b/docs/gen_files.py new file mode 100644 index 00000000..25d4fa61 --- /dev/null +++ b/docs/gen_files.py @@ -0,0 +1,28 @@ +""" +Generate the code reference pages. +""" + +from pathlib import Path + +import mkdocs_gen_files + + +for path in sorted(Path("ebcc").rglob("*.py")): + module_path = path.relative_to("ebcc").with_suffix("") + doc_path = path.relative_to("ebcc").with_suffix(".md") + full_doc_path = Path("reference", doc_path) + parts = ["ebcc", *module_path.parts] + + if parts[-1] == "__init__": + parts = parts[:-1] + doc_path = doc_path.with_name("index.md") + full_doc_path = full_doc_path.with_name("index.md") + + if not len(parts) or parts[-1] == "__main__" or parts[0] == "codegen": + continue + + with mkdocs_gen_files.open(full_doc_path, "w") as fd: + identifier = ".".join(parts) + fd.write("::: " + identifier + "\n") + + mkdocs_gen_files.set_edit_path(full_doc_path, path) diff --git a/docs/index.md b/docs/index.md new file mode 100644 index 00000000..4129e67e --- /dev/null +++ b/docs/index.md @@ -0,0 +1,3 @@ +{% + include-markdown "../README.md" +%} diff --git a/ebcc/ansatz.py b/ebcc/ansatz.py index 24449e04..dd8989e0 100644 --- a/ebcc/ansatz.py +++ b/ebcc/ansatz.py @@ -106,7 +106,7 @@ def from_string(cls, string): Parameters ---------- - input : str + string : str Input string Returns diff --git a/ebcc/util.py b/ebcc/util.py index 8a9a0888..753139e3 100644 --- a/ebcc/util.py +++ b/ebcc/util.py @@ -1,4 +1,4 @@ -"""Utilities. +"""Utility functions. """ import functools @@ -25,8 +25,8 @@ class InheritedType: class Namespace: - """Replacement for SimpleNamespace, which does not trivially allow - conversion to a dict for heterogenously nested objects. + """Replacement for `SimpleNamespace`, which does not trivially allow + conversion to a `dict` for heterogenously nested objects. """ def __init__(self, **kwargs): @@ -62,24 +62,30 @@ def __contains__(self, key): class Timer: + """Class for recording timings. + """ + def __init__(self): self.t_init = time.perf_counter() self.t_prev = time.perf_counter() self.t_curr = time.perf_counter() def lap(self): + """Return the time elapsed since the previous call. Also + aliased to `__call__`. + """ self.t_prev, self.t_curr = self.t_curr, time.perf_counter() return self.t_curr - self.t_prev __call__ = lap def total(self): + """Return the time elapsed since the initialisation. + """ return time.perf_counter() - self.t_init @staticmethod def format_time(seconds, precision=2): - """Return a formatted time.""" - seconds, milliseconds = divmod(seconds, 1) milliseconds *= 1000 minutes, seconds = divmod(seconds, 60) @@ -99,7 +105,18 @@ def format_time(seconds, precision=2): def factorial(n): - """Return the factorial of n.""" + """Compute the factorial of an integer. + + Parameters + ---------- + n : int + Integer value. + + Returns + ------- + nfac : int + Factorial :math:`n!`. + """ if n in (0, 1): return 1 @@ -108,12 +125,36 @@ def factorial(n): def permute_string(string, permutation): - """Permute a string.""" + """Permute a string. + + Parameters + ---------- + string : str + Input string. + permutation : iterable of int + Integer permutation. + """ return "".join([string[i] for i in permutation]) def tril_indices_ndim(n, dims, include_diagonal=False): - """Return lower triangular indices for a multidimensional array.""" + """Return lower triangular indices for a multidimensional array. + + Parameters + ---------- + n : int + Side length of array. + dims : int + Number of dimensions in the array. + include_diagonal : bool, optional + Whether or not to include the diagonal in the triangle. + + Returns + ------- + tril : tuple of numpy.ndarray + Indices for each dimension to extract the n-dimensional lower + triangle. + """ ranges = [np.arange(n)] * dims @@ -142,7 +183,22 @@ def tril_indices_ndim(n, dims, include_diagonal=False): def ntril_ndim(n, dims, include_diagonal=False): - """Return the number of elements in an n-dimensional lower triangle.""" + """Return the number of elements in an n-dimensional lower triangle. + + Parameters + ---------- + n : int + Side length of array. + dims : int + Number of dimensions in the array. + include_diagonal : bool, optional + Whether or not to include the diagonal in the triangle. + + Returns + ------- + count : int + Number of elements in the n-dimensional lower triangle. + """ # FIXME hack until this function is fixed: if include_diagonal: @@ -197,9 +253,20 @@ def generate_spin_combinations(n, excited=False): def permutations_with_signs(seq): - """Generate permutations of seq, yielding also a sign which is + """Generate permutations of `seq`, yielding also a sign which is equal to +1 for an even number of swaps, and -1 for an odd number of swaps. + + Parameters + ---------- + seq : iterable + Sequence to permute. + + Returns + ------- + perms_and_signs : list of tuple of (iterable, int) + List of permutations of `seq`, where each permutation is a + `tuple` of the permuted sequence and the associated sign. """ def _permutations(seq): @@ -245,7 +312,7 @@ def get_symmetry_factor(*numbers): def inherit_docstrings(cls): - """Inherit docstring from superclass.""" + """Decorator to inherit docstrings from superclass.""" for name, func in inspect.getmembers(cls, inspect.isfunction): if not func.__doc__: @@ -257,7 +324,20 @@ def inherit_docstrings(cls): def antisymmetrise_array(v, axes=(0, 1)): - """Antisymmetrise an array.""" + """Antisymmetrise an array. + + Parameters + ---------- + v : numpy.ndarray + Array to antisymmetrise. + axes : tuple of int + Axes to perform the antisymmetrisation upon. Default value is + `(0, 1)`. + + Returns + v_as : numpy.ndarray + Antisymmetrised array. + """ v_as = np.zeros_like(v) @@ -273,6 +353,8 @@ def antisymmetrise_array(v, axes=(0, 1)): def is_mixed_spin(spin): + """Return a boolean indicating if a list of spins are mixed. + """ return len(set(spin)) != 1 @@ -280,6 +362,27 @@ def compress_axes(subscript, array, include_diagonal=False, out=None): """Compress an array into lower-triangular representations using an einsum-like input. + Parameters + ---------- + subscript : str + Einsum-like subscript, where repeated characters are considered + part of the same set of indices to be compressed. + array : numpy.ndarray + Array to compress. + include_diagonal : bool, optional + If `True`, include the diagonal elements in the compression. + Default value is `False`. + + Returns + ------- + array_flat : numpy.ndarray + Compressed array, the number of dimensions will be equal to the + number of unique characters in `subscript`, and the size of + each dimension will correspond to the output of `ntril_ndim` + for that particular set of indices. + + Examples + -------- >>> t2 = np.zeros((4, 4, 10, 10)) >>> compress_axes("iiaa", t2).shape (6, 45) @@ -338,6 +441,35 @@ def decompress_axes( """Reverse operation of `compress_axes`, subscript input is the same. The input symmetry is a string of the same length as subscript, with a "+" indicating symmetry and "-" antisymmetry. + + Parameters + ---------- + subscript : str + Einsum-like subscript, where repeated characters are considered + part of the same set of indices to be compressed. + array_flat : numpy.ndarray + Array to decompress. + shape : tuple of int + Shape of the output array. + include_diagonal : bool, optional + If `True`, include the diagonal elements in the compression. + Default value is `False`. + symmetry : str, optional + Symmetry of the decompression. For each index in `subscript`, + a `+` indcates symmetry and `-` indicates antisymmetry. The + value of `symmetry` must be the same for repeated characters + in the corresponding `subscript`. + + Returns + ------- + array : numpy.ndarray + Decompressed array. + + Examples + -------- + >>> t2 = np.zeros((6, 45)) + >>> decompress_axes("iiaa", t2, symmetry="----").shape + (4, 4, 10, 10) """ # FIXME: if you pass out=array here, it doesn't work - it's not touching all parts of the array?? # --> I guess the diagonals actually!! set out to zero first if used as input. @@ -426,6 +558,16 @@ def get_compressed_size(subscript, **sizes): based on the subscript input to `compressed_axes` and the sizes of each character. + Parameters + ---------- + subscript : str + Einsum-like subscript, where repeated characters are considered + part of the same set of indices to be compressed. + **sizes : dict of {str: int} + Sizes of each character in the subscript. + + Examples + -------- >>> get_compressed_shape("iiaa", i=5, a=3) 30 """ diff --git a/mkdocs.yaml b/mkdocs.yaml index 4461935f..e3ccc244 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -1,10 +1,43 @@ site_name: ebcc +watch: +- ebcc + +theme: + name: material + plugins: +- search +- gen-files: + scripts: + - docs/gen_files.py +- section-index +- include-markdown - mkdocstrings: - enabled: !ENV [ENABLE_MKDOCSTRINGS, true] - default_handler : python - handles: + default_handler: python + handlers: python: - options: + rendering: show_source: false + options: + docstring_style: numpy + members_order: source + line_length: 72 + merge_init_into_class: true + show_if_no_docstring: false + show_root_members_full_path: true + show_object_full_path: true + +nav: +- Home: "index.md" +- Code Reference: + - rebcc: reference/rebcc.md + - uebcc: reference/uebcc.md + - gebcc: reference/gebcc.md + - reom: reference/reom.md + - ueom: reference/ueom.md + - geom: reference/geom.md + - brueckner: reference/brueckner.md + - space: reference/space.md + - ansatz: reference/ansatz.md + - util: reference/util.md diff --git a/pyproject.toml b/pyproject.toml index 4314936f..7ffd9f44 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -49,7 +49,14 @@ dev = [ "pytest", "pytest-cov", "mkdocs", + "mkdocs-gen-files", + "mkdocs-section-index", + "mkdocs-autorefs", + "mkdocs-material", + "mkdocs-material-extensions", + "mkdocs-include-markdown-plugin", "mkdocstrings", + "mkdocstrings-python", ] [tool.black] From 82138399b341278410426836d7186424de095cbe Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:17:26 +0000 Subject: [PATCH 03/23] Adds some more examples --- examples/04-rdms.py | 29 +++++++++++++++++++++++++++++ examples/05-bccd.py | 17 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 examples/04-rdms.py create mode 100644 examples/05-bccd.py diff --git a/examples/04-rdms.py b/examples/04-rdms.py new file mode 100644 index 00000000..9bef6f95 --- /dev/null +++ b/examples/04-rdms.py @@ -0,0 +1,29 @@ +import numpy as np +from pyscf import gto, scf + +from ebcc import REBCC + +mol = gto.Mole() +mol.atom = "H 0 0 0; F 0 0 1.1" +mol.basis = "cc-pvdz" +mol.build() + +mf = scf.RHF(mol) +mf.kernel() + +ccsd = REBCC(mf) +ccsd.kernel() +ccsd.solve_lambda() + +rdm1 = ccsd.make_rdm1_f() +rdm2 = ccsd.make_rdm2_f() + +h1e = np.einsum("pq,pi,qj->ij", mf.get_hcore(), mf.mo_coeff, mf.mo_coeff) +h2e = ccsd.get_eris().xxxx + +e_rdm1 = np.einsum("pq,pq->", rdm1, h1e) +e_rdm2 = np.einsum("pqrs,pqrs->", rdm2, h2e) / 2 + +print("E(rdm1) = %16.10f" % e_rdm1) +print("E(rdm2) = %16.10f" % e_rdm2) +print("E(tot) = %16.10f" % (e_rdm1 + e_rdm2 + mol.energy_nuc())) diff --git a/examples/05-bccd.py b/examples/05-bccd.py new file mode 100644 index 00000000..f09a36e3 --- /dev/null +++ b/examples/05-bccd.py @@ -0,0 +1,17 @@ +import numpy as np +from pyscf import gto, scf + +from ebcc import EBCC, brueckner + +mol = gto.Mole() +mol.atom = "H 0 0 0; Li 0 0 1.64" +mol.basis = "cc-pvdz" +mol.build() + +mf = scf.RHF(mol) +mf.kernel() + +ccsd = EBCC(mf, ansatz="CCSD") +bccd = ccsd.brueckner() + +assert np.allclose(ccsd.t1, 0) From ec28fd59ed2f516df358aa277d2be4f3e65a1723 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:30:35 +0000 Subject: [PATCH 04/23] Adds features to docs --- docs/features.md | 4 ++++ mkdocs.yaml | 1 + 2 files changed, 5 insertions(+) create mode 100644 docs/features.md diff --git a/docs/features.md b/docs/features.md new file mode 100644 index 00000000..e3539329 --- /dev/null +++ b/docs/features.md @@ -0,0 +1,4 @@ +{% + include-markdown "../FEATURES.md" +%} + diff --git a/mkdocs.yaml b/mkdocs.yaml index e3ccc244..a3559a0f 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -30,6 +30,7 @@ plugins: nav: - Home: "index.md" +- Features: "features.md" - Code Reference: - rebcc: reference/rebcc.md - uebcc: reference/uebcc.md From 963f9e0967e6abbf3d19a09edae782d6f96259b4 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:34:43 +0000 Subject: [PATCH 05/23] Add doc deployment to CI --- .github/workflows/ci.yaml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index fe6a33e2..d0f45823 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -45,3 +45,9 @@ jobs: with: token: ${{ secrets.CODECOV_TOKEN }} verbose: true + - name: Deploy documentation + uses: mhausenblas/mkdocs-deploy-gh-pages@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + CONFIG_FILE: mkdocs.yaml + #if: matrix.documentation && github.ref == 'refs/heads/master' From 67bc677d3e7b59b20c849d24c105e91decae2855 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:39:41 +0000 Subject: [PATCH 06/23] Linting --- ebcc/brueckner.py | 41 +++----------------- ebcc/gebcc.py | 5 +-- ebcc/rebcc.py | 99 ++++++++++------------------------------------- ebcc/space.py | 5 +-- ebcc/uebcc.py | 46 +++++----------------- ebcc/ueom.py | 3 +- ebcc/util.py | 2 +- 7 files changed, 39 insertions(+), 162 deletions(-) diff --git a/ebcc/brueckner.py b/ebcc/brueckner.py index 3d6fa84a..841b9328 100644 --- a/ebcc/brueckner.py +++ b/ebcc/brueckner.py @@ -59,11 +59,7 @@ class BruecknerREBCC: Options = Options def __init__( - self, - cc: "AbstractEBCC", - log: logging.Logger = None, - options: Options = None, - **kwargs, + self, cc: "AbstractEBCC", log: logging.Logger = None, options: Options = None, **kwargs, ): # Options: if options is None: @@ -271,12 +267,7 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): if t1 is None: t1 = self.cc.t1 if u_tot is None: - u_tot = np.array( - [ - np.eye(self.cc.space[0].ncorr), - np.eye(self.cc.space[1].ncorr), - ] - ) + u_tot = np.array([np.eye(self.cc.space[0].ncorr), np.eye(self.cc.space[1].ncorr),]) t1_block = np.array( [ @@ -295,12 +286,7 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): ] ) - u = np.array( - [ - scipy.linalg.expm(t1_block[0]), - scipy.linalg.expm(t1_block[1]), - ] - ) + u = np.array([scipy.linalg.expm(t1_block[0]), scipy.linalg.expm(t1_block[1]),]) u_tot = util.einsum("npq,nqi->npi", u_tot, u) if scipy.linalg.det(u_tot[0]) < 0: @@ -308,21 +294,11 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): if scipy.linalg.det(u_tot[1]) < 0: u_tot[1][:, 0] *= -1 - a = np.array( - [ - scipy.linalg.logm(u_tot[0]), - scipy.linalg.logm(u_tot[1]), - ] - ) + a = np.array([scipy.linalg.logm(u_tot[0]), scipy.linalg.logm(u_tot[1]),]) if diis is not None: a = diis.update(a, xerr=np.array([t1.aa, t1.bb])) - u_tot = np.array( - [ - scipy.linalg.expm(a[0]), - scipy.linalg.expm(a[1]), - ] - ) + u_tot = np.array([scipy.linalg.expm(a[0]), scipy.linalg.expm(a[1]),]) return u, u_tot @@ -359,12 +335,7 @@ def get_t1_norm(self, amplitudes=None): if amplitudes is None: amplitudes = self.cc.amplitudes - return np.linalg.norm( - [ - amplitudes["t1"].aa.ravel(), - amplitudes["t1"].bb.ravel(), - ] - ) + return np.linalg.norm([amplitudes["t1"].aa.ravel(), amplitudes["t1"].bb.ravel(),]) def mo_to_correlated(self, mo_coeff): return ( diff --git a/ebcc/gebcc.py b/ebcc/gebcc.py index f4f55081..edf31e14 100644 --- a/ebcc/gebcc.py +++ b/ebcc/gebcc.py @@ -318,10 +318,7 @@ def init_amps(self, eris=None): def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm2_f", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) diff --git a/ebcc/rebcc.py b/ebcc/rebcc.py index 152f38c7..0e4f78fe 100644 --- a/ebcc/rebcc.py +++ b/ebcc/rebcc.py @@ -777,11 +777,7 @@ def energy(self, eris=None, amplitudes=None): Correlation energy. """ - func, kwargs = self._load_function( - "energy", - eris=eris, - amplitudes=amplitudes, - ) + func, kwargs = self._load_function("energy", eris=eris, amplitudes=amplitudes,) return func(**kwargs) @@ -804,10 +800,7 @@ def energy_perturbative(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "energy_perturbative", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "energy_perturbative", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -830,11 +823,7 @@ def update_amps(self, eris=None, amplitudes=None): Updated cluster amplitudes. """ - func, kwargs = self._load_function( - "update_amps", - eris=eris, - amplitudes=amplitudes, - ) + func, kwargs = self._load_function("update_amps", eris=eris, amplitudes=amplitudes,) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -887,10 +876,7 @@ def update_lams(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "update_lams", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "update_lams", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -950,10 +936,7 @@ def make_sing_b_dm(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_sing_b_dm", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_sing_b_dm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -989,10 +972,7 @@ def make_rdm1_b(self, eris=None, amplitudes=None, lambdas=None, unshifted=True, """ func, kwargs = self._load_function( - "make_rdm1_b", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm1_b", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) @@ -1003,7 +983,7 @@ def make_rdm1_b(self, eris=None, amplitudes=None, lambdas=None, unshifted=True, if unshifted and self.options.shift: dm_cre, dm_ann = self.make_sing_b_dm() xi = self.xi - dm[np.diag_indices_from(dm)] -= xi * (dm_cre + dm_ann) - xi**2 + dm[np.diag_indices_from(dm)] -= xi * (dm_cre + dm_ann) - xi ** 2 return dm @@ -1033,10 +1013,7 @@ def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): """ func, kwargs = self._load_function( - "make_rdm1_f", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm1_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) @@ -1074,10 +1051,7 @@ def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): """ func, kwargs = self._load_function( - "make_rdm2_f", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) @@ -1127,10 +1101,7 @@ def make_eb_coup_rdm( """ func, kwargs = self._load_function( - "make_eb_coup_rdm", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_eb_coup_rdm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm_eb = func(**kwargs) @@ -1175,11 +1146,7 @@ def hbar_matvec_ip(self, r1, r2, eris=None, amplitudes=None): # TODO generalise vectors input func, kwargs = self._load_function( - "hbar_matvec_ip", - eris=eris, - amplitudes=amplitudes, - r1=r1, - r2=r2, + "hbar_matvec_ip", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, ) return func(**kwargs) @@ -1212,11 +1179,7 @@ def hbar_matvec_ea(self, r1, r2, eris=None, amplitudes=None): """ func, kwargs = self._load_function( - "hbar_matvec_ea", - eris=eris, - amplitudes=amplitudes, - r1=r1, - r2=r2, + "hbar_matvec_ea", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, ) return func(**kwargs) @@ -1249,11 +1212,7 @@ def hbar_matvec_ee(self, r1, r2, eris=None, amplitudes=None): """ func, kwargs = self._load_function( - "hbar_matvec_ee", - eris=eris, - amplitudes=amplitudes, - r1=r1, - r2=r2, + "hbar_matvec_ee", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, ) return func(**kwargs) @@ -1282,10 +1241,7 @@ def make_ip_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ip_mom_bras", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ip_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1314,10 +1270,7 @@ def make_ea_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ea_mom_bras", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ea_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1346,10 +1299,7 @@ def make_ee_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ee_mom_bras", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ee_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1378,10 +1328,7 @@ def make_ip_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ip_mom_kets", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ip_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1410,10 +1357,7 @@ def make_ea_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ea_mom_kets", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ea_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1442,10 +1386,7 @@ def make_ee_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ee_mom_kets", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_ee_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) return func(**kwargs) @@ -1998,7 +1939,7 @@ def const(self): Shift in the energy from moving to polaritonic basis. """ if self.options.shift: - return lib.einsum("I,I->", self.omega, self.xi**2) + return lib.einsum("I,I->", self.omega, self.xi ** 2) else: return 0.0 diff --git a/ebcc/space.py b/ebcc/space.py index 03085da6..b8783571 100644 --- a/ebcc/space.py +++ b/ebcc/space.py @@ -35,10 +35,7 @@ class Space: """ def __init__( - self, - occupied: np.ndarray, - frozen: np.ndarray, - active: np.ndarray, + self, occupied: np.ndarray, frozen: np.ndarray, active: np.ndarray, ): self.occupied = np.asarray(occupied, dtype=bool) self.frozen = np.asarray(frozen, dtype=bool) diff --git a/ebcc/uebcc.py b/ebcc/uebcc.py index 64cb3ebf..f3f6f505 100644 --- a/ebcc/uebcc.py +++ b/ebcc/uebcc.py @@ -233,10 +233,7 @@ def init_amps(self, eris=None): # Build T amplitudes for n in self.ansatz.correlated_cluster_ranks[0]: if n == 1: - tn = util.Namespace( - aa=self.fock.aa.vo.T / e_ia.aa, - bb=self.fock.bb.vo.T / e_ia.bb, - ) + tn = util.Namespace(aa=self.fock.aa.vo.T / e_ia.aa, bb=self.fock.bb.vo.T / e_ia.bb,) amplitudes["t%d" % n] = tn elif n == 2: e_ijab = util.Namespace( @@ -286,10 +283,7 @@ def init_amps(self, eris=None): aa=lib.direct_sum("ia-x->xia", e_ia.aa, self.omega), bb=lib.direct_sum("ia-x->xia", e_ia.bb, self.omega), ) - u1n = util.Namespace( - aa=h.aa.bov / e_xia.aa, - bb=h.bb.bov / e_xia.bb, - ) + u1n = util.Namespace(aa=h.aa.bov / e_xia.aa, bb=h.bb.bov / e_xia.bb,) amplitudes["u%d%d" % (nf, nb)] = u1n else: u1n = util.Namespace( @@ -332,11 +326,7 @@ def init_lams(self, amplitudes=None): return lambdas def update_amps(self, eris=None, amplitudes=None): - func, kwargs = self._load_function( - "update_amps", - eris=eris, - amplitudes=amplitudes, - ) + func, kwargs = self._load_function("update_amps", eris=eris, amplitudes=amplitudes,) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -385,10 +375,7 @@ def update_amps(self, eris=None, amplitudes=None): def update_lams(self, eris=None, amplitudes=None, lambdas=None): func, kwargs = self._load_function( - "update_lams", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "update_lams", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -438,10 +425,7 @@ def update_lams(self, eris=None, amplitudes=None, lambdas=None): def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm1_f", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm1_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) @@ -454,10 +438,7 @@ def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm2_f", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm = func(**kwargs) @@ -483,10 +464,7 @@ def make_eb_coup_rdm( self, eris=None, amplitudes=None, lambdas=None, unshifted=True, hermitise=True ): func, kwargs = self._load_function( - "make_eb_coup_rdm", - eris=eris, - amplitudes=amplitudes, - lambdas=lambdas, + "make_eb_coup_rdm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, ) dm_eb = func(**kwargs) @@ -968,16 +946,10 @@ def nvir(self): @property def eo(self): - eo = util.Namespace( - a=np.diag(self.fock.aa.oo), - b=np.diag(self.fock.bb.oo), - ) + eo = util.Namespace(a=np.diag(self.fock.aa.oo), b=np.diag(self.fock.bb.oo),) return eo @property def ev(self): - ev = util.Namespace( - a=np.diag(self.fock.aa.vv), - b=np.diag(self.fock.bb.vv), - ) + ev = util.Namespace(a=np.diag(self.fock.aa.vv), b=np.diag(self.fock.bb.vv),) return ev diff --git a/ebcc/ueom.py b/ebcc/ueom.py index 88d2821c..1c2784d5 100644 --- a/ebcc/ueom.py +++ b/ebcc/ueom.py @@ -38,8 +38,7 @@ def moments(self, nmom, eris=None, amplitudes=None, hermitise=True): kets = self.kets(eris=eris) moments = util.Namespace( - aa=np.zeros((nmom, self.nmo, self.nmo)), - bb=np.zeros((nmom, self.nmo, self.nmo)), + aa=np.zeros((nmom, self.nmo, self.nmo)), bb=np.zeros((nmom, self.nmo, self.nmo)), ) for spin in util.generate_spin_combinations(1): diff --git a/ebcc/util.py b/ebcc/util.py index 753139e3..32753b22 100644 --- a/ebcc/util.py +++ b/ebcc/util.py @@ -308,7 +308,7 @@ def get_symmetry_factor(*numbers): for n in numbers: ntot += max(0, n - 1) - return 1.0 / (2.0**ntot) + return 1.0 / (2.0 ** ntot) def inherit_docstrings(cls): From 1e3f1f62431d426fc51c34418d838b8daa8bc279 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:40:05 +0000 Subject: [PATCH 07/23] Deploy docs only on one workflow --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index d0f45823..7ff15bff 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,4 +50,4 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} CONFIG_FILE: mkdocs.yaml - #if: matrix.documentation && github.ref == 'refs/heads/master' + if: matrix.documentation #&& github.ref == 'refs/heads/master' From 331de064c3a5ec760f5a7d56efdadd436cc11381 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 16:44:20 +0000 Subject: [PATCH 08/23] Linting (wrong black version) --- ebcc/brueckner.py | 41 +++++++++++++++++--- ebcc/gebcc.py | 5 ++- ebcc/rebcc.py | 99 +++++++++++++++++++++++++++++++++++++---------- ebcc/space.py | 5 ++- ebcc/uebcc.py | 46 +++++++++++++++++----- ebcc/ueom.py | 3 +- ebcc/util.py | 11 ++---- 7 files changed, 165 insertions(+), 45 deletions(-) diff --git a/ebcc/brueckner.py b/ebcc/brueckner.py index 841b9328..3d6fa84a 100644 --- a/ebcc/brueckner.py +++ b/ebcc/brueckner.py @@ -59,7 +59,11 @@ class BruecknerREBCC: Options = Options def __init__( - self, cc: "AbstractEBCC", log: logging.Logger = None, options: Options = None, **kwargs, + self, + cc: "AbstractEBCC", + log: logging.Logger = None, + options: Options = None, + **kwargs, ): # Options: if options is None: @@ -267,7 +271,12 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): if t1 is None: t1 = self.cc.t1 if u_tot is None: - u_tot = np.array([np.eye(self.cc.space[0].ncorr), np.eye(self.cc.space[1].ncorr),]) + u_tot = np.array( + [ + np.eye(self.cc.space[0].ncorr), + np.eye(self.cc.space[1].ncorr), + ] + ) t1_block = np.array( [ @@ -286,7 +295,12 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): ] ) - u = np.array([scipy.linalg.expm(t1_block[0]), scipy.linalg.expm(t1_block[1]),]) + u = np.array( + [ + scipy.linalg.expm(t1_block[0]), + scipy.linalg.expm(t1_block[1]), + ] + ) u_tot = util.einsum("npq,nqi->npi", u_tot, u) if scipy.linalg.det(u_tot[0]) < 0: @@ -294,11 +308,21 @@ def get_rotation_matrix(self, u_tot=None, diis=None, t1=None): if scipy.linalg.det(u_tot[1]) < 0: u_tot[1][:, 0] *= -1 - a = np.array([scipy.linalg.logm(u_tot[0]), scipy.linalg.logm(u_tot[1]),]) + a = np.array( + [ + scipy.linalg.logm(u_tot[0]), + scipy.linalg.logm(u_tot[1]), + ] + ) if diis is not None: a = diis.update(a, xerr=np.array([t1.aa, t1.bb])) - u_tot = np.array([scipy.linalg.expm(a[0]), scipy.linalg.expm(a[1]),]) + u_tot = np.array( + [ + scipy.linalg.expm(a[0]), + scipy.linalg.expm(a[1]), + ] + ) return u, u_tot @@ -335,7 +359,12 @@ def get_t1_norm(self, amplitudes=None): if amplitudes is None: amplitudes = self.cc.amplitudes - return np.linalg.norm([amplitudes["t1"].aa.ravel(), amplitudes["t1"].bb.ravel(),]) + return np.linalg.norm( + [ + amplitudes["t1"].aa.ravel(), + amplitudes["t1"].bb.ravel(), + ] + ) def mo_to_correlated(self, mo_coeff): return ( diff --git a/ebcc/gebcc.py b/ebcc/gebcc.py index edf31e14..f4f55081 100644 --- a/ebcc/gebcc.py +++ b/ebcc/gebcc.py @@ -318,7 +318,10 @@ def init_amps(self, eris=None): def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm2_f", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) diff --git a/ebcc/rebcc.py b/ebcc/rebcc.py index 0e4f78fe..152f38c7 100644 --- a/ebcc/rebcc.py +++ b/ebcc/rebcc.py @@ -777,7 +777,11 @@ def energy(self, eris=None, amplitudes=None): Correlation energy. """ - func, kwargs = self._load_function("energy", eris=eris, amplitudes=amplitudes,) + func, kwargs = self._load_function( + "energy", + eris=eris, + amplitudes=amplitudes, + ) return func(**kwargs) @@ -800,7 +804,10 @@ def energy_perturbative(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "energy_perturbative", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "energy_perturbative", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -823,7 +830,11 @@ def update_amps(self, eris=None, amplitudes=None): Updated cluster amplitudes. """ - func, kwargs = self._load_function("update_amps", eris=eris, amplitudes=amplitudes,) + func, kwargs = self._load_function( + "update_amps", + eris=eris, + amplitudes=amplitudes, + ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -876,7 +887,10 @@ def update_lams(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "update_lams", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "update_lams", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -936,7 +950,10 @@ def make_sing_b_dm(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_sing_b_dm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_sing_b_dm", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -972,7 +989,10 @@ def make_rdm1_b(self, eris=None, amplitudes=None, lambdas=None, unshifted=True, """ func, kwargs = self._load_function( - "make_rdm1_b", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm1_b", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) @@ -983,7 +1003,7 @@ def make_rdm1_b(self, eris=None, amplitudes=None, lambdas=None, unshifted=True, if unshifted and self.options.shift: dm_cre, dm_ann = self.make_sing_b_dm() xi = self.xi - dm[np.diag_indices_from(dm)] -= xi * (dm_cre + dm_ann) - xi ** 2 + dm[np.diag_indices_from(dm)] -= xi * (dm_cre + dm_ann) - xi**2 return dm @@ -1013,7 +1033,10 @@ def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): """ func, kwargs = self._load_function( - "make_rdm1_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm1_f", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) @@ -1051,7 +1074,10 @@ def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): """ func, kwargs = self._load_function( - "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm2_f", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) @@ -1101,7 +1127,10 @@ def make_eb_coup_rdm( """ func, kwargs = self._load_function( - "make_eb_coup_rdm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_eb_coup_rdm", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm_eb = func(**kwargs) @@ -1146,7 +1175,11 @@ def hbar_matvec_ip(self, r1, r2, eris=None, amplitudes=None): # TODO generalise vectors input func, kwargs = self._load_function( - "hbar_matvec_ip", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, + "hbar_matvec_ip", + eris=eris, + amplitudes=amplitudes, + r1=r1, + r2=r2, ) return func(**kwargs) @@ -1179,7 +1212,11 @@ def hbar_matvec_ea(self, r1, r2, eris=None, amplitudes=None): """ func, kwargs = self._load_function( - "hbar_matvec_ea", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, + "hbar_matvec_ea", + eris=eris, + amplitudes=amplitudes, + r1=r1, + r2=r2, ) return func(**kwargs) @@ -1212,7 +1249,11 @@ def hbar_matvec_ee(self, r1, r2, eris=None, amplitudes=None): """ func, kwargs = self._load_function( - "hbar_matvec_ee", eris=eris, amplitudes=amplitudes, r1=r1, r2=r2, + "hbar_matvec_ee", + eris=eris, + amplitudes=amplitudes, + r1=r1, + r2=r2, ) return func(**kwargs) @@ -1241,7 +1282,10 @@ def make_ip_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ip_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ip_mom_bras", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1270,7 +1314,10 @@ def make_ea_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ea_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ea_mom_bras", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1299,7 +1346,10 @@ def make_ee_mom_bras(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ee_mom_bras", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ee_mom_bras", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1328,7 +1378,10 @@ def make_ip_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ip_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ip_mom_kets", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1357,7 +1410,10 @@ def make_ea_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ea_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ea_mom_kets", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1386,7 +1442,10 @@ def make_ee_mom_kets(self, eris=None, amplitudes=None, lambdas=None): """ func, kwargs = self._load_function( - "make_ee_mom_kets", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_ee_mom_kets", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) return func(**kwargs) @@ -1939,7 +1998,7 @@ def const(self): Shift in the energy from moving to polaritonic basis. """ if self.options.shift: - return lib.einsum("I,I->", self.omega, self.xi ** 2) + return lib.einsum("I,I->", self.omega, self.xi**2) else: return 0.0 diff --git a/ebcc/space.py b/ebcc/space.py index b8783571..03085da6 100644 --- a/ebcc/space.py +++ b/ebcc/space.py @@ -35,7 +35,10 @@ class Space: """ def __init__( - self, occupied: np.ndarray, frozen: np.ndarray, active: np.ndarray, + self, + occupied: np.ndarray, + frozen: np.ndarray, + active: np.ndarray, ): self.occupied = np.asarray(occupied, dtype=bool) self.frozen = np.asarray(frozen, dtype=bool) diff --git a/ebcc/uebcc.py b/ebcc/uebcc.py index f3f6f505..64cb3ebf 100644 --- a/ebcc/uebcc.py +++ b/ebcc/uebcc.py @@ -233,7 +233,10 @@ def init_amps(self, eris=None): # Build T amplitudes for n in self.ansatz.correlated_cluster_ranks[0]: if n == 1: - tn = util.Namespace(aa=self.fock.aa.vo.T / e_ia.aa, bb=self.fock.bb.vo.T / e_ia.bb,) + tn = util.Namespace( + aa=self.fock.aa.vo.T / e_ia.aa, + bb=self.fock.bb.vo.T / e_ia.bb, + ) amplitudes["t%d" % n] = tn elif n == 2: e_ijab = util.Namespace( @@ -283,7 +286,10 @@ def init_amps(self, eris=None): aa=lib.direct_sum("ia-x->xia", e_ia.aa, self.omega), bb=lib.direct_sum("ia-x->xia", e_ia.bb, self.omega), ) - u1n = util.Namespace(aa=h.aa.bov / e_xia.aa, bb=h.bb.bov / e_xia.bb,) + u1n = util.Namespace( + aa=h.aa.bov / e_xia.aa, + bb=h.bb.bov / e_xia.bb, + ) amplitudes["u%d%d" % (nf, nb)] = u1n else: u1n = util.Namespace( @@ -326,7 +332,11 @@ def init_lams(self, amplitudes=None): return lambdas def update_amps(self, eris=None, amplitudes=None): - func, kwargs = self._load_function("update_amps", eris=eris, amplitudes=amplitudes,) + func, kwargs = self._load_function( + "update_amps", + eris=eris, + amplitudes=amplitudes, + ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -375,7 +385,10 @@ def update_amps(self, eris=None, amplitudes=None): def update_lams(self, eris=None, amplitudes=None, lambdas=None): func, kwargs = self._load_function( - "update_lams", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "update_lams", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) res = func(**kwargs) res = {key.rstrip("new"): val for key, val in res.items()} @@ -425,7 +438,10 @@ def update_lams(self, eris=None, amplitudes=None, lambdas=None): def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm1_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm1_f", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) @@ -438,7 +454,10 @@ def make_rdm1_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): def make_rdm2_f(self, eris=None, amplitudes=None, lambdas=None, hermitise=True): func, kwargs = self._load_function( - "make_rdm2_f", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_rdm2_f", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm = func(**kwargs) @@ -464,7 +483,10 @@ def make_eb_coup_rdm( self, eris=None, amplitudes=None, lambdas=None, unshifted=True, hermitise=True ): func, kwargs = self._load_function( - "make_eb_coup_rdm", eris=eris, amplitudes=amplitudes, lambdas=lambdas, + "make_eb_coup_rdm", + eris=eris, + amplitudes=amplitudes, + lambdas=lambdas, ) dm_eb = func(**kwargs) @@ -946,10 +968,16 @@ def nvir(self): @property def eo(self): - eo = util.Namespace(a=np.diag(self.fock.aa.oo), b=np.diag(self.fock.bb.oo),) + eo = util.Namespace( + a=np.diag(self.fock.aa.oo), + b=np.diag(self.fock.bb.oo), + ) return eo @property def ev(self): - ev = util.Namespace(a=np.diag(self.fock.aa.vv), b=np.diag(self.fock.bb.vv),) + ev = util.Namespace( + a=np.diag(self.fock.aa.vv), + b=np.diag(self.fock.bb.vv), + ) return ev diff --git a/ebcc/ueom.py b/ebcc/ueom.py index 1c2784d5..88d2821c 100644 --- a/ebcc/ueom.py +++ b/ebcc/ueom.py @@ -38,7 +38,8 @@ def moments(self, nmom, eris=None, amplitudes=None, hermitise=True): kets = self.kets(eris=eris) moments = util.Namespace( - aa=np.zeros((nmom, self.nmo, self.nmo)), bb=np.zeros((nmom, self.nmo, self.nmo)), + aa=np.zeros((nmom, self.nmo, self.nmo)), + bb=np.zeros((nmom, self.nmo, self.nmo)), ) for spin in util.generate_spin_combinations(1): diff --git a/ebcc/util.py b/ebcc/util.py index 32753b22..5dbcbaea 100644 --- a/ebcc/util.py +++ b/ebcc/util.py @@ -62,8 +62,7 @@ def __contains__(self, key): class Timer: - """Class for recording timings. - """ + """Class for recording timings.""" def __init__(self): self.t_init = time.perf_counter() @@ -80,8 +79,7 @@ def lap(self): __call__ = lap def total(self): - """Return the time elapsed since the initialisation. - """ + """Return the time elapsed since the initialisation.""" return time.perf_counter() - self.t_init @staticmethod @@ -308,7 +306,7 @@ def get_symmetry_factor(*numbers): for n in numbers: ntot += max(0, n - 1) - return 1.0 / (2.0 ** ntot) + return 1.0 / (2.0**ntot) def inherit_docstrings(cls): @@ -353,8 +351,7 @@ def antisymmetrise_array(v, axes=(0, 1)): def is_mixed_spin(spin): - """Return a boolean indicating if a list of spins are mixed. - """ + """Return a boolean indicating if a list of spins are mixed.""" return len(set(spin)) != 1 From 162bf8addb1ca223d846cb3b55545b7c5bded03d Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 18:26:29 +0000 Subject: [PATCH 09/23] Update documentation deployment --- .github/workflows/ci.yaml | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 7ff15bff..608398f9 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,8 +46,9 @@ jobs: token: ${{ secrets.CODECOV_TOKEN }} verbose: true - name: Deploy documentation - uses: mhausenblas/mkdocs-deploy-gh-pages@master - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - CONFIG_FILE: mkdocs.yaml + uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache + - run: mkdocs gh-deploy --force if: matrix.documentation #&& github.ref == 'refs/heads/master' From a9dc620a5e0a05b64050d11c71cfff56670da18f Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 3 Mar 2023 18:44:31 +0000 Subject: [PATCH 10/23] Only deploy on master --- .github/workflows/ci.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 608398f9..4b699ce1 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -50,5 +50,5 @@ jobs: with: key: ${{ github.ref }} path: .cache - - run: mkdocs gh-deploy --force - if: matrix.documentation #&& github.ref == 'refs/heads/master' + run: mkdocs gh-deploy --force + if: matrix.documentation && github.ref == 'refs/heads/master' From e966b1ea8357918c6efb5fa9087494e835128a10 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 20:41:06 +0100 Subject: [PATCH 11/23] Update nav --- ...tive_space.py => 14-ccsdt_active_space.py} | 0 mkdocs.yaml | 46 ++++++++++++++----- 2 files changed, 34 insertions(+), 12 deletions(-) rename examples/{04-ccsdt_active_space.py => 14-ccsdt_active_space.py} (100%) diff --git a/examples/04-ccsdt_active_space.py b/examples/14-ccsdt_active_space.py similarity index 100% rename from examples/04-ccsdt_active_space.py rename to examples/14-ccsdt_active_space.py diff --git a/mkdocs.yaml b/mkdocs.yaml index a3559a0f..c9d94545 100644 --- a/mkdocs.yaml +++ b/mkdocs.yaml @@ -20,9 +20,9 @@ plugins: rendering: show_source: false options: - docstring_style: numpy + docstring_style: google members_order: source - line_length: 72 + line_length: 100 merge_init_into_class: true show_if_no_docstring: false show_root_members_full_path: true @@ -32,13 +32,35 @@ nav: - Home: "index.md" - Features: "features.md" - Code Reference: - - rebcc: reference/rebcc.md - - uebcc: reference/uebcc.md - - gebcc: reference/gebcc.md - - reom: reference/reom.md - - ueom: reference/ueom.md - - geom: reference/geom.md - - brueckner: reference/brueckner.md - - space: reference/space.md - - ansatz: reference/ansatz.md - - util: reference/util.md + - Coupled cluster: + - Restricted: reference/cc/rebcc.md + - Unrestricted: reference/cc/uebcc.md + - Generalised: reference/cc/gebcc.md + - Base: reference/cc/base.md + - Equation of motion: + - Restricted: reference/eom/reom.md + - Unrestricted: reference/eom/ueom.md + - Generalised: reference/eom/geom.md + - Base: reference/eom/base.md + - Orbital optimisation: + - Brueckner: + - Restricted: reference/opt/rbrueckner.md + - Unrestricted: reference/opt/ubrueckner.md + - Generalised: reference/opt/gbrueckner.md + - Base: reference/opt/base.md + - Core: + - Ansatz: reference/core/ansatz.md + - Damping: reference/core/damping.md + - Dumping: reference/core/dump.md + - Logging: reference/core/logging.md + - Precision: reference/core/precision.md + - Hamiltonian: + - Space: reference/ham/space.md + - Fock: reference/ham/fock.md + - ERIs: reference/ham/eris.md + - CDERIs: reference/ham/cderis.md + - Bosonic: reference/ham/elbos.md + - Base: reference/ham/base.md + - Utility: + - Permutations: reference/util/permutations.py + - Einstein summations: reference/util/einsumfunc.py From f72f7ca1fce65299767d0f056acb2b833cac180d Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 20:46:08 +0100 Subject: [PATCH 12/23] Add cache --- .github/workflows/ci.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f2299ab1..8739b7b7 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -22,6 +22,10 @@ jobs: steps: - uses: actions/checkout@v2 + - uses: actions/cache@v2 + with: + key: ${{ github.ref }} + path: .cache - name: Set up python ${{ matrix.python-version }} uses: actions/setup-python@v2 with: From ebb0a8577b8df372a23774621eb66e20c1684fb1 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 20:49:36 +0100 Subject: [PATCH 13/23] Move config --- .github/workflows/ci.yaml | 6 +----- mkdocs.yaml => docs/mkdocs.yaml | 0 2 files changed, 1 insertion(+), 5 deletions(-) rename mkdocs.yaml => docs/mkdocs.yaml (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 8739b7b7..83749d11 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -60,9 +60,5 @@ jobs: verbose: true if: matrix.coverage - name: Deploy documentation - uses: actions/cache@v2 - with: - key: ${{ github.ref }} - path: .cache - run: mkdocs gh-deploy --force + run: mkdocs gh-deploy --force -f docs/mkdocs.yaml if: matrix.documentation && github.ref == 'refs/heads/master' diff --git a/mkdocs.yaml b/docs/mkdocs.yaml similarity index 100% rename from mkdocs.yaml rename to docs/mkdocs.yaml From 4be09e87de69c24820b4ec7470a0dfbeef9fb24b Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:10:21 +0100 Subject: [PATCH 14/23] Don't constrain branches yet --- .github/workflows/ci.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 83749d11..46de7ca3 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -61,4 +61,4 @@ jobs: if: matrix.coverage - name: Deploy documentation run: mkdocs gh-deploy --force -f docs/mkdocs.yaml - if: matrix.documentation && github.ref == 'refs/heads/master' + if: matrix.documentation #&& github.ref == 'refs/heads/master' From 155c1549164c427944736690c971fe36f7dcbf61 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:11:56 +0100 Subject: [PATCH 15/23] Don't test for now --- .github/workflows/ci.yaml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 46de7ca3..3ac79df4 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,16 +43,16 @@ jobs: python -m isort ebcc/ --diff --check-only --verbose python -m flake8 ebcc/ --verbose python -m mypy ebcc/ --verbose - - name: Run unit tests with coverage - run: | - python -m pip install pytest pytest-cov - pytest --cov ebcc/ - if: matrix.coverage - - name: Run unit tests - run: | - python -m pip install pytest - pytest - if: ${{ ! matrix.coverage }} + #- name: Run unit tests with coverage + # run: | + # python -m pip install pytest pytest-cov + # pytest --cov ebcc/ + # if: matrix.coverage + #- name: Run unit tests + # run: | + # python -m pip install pytest + # pytest + # if: ${{ ! matrix.coverage }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: From dd443ba6fca471af42e053093152a801e9f7639a Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:24:31 +0100 Subject: [PATCH 16/23] Try relative --- docs/mkdocs.yaml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index c9d94545..86fc322f 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -6,11 +6,13 @@ watch: theme: name: material +docs_dir: . + plugins: - search - gen-files: scripts: - - docs/gen_files.py + - gen_files.py - section-index - include-markdown - mkdocstrings: From f44e1c15f5c6e2b46181fec43d3d02c8ee31c977 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:28:15 +0100 Subject: [PATCH 17/23] Relative watch --- docs/mkdocs.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index 86fc322f..dc59ffd8 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -1,7 +1,7 @@ site_name: ebcc watch: -- ebcc +- ../ebcc theme: name: material From ae281035c39604f4ea8ba1a836e319dfee47ea7a Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:30:13 +0100 Subject: [PATCH 18/23] Site outside docs --- docs/mkdocs.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index dc59ffd8..691c7cd1 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -8,6 +8,8 @@ theme: docs_dir: . +site_dir: ../site + plugins: - search - gen-files: From 21687f1cde31277b5b10a47141e2044932d2f633 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:42:40 +0100 Subject: [PATCH 19/23] Remove attributes fields --- docs/mkdocs.yaml | 1 + ebcc/cc/base.py | 14 +------------- ebcc/cc/gebcc.py | 14 +------------- ebcc/cc/rebcc.py | 14 +------------- ebcc/cc/uebcc.py | 14 +------------- ebcc/core/ansatz.py | 11 +---------- ebcc/core/damping.py | 8 +------- ebcc/eom/base.py | 7 +------ ebcc/ham/base.py | 20 ++------------------ ebcc/ham/cderis.py | 18 ++---------------- ebcc/ham/elbos.py | 24 +++--------------------- ebcc/ham/eris.py | 27 +++------------------------ ebcc/ham/fock.py | 34 +++------------------------------- ebcc/ham/space.py | 33 +++++++++++++++------------------ ebcc/opt/base.py | 7 +------ ebcc/opt/gbrueckner.py | 7 +------ ebcc/opt/rbrueckner.py | 7 +------ ebcc/opt/ubrueckner.py | 7 +------ 18 files changed, 40 insertions(+), 227 deletions(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index 691c7cd1..5b7699d6 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -68,3 +68,4 @@ nav: - Utility: - Permutations: reference/util/permutations.py - Einstein summations: reference/util/einsumfunc.py + - Miscellaneous: reference/util/misc.py diff --git a/ebcc/cc/base.py b/ebcc/cc/base.py index d2f9a674..eb4753d4 100644 --- a/ebcc/cc/base.py +++ b/ebcc/cc/base.py @@ -60,19 +60,7 @@ class BaseOptions: class BaseEBCC(ABC): - """Base class for electron-boson coupled cluster. - - Attributes: - mf: PySCF mean-field object. - log: Log to write output to. - options: Options for the EBCC calculation. - e_corr: Correlation energy. - amplitudes: Cluster amplitudes. - converged: Convergence flag. - lambdas: Cluster lambda amplitudes. - converged_lambda: Lambda convergence flag. - name: Name of the method. - """ + """Base class for electron-boson coupled cluster.""" # Types Options: type[BaseOptions] = BaseOptions diff --git a/ebcc/cc/gebcc.py b/ebcc/cc/gebcc.py index de3368d4..422e2f66 100644 --- a/ebcc/cc/gebcc.py +++ b/ebcc/cc/gebcc.py @@ -33,19 +33,7 @@ class GEBCC(BaseEBCC): - """Restricted electron-boson coupled cluster. - - Attributes: - mf: PySCF mean-field object. - log: Log to write output to. - options: Options for the EBCC calculation. - e_corr: Correlation energy. - amplitudes: Cluster amplitudes. - converged: Convergence flag. - lambdas: Cluster lambda amplitudes. - converged_lambda: Lambda convergence flag. - name: Name of the method. - """ + """Restricted electron-boson coupled cluster.""" # Types ERIs = GERIs diff --git a/ebcc/cc/rebcc.py b/ebcc/cc/rebcc.py index 243cb0df..26286465 100644 --- a/ebcc/cc/rebcc.py +++ b/ebcc/cc/rebcc.py @@ -29,19 +29,7 @@ class REBCC(BaseEBCC): - """Restricted electron-boson coupled cluster. - - Attributes: - mf: PySCF mean-field object. - log: Log to write output to. - options: Options for the EBCC calculation. - e_corr: Correlation energy. - amplitudes: Cluster amplitudes. - converged: Convergence flag. - lambdas: Cluster lambda amplitudes. - converged_lambda: Lambda convergence flag. - name: Name of the method. - """ + """Restricted electron-boson coupled cluster.""" # Types ERIs = RERIs diff --git a/ebcc/cc/uebcc.py b/ebcc/cc/uebcc.py index d94f9b52..532d40a1 100644 --- a/ebcc/cc/uebcc.py +++ b/ebcc/cc/uebcc.py @@ -31,19 +31,7 @@ class UEBCC(BaseEBCC): - """Unrestricted electron-boson coupled cluster. - - Attributes: - mf: PySCF mean-field object. - log: Log to write output to. - options: Options for the EBCC calculation. - e_corr: Correlation energy. - amplitudes: Cluster amplitudes. - converged: Convergence flag. - lambdas: Cluster lambda amplitudes. - converged_lambda: Lambda convergence flag. - name: Name of the method. - """ + """Unrestricted electron-boson coupled cluster.""" # Types ERIs = UERIs diff --git a/ebcc/core/ansatz.py b/ebcc/core/ansatz.py index 08a55265..afbf2c90 100644 --- a/ebcc/core/ansatz.py +++ b/ebcc/core/ansatz.py @@ -83,16 +83,7 @@ def identifity_to_name(iden: str) -> str: class Ansatz: - """Ansatz class. - - Attributes: - fermion_ansatz: Fermionic ansatz. - boson_ansatz: Rank of bosonic excitations. - fermion_coupling_rank: Rank of fermionic term in coupling. - boson_coupling_rank: Rank of bosonic term in coupling. - density_fitting: Use density fitting. - module_name: Name of the module containing the generated equations. - """ + """Ansatz class.""" def __init__( self, diff --git a/ebcc/core/damping.py b/ebcc/core/damping.py index 8dff8480..fe9b364e 100644 --- a/ebcc/core/damping.py +++ b/ebcc/core/damping.py @@ -11,13 +11,7 @@ class DIIS(diis.DIIS): - """Direct inversion in the iterative subspace. - - Attributes: - space: The number of vectors to store in the DIIS space. - min_space: The minimum number of vectors to store in the DIIS space. - damping: The damping factor to apply to the extrapolated vector. - """ + """Direct inversion in the iterative subspace.""" def __init__(self, space: int = 6, min_space: int = 1, damping: float = 0.0) -> None: """Initialize the DIIS object. diff --git a/ebcc/eom/base.py b/ebcc/eom/base.py index b337495b..fe19ce04 100644 --- a/ebcc/eom/base.py +++ b/ebcc/eom/base.py @@ -47,12 +47,7 @@ class BaseOptions: class BaseEOM(ABC): - """Base class for equation-of-motion coupled cluster. - - Attributes: - ebcc: Parent `EBCC` object. - options: Options for the EBCC calculation. - """ + """Base class for equation-of-motion coupled cluster.""" # Types Options = BaseOptions diff --git a/ebcc/ham/base.py b/ebcc/ham/base.py index b0124e9e..5bdcc087 100644 --- a/ebcc/ham/base.py +++ b/ebcc/ham/base.py @@ -33,17 +33,7 @@ def __getitem__(self, key: str) -> Any: class BaseFock(BaseHamiltonian): - """Base class for Fock matrices. - - Attributes: - cc: Coupled cluster object. - space: Space object. - mo_coeff: Molecular orbital coefficients. - array: Fock matrix in the MO basis. - g: Namespace containing blocks of the electron-boson coupling matrix. - shift: Shift parameter. - xi: Boson parameters. - """ + """Base class for Fock matrices.""" def __init__( self, @@ -109,13 +99,7 @@ def __init__( class BaseElectronBoson(BaseHamiltonian): - """Base class for electron-boson coupling matrices. - - Attributes: - cc: Coupled cluster object. - space: Space object. - array: Electron-boson coupling matrix in the MO basis. - """ + """Base class for electron-boson coupling matrices.""" def __init__( self, diff --git a/ebcc/ham/cderis.py b/ebcc/ham/cderis.py index c18dae78..224e023b 100644 --- a/ebcc/ham/cderis.py +++ b/ebcc/ham/cderis.py @@ -18,14 +18,7 @@ class RCDERIs(BaseERIs): - """Restricted Cholesky-decomposed ERIs container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: ERIs in the MO basis. - """ + """Restricted Cholesky-decomposed ERIs container class.""" def __getitem__(self, key: str, e2: Optional[bool] = False) -> NDArray[float]: """Just-in-time getter. @@ -93,14 +86,7 @@ def __getitem__(self, key: str, e2: Optional[bool] = False) -> NDArray[float]: class UCDERIs(BaseERIs): - """Unrestricted Cholesky-decomposed ERIs container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: ERIs in the MO basis. - """ + """Unrestricted Cholesky-decomposed ERIs container class.""" _members: dict[str, RCDERIs] diff --git a/ebcc/ham/elbos.py b/ebcc/ham/elbos.py index 5653293c..99a40fc8 100644 --- a/ebcc/ham/elbos.py +++ b/ebcc/ham/elbos.py @@ -12,13 +12,7 @@ class RElectronBoson(BaseElectronBoson): - """Restricted electron-boson coupling matrices. - - Attributes: - cc: Coupled cluster object. - space: Space object. - array: Electron-boson coupling matrix in the MO basis. - """ + """Restricted electron-boson coupling matrices.""" _members: dict[str, NDArray[float]] @@ -40,13 +34,7 @@ def __getitem__(self, key: str) -> NDArray[float]: class UElectronBoson(BaseElectronBoson): - """Unrestricted electron-boson coupling matrices. - - Attributes: - cc: Coupled cluster object. - space: Space object. - array: Electron-boson coupling matrix in the MO basis. - """ + """Unrestricted electron-boson coupling matrices.""" _members: dict[str, RElectronBoson] @@ -72,13 +60,7 @@ def __getitem__(self, key: str) -> RElectronBoson: class GElectronBoson(BaseElectronBoson): - """Generalised electron-boson coupling matrices. - - Attributes: - cc: Coupled cluster object. - space: Space object. - array: Electron-boson coupling matrix in the MO basis. - """ + """Generalised electron-boson coupling matrices.""" _members: dict[str, NDArray[float]] diff --git a/ebcc/ham/eris.py b/ebcc/ham/eris.py index 3f6c45a4..63b8f60a 100644 --- a/ebcc/ham/eris.py +++ b/ebcc/ham/eris.py @@ -17,14 +17,7 @@ class RERIs(BaseERIs): - """Restricted ERIs container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: ERIs in the MO basis. - """ + """Restricted ERIs container class.""" _members: dict[str, NDArray[float]] @@ -54,14 +47,7 @@ def __getitem__(self, key: str) -> NDArray[float]: class UERIs(BaseERIs): - """Unrestricted ERIs container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: ERIs in the MO basis. - """ + """Unrestricted ERIs container class.""" _members: dict[str, RERIs] @@ -112,14 +98,7 @@ def __getitem__(self, key: str) -> RERIs: class GERIs(BaseERIs): - """Generalised ERIs container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: ERIs in the MO basis. - """ + """Generalised ERIs container class.""" _members: dict[str, UERIs] diff --git a/ebcc/ham/fock.py b/ebcc/ham/fock.py index fdc0045c..90c3c35d 100644 --- a/ebcc/ham/fock.py +++ b/ebcc/ham/fock.py @@ -14,17 +14,7 @@ class RFock(BaseFock): - """Restricted Fock matrix container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: Fock matrix in the MO basis. - g: Namespace containing blocks of the electron-boson coupling matrix. - shift: Shift parameter. - xi: Boson parameters. - """ + """Restricted Fock matrix container class.""" _members: dict[str, NDArray[float]] @@ -56,15 +46,7 @@ def __getitem__(self, key: str) -> NDArray[float]: class UFock(BaseFock): - """Unrestricted Fock matrix container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: Fock matrix in the MO basis. - g: Namespace containing blocks of the electron-boson coupling matrix - """ + """Unrestricted Fock matrix container class.""" _members: dict[str, RFock] @@ -99,17 +81,7 @@ def __getitem__(self, key: str) -> RFock: class GFock(BaseFock): - """Generalised Fock matrix container class. - - Attributes: - cc: Coupled cluster object. - space: Space object for each index. - mo_coeff: Molecular orbital coefficients for each index. - array: Fock matrix in the MO basis. - g: Namespace containing blocks of the electron-boson coupling matrix. - shift: Shift parameter. - xi: Boson parameters. - """ + """Generalised Fock matrix container class.""" _members: dict[str, NDArray[float]] diff --git a/ebcc/ham/space.py b/ebcc/ham/space.py index ce730dcc..b1347eb6 100644 --- a/ebcc/ham/space.py +++ b/ebcc/ham/space.py @@ -23,24 +23,21 @@ class Space: """Space class. - ─┬─ ┌──────────┐ - │ │ frozen │ - │ ├──────────┤ ─┬─ - virtual │ │ active │ │ - │ ├──────────┤ │ correlated - │ │ inactive │ │ - ─┼─ ├══════════┤ ─┼─ - │ │ inactive │ │ - │ ├──────────┤ │ correlated - occupied │ │ active │ │ - │ ├──────────┤ ─┴─ - │ │ frozen │ - ─┴─ └──────────┘ - - Args: - occupied: Array containing boolean flags indicating whether or not each orbital is occupied. - frozen: Array containing boolean flags indicating whether or not each orbital is frozen. - active: Array containing boolean flags indicating whether or not each orbital is active. + .. code-block:: none + + ─┬─ ┌──────────┐ + │ │ frozen │ + │ ├──────────┤ ─┬─ + virtual │ │ active │ │ + │ ├──────────┤ │ correlated + │ │ inactive │ │ + ─┼─ ├══════════┤ ─┼─ + │ │ inactive │ │ + │ ├──────────┤ │ correlated + occupied │ │ active │ │ + │ ├──────────┤ ─┴─ + │ │ frozen │ + ─┴─ └──────────┘ """ def __init__( diff --git a/ebcc/opt/base.py b/ebcc/opt/base.py index 5aad5157..8358d0f9 100644 --- a/ebcc/opt/base.py +++ b/ebcc/opt/base.py @@ -44,12 +44,7 @@ class BaseOptions: class BaseBruecknerEBCC(ABC): - """Base class for Brueckner-orbital coupled cluster. - - Attributes: - cc: Parent `BaseEBCC` object. - options: Options for the EOM calculation. - """ + """Base class for Brueckner-orbital coupled cluster.""" # Types Options: type[BaseOptions] = BaseOptions diff --git a/ebcc/opt/gbrueckner.py b/ebcc/opt/gbrueckner.py index 92f74513..afd8b552 100644 --- a/ebcc/opt/gbrueckner.py +++ b/ebcc/opt/gbrueckner.py @@ -21,12 +21,7 @@ class BruecknerGEBCC(BaseBruecknerEBCC): - """Generalised Brueckner-orbital coupled cluster. - - Attributes: - cc: Parent `BaseEBCC` object. - options: Options for the EOM calculation. - """ + """Generalised Brueckner-orbital coupled cluster.""" # Attributes cc: GEBCC diff --git a/ebcc/opt/rbrueckner.py b/ebcc/opt/rbrueckner.py index 4f485555..cf8330f1 100644 --- a/ebcc/opt/rbrueckner.py +++ b/ebcc/opt/rbrueckner.py @@ -21,12 +21,7 @@ class BruecknerREBCC(BaseBruecknerEBCC): - """Restricted Brueckner-orbital coupled cluster. - - Attributes: - cc: Parent `BaseEBCC` object. - options: Options for the EOM calculation. - """ + """Restricted Brueckner-orbital coupled cluster.""" # Attributes cc: REBCC diff --git a/ebcc/opt/ubrueckner.py b/ebcc/opt/ubrueckner.py index f2b0d8c8..50637cc5 100644 --- a/ebcc/opt/ubrueckner.py +++ b/ebcc/opt/ubrueckner.py @@ -21,12 +21,7 @@ class BruecknerUEBCC(BaseBruecknerEBCC): - """Unrestricted Brueckner-orbital coupled cluster. - - Attributes: - cc: Parent `BaseEBCC` object. - options: Options for the EOM calculation. - """ + """Unrestricted Brueckner-orbital coupled cluster.""" # Attributes cc: UEBCC From 02fc180c0ff9276454118891ff924f44b9d61500 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:48:55 +0100 Subject: [PATCH 20/23] Material sucks --- docs/mkdocs.yaml | 3 ++- pyproject.toml | 3 +-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index 5b7699d6..5b27d29f 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -4,7 +4,7 @@ watch: - ../ebcc theme: - name: material + name: terminal docs_dir: . @@ -17,6 +17,7 @@ plugins: - gen_files.py - section-index - include-markdown +- md-to-html - mkdocstrings: default_handler: python handlers: diff --git a/pyproject.toml b/pyproject.toml index 7cc4bdd3..7d9914c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,8 +54,7 @@ dev = [ "mkdocs-gen-files>=0.5.0", "mkdocs-section-index>=0.3.0", "mkdocs-autorefs>=1.0.0", - "mkdocs-material>=9.5.0", - "mkdocs-material-extensions>=1.3.0", + "mkdocs-terminal>=4.0.0", "mkdocs-include-markdown-plugin>=6.2.0", "mkdocstrings>=0.25.0", "mkdocstrings-python>=1.10.0", From 25e6d54392c6fd19fb2ef2f9c17ee06c077e7882 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 21:58:28 +0100 Subject: [PATCH 21/23] Use html for nav --- docs/mkdocs.yaml | 52 ++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index 5b27d29f..17796313 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -38,35 +38,35 @@ nav: - Features: "features.md" - Code Reference: - Coupled cluster: - - Restricted: reference/cc/rebcc.md - - Unrestricted: reference/cc/uebcc.md - - Generalised: reference/cc/gebcc.md - - Base: reference/cc/base.md + - Restricted: reference/cc/rebcc.html + - Unrestricted: reference/cc/uebcc.html + - Generalised: reference/cc/gebcc.html + - Base: reference/cc/base.html - Equation of motion: - - Restricted: reference/eom/reom.md - - Unrestricted: reference/eom/ueom.md - - Generalised: reference/eom/geom.md - - Base: reference/eom/base.md + - Restricted: reference/eom/reom.html + - Unrestricted: reference/eom/ueom.html + - Generalised: reference/eom/geom.html + - Base: reference/eom/base.html - Orbital optimisation: - Brueckner: - - Restricted: reference/opt/rbrueckner.md - - Unrestricted: reference/opt/ubrueckner.md - - Generalised: reference/opt/gbrueckner.md - - Base: reference/opt/base.md + - Restricted: reference/opt/rbrueckner.html + - Unrestricted: reference/opt/ubrueckner.html + - Generalised: reference/opt/gbrueckner.html + - Base: reference/opt/base.html - Core: - - Ansatz: reference/core/ansatz.md - - Damping: reference/core/damping.md - - Dumping: reference/core/dump.md - - Logging: reference/core/logging.md - - Precision: reference/core/precision.md + - Ansatz: reference/core/ansatz.html + - Damping: reference/core/damping.html + - Dumping: reference/core/dump.html + - Logging: reference/core/logging.html + - Precision: reference/core/precision.html - Hamiltonian: - - Space: reference/ham/space.md - - Fock: reference/ham/fock.md - - ERIs: reference/ham/eris.md - - CDERIs: reference/ham/cderis.md - - Bosonic: reference/ham/elbos.md - - Base: reference/ham/base.md + - Space: reference/ham/space.html + - Fock: reference/ham/fock.html + - ERIs: reference/ham/eris.html + - CDERIs: reference/ham/cderis.html + - Bosonic: reference/ham/elbos.html + - Base: reference/ham/base.html - Utility: - - Permutations: reference/util/permutations.py - - Einstein summations: reference/util/einsumfunc.py - - Miscellaneous: reference/util/misc.py + - Permutations: reference/util/permutations.html + - Einstein summations: reference/util/einsumfunc.html + - Miscellaneous: reference/util/misc.html From 33016aa1737250ad25878271cdcd9df27012f0a0 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 22:03:28 +0100 Subject: [PATCH 22/23] Just use rtd --- docs/mkdocs.yaml | 55 ++++++++++++++++++++++++------------------------ pyproject.toml | 1 - 2 files changed, 27 insertions(+), 29 deletions(-) diff --git a/docs/mkdocs.yaml b/docs/mkdocs.yaml index 17796313..7816243d 100644 --- a/docs/mkdocs.yaml +++ b/docs/mkdocs.yaml @@ -4,7 +4,7 @@ watch: - ../ebcc theme: - name: terminal + name: readthedocs docs_dir: . @@ -17,7 +17,6 @@ plugins: - gen_files.py - section-index - include-markdown -- md-to-html - mkdocstrings: default_handler: python handlers: @@ -38,35 +37,35 @@ nav: - Features: "features.md" - Code Reference: - Coupled cluster: - - Restricted: reference/cc/rebcc.html - - Unrestricted: reference/cc/uebcc.html - - Generalised: reference/cc/gebcc.html - - Base: reference/cc/base.html + - Restricted: reference/cc/rebcc.md + - Unrestricted: reference/cc/uebcc.md + - Generalised: reference/cc/gebcc.md + - Base: reference/cc/base.md - Equation of motion: - - Restricted: reference/eom/reom.html - - Unrestricted: reference/eom/ueom.html - - Generalised: reference/eom/geom.html - - Base: reference/eom/base.html + - Restricted: reference/eom/reom.md + - Unrestricted: reference/eom/ueom.md + - Generalised: reference/eom/geom.md + - Base: reference/eom/base.md - Orbital optimisation: - Brueckner: - - Restricted: reference/opt/rbrueckner.html - - Unrestricted: reference/opt/ubrueckner.html - - Generalised: reference/opt/gbrueckner.html - - Base: reference/opt/base.html + - Restricted: reference/opt/rbrueckner.md + - Unrestricted: reference/opt/ubrueckner.md + - Generalised: reference/opt/gbrueckner.md + - Base: reference/opt/base.md - Core: - - Ansatz: reference/core/ansatz.html - - Damping: reference/core/damping.html - - Dumping: reference/core/dump.html - - Logging: reference/core/logging.html - - Precision: reference/core/precision.html + - Ansatz: reference/core/ansatz.md + - Damping: reference/core/damping.md + - Dumping: reference/core/dump.md + - Logging: reference/core/logging.md + - Precision: reference/core/precision.md - Hamiltonian: - - Space: reference/ham/space.html - - Fock: reference/ham/fock.html - - ERIs: reference/ham/eris.html - - CDERIs: reference/ham/cderis.html - - Bosonic: reference/ham/elbos.html - - Base: reference/ham/base.html + - Space: reference/ham/space.md + - Fock: reference/ham/fock.md + - ERIs: reference/ham/eris.md + - CDERIs: reference/ham/cderis.md + - Bosonic: reference/ham/elbos.md + - Base: reference/ham/base.md - Utility: - - Permutations: reference/util/permutations.html - - Einstein summations: reference/util/einsumfunc.html - - Miscellaneous: reference/util/misc.html + - Permutations: reference/util/permutations.md + - Einstein summations: reference/util/einsumfunc.md + - Miscellaneous: reference/util/misc.md diff --git a/pyproject.toml b/pyproject.toml index 7d9914c8..134e5fc8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -54,7 +54,6 @@ dev = [ "mkdocs-gen-files>=0.5.0", "mkdocs-section-index>=0.3.0", "mkdocs-autorefs>=1.0.0", - "mkdocs-terminal>=4.0.0", "mkdocs-include-markdown-plugin>=6.2.0", "mkdocstrings>=0.25.0", "mkdocstrings-python>=1.10.0", From 2efd10859367c8c7246b0f133130fa8a8fb2f4f0 Mon Sep 17 00:00:00 2001 From: Oliver Backhouse Date: Fri, 9 Aug 2024 22:08:16 +0100 Subject: [PATCH 23/23] Re-enable tests and set doc publish branch to master --- .github/workflows/ci.yaml | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 3ac79df4..83749d11 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -43,16 +43,16 @@ jobs: python -m isort ebcc/ --diff --check-only --verbose python -m flake8 ebcc/ --verbose python -m mypy ebcc/ --verbose - #- name: Run unit tests with coverage - # run: | - # python -m pip install pytest pytest-cov - # pytest --cov ebcc/ - # if: matrix.coverage - #- name: Run unit tests - # run: | - # python -m pip install pytest - # pytest - # if: ${{ ! matrix.coverage }} + - name: Run unit tests with coverage + run: | + python -m pip install pytest pytest-cov + pytest --cov ebcc/ + if: matrix.coverage + - name: Run unit tests + run: | + python -m pip install pytest + pytest + if: ${{ ! matrix.coverage }} - name: Upload coverage to Codecov uses: codecov/codecov-action@v3 with: @@ -61,4 +61,4 @@ jobs: if: matrix.coverage - name: Deploy documentation run: mkdocs gh-deploy --force -f docs/mkdocs.yaml - if: matrix.documentation #&& github.ref == 'refs/heads/master' + if: matrix.documentation && github.ref == 'refs/heads/master'