Skip to content

Commit d3dd34e

Browse files
ArmavicaricardoV94
authored andcommitted
Manual simplification of RUF005 fixes
1 parent 8aeda39 commit d3dd34e

30 files changed

+75
-81
lines changed

pytensor/breakpoint.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def make_node(self, condition, *monitored_vars):
9292
new_op.inp_types.append(monitored_vars[i].type)
9393

9494
# Build the Apply node
95-
inputs = [condition, *list(monitored_vars)]
95+
inputs = [condition, *monitored_vars]
9696
outputs = [inp.type() for inp in monitored_vars]
9797
return Apply(op=new_op, inputs=inputs, outputs=outputs)
9898

pytensor/graph/rewriting/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1139,7 +1139,7 @@ def decorator(f):
11391139
if inplace:
11401140
dh_handler = dh.DestroyHandler
11411141
req = (
1142-
*tuple(requirements),
1142+
*requirements,
11431143
lambda fgraph: fgraph.attach_feature(dh_handler()),
11441144
)
11451145
rval = FromFunctionNodeRewriter(f, tracks, req)

pytensor/graph/rewriting/unify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _convert(y):
283283
var_map[pattern] = v
284284
return v
285285
elif isinstance(y, tuple):
286-
return etuple(*tuple(_convert(e) for e in y))
286+
return etuple(*(_convert(e) for e in y))
287287
elif isinstance(y, (Number, np.ndarray)):
288288
from pytensor.tensor import as_tensor_variable
289289

pytensor/ifelse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ def ifelse(
397397

398398
new_ifelse = IfElse(n_outs=len(then_branch), as_view=False, name=name)
399399

400-
ins = [condition, *list(then_branch), *list(else_branch)]
400+
ins = [condition, *then_branch, *else_branch]
401401
rval = new_ifelse(*ins, return_list=True)
402402

403403
if rval_type is None:

pytensor/link/c/type.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -508,8 +508,8 @@ def __hash__(self):
508508
(
509509
type(self),
510510
self.ctype,
511-
*tuple((k, self[k]) for k in sorted(self.keys())),
512-
*tuple((a, self.aliases[a]) for a in sorted(self.aliases.keys())),
511+
*((k, self[k]) for k in sorted(self.keys())),
512+
*((a, self.aliases[a]) for a in sorted(self.aliases.keys())),
513513
)
514514
)
515515

pytensor/link/numba/dispatch/elemwise.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -447,7 +447,7 @@ def jit_compile_reducer(
447447
def create_axis_apply_fn(fn, axis, ndim, dtype):
448448
axis = normalize_axis_index(axis, ndim)
449449

450-
reaxis_first = (*tuple(i for i in range(ndim) if i != axis), axis)
450+
reaxis_first = (*(i for i in range(ndim) if i != axis), axis)
451451

452452
@numba_basic.numba_njit(boundscheck=False)
453453
def axis_apply_fn(x):

pytensor/link/numba/dispatch/extra_ops.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def numba_funcify_CumOp(op: CumOp, node: Apply, **kwargs):
4444
if axis < 0 or axis >= ndim:
4545
raise ValueError(f"Invalid axis {axis} for array with ndim {ndim}")
4646

47-
reaxis_first = (axis, *tuple(i for i in range(ndim) if i != axis))
47+
reaxis_first = (axis, *(i for i in range(ndim) if i != axis))
4848
reaxis_first_inv = tuple(np.argsort(reaxis_first))
4949

5050
if mode == "add":

pytensor/link/numba/dispatch/random.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def create_numba_random_fn(
240240
np_global_env["numba_vectorize"] = numba_basic.numba_vectorize
241241

242242
unique_names = unique_name_generator(
243-
[np_random_fn_name, *list(np_global_env.keys()), "rng", "size", "dtype"],
243+
[np_random_fn_name, *np_global_env.keys(), "rng", "size", "dtype"],
244244
suffix_sep="_",
245245
)
246246

pytensor/link/numba/dispatch/scalar.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ def {scalar_op_fn_name}({input_names}):
115115
global_env.update(input_tmp_dtype_names)
116116

117117
unique_names = unique_name_generator(
118-
[scalar_op_fn_name, "scalar_func_numba", *list(global_env.keys())],
118+
[scalar_op_fn_name, "scalar_func_numba", *global_env.keys()],
119119
suffix_sep="_",
120120
)
121121

pytensor/scalar/basic.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def dtype_specs(self):
416416
)
417417

418418
def upcast(self, *others):
419-
return upcast(*[x.dtype for x in [self, *list(others)]])
419+
return upcast(*[x.dtype for x in [self, *others]])
420420

421421
def make_variable(self, name=None):
422422
return ScalarVariable(self, None, name=name)
@@ -1501,7 +1501,7 @@ def c_code(self, node, name, inputs, outputs, sub):
15011501

15021502
def c_code_cache_version(self):
15031503
scalarop_version = super().c_code_cache_version()
1504-
return (*tuple(scalarop_version), 3)
1504+
return (*scalarop_version, 3)
15051505

15061506

15071507
isnan = IsNan()
@@ -1529,7 +1529,7 @@ def c_code(self, node, name, inputs, outputs, sub):
15291529

15301530
def c_code_cache_version(self):
15311531
scalarop_version = super().c_code_cache_version()
1532-
return (*tuple(scalarop_version), 3)
1532+
return (*scalarop_version, 3)
15331533

15341534

15351535
isinf = IsInf()

0 commit comments

Comments
 (0)