diff --git a/atomdb/api.py b/atomdb/api.py index d7d104ea..7c6cfb22 100644 --- a/atomdb/api.py +++ b/atomdb/api.py @@ -363,7 +363,9 @@ def load_all(elem, nexc=0, dataset=DEFAULT_DATASET, datapath=DEFAULT_DATAPATH): with open(file, "rb") as f: msg = unpack_msg(f) # Convert raw bytes back to numpy arrays, initialize the Species instance, store it - species.append(Species(**{k: frombuffer(v) if isinstance(v, bytes) else v for k, v in msg.items()})) + species.append( + Species(**{k: frombuffer(v) if isinstance(v, bytes) else v for k, v in msg.items()}) + ) return species diff --git a/atomdb/datasets/uhf_augccpvdz/__init__.py b/atomdb/datasets/uhf_augccpvdz/__init__.py index 87ba6040..be0f9538 100644 --- a/atomdb/datasets/uhf_augccpvdz/__init__.py +++ b/atomdb/datasets/uhf_augccpvdz/__init__.py @@ -94,9 +94,7 @@ def eval_orb_ked(one_density_matrix, basis, points, transform=None): "Adapted from Gbasis" orbt_ked = 0 for orders in np.identity(3, dtype=int): - deriv_orb_eval_one = evaluate_deriv_basis( - basis, points, orders, transform=transform - ) + deriv_orb_eval_one = evaluate_deriv_basis(basis, points, orders, transform=transform) deriv_orb_eval_two = deriv_orb_eval_one # orders_one == orders_two density = one_density_matrix.dot(deriv_orb_eval_two) density *= deriv_orb_eval_one diff --git a/atomdb/promolecule.py b/atomdb/promolecule.py index b116181c..9aa38f8e 100644 --- a/atomdb/promolecule.py +++ b/atomdb/promolecule.py @@ -407,7 +407,10 @@ def make_promolecule( # Handle default multiplicity parameters if mults is None: # Force non-int charge to be integer here; it will be overwritten below. - mults = [MULTIPLICITIES[int(np.round(atnum - charge))] for (atnum, charge) in zip(atnums, charges)] + mults = [ + MULTIPLICITIES[int(np.round(atnum - charge))] + for (atnum, charge) in zip(atnums, charges) + ] # Construct linear combination of species promol = Promolecule() @@ -424,8 +427,10 @@ def make_promolecule( promol.append(specie, coord, 1.0) continue except FileNotFoundError: - warn("Unable to load species corresponding to `charge, mult`; " - "generating species via linear combination of other species'") + warn( + "Unable to load species corresponding to `charge, mult`; " + "generating species via linear combination of other species'" + ) # Non-integer charge and multiplicity # @@ -433,7 +438,7 @@ def make_promolecule( nspin = np.sign(mult) * (abs(mult) - 1) # Get all candidates for linear combination species_list = load_all(atom, dataset=dataset, datapath=datapath) - for specie in species_list[:len(species_list)]: + for specie in species_list[: len(species_list)]: if specie.nspin > 0: specie_neg_spinpol = deepcopy(specie) specie_neg_spinpol.spinpol = -1 @@ -445,11 +450,14 @@ def make_promolecule( energies = np.asarray([t.energy for t in ts], dtype=float) result = linprog( energies, - A_eq=np.asarray([ - [1 for t in ts], - [t.nelec for t in ts], - [t.nspin * t.spinpol for t in ts], - ], dtype=float), + A_eq=np.asarray( + [ + [1 for t in ts], + [t.nelec for t in ts], + [t.nspin * t.spinpol for t in ts], + ], + dtype=float, + ), b_eq=np.asarray([1, nelec, nspin], dtype=float), bounds=(0, 1), ) @@ -508,9 +516,15 @@ def _cart_to_bary(x0, y0, s1, s2, s3): r"""Helper function for computing barycentric coordinates.""" x1, x2, x3 = s1.nelec, s2.nelec, s3.nelec y1, y2, y3 = s1.nspin, s2.nspin, s3.nspin - lambda1 = ((y2 - y3) * (x0 - x3) + (x3 - x2) * (y0 - y3) / - (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3)) - lambda2 = ((y3 - y1) * (x0 - x3) + (x1 - x3) * (y0 - y3) / - (y2 - y3) * (x1 - x3) + (x3 - x2) * (y1 - y3)) + lambda1 = ( + (y2 - y3) * (x0 - x3) + + (x3 - x2) * (y0 - y3) / (y2 - y3) * (x1 - x3) + + (x3 - x2) * (y1 - y3) + ) + lambda2 = ( + (y3 - y1) * (x0 - x3) + + (x1 - x3) * (y0 - y3) / (y2 - y3) * (x1 - x3) + + (x3 - x2) * (y1 - y3) + ) lambda3 = 1 - lambda1 - lambda2 return (lambda1, lambda2, lambda3) diff --git a/atomdb/test/test_promolecule.py b/atomdb/test/test_promolecule.py index 466740dc..7c4f14db 100644 --- a/atomdb/test/test_promolecule.py +++ b/atomdb/test/test_promolecule.py @@ -36,10 +36,13 @@ pytest.param( { "atnums": [1, 1], - "coords": np.asarray([ - [ 0., 0., 0.], - [ 0., 0., 1.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + [0.0, 0.0, 1.0], + ], + dtype=float, + ), "dataset": "slater", }, id="H2 default charge/mult", @@ -48,10 +51,13 @@ { "atnums": [6, 6], "charges": [1, -1], - "coords": np.asarray([ - [ 0., 0., 0.], - [ 0., 0., 1.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + [0.0, 0.0, 1.0], + ], + dtype=float, + ), "dataset": "slater", }, id="C2 +/-1 charge, default mult", @@ -61,10 +67,13 @@ "atnums": [6, 6], "charges": [0.5, -0.5], "mults": [1, -1], - "coords": np.asarray([ - [ 0., 0., 0.], - [ 0., 0., 1.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + [0.0, 0.0, 1.0], + ], + dtype=float, + ), "dataset": "slater", }, id="C2 +/-0.5 charge", @@ -74,9 +83,12 @@ "atnums": [4], "charges": [1.2], "mults": [1.2], - "coords": np.asarray([ - [ 0., 0., 0.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + ], + dtype=float, + ), "dataset": "uhf_augccpvdz", }, id="Be floating point charge/floating point mult", @@ -86,9 +98,12 @@ "atnums": [4], "charges": [1.2], "mults": [1], - "coords": np.asarray([ - [ 0., 0., 0.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + ], + dtype=float, + ), "dataset": "uhf_augccpvdz", }, id="Be floating point charge/integer mult", @@ -98,9 +113,12 @@ "atnums": [4], "charges": [1.2], "mults": [-1.2], - "coords": np.asarray([ - [ 0., 0., 0.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + ], + dtype=float, + ), "dataset": "uhf_augccpvdz", }, id="Be floating point charge/floating point mult (neg)", @@ -110,9 +128,12 @@ "atnums": [4], "charges": [1.2], "mults": [-1], - "coords": np.asarray([ - [ 0., 0., 0.], - ], dtype=float), + "coords": np.asarray( + [ + [0.0, 0.0, 0.0], + ], + dtype=float, + ), "dataset": "uhf_augccpvdz", }, id="Be floating point charge/integer mult (neg)",