Skip to content

Commit 9fbf8be

Browse files
committed
Format according to preview ruff rules
1 parent 1ccc83d commit 9fbf8be

53 files changed

Lines changed: 277 additions & 279 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

qstack/basis_opt/opt.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ def energy(x):
4343
E += qbbt.energy_mol(newbasis, m)
4444
return E
4545

46-
4746
def gradient(x):
4847
"""Compute total loss function (fitting error) and gradient for given exponents.
4948
@@ -76,7 +75,6 @@ def gradient(x):
7675
dE_dx = dE_da * exponents
7776
return E, dE_dx
7877

79-
8078
def gradient_only(x):
8179
"""Compute only the gradient of the loss function (wrapper for optimization algorithms).
8280
@@ -88,7 +86,6 @@ def gradient_only(x):
8886
"""
8987
return gradient(x)[1]
9088

91-
9289
def read_bases(basis_files):
9390
"""Read basis set definitions from files or dicts.
9491
@@ -117,7 +114,6 @@ def read_bases(basis_files):
117114
basis.update(i)
118115
return basis
119116

120-
121117
def make_bf_start():
122118
"""Create basis function index bounds for each element.
123119
@@ -131,7 +127,6 @@ def make_bf_start():
131127
bf_bounds[q] = [start, start+nbf[i]]
132128
return bf_bounds
133129

134-
135130
def make_moldata(fname):
136131
"""Create molecular data dictionary from file or dict.
137132

