Skip to content

Commit

Permalink
simplify some iterations (ruff PERF102)
Browse files Browse the repository at this point in the history
  • Loading branch information
fchapoton committed Jul 19, 2024
1 parent 820502f commit ef2b223
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion src/sage/algebras/fusion_rings/f_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -892,7 +892,7 @@ def _get_known_nonz(self):
100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100)
"""
nonz = {idx: 100 for idx in self._singles}
for idx, _ in self._ks.items():
for idx in self._ks.keys():
nonz[idx] = 100
return ETuple(nonz, self._poly_ring.ngens())

Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/pushout.py
Original file line number Diff line number Diff line change
Expand Up @@ -1985,12 +1985,12 @@ def _apply_functor(self, R):
name = self.name_mapping.get(R, None)
latex_name = self.latex_name_mapping.get(R, None)
if name is None:
for base_ring, name in self.name_mapping.items():
for name in self.name_mapping.values():
name = f'{name}_base_ext'
break
if latex_name is None:
from sage.misc.latex import latex
for base_ring, latex_name in self.latex_name_mapping.items():
for latex_name in self.latex_name_mapping.values():
latex_name = fr'{latex_name} \otimes {latex(R)}'
break
if name is None and latex_name is None:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/scalarfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ def _del_derived(self):
ScalarField._del_derived(self) # derived quantities of the mother class
self._differential = None # reset of the differential
# First deletes any reference to self in the vectors' dictionaries:
for vid, val in self._lie_derivatives.items():
for val in self._lie_derivatives.values():
del val[0]._lie_der_along_self[id(self)]
# Then clears the dictionary of Lie derivatives
self._lie_derivatives.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/tensorfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ def _del_derived(self):
"""
# First deletes any reference to self in the vectors' dictionaries:
for vid, val in self._lie_derivatives.items():
for val in self._lie_derivatives.values():
del val[0]._lie_der_along_self[id(self)]
# Then clears the dictionary of Lie derivatives
self._lie_derivatives.clear()
Expand Down
2 changes: 1 addition & 1 deletion src/sage/manifolds/differentiable/vectorfield.py
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ def _del_dependencies(self):
"""
if self._lie_der_along_self != {}:
for idtens, tens in self._lie_der_along_self.items():
for tens in self._lie_der_along_self.values():
del tens._lie_derivatives[id(self)]
self._lie_der_along_self.clear()

Expand Down
2 changes: 1 addition & 1 deletion src/sage/repl/rich_output/preferences.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ def available_options(self):
(align_latex, graphics, supplemental_plot, text)
"""
options = []
for key, value in self.__class__.__dict__.items():
for value in self.__class__.__dict__.values():
if isinstance(value, Property):
options.append(value)
return tuple(sorted(options, key=str))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/finite_rings/conway_polynomials.py
Original file line number Diff line number Diff line change
Expand Up @@ -433,7 +433,7 @@ def _frobenius_shift(K, generators, check_only=False):
q, x = compatible[m].popitem()
except KeyError:
break
for qq, xx in compatible[m].items():
for xx in compatible[m].values():
assert x == xx
return
crt = {}
Expand Down

0 comments on commit ef2b223

Please sign in to comment.