From 08c8dd8d52a392cf3d9d9be7953df9606c2fac5b Mon Sep 17 00:00:00 2001 From: Toon Verstraelen Date: Fri, 2 Aug 2024 08:55:42 +0200 Subject: [PATCH] Fix compatibility with changes in IOData (prepare_segmented) Fixes #195 The required function is imported locally from the iodata library because the wrapper module also contains a wrapper for pyscf. When the import is made at the top and IOData is not installed, it would also become impossible to use the pyscf wrapper. (You may want to split the wrapper module into one per package to avoid local imports, but this is not critical.) This commit includes a few side effects: - Ruff fixes were required in wrappers.py to make the commit. - .envrc is added to .gitignore. I used direnv for managing environments --- .gitignore | 1 + gbasis/wrappers.py | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index b43b2b0b..7ffda729 100644 --- a/.gitignore +++ b/.gitignore @@ -83,6 +83,7 @@ celerybeat-schedule *.sage.py # Environments +.envrc .env .venv env/ diff --git a/gbasis/wrappers.py b/gbasis/wrappers.py index cb550b2f..f006a4a7 100644 --- a/gbasis/wrappers.py +++ b/gbasis/wrappers.py @@ -1,8 +1,8 @@ """Module for interfacing to other quantum chemistry packages.""" -from gbasis.contractions import GeneralizedContractionShell import numpy as np +from gbasis.contractions import GeneralizedContractionShell CONVENTIONS_LIBCINT = { (5, "p"): ["s5", "s4", "s3", "s2", "s1", "c0", "c1", "c2", "c3", "c4", "c5"], @@ -123,7 +123,9 @@ def from_iodata(mol): raise ValueError("`mol` must be an IOData instance.") # GBasis can only work with segmented basis sets. - molbasis = mol.obasis.get_segmented() + from iodata.convert import convert_to_segmented + + molbasis = convert_to_segmented(mol.obasis) cart_conventions = {i[0]: j for i, j in molbasis.conventions.items() if i[1] == "c"} sph_conventions = {i[0]: j for i, j in molbasis.conventions.items() if i[1] == "p"} @@ -187,7 +189,7 @@ def angmom_components_sph(self): if self.angmom not in sph_conventions: raise ValueError( "Given convention does not support spherical contractions for the angular " - "momentum {0}".format(self.angmom) + f"momentum {self.angmom}" ) return tuple(sph_conventions[self.angmom]) @@ -228,7 +230,7 @@ def permutation_libcint(self): if molbasis.primitive_normalization != "L2": # pragma: no cover raise ValueError( "Only L2 normalization scheme is supported in `gbasis`. Given `IOData` instance uses " - "primitive normalization scheme, {}".format(molbasis.primitive_normalization) + f"primitive normalization scheme, {molbasis.primitive_normalization}" ) basis = []