Skip to content

Commit e1c7389

Browse files
committed
Formatting feedback from flake
1 parent 68eaf19 commit e1c7389

10 files changed

+232
-233
lines changed

src/qmllib/kernels/__init__.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
from .distance import *
2-
from .gradient_kernels import *
3-
from .kernels import *
1+
from qmllib.kernels.distance import * # noqa:F403
2+
from qmllib.kernels.gradient_kernels import * # noqa:F403
3+
from qmllib.kernels.kernels import * # noqa:F403

src/qmllib/kernels/distance.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def p_distance(A, B, p=2):
7777
The value of the keyword argument ``p =`` sets the norm order.
7878
E.g. ``p = 1.0`` and ``p = 2.0`` with yield the Manhattan and L2 distances, respectively.
7979
80-
.. math:: D_{ij} = \|A_i - B_j\|_p
80+
.. math:: D_{ij} = \\|A_i - B_j\\|_p
8181
8282
Where :math:`A_{i}` and :math:`B_{j}` are representation vectors.
8383
D is calculated using an OpenMP parallel Fortran routine.
@@ -104,13 +104,13 @@ def p_distance(A, B, p=2):
104104

105105
D = np.empty((na, nb), order="F")
106106

107-
if type(p) == type(1):
107+
if isinstance(p, int):
108108
if p == 2:
109109
fl2_distance(A, B, D)
110110
else:
111111
fp_distance_integer(A.T, B.T, D, p)
112112

113-
elif type(p) == type(1.0):
113+
elif isinstance(p, float):
114114
if p.is_integer():
115115
p = int(p)
116116
if p == 2:

src/qmllib/kernels/gradient_kernels.py

+15-15
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import ctypes
2-
31
import numpy as np
42

