diff --git a/pmda/hbond_analysis.py b/pmda/hbond_analysis.py index db2ab4d4..3604aa6e 100644 --- a/pmda/hbond_analysis.py +++ b/pmda/hbond_analysis.py @@ -491,7 +491,7 @@ def count_by_time(self): indices /= self.step counts = np.zeros_like(self.frames) - counts[indices.astype(np.int)] = tmp_counts + counts[indices.astype("int")] = tmp_counts return counts def count_by_type(self): @@ -511,11 +511,11 @@ def count_by_type(self): bond. """ u = self._universe() - d = u.atoms[self.hbonds[:, 1].astype(np.int)] - a = u.atoms[self.hbonds[:, 3].astype(np.int)] + d = u.atoms[self.hbonds[:, 1].astype("int")] + a = u.atoms[self.hbonds[:, 3].astype("int")] tmp_hbonds = np.array([d.resnames, d.types, a.resnames, a.types], - dtype=np.str).T + dtype="str").T hbond_type, type_counts = np.unique(tmp_hbonds, axis=0, return_counts=True) hbond_type_list = [] @@ -544,9 +544,9 @@ def count_by_ids(self): """ u = self._universe() - d = u.atoms[self.hbonds[:, 1].astype(np.int)] - h = u.atoms[self.hbonds[:, 2].astype(np.int)] - a = u.atoms[self.hbonds[:, 3].astype(np.int)] + d = u.atoms[self.hbonds[:, 1].astype("int")] + h = u.atoms[self.hbonds[:, 2].astype("int")] + a = u.atoms[self.hbonds[:, 3].astype("int")] tmp_hbonds = np.array([d.ids, h.ids, a.ids]).T hbond_ids, ids_counts = np.unique(tmp_hbonds, axis=0, diff --git a/pmda/leaflet.py b/pmda/leaflet.py index b0e0bbed..2c268e5b 100644 --- a/pmda/leaflet.py +++ b/pmda/leaflet.py @@ -145,7 +145,7 @@ def _find_connected_components(self, data, cutoff=15.0): res[0] = res[0] + i_index - 1 res[1] = res[1] - num + j_index - 1 if res.shape[1] == 0: - res = np.zeros((2, 1), dtype=np.int) + res = np.zeros((2, 1), dtype="int") edges = [(res[0, k], res[1, k]) for k in range(0, res.shape[1])] graph.add_edges_from(edges) diff --git a/pmda/rdf.py b/pmda/rdf.py index a8aabde6..20f7e1b7 100644 --- a/pmda/rdf.py +++ b/pmda/rdf.py @@ -134,7 +134,7 @@ def _single_frame(self, ts, atomgroups): count = np.histogram(dist, **self.rdf_settings)[0] volume = u.trajectory.ts.volume - return np.array([count, np.array(volume, dtype=np.float64)]) + return np.array([count, np.array(volume, dtype="float64")]) def _conclude(self, ): self.count = np.sum(self._results[:, 0]) @@ -292,7 +292,7 @@ def _prepare(self): def _single_frame(self, ts, atomgroups): ags = [[atomgroups[2*i], atomgroups[2*i+1]] for i in range(self.n)] count = [np.zeros((ag1.n_atoms, ag2.n_atoms, self.len), - dtype=np.float64) for ag1, ag2 in ags] + dtype="float64") for ag1, ag2 in ags] for i, (ag1, ag2) in enumerate(ags): u = ag1.universe pairs, dist = distances.capped_distance(ag1.positions, @@ -306,7 +306,7 @@ def _single_frame(self, ts, atomgroups): volume = u.trajectory.ts.volume - return np.array([np.array(count), np.array(volume, dtype=np.float64)]) + return np.array([np.array(count), np.array(volume, dtype="float64")]) def _conclude(self): self.count = np.sum(self._results[:, 0]) diff --git a/pmda/rms/rmsf.py b/pmda/rms/rmsf.py index ad563b55..30a56c73 100644 --- a/pmda/rms/rmsf.py +++ b/pmda/rms/rmsf.py @@ -214,7 +214,7 @@ def _reduce(res, result_single_frame): 'sum' action for time series """ atoms = result_single_frame - positions = atoms.positions.astype(np.float64) + positions = atoms.positions.astype("float64") # initial time step case if isinstance(res, list) and len(res) == 0: # initial mean position = initial position diff --git a/pmda/test/test_util.py b/pmda/test/test_util.py index 76ffecf3..1b8485d8 100644 --- a/pmda/test/test_util.py +++ b/pmda/test/test_util.py @@ -146,8 +146,8 @@ def sumofsquares(a): sos : array `n x m` array of the sum of squares for 'n' atoms """ - dev = a - np.mean(a, axis=0, dtype=np.float64) - sos = np.sum(dev**2, axis=0, dtype=np.float64) + dev = a - np.mean(a, axis=0, dtype="float64") + sos = np.sum(dev**2, axis=0, dtype="float64") return sos @@ -156,7 +156,7 @@ def pos(): """Generates array of random positions in range [-100, 100]""" return 200*(np.random.random(size=(100000, 1000, - 3)) - 0.5).astype(np.float64) + 3)) - 0.5).astype("float64") @pytest.mark.parametrize('n_frames', [3, 4, 10, 19, 101, 331, 1000]) @@ -197,7 +197,7 @@ def test_fold_second_order_moments(pos, n_frames, n_blocks): # slice "trajectory" pos into random length blocks to test more than two # cases per iteration blocks = [pos[i:j] for i, j in zip(start_indices, stop_indices)] - S = [(len(block), block.mean(axis=0, dtype=np.float64), + S = [(len(block), block.mean(axis=0, dtype="float64"), sumofsquares(block)) for block in blocks] # combine block results using fold method results = fold_second_order_moments(S) diff --git a/pmda/util.py b/pmda/util.py index ccf0eb90..d13fc0fc 100644 --- a/pmda/util.py +++ b/pmda/util.py @@ -166,8 +166,8 @@ def make_balanced_slices(n_frames, n_blocks, start=None, stop=None, step=None): # not very useful but allows calling code to work more gracefully return [] - bsizes = np.ones(n_blocks, dtype=np.int64) * n_frames // n_blocks - bsizes += (np.arange(n_blocks, dtype=np.int64) < n_frames % n_blocks) + bsizes = np.ones(n_blocks, dtype="int64") * n_frames // n_blocks + bsizes += (np.arange(n_blocks, dtype="int64") < n_frames % n_blocks) # This can give a last index that is larger than the real last index; # this is not a problem for slicing but it's not pretty. # Example: original [0:20:3] -> n_frames=7, start=0, step=3: