Skip to content

Commit da4d44c

Browse files
authored
Merge pull request #454 from ComputationalCryoEM/py_39_np_updates
Numpy Updates
2 parents 9866e0a + 9b5ac4b commit da4d44c

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

src/aspire/basis/fb_2d.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def _compute_indices(self):
8080
# We'll also generate a mapping for complex construction
8181
self.complex_count = sum(self.k_max)
8282
# These map indices in complex array to pair of indices in real array
83-
self._pos = np.zeros(self.complex_count, dtype=np.int)
84-
self._neg = np.zeros(self.complex_count, dtype=np.int)
83+
self._pos = np.zeros(self.complex_count, dtype=int)
84+
self._neg = np.zeros(self.complex_count, dtype=int)
8585

8686
i = 0
8787
ci = 0
@@ -217,7 +217,7 @@ def evaluate(self, v):
217217
x = np.zeros(shape=tuple([np.prod(self.sz)] + list(v.shape[1:])), dtype=v.dtype)
218218
for ell in range(0, self.ell_max + 1):
219219
k_max = self.k_max[ell]
220-
idx_radial = ind_radial + np.arange(0, k_max, dtype=np.int)
220+
idx_radial = ind_radial + np.arange(0, k_max, dtype=int)
221221

222222
# include the normalization factor of angular part
223223
ang_nrms = self.angular_norms[idx_radial]
@@ -228,7 +228,7 @@ def evaluate(self, v):
228228
for _ in sgns:
229229
ang = self._precomp["ang"][:, ind_ang]
230230
ang_radial = np.expand_dims(ang[ang_idx], axis=1) * radial[r_idx]
231-
idx = ind + np.arange(0, k_max, dtype=np.int)
231+
idx = ind + np.arange(0, k_max, dtype=int)
232232
x[mask] += ang_radial @ v[idx]
233233
ind += len(idx)
234234
ind_ang += 1

src/aspire/basis/fb_3d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ def indices(self):
6767
"""
6868
Create the indices for each basis function
6969
"""
70-
indices_ells = np.zeros(self.count, dtype=np.int)
71-
indices_ms = np.zeros(self.count, dtype=np.int)
72-
indices_ks = np.zeros(self.count, dtype=np.int)
70+
indices_ells = np.zeros(self.count, dtype=int)
71+
indices_ms = np.zeros(self.count, dtype=int)
72+
indices_ks = np.zeros(self.count, dtype=int)
7373

7474
ind = 0
7575
for ell in range(self.ell_max + 1):

src/aspire/basis/ffb_2d.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def evaluate(self, v):
135135

136136
ind = 0
137137

138-
idx = ind + np.arange(self.k_max[0], dtype=np.int)
138+
idx = ind + np.arange(self.k_max[0], dtype=int)
139139

140140
# include the normalization factor of angular part into radial part
141141
radial_norm = self._precomp["radial"] / np.expand_dims(self.angular_norms, 1)
@@ -145,8 +145,8 @@ def evaluate(self, v):
145145
ind_pos = ind
146146

147147
for ell in range(1, self.ell_max + 1):
148-
idx = ind + np.arange(self.k_max[ell], dtype=np.int)
149-
idx_pos = ind_pos + np.arange(self.k_max[ell], dtype=np.int)
148+
idx = ind + np.arange(self.k_max[ell], dtype=int)
149+
idx_pos = ind_pos + np.arange(self.k_max[ell], dtype=int)
150150
idx_neg = idx_pos + self.k_max[ell]
151151

152152
v_ell = (v[:, idx_pos] - 1j * v[:, idx_neg]) / 2.0

src/aspire/classification/legacy_implementations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def bispec_2drot_large(coeff, freqs, eigval, alpha, sample_n):
191191
freqs_not_zero = freqs != 0
192192

193193
coeff_norm = np.log(np.power(np.absolute(coeff[freqs_not_zero]), alpha))
194-
if np.any(coeff_norm == np.float("-inf")):
194+
if np.any(coeff_norm == float("-inf")):
195195
raise ValueError("coeff_norm should not be -inf")
196196

197197
phase = coeff[freqs_not_zero] / np.absolute(coeff[freqs_not_zero])

src/aspire/ctf/ctf_estimator.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,8 +581,8 @@ def gd(
581581
rad_sq_min = N * pixel_size / g_min
582582
rad_sq_max = N * pixel_size / g_max
583583

584-
max_val = r[center, np.int(center - 1 + np.floor(rad_sq_max))]
585-
min_val = r[center, np.int(center - 1 + np.ceil(rad_sq_min))]
584+
max_val = r[center, int(center - 1 + np.floor(rad_sq_max))]
585+
min_val = r[center, int(center - 1 + np.ceil(rad_sq_min))]
586586

587587
mask = (r <= max_val) & (r > min_val)
588588
a = a[mask]

src/aspire/operators/blk_diag_matrix.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -642,7 +642,7 @@ def partition(self):
642642
"""
643643

644644
if self._cached_blk_sizes is None:
645-
blk_sizes = np.empty((self.nblocks, 2), dtype=np.int)
645+
blk_sizes = np.empty((self.nblocks, 2), dtype=int)
646646
for i, blk in enumerate(self.data):
647647
blk_sizes[i] = np.shape(blk)
648648
self._cached_blk_sizes = blk_sizes

src/aspire/reconstruction/mean.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def compute_kernel(self):
1919
sq_filters_f = self.src.eval_filter_grid(self.L, power=2)
2020

2121
for i in range(0, self.n, self.batch_size):
22-
_range = np.arange(i, min(self.n, i + self.batch_size), dtype=np.int)
22+
_range = np.arange(i, min(self.n, i + self.batch_size), dtype=int)
2323
pts_rot = rotated_grids(self.L, self.src.rots[_range, :, :])
2424
weights = sq_filters_f[:, :, _range]
2525
weights *= self.src.amplitudes[_range] ** 2

src/aspire/source/image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ def images(self, start, num, *args, **kwargs):
387387
:param kwargs: Any additional keyword arguments to pass on to the `ImageSource`'s underlying `_images` method.
388388
:return: an `Image` object.
389389
"""
390-
indices = np.arange(start, min(start + num, self.n), dtype=np.int)
390+
indices = np.arange(start, min(start + num, self.n), dtype=int)
391391

392392
if self._cached_im is not None:
393393
logger.info("Loading images from cache")

src/aspire/source/simulation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ def clean_images(self, start=0, num=np.inf, indices=None):
179179

180180
def _images(self, start=0, num=np.inf, indices=None, enable_noise=True):
181181
if indices is None:
182-
indices = np.arange(start, min(start + num, self.n), dtype=np.int)
182+
indices = np.arange(start, min(start + num, self.n), dtype=int)
183183

184184
im = self.projections(start=start, num=num, indices=indices)
185185

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ def testGetTestTol(self):
4747
self.assertEqual(1e-8, utest_tolerance(np.float64))
4848
self.assertEqual(1e-5, utest_tolerance(np.float32))
4949
with raises(TypeError):
50-
utest_tolerance(np.int)
50+
utest_tolerance(int)

0 commit comments

Comments
 (0)