Skip to content

Commit 9c58c28

Browse files
sty: Apply ruff preview rule RUF046
RUF046 Value being cast to `int` is already an integer
1 parent 9372fbc commit 9c58c28

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

nibabel/benchmarks/bench_arrayproxy_slicing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def fmt_sliceobj(sliceobj):
9999
return f'[{", ".join(slcstr)}]'
100100

101101
with InTemporaryDirectory():
102-
print(f'Generating test data... ({int(round(np.prod(SHAPE) * 4 / 1048576.0))} MB)')
102+
print(f'Generating test data... ({round(np.prod(SHAPE) * 4 / 1048576.0)} MB)')
103103

104104
data = np.array(np.random.random(SHAPE), dtype=np.float32)
105105

nibabel/viewers.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -373,11 +373,11 @@ def set_volume_idx(self, v):
373373

374374
def _set_volume_index(self, v, update_slices=True):
375375
"""Set the plot data using a volume index"""
376-
v = self._data_idx[3] if v is None else int(round(v))
376+
v = self._data_idx[3] if v is None else round(v)
377377
if v == self._data_idx[3]:
378378
return
379379
max_ = np.prod(self._volume_dims)
380-
self._data_idx[3] = max(min(int(round(v)), max_ - 1), 0)
380+
self._data_idx[3] = max(min(round(v), max_ - 1), 0)
381381
idx = (slice(None), slice(None), slice(None))
382382
if self._data.ndim > 3:
383383
idx = idx + tuple(np.unravel_index(self._data_idx[3], self._volume_dims))
@@ -401,7 +401,7 @@ def _set_position(self, x, y, z, notify=True):
401401
idxs = np.dot(self._inv_affine, self._position)[:3]
402402
idxs_new_order = idxs[self._order]
403403
for ii, (size, idx) in enumerate(zip(self._sizes, idxs_new_order)):
404-
self._data_idx[ii] = max(min(int(round(idx)), size - 1), 0)
404+
self._data_idx[ii] = max(min(round(idx), size - 1), 0)
405405
for ii in range(3):
406406
# sagittal: get to S/A
407407
# coronal: get to S/L

0 commit comments

Comments
 (0)