53
from .fgradient_kernels import (
@@ -20,29 +18,31 @@
2018

2119
def mkl_set_num_threads(cores):
2220

23-
if cores is None:
24-
return
21+
raise NotImplementedError("Should not be here")
22+
# if cores is None:
23+
# return
2524

26-
try:
27-
mkl_rt = ctypes.CDLL("libmkl_rt.so")
28-
mkl_rt.mkl_set_num_threads(ctypes.byref(ctypes.c_int(cores)))
25+
# try:
26+
# mkl_rt = ctypes.CDLL("libmkl_rt.so")
27+
# mkl_rt.mkl_set_num_threads(ctypes.byref(ctypes.c_int(cores)))
2928

30-
except:
29+
# except:
3130

32-
pass
31+
# pass
3332

3433

3534
def mkl_get_num_threads():
3635

37-
try:
38-
mkl_rt = ctypes.CDLL("libmkl_rt.so")
39-
mkl_num_threads = mkl_rt.mkl_get_max_threads()
36+
raise NotImplementedError("Should not be here")
37+
# try:
38+
# mkl_rt = ctypes.CDLL("libmkl_rt.so")
39+
# mkl_num_threads = mkl_rt.mkl_get_max_threads()
4040

41-
return mkl_num_threads
41+
# return mkl_num_threads
4242

43-
except:
43+
# except:
4444

45-
return None
45+
# return None
4646

4747

4848
def get_global_kernel(X1, X2, Q1, Q2, SIGMA):

src/qmllib/kernels/wrappers.py

+49-50
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,65 @@
11
import numpy as np
22

33
from ..arad import get_local_kernels_arad, get_local_symmetric_kernels_arad
4-
from .fkernels import (
5-
fget_vector_kernels_gaussian,
6-
fget_vector_kernels_gaussian_symmetric,
7-
fget_vector_kernels_laplacian,
8-
)
4+
from .fkernels import fget_vector_kernels_gaussian, fget_vector_kernels_laplacian
95

6+
# TODO Duplicate function definition
7+
# def get_atomic_kernels_laplacian(mols1, mols2, sigmas):
108

11-
def get_atomic_kernels_laplacian(mols1, mols2, sigmas):
9+
# n1 = np.array([mol.natoms for mol in mols1], dtype=np.int32)
10+
# n2 = np.array([mol.natoms for mol in mols2], dtype=np.int32)
1211

13-
n1 = np.array([mol.natoms for mol in mols1], dtype=np.int32)
14-
n2 = np.array([mol.natoms for mol in mols2], dtype=np.int32)
12+
# max1 = np.max(n1)
13+
# max2 = np.max(n2)
1514

16-
max1 = np.max(n1)
17-
max2 = np.max(n2)
15+
# nm1 = n1.size
16+
# nm2 = n2.size
1817

19-
nm1 = n1.size
20-
nm2 = n2.size
18+
# cmat_size = mols1[0].representation.shape[1]
2119

22-
cmat_size = mols1[0].representation.shape[1]
20+
# x1 = np.zeros((nm1, max1, cmat_size), dtype=np.float64, order="F")
21+
# x2 = np.zeros((nm2, max2, cmat_size), dtype=np.float64, order="F")
2322

24-
x1 = np.zeros((nm1, max1, cmat_size), dtype=np.float64, order="F")
25-
x2 = np.zeros((nm2, max2, cmat_size), dtype=np.float64, order="F")
23+
# for imol in range(nm1):
24+
# x1[imol, : n1[imol], :cmat_size] = mols1[imol].representation
2625

27-
for imol in range(nm1):
28-
x1[imol, : n1[imol], :cmat_size] = mols1[imol].representation
26+
# for imol in range(nm2):
27+
# x2[imol, : n2[imol], :cmat_size] = mols2[imol].representation
2928

30-
for imol in range(nm2):
31-
x2[imol, : n2[imol], :cmat_size] = mols2[imol].representation
29+
# # Reorder for Fortran speed
30+
# x1 = np.swapaxes(x1, 0, 2)
31+
# x2 = np.swapaxes(x2, 0, 2)
3232

33-
# Reorder for Fortran speed
34-
x1 = np.swapaxes(x1, 0, 2)
35-
x2 = np.swapaxes(x2, 0, 2)
33+
# sigmas = np.asarray(sigmas, dtype=np.float64)
34+
# nsigmas = sigmas.size
3635

37-
sigmas = np.asarray(sigmas, dtype=np.float64)
38-
nsigmas = sigmas.size
39-
40-
return fget_vector_kernels_laplacian(x1, x2, n1, n2, sigmas, nm1, nm2, nsigmas)
36+
# return fget_vector_kernels_laplacian(x1, x2, n1, n2, sigmas, nm1, nm2, nsigmas)
4137

4238

4339
def get_atomic_kernels_laplacian_symmetric(mols, sigmas):
4440

45-
n = np.array([mol.natoms for mol in mols], dtype=np.int32)
41+
raise NotImplementedError("x1 is missing definition")
4642

47-
max_atoms = np.max(n)
43+
# n = np.array([mol.natoms for mol in mols], dtype=np.int32)
4844

49-
nm = n.size
45+
# max_atoms = np.max(n)
5046

51-
cmat_size = mols[0].representation.shape[1]
47+
# nm = n.size
5248

53-
x = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F")
49+
# cmat_size = mols[0].representation.shape[1]
5450

55-
for imol in range(nm):
56-
x[imol, : n[imol], :cmat_size] = mols[imol].representation
51+
# x = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F")
5752

58-
# Reorder for Fortran speed
59-
x = np.swapaxes(x, 0, 2)
53+
# for imol in range(nm):
54+
# x[imol, : n[imol], :cmat_size] = mols[imol].representation
6055

61-
sigmas = np.asarray(sigmas, dtype=np.float64)
62-
nsigmas = sigmas.size
56+
# # Reorder for Fortran speed
57+
# x = np.swapaxes(x, 0, 2)
6358

64-
return fget_vector_kernels_laplacian(x1, n, sigmas, nm, nsigmas)
59+
# sigmas = np.asarray(sigmas, dtype=np.float64)
60+
# nsigmas = sigmas.size
61+
62+
# return fget_vector_kernels_laplacian(x1, n, sigmas, nm, nsigmas)
6563

6664

6765
def arad_local_kernels(
@@ -165,23 +163,24 @@ def get_atomic_kernels_gaussian(mols1, mols2, sigmas):
165163

166164
def get_atomic_kernels_gaussian_symmetric(mols, sigmas):
167165

168-
n = np.array([mol.natoms for mol in mols], dtype=np.int32)
166+
raise NotImplementedError("nm1 not defined and x1 not used")
167+
# n = np.array([mol.natoms for mol in mols], dtype=np.int32)
169168

170-
max_atoms = np.max(n)
169+
# max_atoms = np.max(n)
171170

172-
nm = n.size
171+
# nm = n.size
173172

174-
cmat_size = mols[0].representation.shape[1]
173+
# cmat_size = mols[0].representation.shape[1]
175174

176-
x1 = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F")
175+
# x1 = np.zeros((nm, max_atoms, cmat_size), dtype=np.float64, order="F")
177176

178-
for imol in range(nm1):
179-
x[imol, : n[imol], :cmat_size] = mols[imol].representation
177+
# for imol in range(nm1):
178+
# x[imol, : n[imol], :cmat_size] = mols[imol].representation
180179

181-
# Reorder for Fortran speed
182-
x = np.swapaxes(x, 0, 2)
180+
# # Reorder for Fortran speed
181+
# x = np.swapaxes(x, 0, 2)
183182

184-
sigmas = np.array(sigmas, dtype=np.float64)
185-
nsigmas = sigmas.size
183+
# sigmas = np.array(sigmas, dtype=np.float64)
184+
# nsigmas = sigmas.size
186185

187-
return fget_vector_kernels_gaussian_symmetric(x, n, sigmas, nm, nsigmas)
186+
# return fget_vector_kernels_gaussian_symmetric(x, n, sigmas, nm, nsigmas)
+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
from .representations import *
1+
from .representations import * # noqa:F403
+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from .fchl_electric_field_kernels import *
2-
from .fchl_force_kernels import *
3-
from .fchl_representations import *
4-
from .fchl_scalar_kernels import *
1+
from .fchl_electric_field_kernels import * # noqa:F403
2+
from .fchl_force_kernels import * # noqa:F403
3+
from .fchl_representations import * # noqa:F403
4+
from .fchl_scalar_kernels import * # noqa:F403

0 commit comments

Comments
 (0)