Skip to content

Commit 0035ab7

Browse files
committed
Replace arange by range for iteration
1 parent 9343436 commit 0035ab7

File tree

4 files changed

+9
-11
lines changed

4 files changed

+9
-11
lines changed

pymc/backends/mcbackend.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ def get_sampler_stats(
181181
def _slice(self, idx: slice) -> "IBaseTrace":
182182
# Get the integer indices
183183
start, stop, step = idx.indices(len(self))
184-
indices = np.arange(start, stop, step)
184+
indices = tuple(range(start, stop, step))
185185

186186
# Create a NumPyChain for the sliced data
187187
nchain = mcb.backends.numpy.NumPyChain(

pymc/distributions/shape_utils.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -378,9 +378,7 @@ def get_support_shape(
378378
raise ValueError(
379379
f"Number of shape dimensions is too small for ndim_supp of {ndim_supp}"
380380
)
381-
inferred_support_shape = [
382-
shape[i] - support_shape_offset[i] for i in np.arange(-ndim_supp, 0)
383-
]
381+
inferred_support_shape = [shape[i] - support_shape_offset[i] for i in range(-ndim_supp, 0)]
384382

385383
if inferred_support_shape is None and dims is not None:
386384
dims = convert_dims(dims)
@@ -389,7 +387,7 @@ def get_support_shape(
389387
raise ValueError(f"Number of dims is too small for ndim_supp of {ndim_supp}")
390388
model = modelcontext(None)
391389
inferred_support_shape = [
392-
model.dim_lengths[dims[i]] - support_shape_offset[i] for i in np.arange(-ndim_supp, 0)
390+
model.dim_lengths[dims[i]] - support_shape_offset[i] for i in range(-ndim_supp, 0)
393391
]
394392

395393
if inferred_support_shape is None and observed is not None:
@@ -399,7 +397,7 @@ def get_support_shape(
399397
f"Number of observed dimensions is too small for ndim_supp of {ndim_supp}"
400398
)
401399
inferred_support_shape = [
402-
observed.shape[i] - support_shape_offset[i] for i in np.arange(-ndim_supp, 0)
400+
observed.shape[i] - support_shape_offset[i] for i in range(-ndim_supp, 0)
403401
]
404402

405403
if inferred_support_shape is None:

pymc/sampling/forward.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -876,7 +876,7 @@ def sample_posterior_predictive(
876876
try:
877877
with progress:
878878
task = progress.add_task("Sampling ...", completed=0, total=samples)
879-
for idx in np.arange(samples):
879+
for idx in range(samples):
880880
if nchain > 1:
881881
# the trace object will either be a MultiTrace (and have _straces)...
882882
if hasattr(_trace, "_straces"):

tests/distributions/test_multivariate.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,8 +1564,8 @@ def test_zsn_dims(self, dims, n_zerosum_axes):
15641564
)
15651565

15661566
ndim_supp = v.owner.op.ndim_supp
1567-
n_zerosum_axes = np.arange(-ndim_supp, 0)
1568-
nonzero_axes = np.arange(v.ndim - ndim_supp)
1567+
n_zerosum_axes = tuple(range(-ndim_supp, 0))
1568+
nonzero_axes = tuple(range(v.ndim - ndim_supp))
15691569
for samples in [
15701570
s.posterior.v,
15711571
random_samples,
@@ -1595,8 +1595,8 @@ def test_zsn_shape(self, n_zerosum_axes):
15951595
)
15961596

15971597
ndim_supp = v.owner.op.ndim_supp
1598-
n_zerosum_axes = np.arange(-ndim_supp, 0)
1599-
nonzero_axes = np.arange(v.ndim - ndim_supp)
1598+
n_zerosum_axes = tuple(range(-ndim_supp, 0))
1599+
nonzero_axes = tuple(range(v.ndim - ndim_supp))
16001600
for samples in [
16011601
s.posterior.v,
16021602
random_samples,

0 commit comments

Comments
 (0)