From ffa46ab660f5e43214f547feeecd38e8107663b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Fri, 19 Jul 2024 18:27:09 +0200 Subject: [PATCH] simplify some iterations (ruff PERF102) --- src/sage/categories/pushout.py | 4 ++-- src/sage/manifolds/differentiable/scalarfield.py | 2 +- src/sage/manifolds/differentiable/tensorfield.py | 2 +- src/sage/manifolds/differentiable/vectorfield.py | 2 +- src/sage/repl/rich_output/preferences.py | 2 +- src/sage/rings/finite_rings/conway_polynomials.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/sage/categories/pushout.py b/src/sage/categories/pushout.py index 1b98e358511..0eb5bad5c68 100644 --- a/src/sage/categories/pushout.py +++ b/src/sage/categories/pushout.py @@ -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: diff --git a/src/sage/manifolds/differentiable/scalarfield.py b/src/sage/manifolds/differentiable/scalarfield.py index 179909868a8..8a0c1b97fbd 100644 --- a/src/sage/manifolds/differentiable/scalarfield.py +++ b/src/sage/manifolds/differentiable/scalarfield.py @@ -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() diff --git a/src/sage/manifolds/differentiable/tensorfield.py b/src/sage/manifolds/differentiable/tensorfield.py index 2a958a20640..23c69bc290c 100644 --- a/src/sage/manifolds/differentiable/tensorfield.py +++ b/src/sage/manifolds/differentiable/tensorfield.py @@ -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() diff --git a/src/sage/manifolds/differentiable/vectorfield.py b/src/sage/manifolds/differentiable/vectorfield.py index fd71f2ee2e6..09a0774cb89 100644 --- a/src/sage/manifolds/differentiable/vectorfield.py +++ b/src/sage/manifolds/differentiable/vectorfield.py @@ -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() diff --git a/src/sage/repl/rich_output/preferences.py b/src/sage/repl/rich_output/preferences.py index 00cb5ec2ab6..09466819d19 100644 --- a/src/sage/repl/rich_output/preferences.py +++ b/src/sage/repl/rich_output/preferences.py @@ -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)) diff --git a/src/sage/rings/finite_rings/conway_polynomials.py b/src/sage/rings/finite_rings/conway_polynomials.py index 7d6e558f030..b6e86612445 100644 --- a/src/sage/rings/finite_rings/conway_polynomials.py +++ b/src/sage/rings/finite_rings/conway_polynomials.py @@ -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 = {}