diff options
author | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-29 11:45:17 -0700 |
---|---|---|
committer | David Luevano Alvarado <55825613+luevano@users.noreply.github.com> | 2020-02-29 11:45:17 -0700 |
commit | 53c84552df5c7a7e1f084b0aec8eac63f7813e52 (patch) | |
tree | 3f656bb9b76e8a4abb2ceeda8adac1c6b59139c7 | |
parent | 9e90b73721edf370f7be9c77aba8431bbe762bdb (diff) |
Change dtypes to np dtypes
-rw-r--r-- | ml_exp/compound.py | 8 | ||||
-rw-r--r-- | ml_exp/do_ml.py | 8 | ||||
-rw-r--r-- | ml_exp/math.py | 4 | ||||
-rw-r--r-- | ml_exp/qm7db.py | 8 | ||||
-rw-r--r-- | ml_exp/representations.py | 10 |
5 files changed, 19 insertions, 19 deletions
diff --git a/ml_exp/compound.py b/ml_exp/compound.py index e2b7ab7fd..4428e9164 100644 --- a/ml_exp/compound.py +++ b/ml_exp/compound.py @@ -153,15 +153,15 @@ class Compound: lines = f.readlines() self.name = filename.split('/')[-1] - self.n = int(lines[0]) + self.n = np.int32(lines[0]) self.extra = lines[1] self.atoms = [] - self.atoms_nc = np.empty(self.n, dtype=int) - self.coordinates = np.empty((self.n, 3), dtype=float) + self.atoms_nc = np.empty(self.n, dtype=np.int64) + self.coordinates = np.empty((self.n, 3), dtype=np.float64) for i, atom in enumerate(lines[2:self.n + 2]): atom_d = atom.split() self.atoms.append(atom_d[0]) self.atoms_nc[i] = NUCLEAR_CHARGE[atom_d[0]] - self.coordinates[i] = np.asarray(atom_d[1:4], dtype=float) + self.coordinates[i] = np.asarray(atom_d[1:4], dtype=np.float64) diff --git a/ml_exp/do_ml.py b/ml_exp/do_ml.py index db50cc8fa..04f8abe87 100644 --- a/ml_exp/do_ml.py +++ b/ml_exp/do_ml.py @@ -186,13 +186,13 @@ def do_ml(db_path='data', # Create a numpy array for the descriptors. if 'CM' in identifiers: - cm_data = np.array([comp.cm for comp in compounds], dtype=float) + cm_data = np.array([comp.cm for comp in compounds], dtype=np.float64) if 'LJM' in identifiers: - ljm_data = np.array([comp.ljm for comp in compounds], dtype=float) + ljm_data = np.array([comp.ljm for comp in compounds], dtype=np.float64) if 'AM' in identifiers: - am_data = np.array([comp.cm for comp in compounds], dtype=float) + am_data = np.array([comp.cm for comp in compounds], dtype=np.float64) if 'BOB' in identifiers: - bob_data = np.array([comp.bob for comp in compounds], dtype=float) + bob_data = np.array([comp.bob for comp in compounds], dtype=np.float64) toc = time.perf_counter() tictoc = toc - tic diff --git a/ml_exp/math.py b/ml_exp/math.py index da1fdf08f..253abe5d2 100644 --- a/ml_exp/math.py +++ b/ml_exp/math.py @@ -39,7 +39,7 @@ def cholesky_solve(K, size = K.shape[0] # Solve Lx=y for x. - x = np.zeros(size, dtype=float) + x = np.zeros(size, dtype=np.float64) x[0] = y[0] / L[0, 0] for i in range(1, size): temp_sum = 0.0 @@ -49,7 +49,7 @@ def cholesky_solve(K, # Now, solve LTa=x for a. L2 = L.T - a = np.zeros(size, dtype=float) + a = np.zeros(size, dtype=np.float64) a[size - 1] = x[size - 1] / L2[size - 1, size - 1] for i in range(0, size - 1)[::-1]: temp_sum = 0.0 diff --git a/ml_exp/qm7db.py b/ml_exp/qm7db.py index 3fd46b6bc..3ba2c5814 100644 --- a/ml_exp/qm7db.py +++ b/ml_exp/qm7db.py @@ -42,14 +42,14 @@ def qm7db(db_path='data', for i, line in enumerate(lines): line = line.split() compounds.append(Compound(f'{db_path}/{line[0]}')) - compounds[i].pbe0 = float(line[1]) - compounds[i].delta = float(line[1]) - float(line[2]) + compounds[i].pbe0 = np.float64(line[1]) + compounds[i].delta = np.float64(line[1]) - np.float64(line[2]) if is_shuffled: random.seed(r_seed) random.shuffle(compounds) - e_pbe0 = np.array([compound.pbe0 for compound in compounds], dtype=float) - e_delta = np.array([compound.delta for compound in compounds], dtype=float) + e_pbe0 = np.array([comp.pbe0 for comp in compounds], dtype=np.float64) + e_delta = np.array([comp.delta for comp in compounds], dtype=np.float64) return compounds, e_pbe0, e_delta diff --git a/ml_exp/representations.py b/ml_exp/representations.py index 5e99627df..31259c79c 100644 --- a/ml_exp/representations.py +++ b/ml_exp/representations.py @@ -53,7 +53,7 @@ size. Arrays are not of the right shape.') 'instead of (size).') size = n - cm = np.zeros((size, size), dtype=float) + cm = np.zeros((size, size), dtype=np.float64) # Actual calculation of the coulomb matrix. for i, xyz_i in enumerate(coords): @@ -120,7 +120,7 @@ size. Arrays are not of the right shape.') 'instead of (size).') size = n - lj = np.zeros((size, size), dtype=float) + lj = np.zeros((size, size), dtype=np.float64) # Actual calculation of the lennard-jones matrix. for i, xyz_i in enumerate(coords): @@ -259,7 +259,7 @@ def adjacency_matrix(fnm, instead of (size).') size = n - am = np.zeros((size, size), dtype=float) + am = np.zeros((size, size), dtype=np.float64) for i, bond_i in enumerate(bonds): for j, bond_j in enumerate(bonds): @@ -317,7 +317,7 @@ generated as the vector of eigenvalues, try (re-)generating the CM.') size = n # Bond max length, calculated using only the upper triangular matrix. - bond_size = int((size * size - size)/2 + size) + bond_size = np.int32((size * size - size)/2 + size) # List where each bag data is stored. bags = [] @@ -350,7 +350,7 @@ generated as the vector of eigenvalues, try (re-)generating the CM.') bonds = atom_list + bonds # Create the final vector for the bob. - bob = np.zeros(bond_size, dtype=float) + bob = np.zeros(bond_size, dtype=np.float64) c_i = 0 for i, bond in enumerate(bonds): checker = check_bond(bags, bond) |