Skip to content

Commit

Permalink
STY: Apply ruff/refurb rule FURB118
Browse files Browse the repository at this point in the history
	FURB118 Use `operator.pow` instead of defining a function
  • Loading branch information
DimitriPapadopoulos committed May 5, 2024
1 parent 3848728 commit e1fdf90
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
6 changes: 2 additions & 4 deletions nipype/pipeline/engine/tests/test_join.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# vi: set ft=python sts=4 ts=4 sw=4 et:
"""Tests for join expansion
"""
import operator
import pytest

from .... import config
Expand Down Expand Up @@ -640,14 +641,11 @@ def sq(x):
def test_join_nestediters(tmpdir):
tmpdir.chdir()

def exponent(x, p):
return x**p

wf = pe.Workflow("wf", base_dir=tmpdir.strpath)

xs = pe.Node(IdentityInterface(["x"]), iterables=[("x", [1, 2])], name="xs")
ps = pe.Node(IdentityInterface(["p"]), iterables=[("p", [3, 4])], name="ps")
exp = pe.Node(Function(function=exponent), name="exp")
exp = pe.Node(Function(function=operator.pow), name="exp")
exp_joinx = pe.JoinNode(
Merge(1, ravel_inputs=True),
name="exp_joinx",
Expand Down
3 changes: 2 additions & 1 deletion nipype/pipeline/engine/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import sys
import pickle
import operator
from collections import defaultdict
import re
from copy import deepcopy
Expand Down Expand Up @@ -612,7 +613,7 @@ def count_iterables(iterables, synchronize=False):
Otherwise, the count is the product of the iterables value
list sizes.
"""
op = max if synchronize else lambda x, y: x * y
op = max if synchronize else operator.mul
return reduce(op, [len(func()) for _, func in list(iterables.items())])


Expand Down

0 comments on commit e1fdf90

Please sign in to comment.