Skip to content

Commit

Permalink
Merge pull request #26584 from Skylion007/skylion007/ruff-FURB192-202…
Browse files Browse the repository at this point in the history
…4-05-09

Replace `sorted(x)[0]` calls with min
  • Loading branch information
sylee957 committed May 9, 2024
2 parents 8f9d043 + d9c89f5 commit 60c063b
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion sympy/codegen/rewriting.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, cost_function=None, priority=1):
self.priority=priority

def cheapest(self, *args):
return sorted(args, key=self.cost_function)[0]
return min(args, key=self.cost_function)


class ReplaceOptim(Optimization):
Expand Down
2 changes: 1 addition & 1 deletion sympy/combinatorics/perm_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -874,7 +874,7 @@ def _coset_representative(self, g, H):
base = self.base
base_ordering = _base_ordering(base, self.degree)
def step(l, x):
gamma = sorted(orbits[l], key = lambda y: base_ordering[y^x])[0]
gamma = min(orbits[l], key = lambda y: base_ordering[y^x])
i = [base[l]^h for h in h_transversals[l]].index(gamma)
x = h_transversals[l][i]*x
if l < len(orbits)-1:
Expand Down
6 changes: 3 additions & 3 deletions sympy/logic/algorithms/lra_theory.py
Original file line number Diff line number Diff line change
Expand Up @@ -584,7 +584,7 @@ def check(self):
if len(cand) == 0:
return True, {var: var.assign for var in self.all_var}

xi = sorted(cand, key=lambda v: v.col_idx)[0] # Bland's rule
xi = min(cand, key=lambda v: v.col_idx) # Bland's rule
i = basic[xi]

if xi.assign < xi.lower:
Expand All @@ -601,7 +601,7 @@ def check(self):
conflict.append(Boundary.from_lower(xi))
conflict = [-neg*self.boundary_to_enc[c] for c, neg in conflict]
return False, conflict
xj = sorted(cand, key=lambda v: str(v))[0]
xj = min(cand, key=str)
M = self._pivot_and_update(M, basic, nonbasic, xi, xj, xi.lower)

if xi.assign > xi.upper:
Expand All @@ -620,7 +620,7 @@ def check(self):

conflict = [-neg*self.boundary_to_enc[c] for c, neg in conflict]
return False, conflict
xj = sorted(cand, key=lambda v: v.col_idx)[0]
xj = min(cand, key=lambda v: v.col_idx)
M = self._pivot_and_update(M, basic, nonbasic, xi, xj, xi.upper)

def _pivot_and_update(self, M, basic, nonbasic, xi, xj, v):
Expand Down
2 changes: 1 addition & 1 deletion sympy/simplify/trigsimp.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,7 +1114,7 @@ def __trigsimp(expr, deep=False):
raise TypeError
fnew = factor(new)
if fnew != new:
new = sorted([new, factor(new)], key=count_ops)[0]
new = min([new, factor(new)], key=count_ops)
# if all exp that were introduced disappeared then accept it
if not (new.atoms(exp) - e):
expr = new
Expand Down

0 comments on commit 60c063b

Please sign in to comment.