diff --git a/src/aspire/basis/fb_2d.py b/src/aspire/basis/fb_2d.py index 462799eddd..80225449a5 100644 --- a/src/aspire/basis/fb_2d.py +++ b/src/aspire/basis/fb_2d.py @@ -80,8 +80,8 @@ def _compute_indices(self): # We'll also generate a mapping for complex construction self.complex_count = sum(self.k_max) # These map indices in complex array to pair of indices in real array - self._pos = np.zeros(self.complex_count, dtype=np.int) - self._neg = np.zeros(self.complex_count, dtype=np.int) + self._pos = np.zeros(self.complex_count, dtype=int) + self._neg = np.zeros(self.complex_count, dtype=int) i = 0 ci = 0 @@ -217,7 +217,7 @@ def evaluate(self, v): x = np.zeros(shape=tuple([np.prod(self.sz)] + list(v.shape[1:])), dtype=v.dtype) for ell in range(0, self.ell_max + 1): k_max = self.k_max[ell] - idx_radial = ind_radial + np.arange(0, k_max, dtype=np.int) + idx_radial = ind_radial + np.arange(0, k_max, dtype=int) # include the normalization factor of angular part ang_nrms = self.angular_norms[idx_radial] @@ -228,7 +228,7 @@ def evaluate(self, v): for _ in sgns: ang = self._precomp["ang"][:, ind_ang] ang_radial = np.expand_dims(ang[ang_idx], axis=1) * radial[r_idx] - idx = ind + np.arange(0, k_max, dtype=np.int) + idx = ind + np.arange(0, k_max, dtype=int) x[mask] += ang_radial @ v[idx] ind += len(idx) ind_ang += 1 diff --git a/src/aspire/basis/fb_3d.py b/src/aspire/basis/fb_3d.py index d6f2080929..abd37fc1d4 100644 --- a/src/aspire/basis/fb_3d.py +++ b/src/aspire/basis/fb_3d.py @@ -67,9 +67,9 @@ def indices(self): """ Create the indices for each basis function """ - indices_ells = np.zeros(self.count, dtype=np.int) - indices_ms = np.zeros(self.count, dtype=np.int) - indices_ks = np.zeros(self.count, dtype=np.int) + indices_ells = np.zeros(self.count, dtype=int) + indices_ms = np.zeros(self.count, dtype=int) + indices_ks = np.zeros(self.count, dtype=int) ind = 0 for ell in range(self.ell_max + 1): diff --git a/src/aspire/basis/ffb_2d.py b/src/aspire/basis/ffb_2d.py index d99ac9faca..af9c58063b 100644 --- a/src/aspire/basis/ffb_2d.py +++ b/src/aspire/basis/ffb_2d.py @@ -135,7 +135,7 @@ def evaluate(self, v): ind = 0 - idx = ind + np.arange(self.k_max[0], dtype=np.int) + idx = ind + np.arange(self.k_max[0], dtype=int) # include the normalization factor of angular part into radial part radial_norm = self._precomp["radial"] / np.expand_dims(self.angular_norms, 1) @@ -145,8 +145,8 @@ def evaluate(self, v): ind_pos = ind for ell in range(1, self.ell_max + 1): - idx = ind + np.arange(self.k_max[ell], dtype=np.int) - idx_pos = ind_pos + np.arange(self.k_max[ell], dtype=np.int) + idx = ind + np.arange(self.k_max[ell], dtype=int) + idx_pos = ind_pos + np.arange(self.k_max[ell], dtype=int) idx_neg = idx_pos + self.k_max[ell] v_ell = (v[:, idx_pos] - 1j * v[:, idx_neg]) / 2.0 diff --git a/src/aspire/classification/legacy_implementations.py b/src/aspire/classification/legacy_implementations.py index 295bb40d31..9f7795e137 100644 --- a/src/aspire/classification/legacy_implementations.py +++ b/src/aspire/classification/legacy_implementations.py @@ -191,7 +191,7 @@ def bispec_2drot_large(coeff, freqs, eigval, alpha, sample_n): freqs_not_zero = freqs != 0 coeff_norm = np.log(np.power(np.absolute(coeff[freqs_not_zero]), alpha)) - if np.any(coeff_norm == np.float("-inf")): + if np.any(coeff_norm == float("-inf")): raise ValueError("coeff_norm should not be -inf") phase = coeff[freqs_not_zero] / np.absolute(coeff[freqs_not_zero]) diff --git a/src/aspire/ctf/ctf_estimator.py b/src/aspire/ctf/ctf_estimator.py index 9cc8a232ae..560f53ca8d 100644 --- a/src/aspire/ctf/ctf_estimator.py +++ b/src/aspire/ctf/ctf_estimator.py @@ -581,8 +581,8 @@ def gd( rad_sq_min = N * pixel_size / g_min rad_sq_max = N * pixel_size / g_max - max_val = r[center, np.int(center - 1 + np.floor(rad_sq_max))] - min_val = r[center, np.int(center - 1 + np.ceil(rad_sq_min))] + max_val = r[center, int(center - 1 + np.floor(rad_sq_max))] + min_val = r[center, int(center - 1 + np.ceil(rad_sq_min))] mask = (r <= max_val) & (r > min_val) a = a[mask] diff --git a/src/aspire/operators/blk_diag_matrix.py b/src/aspire/operators/blk_diag_matrix.py index 3fccc4a7c0..884e1f9581 100644 --- a/src/aspire/operators/blk_diag_matrix.py +++ b/src/aspire/operators/blk_diag_matrix.py @@ -621,7 +621,7 @@ def partition(self): """ if self._cached_blk_sizes is None: - blk_sizes = np.empty((self.nblocks, 2), dtype=np.int) + blk_sizes = np.empty((self.nblocks, 2), dtype=int) for i, blk in enumerate(self.data): blk_sizes[i] = np.shape(blk) self._cached_blk_sizes = blk_sizes diff --git a/src/aspire/reconstruction/mean.py b/src/aspire/reconstruction/mean.py index a126848ee3..6c2f7151fc 100644 --- a/src/aspire/reconstruction/mean.py +++ b/src/aspire/reconstruction/mean.py @@ -19,7 +19,7 @@ def compute_kernel(self): sq_filters_f = self.src.eval_filter_grid(self.L, power=2) for i in range(0, self.n, self.batch_size): - _range = np.arange(i, min(self.n, i + self.batch_size), dtype=np.int) + _range = np.arange(i, min(self.n, i + self.batch_size), dtype=int) pts_rot = rotated_grids(self.L, self.src.rots[_range, :, :]) weights = sq_filters_f[:, :, _range] weights *= self.src.amplitudes[_range] ** 2 diff --git a/src/aspire/source/image.py b/src/aspire/source/image.py index b345692d71..08fedc9d00 100644 --- a/src/aspire/source/image.py +++ b/src/aspire/source/image.py @@ -387,7 +387,7 @@ def images(self, start, num, *args, **kwargs): :param kwargs: Any additional keyword arguments to pass on to the `ImageSource`'s underlying `_images` method. :return: an `Image` object. """ - indices = np.arange(start, min(start + num, self.n), dtype=np.int) + indices = np.arange(start, min(start + num, self.n), dtype=int) if self._cached_im is not None: logger.info("Loading images from cache") diff --git a/src/aspire/source/simulation.py b/src/aspire/source/simulation.py index aaa933923e..f199fecdfb 100644 --- a/src/aspire/source/simulation.py +++ b/src/aspire/source/simulation.py @@ -179,7 +179,7 @@ def clean_images(self, start=0, num=np.inf, indices=None): def _images(self, start=0, num=np.inf, indices=None, enable_noise=True): if indices is None: - indices = np.arange(start, min(start + num, self.n), dtype=np.int) + indices = np.arange(start, min(start + num, self.n), dtype=int) im = self.projections(start=start, num=num, indices=indices) diff --git a/tests/test_utils.py b/tests/test_utils.py index b78e68a8cc..a9c108c7d2 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -47,4 +47,4 @@ def testGetTestTol(self): self.assertEqual(1e-8, utest_tolerance(np.float64)) self.assertEqual(1e-5, utest_tolerance(np.float32)) with raises(TypeError): - utest_tolerance(np.int) + utest_tolerance(int) diff --git a/tutorials/examples/basic_image_array.py b/tutorials/examples/basic_image_array.py index ff5f7035ab..ee7873ce0b 100644 --- a/tutorials/examples/basic_image_array.py +++ b/tutorials/examples/basic_image_array.py @@ -143,7 +143,7 @@ def noise_function(x, y): def radial_profile(data): y, x = np.indices((data.shape)) # Distance from origin to lower left corner - r = np.sqrt(x ** 2 + y ** 2).astype(np.int) + r = np.sqrt(x ** 2 + y ** 2).astype(int) binsum = np.bincount(r.ravel(), np.log(1 + data.ravel())) bincount = np.bincount(r.ravel()) # Return the mean per bin diff --git a/tutorials/notebooks/Class_Averaging_RIR_FSPCA.ipynb b/tutorials/notebooks/Class_Averaging_RIR_FSPCA.ipynb index 6f573f5462..5b36a47e96 100644 --- a/tutorials/notebooks/Class_Averaging_RIR_FSPCA.ipynb +++ b/tutorials/notebooks/Class_Averaging_RIR_FSPCA.ipynb @@ -425,7 +425,7 @@ "include_refl = True # I'll have to get some help regarding the reflected set. I don't like the results.\n", "\n", "# angles had a bug in Simulation\n", - "angles = src._rotations.as_euler('ZYZ', degrees=True).astype(np.int)\n", + "angles = src._rotations.as_euler('ZYZ', degrees=True).astype(int)\n", "print(angles.shape)\n", "\n", "logger.info(\"Classed Sample:\")\n", @@ -1552,7 +1552,7 @@ "source": [ "\n", "# angles had a bug in Simulation\n", - "angles = src._rotations.as_euler('ZYZ', degrees=True).astype(np.int)\n", + "angles = src._rotations.as_euler('ZYZ', degrees=True).astype(int)\n", "#ex_a = angles[neighbors][class_refl[c]][:,[1,0,2]].shape\n", "#ex_r = src.rots[neighbors]\n", "\n",