qstack/constants.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@
33
https://physics.nist.gov/cuu/Constants/
44
https://physics.nist.gov/cuu/Constants/Table/allascii.txt
55
"""
6+
import math
7+
8+
69
# Constants
710
SPEED_LIGHT = 299792458.0
811
PLANCK = 6.62607004e-34
9-
HBAR = PLANCK/(2*3.141592653589793)
12+
HBAR = PLANCK/(2*math.pi)
1013
FUND_CHARGE = 1.6021766208e-19
1114
MOL_NA = 6.022140857e23
1215
MASS_E = 9.10938356e-31
@@ -20,4 +23,4 @@
2023
BOHR2ANGS = 0.52917721092 # Angstroms
2124
HARTREE2J = HBAR**2/(MASS_E*(BOHR2ANGS*1e-10)**2)
2225
HARTREE2EV = 27.21138602
23-
AU2DEBYE = FUND_CHARGE * BOHR2ANGS*1e-10 / DEBYE # 2.541746
26+
AU2DEBYE = FUND_CHARGE * BOHR2ANGS*1e-10 / DEBYE # 2.541746

qstack/equio.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
_molid_name = 'mol_id'
2929

3030

31-
3231
def _get_llist(mol):
3332
"""Get list of angular momentum quantum numbers for basis functions of each element of a molecule.
3433
@@ -50,7 +49,7 @@ def _get_tsize(tensor):
5049
Returns:
5150
int: Total size of the tensor (total number of elements).
5251
"""
53-
return sum([np.prod(tensor.block(key).values.shape) for key in tensor.keys])
52+
return sum(np.prod(tensor.block(key).values.shape) for key in tensor.keys)
5453

5554

5655
def _labels_to_array(labels):
@@ -120,19 +119,19 @@ def vector_to_tensormap(mol, c):
120119
if llists[q]==sorted(llists[q]):
121120
for l in set(llists[q]):
122121
msize = 2*l+1
123-
nsize = blocks[(l,q)].shape[-1]
122+
nsize = blocks[l,q].shape[-1]
124123
cslice = c[i(nsize*msize)].reshape(nsize,msize).T
125124
if l==1: # for l=1, the pyscf order is x,y,z (1,-1,0)
126125
cslice = cslice[pyscf2gpr_l1_order]
127-
blocks[(l,q)][iq[q],:,:] = cslice
126+
blocks[l,q][iq[q],:,:] = cslice
128127
else:
129128
il = dict.fromkeys(range(max(llists[q]) + 1), 0)
130129
for l in llists[q]:
131130
msize = 2*l+1
132131
cslice = c[i(msize)]
133132
if l==1: # for l=1, the pyscf order is x,y,z (1,-1,0)
134133
cslice = cslice[pyscf2gpr_l1_order]
135-
blocks[(l,q)][iq[q],:,il[l]] = cslice
134+
blocks[l,q][iq[q],:,il[l]] = cslice
136135
il[l] += 1
137136
iq[q] += 1
138137

@@ -256,7 +255,7 @@ def matrix_to_tensormap(mol, dm):
256255
dmslice = np.transpose(dmslice, axes=[1,3,0,2]).reshape(msize1,msize2,-1)
257256
block = tensor_blocks[tm_label_vals.index((l1,l2,q1,q2))]
258257
at_p = block.samples.position((iat1,iat2))
259-
blocks[(l1,l2,q1,q2)][at_p,:,:,:] = dmslice
258+
blocks[l1,l2,q1,q2][at_p,:,:,:] = dmslice
260259
iq2[q2] += 1
261260
iq1[q1] += 1
262261
else:
@@ -275,7 +274,7 @@ def matrix_to_tensormap(mol, dm):
275274
block = tensor_blocks[tm_label_vals.index((l1, l2, q1, q2))]
276275
at_p = block.samples.position((iat1, iat2))
277276
n_p = block.properties.position((il1[l1], il2[l2]))
278-
blocks[(l1,l2,q1,q2)][at_p,:,:,n_p] = dmslice
277+
blocks[l1,l2,q1,q2][at_p,:,:,n_p] = dmslice
279278
il2[l2] += 1
280279
iq2[q2] += 1
281280
il1[l1] += 1
@@ -486,7 +485,7 @@ def split(tensor):
486485
continue
487486
sampleidx = [t[0] for t in samples]
488487
samplelbl = [t[1] for t in samples]
489-
#sampleidx = [block.samples.position(lbl) for lbl in samplelbl]
488+
# sampleidx = [block.samples.position(lbl) for lbl in samplelbl]
490489

491490
blocks[key] = block.values[sampleidx]
492491
block_samp_labels[key] = metatensor.Labels(tensor.sample_names[1:], np.array(samplelbl)[:,1:])

qstack/fields/dm.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,4 +103,3 @@ def sphericalize_density_matrix(mol, dm):
103103
spherical_dm[idx+m,jdx+m] = trace / msize
104104

105105
return spherical_dm
106-

qstack/fields/dori.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def eval_rho_dm(mol, ao, dm, deriv=2):
4444
if deriv==2:
4545
DM_dAO_dr_i = 2 * _dot_ao_dm(mol, dAO_dr[i], dm, None, None, None)
4646
for j in range(i, 3):
47-
d2rho_dr2[i,j] = _contract_rho(dAO_dr[j], DM_dAO_dr_i) + 2.0*np.einsum('ip,ip->i', d2AO_dr2[triu_idx[(i,j)]], DM_AO)
47+
d2rho_dr2[i,j] = _contract_rho(dAO_dr[j], DM_dAO_dr_i) + 2.0*np.einsum('ip,ip->i', d2AO_dr2[triu_idx[i,j]], DM_AO)
4848
d2rho_dr2[j,i] = d2rho_dr2[i,j]
4949

5050
if deriv==1:

qstack/fields/excited.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def exciton_properties_dm(mol, hole, part):
120120
dist = np.linalg.norm(hole_r-part_r)
121121
hole_extent = np.sqrt(hole_r2-hole_r@hole_r)
122122
part_extent = np.sqrt(part_r2-part_r@part_r)
123-
return(dist, hole_extent, part_extent)
123+
return dist, hole_extent, part_extent
124124

125125

126126
def exciton_properties(mol, hole, part):

qstack/mathutils/wigner.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def get_polynom_Y(l, m):
5656
r = Symbol('r', nonnegative=True)
5757
expr = real_Y_correct_phase(l,m, theta, phi) * r**l
5858
expr = expand(expr, func=True)
59-
expr = expr.rewrite(sp.cos)#.simplify().trigsimp()
59+
expr = expr.rewrite(sp.cos) # .simplify().trigsimp()
6060
expr = expand_trig(expr)
6161
expr = cancel(expr)
6262
expr = expr.subs({r: sp.sqrt(x*x+y*y+z*z), phi: sp.atan2(y,x), theta: sp.atan2(sp.sqrt(x*x+y*y),z)})
@@ -139,7 +139,6 @@ def compute_wigner(lmax):
139139
# rotated spherical harmonic
140140
Y_rot[l][m] = Y[l][m].subs({x: x1, y:y1, z:z1}).subs({x1:xx*x+xy*y+xz*z, y1:yx*x+yy*y+yz*z, z1:zx*x+zy*y+zz*z})
141141

142-
143142
D = [zeros(2*l+1,2*l+1) for l in range(lmax+1)]
144143
integrals_xyz_dict = {}
145144
for l in range(lmax+1):
@@ -159,4 +158,3 @@ def compute_wigner(lmax):
159158

160159
D = compute_wigner(lmax)
161160
print_wigner(D)
162-

qstack/mathutils/xyz_integrals_float.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,4 +70,3 @@ def trinomial(k1, k2, k3):
7070
if __name__ == "__main__":
7171
k,n,m = map(int, sys.argv[1:4])
7272
print(f"{xyz(k,n,m):.15f} π")
73-

qstack/orcaio.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,6 @@ def read_density(mol, basename, directory='./', version=500, openshell=False, re
9191
else:
9292
dm = np.fromfile(path[0], offset=8, count=mol.nao*mol.nao*nspin).reshape((nspin,mol.nao,mol.nao))
9393

94-
9594
is_def2 = 'def2' in pyscf.gto.basis._format_basis_name(mol.basis)
9695
has_3d = np.any([21 <= pyscf.data.elements.charge(q) <= 30 for q in mol.elements])
9796
if is_def2 and has_3d:
@@ -277,4 +276,3 @@ def read_gbw(mol, fname, reorder_dest='pyscf', sort_l=True):
277276
if reorder_dest is not None:
278277
reorder_coeff_inplace(c, mol, reorder_dest, ls if (ls and sort_l) else None)
279278
return c, e, occ
280-

qstack/qml/b2r2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ def get_b2r2_a_molecular(ncharges, coords, elements,
177177
coords_b = coords[j]
178178
R = np.linalg.norm(coords_b - coords_a)
179179
if R < rcut:
180-
twobodyrep[bag_idx[(ncharge_a, ncharge_b)]] += get_gaussian(grid, R)
180+
twobodyrep[bag_idx[ncharge_a, ncharge_b]] += get_gaussian(grid, R)
181181

182182
twobodyrep = 2.0*np.concatenate(twobodyrep)
183183
return twobodyrep

0 commit comments

Comments
 (0)