From ba363dee5ff4d51f146cebea5701a0692599fdd6 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Wed, 30 Oct 2019 23:51:52 +0100 Subject: [PATCH 1/7] Introduce special InvalidReference exception - Also rework psi4 bindings a bit --- adcc/backends/InvalidReference.py | 31 +++++++++++++++ adcc/backends/psi4.py | 63 +++++++++++++++++++------------ adcc/backends/pyscf.py | 51 ++++++++++++++----------- adcc/backends/veloxchem.py | 29 +++++++------- 4 files changed, 115 insertions(+), 59 deletions(-) create mode 100644 adcc/backends/InvalidReference.py diff --git a/adcc/backends/InvalidReference.py b/adcc/backends/InvalidReference.py new file mode 100644 index 00000000..a2caf8f2 --- /dev/null +++ b/adcc/backends/InvalidReference.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python3 +## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab +## --------------------------------------------------------------------- +## +## Copyright (C) 2019 by the adcc authors +## +## This file is part of adcc. +## +## adcc is free software: you can redistribute it and/or modify +## it under the terms of the GNU General Public License as published +## by the Free Software Foundation, either version 3 of the License, or +## (at your option) any later version. +## +## adcc is distributed in the hope that it will be useful, +## but WITHOUT ANY WARRANTY; without even the implied warranty of +## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +## GNU General Public License for more details. +## +## You should have received a copy of the GNU General Public License +## along with adcc. If not, see . +## +## --------------------------------------------------------------------- + + +class InvalidReference(ValueError): + """ + Exception thrown if a passed SCF reference is invalid, e.g. because + a feature like density-fitting has been applied, which is inconsistent + with the current capabilities of adcc. + """ + pass diff --git a/adcc/backends/psi4.py b/adcc/backends/psi4.py index 241bbc5c..61dba46a 100644 --- a/adcc/backends/psi4.py +++ b/adcc/backends/psi4.py @@ -23,7 +23,9 @@ import psi4 import numpy as np +from .InvalidReference import InvalidReference from .eri_build_helper import EriBuilder + from adcc.misc import cached_property from libadcc import HartreeFockProvider @@ -33,7 +35,7 @@ class Psi4OperatorIntegralProvider: def __init__(self, wfn): self.wfn = wfn self.backend = "psi4" - self.mints = psi4.core.MintsHelper(self.wfn.basisset()) + self.mints = psi4.core.MintsHelper(self.wfn) @cached_property def electric_dipole(self): @@ -43,7 +45,7 @@ def electric_dipole(self): class Psi4EriBuilder(EriBuilder): def __init__(self, wfn, n_orbs, n_orbs_alpha, n_alpha, n_beta): self.wfn = wfn - self.mints = psi4.core.MintsHelper(self.wfn.basisset()) + self.mints = psi4.core.MintsHelper(self.wfn) super().__init__(n_orbs, n_orbs_alpha, n_alpha, n_beta) @property @@ -72,7 +74,7 @@ def __init__(self, wfn): super().__init__() if not isinstance(wfn, psi4.core.RHF): - raise TypeError("Only restricted references (RHF) are supported.") + raise InvalidReference("Only restricted references (RHF) are supported.") self.wfn = wfn self.eri_ffff = None @@ -157,33 +159,46 @@ def flush_cache(self): self.eri_cache = None -def import_scf(scfdrv): - if not isinstance(scfdrv, psi4.core.HF): - raise TypeError("Unsupported type for backends.psi4.import_scf.") - - if not isinstance(scfdrv, psi4.core.RHF): - raise TypeError("Only restricted references (RHF) are supported.") - - # TODO: Psi4 throws an exception if SCF is not converged - # and there is, to the best of my knowledge, no `is_converged` property - # of the psi4 wavefunction - # if not scfdrv.is_converged: - # raise ValueError("Cannot start an adc calculation on top of an SCF, " - # "which is not converged.") +def import_scf(wfn): + if not isinstance(wfn, psi4.core.HF): + raise InvalidReference( + "Only psi4.core.HF and its subtypes are supported references in " + "backends.psi4.import_scf. This indicates that you passed an unsupported " + "SCF reference. Make sure you did a restricted or unrestricted HF " + "calculation." + ) - provider = Psi4HFProvider(scfdrv) + if not isinstance(wfn, psi4.core.RHF): + raise InvalidReference("Right now only restricted references (RHF) are " + "supported for Psi4.") + + # TODO This is not fully correct, because the core.Wavefunction object + # has an internal, but py-invisible Options structure, which contains + # the actual set of options ... theoretically they could differ + scf_type = psi4.core.get_global_option('SCF_TYPE') + unsupported_scf_types = ["CD", "DISK_DF", "MEM_DF"] # Choleski or density-fitting + if scf_type in unsupported_scf_types: + raise InvalidReference(f"Unsupported Psi4 SCF_TYPE, should not be one " + "of {unsupported_scf_types}") + + if wfn.nirrep() > 1: + raise InvalidReference("The passed Psi4 wave function object needs to have " + "exactly one irrep, i.e. be of C1 symmetry.") + + # Psi4 throws an exception if SCF is not converged, so there is no need + # to assert that here. + provider = Psi4HFProvider(wfn) return provider -basissets = { - "sto3g": "sto-3g", - "def2tzvp": "def2-tzvp", - "ccpvdz": "cc-pvdz", -} - - def run_hf(xyz, basis, charge=0, multiplicity=1, conv_tol=1e-12, conv_tol_grad=1e-8, max_iter=150): + basissets = { + "sto3g": "sto-3g", + "def2tzvp": "def2-tzvp", + "ccpvdz": "cc-pvdz", + } + mol = psi4.geometry(""" {charge} {multiplicity} {xyz} diff --git a/adcc/backends/pyscf.py b/adcc/backends/pyscf.py index cb3cd5cb..6de1fdea 100644 --- a/adcc/backends/pyscf.py +++ b/adcc/backends/pyscf.py @@ -23,9 +23,11 @@ import warnings import numpy as np -from pyscf import ao2mo, gto, scf +from .InvalidReference import InvalidReference from .eri_build_helper import EriBuilder +from pyscf import ao2mo, gto, scf + from adcc.misc import cached_property from adcc.DataHfProvider import DataHfProvider @@ -106,8 +108,8 @@ def get_restricted(self): elif isinstance(self.scfres.mo_occ, np.ndarray): restricted = self.scfres.mo_occ.ndim < 2 else: - raise ValueError("Unusual pyscf SCF class encountered. Could not " - "determine restricted / unrestricted.") + raise InvalidReference("Unusual pyscf SCF class encountered. Could not " + "determine restricted / unrestricted.") return restricted def get_energy_scf(self): @@ -187,13 +189,13 @@ def flush_cache(self): def convert_scf_to_dict(scfres): if not isinstance(scfres, scf.hf.SCF): - raise TypeError("Unsupported type for backends.pyscf.import_scf.") + raise InvalidReference("Unsupported type for backends.pyscf.convert_scf_to_dict.") if not scfres.converged: - raise ValueError("Cannot start an adc calculation on top of an SCF, " - "which is not yet converged. Did you forget to run " - "the kernel() or the scf() function of the pyscf scf " - "object?") + raise InvalidReference("Cannot start an adc calculation on top of an SCF, " + "which is not yet converged. Did you forget to run " + "the kernel() or the scf() function of the pyscf scf " + "object?") # Try to determine whether we are restricted if isinstance(scfres.mo_occ, list): @@ -201,8 +203,8 @@ def convert_scf_to_dict(scfres): elif isinstance(scfres.mo_occ, np.ndarray): restricted = scfres.mo_occ.ndim < 2 else: - raise ValueError("Unusual pyscf SCF class encountered. Could not " - "determine restricted / unrestricted.") + raise InvalidReference("Unusual pyscf SCF class encountered. Could not " + "determine restricted / unrestricted.") mo_occ = scfres.mo_occ mo_energy = scfres.mo_energy @@ -228,16 +230,16 @@ def convert_scf_to_dict(scfres): n_orbs_beta = mo_coeff[1].shape[1] n_orbs = n_orbs_alpha + n_orbs_beta if n_orbs_alpha != n_orbs_beta: - raise ValueError("adcc cannot deal with different number of alpha and " - "beta orbitals like in a restricted " - "open-shell reference at the moment.") + raise InvalidReference("adcc cannot deal with different number of alpha and " + "beta orbitals like in a restricted " + "open-shell reference at the moment.") # Determine number of electrons n_alpha = np.sum(mo_occ[0] > 0) n_beta = np.sum(mo_occ[1] > 0) if n_alpha != np.sum(mo_occ[0]) or n_beta != np.sum(mo_occ[1]): - raise ValueError("Fractional occupation numbers are not supported " - "in adcc.") + raise InvalidReference("Fractional occupation numbers are not supported " + "in adcc.") # conv_tol is energy convergence, conv_tol_grad is gradient convergence if scfres.conv_tol_grad is None: @@ -365,14 +367,19 @@ def convert_scf_to_dict(scfres): def import_scf(scfres): + # TODO This could be a bit more verbose + if not isinstance(scfres, scf.hf.SCF): - raise TypeError("Unsupported type for backends.pyscf.import_scf.") + raise InvalidReference("Unsupported type for backends.pyscf.import_scf.") if not scfres.converged: - raise ValueError("Cannot start an adc calculation on top of an SCF, " - "which is not yet converged. Did you forget to run " - "the kernel() or the scf() function of the pyscf scf " - "object?") + raise InvalidReference("Cannot start an adc calculation on top of an SCF, " + "which is not yet converged. Did you forget to run " + "the kernel() or the scf() function of the pyscf scf " + "object?") + + # TODO Check for point-group symmetry, + # check for density-fitting or choleski # Try to determine whether we are restricted if isinstance(scfres.mo_occ, list): @@ -380,8 +387,8 @@ def import_scf(scfres): elif isinstance(scfres.mo_occ, np.ndarray): restricted = scfres.mo_occ.ndim < 2 else: - raise ValueError("Unusual pyscf SCF class encountered. Could not " - "determine restricted / unrestricted.") + raise InvalidReference("Unusual pyscf SCF class encountered. Could not " + "determine restricted / unrestricted.") if restricted: return PyScfHFProvider(scfres) diff --git a/adcc/backends/veloxchem.py b/adcc/backends/veloxchem.py index d657fb2c..bee0665e 100644 --- a/adcc/backends/veloxchem.py +++ b/adcc/backends/veloxchem.py @@ -25,9 +25,11 @@ import numpy as np import veloxchem as vlx -from mpi4py import MPI +from .InvalidReference import InvalidReference from .eri_build_helper import (EriBuilder, SpinBlockSlice, get_symm_equivalent_transpositions_for_block) + +from mpi4py import MPI from adcc.misc import cached_property from libadcc import HartreeFockProvider @@ -279,30 +281,31 @@ def flush_cache(self): def import_scf(scfdrv): + # TODO This could be a little more informative + if not isinstance(scfdrv, vlx.scfrestdriver.ScfRestrictedDriver): - raise TypeError("Unsupported type for backends.veloxchem.import_scf.") + raise InvalidReference("Unsupported type for backends.veloxchem.import_scf.") if not hasattr(scfdrv, "task"): - raise TypeError("Please attach the VeloxChem task to " - "the VeloxChem SCF driver") + raise InvalidReference("Please attach the VeloxChem task to " + "the VeloxChem SCF driver") if not scfdrv.is_converged: - raise ValueError("Cannot start an adc calculation on top of an SCF, " - "which is not converged.") + raise InvalidReference("Cannot start an adc calculation on top of an SCF, " + "which is not converged.") provider = VeloxChemHFProvider(scfdrv) return provider -basis_remap = { - "sto3g": "sto-3g", - "def2tzvp": "def2-tzvp", - "ccpvdz": "cc-pvdz", -} - - def run_hf(xyz, basis, charge=0, multiplicity=1, conv_tol=None, conv_tol_grad=1e-8, max_iter=150): + basis_remap = { + "sto3g": "sto-3g", + "def2tzvp": "def2-tzvp", + "ccpvdz": "cc-pvdz", + } + with tempfile.TemporaryDirectory() as tmpdir: infile = os.path.join(tmpdir, "vlx.in") outfile = os.path.join(tmpdir, "vlx.out") From 3a4a9d791528c5bcd374ab284848f97122d3b18b Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Thu, 31 Oct 2019 10:57:25 +0100 Subject: [PATCH 2/7] Move available_backends and add version check --- adcc/backends/__init__.py | 65 +++++++++++++++++++++++++++-- adcc/backends/available_backends.py | 54 ------------------------ adcc/conftest.py | 2 +- 3 files changed, 63 insertions(+), 58 deletions(-) delete mode 100644 adcc/backends/available_backends.py diff --git a/adcc/backends/__init__.py b/adcc/backends/__init__.py index db90bc36..232d943a 100644 --- a/adcc/backends/__init__.py +++ b/adcc/backends/__init__.py @@ -23,11 +23,60 @@ import os import warnings -from .available_backends import available, first_available, have_backend +from pkg_resources import parse_version import h5py -__all__ = ["import_scf_results", "run_hf", "have_backend", "available"] +from .InvalidReference import InvalidReference + +__all__ = ["import_scf_results", "run_hf", "have_backend", "available", + "InvalidReference"] + + +def is_module_available(module, min_version=None): + """Check using importlib if a module is available.""" + import importlib + + try: + mod = importlib.import_module(module) + except ImportError: + return False + + if not min_version: # No version check + return True + + if not hasattr(mod, "__version__"): + warnings.warn( + "Could not check host program {} minimal version, " + "since __version__ tag not found. Proceeding anyway." + "".format(module) + ) + return True + + if parse_version(mod.__version__) < parse_version(min_version): + warnings.warn( + "Found host program module {}, but its version {} is below " + "the least required (== {}). This host program will be ignored." + "".format(module, mod.__version__, min_version) + ) + return False + return True + + +status = { + "pyscf": is_module_available("pyscf", "1.5.0"), + "psi4": is_module_available("psi4", "1.2.1") and is_module_available("psi4.core"), + "veloxchem": is_module_available("veloxchem"), # Exports no version info + "molsturm": is_module_available("molsturm"), # Exports no version info +} + + +available = sorted([b for b in status if status[b]]) + + +def have_backend(backend): + """Is a particular backend available?""" + return status.get(backend, False) def import_scf_results(res): @@ -100,10 +149,20 @@ def run_hf(backend=None, xyz=None, basis="sto-3g", charge=0, multiplicity=1, conv_tol: energy convergence tolerance conv_tol_grad: convergence tolerance of the electronic gradient max_iter: maximum number of SCF iterations + + Note: This function only exists for testing purposes and should + not be used in production calculations. """ if not backend: - backend = first_available() + if len(available) == 0: + raise RuntimeError( + "No supported host-program available as SCF backend. " + "See https://adc-connect.org/installation.html#install-hostprogram " + "for installation instructions." + ) + else: + backend = available[0] warnings.warn("No backend specified. Using {}.".format(backend)) if not have_backend(backend): diff --git a/adcc/backends/available_backends.py b/adcc/backends/available_backends.py deleted file mode 100644 index b32dcbb0..00000000 --- a/adcc/backends/available_backends.py +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 -## vi: tabstop=4 shiftwidth=4 softtabstop=4 expandtab -## --------------------------------------------------------------------- -## -## Copyright (C) 2019 by the adcc authors -## -## This file is part of adcc. -## -## adcc is free software: you can redistribute it and/or modify -## it under the terms of the GNU General Public License as published -## by the Free Software Foundation, either version 3 of the License, or -## (at your option) any later version. -## -## adcc is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -## GNU General Public License for more details. -## -## You should have received a copy of the GNU General Public License -## along with adcc. If not, see . -## -## --------------------------------------------------------------------- - - -def is_module_available(module): - import importlib - - try: - importlib.import_module(module) - return True - except ImportError: - return False - - -status = { - "pyscf": is_module_available("pyscf"), - "psi4": is_module_available("psi4") and is_module_available("psi4.core"), - "veloxchem": is_module_available("veloxchem"), - "molsturm": is_module_available("molsturm"), -} - - -available = sorted([b for b in status if status[b]]) - - -def first_available(): - if len(available) == 0: - raise RuntimeError("No backend available.") - else: - return available[0] - - -def have_backend(backend): - return status.get(backend, False) diff --git a/adcc/conftest.py b/adcc/conftest.py index 02ffd0b8..347c7889 100644 --- a/adcc/conftest.py +++ b/adcc/conftest.py @@ -47,11 +47,11 @@ def setup_continuous_integration(session): print("Detected continuous integration session") adcc.thread_pool.reinit(2, 3) + # # Pytest Hooks # - def pytest_addoption(parser): parser.addoption( "--mode", default="fast", choices=["fast", "full"], From 341f7ed442e39d5314890129dd155b5efa0e33fe Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Thu, 31 Oct 2019 23:21:40 +0100 Subject: [PATCH 3/7] Total energy function for MP --- adcc/LazyMp.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/adcc/LazyMp.py b/adcc/LazyMp.py index a681f7b6..3f72a669 100644 --- a/adcc/LazyMp.py +++ b/adcc/LazyMp.py @@ -81,6 +81,21 @@ def dipole_moment(self, level=2): raise NotImplementedError("Only dipole moments for level 1 and 2" " are implemented.") + def energy(self, level=2): + """ + Obtain the total energy (SCF energy plus all corrections) + at a particular level of perturbation theory. + """ + if level == 0: + # Sum of orbital energies ... + raise NotImplementedError("Total MP(0) energy not implemented.") + + # Accumulator for all energy terms + energies = [self.reference_state.energy_scf] + for il in range(2, level + 1): + energies.append(self.energy_correction(il)) + return sum(energies) + @property def mp2_density(self): return self.density(2) From edc37b16844ecfbbe7fe3fd3a4dd567576f495d6 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Sat, 2 Nov 2019 14:57:40 +0100 Subject: [PATCH 4/7] Make backend detection lazy --- adcc/backends/__init__.py | 26 +++++++++++++++---------- adcc/backends/test_backends_crossref.py | 8 ++++---- adcc/test_ReferenceState_backends.py | 8 ++++---- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/adcc/backends/__init__.py b/adcc/backends/__init__.py index 232d943a..18362d3e 100644 --- a/adcc/backends/__init__.py +++ b/adcc/backends/__init__.py @@ -63,20 +63,26 @@ def is_module_available(module, min_version=None): return True -status = { - "pyscf": is_module_available("pyscf", "1.5.0"), - "psi4": is_module_available("psi4", "1.2.1") and is_module_available("psi4.core"), - "veloxchem": is_module_available("veloxchem"), # Exports no version info - "molsturm": is_module_available("molsturm"), # Exports no version info -} +# Cache for the list of available backends ... cannot be filled right now, +# since this can lead to import loops when adcc is e.g. used from Psi4 +__status = dict() -available = sorted([b for b in status if status[b]]) +def available(): + global __status + if not __status: + status = { + "pyscf": is_module_available("pyscf", "1.5.0"), + "psi4": is_module_available("psi4", "1.2.1") and is_module_available("psi4.core"), + "veloxchem": is_module_available("veloxchem"), # Exports no version info + "molsturm": is_module_available("molsturm"), # Exports no version info + } + return sorted([b for b in status if status[b]]) def have_backend(backend): """Is a particular backend available?""" - return status.get(backend, False) + return backend in available() def import_scf_results(res): @@ -155,14 +161,14 @@ def run_hf(backend=None, xyz=None, basis="sto-3g", charge=0, multiplicity=1, """ if not backend: - if len(available) == 0: + if len(available()) == 0: raise RuntimeError( "No supported host-program available as SCF backend. " "See https://adc-connect.org/installation.html#install-hostprogram " "for installation instructions." ) else: - backend = available[0] + backend = available()[0] warnings.warn("No backend specified. Using {}.".format(backend)) if not have_backend(backend): diff --git a/adcc/backends/test_backends_crossref.py b/adcc/backends/test_backends_crossref.py index 26928730..4436fdda 100644 --- a/adcc/backends/test_backends_crossref.py +++ b/adcc/backends/test_backends_crossref.py @@ -26,15 +26,15 @@ import adcc import adcc.backends -from ..misc import expand_test_templates -from .testing import cached_backend_hf - from numpy.testing import assert_allclose import pytest +from ..misc import expand_test_templates +from .testing import cached_backend_hf + # molsturm is super slow -backends = [b for b in adcc.backends.available if b != "molsturm"] +backends = [b for b in adcc.backends.available() if b != "molsturm"] basissets = ["sto3g", "sto3g", "ccpvdz"] diff --git a/adcc/test_ReferenceState_backends.py b/adcc/test_ReferenceState_backends.py index 171ab53f..7e0fa663 100644 --- a/adcc/test_ReferenceState_backends.py +++ b/adcc/test_ReferenceState_backends.py @@ -24,18 +24,18 @@ import unittest import itertools -from .misc import expand_test_templates -from .test_ReferenceState_refdata import compare_refstate_with_reference - from adcc.testdata.cache import cache from adcc.backends.testing import cached_backend_hf import pytest +from .misc import expand_test_templates +from .test_ReferenceState_refdata import compare_refstate_with_reference + # The methods to test (currently only restricted is supported in this test) testcases = [case for case in cache.hfimport.keys() if cache.hfdata[case]["restricted"]] -backends = [b for b in adcc.backends.available if b != "molsturm"] +backends = [b for b in adcc.backends.available() if b != "molsturm"] @expand_test_templates(list(itertools.product(testcases, backends))) From cd041f3c31afa319cc81ed63171c9139e5e4f325 Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Sat, 2 Nov 2019 16:29:45 +0100 Subject: [PATCH 5/7] Forgotten redirects --- adcc/solver/davidson.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/adcc/solver/davidson.py b/adcc/solver/davidson.py index a1e60668..4ec11d84 100644 --- a/adcc/solver/davidson.py +++ b/adcc/solver/davidson.py @@ -77,8 +77,8 @@ def default_print(state, identifier, file=sys.stdout): elif identifier == "is_converged": soltime = state.timer.total("iteration") print("=== Converged ===", file=file) - print(" Number of matrix applies: ", state.n_applies) - print(" Total solver time: ", strtime(soltime)) + print(" Number of matrix applies: ", state.n_applies, file=file) + print(" Total solver time: ", strtime(soltime), file=file) elif identifier == "restart": print("=== Restart ===", file=file) From 0f6af891867f57c30e82e204f5ad28d4365d22dc Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Sat, 9 Nov 2019 15:18:28 +0100 Subject: [PATCH 6/7] Index formatting tweaks --- adcc/ExcitedStates.py | 4 ++-- adcc/FormatDominantElements.py | 4 ++-- adcc/FormatIndex.py | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/adcc/ExcitedStates.py b/adcc/ExcitedStates.py index 53d5d16e..57d08e05 100644 --- a/adcc/ExcitedStates.py +++ b/adcc/ExcitedStates.py @@ -41,7 +41,7 @@ class FormatExcitationVector: - def __init__(self, matrix, tolerance=1e-3, index_format=None): + def __init__(self, matrix, tolerance=0.01, index_format=None): """ Set up a formatter class for formatting excitation vectors. @@ -471,7 +471,7 @@ def _repr_pretty_(self, pp, cycle): else: pp.text(self.describe()) - def describe_amplitudes(self, tolerance=1e-3, index_format=None): + def describe_amplitudes(self, tolerance=0.01, index_format=None): """ Return a string describing the dominant amplitudes of each excitation vector in human-readable form. The ``kwargs`` diff --git a/adcc/FormatDominantElements.py b/adcc/FormatDominantElements.py index f418ec1d..2323d241 100644 --- a/adcc/FormatDominantElements.py +++ b/adcc/FormatDominantElements.py @@ -29,9 +29,9 @@ class FormatDominantElements: - def __init__(self, mospaces, tolerance=1e-3, index_format=FormatIndexAdcc): + def __init__(self, mospaces, tolerance=0.01, index_format=FormatIndexAdcc): self.mospaces = mospaces - self.tolerance = 1e-3 + self.tolerance = tolerance self.value_format = "{:+8.3g}" # Formatting used for the values if isinstance(index_format, type): diff --git a/adcc/FormatIndex.py b/adcc/FormatIndex.py index 78d0aef0..997d48bd 100644 --- a/adcc/FormatIndex.py +++ b/adcc/FormatIndex.py @@ -245,8 +245,7 @@ def optimise_formatting(self, space_index_pairs): """ maxlen = max(len(self._translate_index(space, idx)[1]) for space, idx in space_index_pairs) - log_max_idx = int(np.log(max(1, maxlen))) - self.maxlen_offset = max(log_max_idx, self.maxlen_offset, 2) + self.maxlen_offset = max(maxlen, self.maxlen_offset, 2) def format(self, space, idx, concat_spin=True): word, offset, spin = self._translate_index(space, idx) From 53e314b6def65c8c48bffc7d167140d6c2c761fd Mon Sep 17 00:00:00 2001 From: "Michael F. Herbst" Date: Sat, 9 Nov 2019 16:46:01 +0100 Subject: [PATCH 7/7] Remove further references to ctx --- LICENSE_adccore | 15 +-------------- MANIFEST.in | 2 -- extension/AdcCore.py | 2 -- setup.py | 3 +-- 4 files changed, 2 insertions(+), 20 deletions(-) diff --git a/LICENSE_adccore b/LICENSE_adccore index 66ac3c87..f25c494a 100644 --- a/LICENSE_adccore +++ b/LICENSE_adccore @@ -2,7 +2,7 @@ #-- Introduction --# ###################### adcc and the adcc source code is released under the terms of the GNU General Public - License Version 3 (LGPLv3). This terms of release, however, do not apply to the + License Version 3 (GPLv3). This terms of release, however, do not apply to the adccore binary file `libadccore.so` (or a simlilarly named dylib file for MacOS), contained in the `adcc/lib` directory of the python code tarball or the python package directory. @@ -119,19 +119,6 @@ them, and agree to be bound by their terms and conditions. This section lists the third-party components integrated into adccore in binary form, provides the copyright holders and their terms of use. -# -# ctx -# -- **Description:** Library providing key-value C++ datastructures - for organised hierarchical storage. -- **Copyright:** Copyright (c) 2019 Michael F. Herbst -- **License:** Apache License 2.0 -- **Website:** https://github.com/mfherbst/ctx -- **Publication:** http://doi.org/10.5281/zenodo.2590706 - -To view the license statement and copyright notices, see the files -in the folder adcc/lib/libadccore_thirdparty/ctx - # # libadc # diff --git a/MANIFEST.in b/MANIFEST.in index 6fd3fc3b..8c171b99 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -14,11 +14,9 @@ include extension/AdcCore.py # (i.e. include files and compiled binary) include extension/adccore/adccore_config.json recursive-include extension/adccore/include/adcc/ *.hh -recursive-include extension/adccore/include/ctx/ *.hh include adcc/lib/libadccore.so include adcc/lib/libadccore.dylib include adcc/lib/libadccore.*.dylib include adcc/lib/libstdc++.so.* include adcc/lib/libc++.so.* include adcc/lib/libadccore_LICENSE -recursive-include adcc/lib/libadccore_thirdparty/ctx/ * diff --git a/extension/AdcCore.py b/extension/AdcCore.py index cfe7dc52..7ee1ae53 100644 --- a/extension/AdcCore.py +++ b/extension/AdcCore.py @@ -175,7 +175,6 @@ def file_globs(self): """ return [ self.install_dir + "/adccore_config.json", - self.install_dir + "/include/ctx/*.hh", self.install_dir + "/include/adcc/*.hh", self.install_dir + "/include/adcc/*/*.hh", self.library_dir + "/libadccore.so", @@ -184,7 +183,6 @@ def file_globs(self): self.library_dir + "/libstdc++.so.*", self.library_dir + "/libc++.so.*", self.library_dir + "/libadccore_LICENSE", - self.library_dir + "/libadccore_thirdparty/ctx/*", ] def get_tarball_name(self, version=None, postfix=None): diff --git a/setup.py b/setup.py index 72130ca6..d3692bd2 100755 --- a/setup.py +++ b/setup.py @@ -349,8 +349,7 @@ def run_tests(self): packages=find_packages(exclude=["*.test*", "test"]), package_data={"adcc": ["lib/*.so", "lib/*.dylib", "lib/*.so.*", - "lib/libadccore_LICENSE", - "lib/libadccore_thirdparty/ctx/*"], + "lib/libadccore_LICENSE"], "": ["LICENSE*"]}, ext_modules=ext_modules, zip_safe=False,