Skip to content

Commit

Permalink
sagemathgh-38390: simplify some iterations (ruff PERF102)
Browse files Browse the repository at this point in the history
    
this is simplifying some iterations, and was scripted using `ruff`

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#38390
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert
  • Loading branch information
Release Manager committed Jul 24, 2024
2 parents a9920de + ffa46ab commit be4e797
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 7 deletions.
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 be4e797

Please sign in to comment.