Skip to content

Commit

Permalink
sagemathgh-38477: fix many pep8 E302 warnings in repl,rings,schemes,s…
Browse files Browse the repository at this point in the history
…at,etc

    
mostly scripted with `autopep8` except for a few files handled by hand

### 📝 Checklist

<!-- Put an `x` in all the boxes that apply. -->

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#38477
Reported by: Frédéric Chapoton
Reviewer(s): David Coudert, Vincent Macri
  • Loading branch information
Release Manager committed Aug 27, 2024
2 parents 60957ac + 1046e84 commit 1d9ac17
Show file tree
Hide file tree
Showing 78 changed files with 267 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/sage/misc/sageinspect.py
Original file line number Diff line number Diff line change
Expand Up @@ -2255,7 +2255,7 @@ def sage_getsourcelines(obj):
sage: sage_getsourcelines(test_func)
(['def base(x):\n',
...
' return x\n'], 7)
' return x\n'], 8)
Here are some cases that were covered in :issue:`11298`;
note that line numbers may easily change, and therefore we do
Expand Down
1 change: 1 addition & 0 deletions src/sage/repl/interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ def prompt_for_code(self):
pythonapi.PyOS_setsig(signal.SIGINT, sigint_os)
return text


class SageTestShell(SageShellOverride, TerminalInteractiveShell):
"""
Test Shell.
Expand Down
1 change: 1 addition & 0 deletions src/sage/repl/ipython_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
from sage.misc.lazy_import import LazyImport
from sage.misc.misc import run_once


@magics_class
class SageMagics(Magics):

Expand Down
1 change: 1 addition & 0 deletions src/sage/repl/rich_output/output_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
latex_re = re.compile(r'<html>(?P<mathstart>\\\[|\\\()(?P<latex>.*)(?P<mathend>\\\]|\\\))</html>',
flags=re.DOTALL)


class OutputHtml(OutputBase):

def __init__(self, html):
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/continued_fraction_gosper.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
from sage.rings.infinity import Infinity
from sage.rings.integer import Integer


class gosper_iterator():
r"""
Iterable for the partial quotients of `(a*x+b)/(c*x+d)`, where `a, b, c, d`
Expand Down
2 changes: 2 additions & 0 deletions src/sage/rings/number_field/galois_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -1025,6 +1025,7 @@ def artin_symbol(self, P):
raise ValueError("%s is ramified" % P)
return t[0]


class GaloisGroup_subgroup(GaloisSubgroup_perm):
r"""
A subgroup of a Galois group, as returned by functions such as
Expand Down Expand Up @@ -1188,6 +1189,7 @@ def fixed_field(self, name=None, polred=None, threshold=None):
name = G._field.variable_name() + '0'
return L.subfield(x, name=name)


class GaloisGroupElement(PermutationGroupElement):
r"""
An element of a Galois group. This is stored as a permutation, but may also
Expand Down
9 changes: 9 additions & 0 deletions src/sage/rings/number_field/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@

IdentityMap = IdentityMorphism


class NumberFieldIsomorphism(Map):
r"""
A base class for various isomorphisms between number fields and
Expand Down Expand Up @@ -101,6 +102,7 @@ def is_surjective(self):
"""
return True


class MapVectorSpaceToNumberField(NumberFieldIsomorphism):
r"""
The map to an absolute number field from its underlying `\QQ`-vector space.
Expand Down Expand Up @@ -191,6 +193,7 @@ def _call_(self, v):
f = K.polynomial_ring()(v.list())
return K._element_class(K, f)


class MapNumberFieldToVectorSpace(Map):
r"""
A class for the isomorphism from an absolute number field to its underlying
Expand Down Expand Up @@ -249,6 +252,7 @@ def _call_(self, x):
v = v + [QQ.zero()] * k
return self.codomain()(v)


class MapRelativeVectorSpaceToRelativeNumberField(NumberFieldIsomorphism):
r"""
EXAMPLES::
Expand Down Expand Up @@ -314,6 +318,7 @@ def _call_(self, v):
g = K._pari_rnfeq()._eltreltoabs(h)
return K._element_class(K, g)


class MapRelativeNumberFieldToRelativeVectorSpace(NumberFieldIsomorphism):
r"""
EXAMPLES::
Expand Down Expand Up @@ -456,6 +461,7 @@ def _call_(self, x):
y = x._copy_for_parent(self.codomain())
return y


class MapRelativeToAbsoluteNumberField(NumberFieldIsomorphism):
r"""
EXAMPLES::
Expand Down Expand Up @@ -533,6 +539,7 @@ def _call_(self, x):
f = x.polynomial()
return A._element_class(A, f)


class MapAbsoluteToRelativeNumberField(NumberFieldIsomorphism):
r"""
See :class:`~MapRelativeToAbsoluteNumberField` for examples.
Expand Down Expand Up @@ -565,6 +572,7 @@ def _call_(self, x):
f = x.polynomial()
return R._element_class(R, f)


class MapVectorSpaceToRelativeNumberField(NumberFieldIsomorphism):
r"""
The isomorphism to a relative number field from its underlying `\QQ`-vector
Expand Down Expand Up @@ -609,6 +617,7 @@ def _call_(self, x):
"""
return self._from_K(self._from_V(x))


class MapRelativeNumberFieldToVectorSpace(NumberFieldIsomorphism):
r"""
The isomorphism from a relative number field to its underlying `\QQ`-vector
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/number_field/number_field_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -1775,6 +1775,7 @@ def basis_to_module(B, K):
C = [to_V(K(b)) for b in B]
return M.span_of_basis(C)


def is_NumberFieldIdeal(x):
"""
Return ``True`` if `x` is an ideal of a number field.
Expand Down
2 changes: 2 additions & 0 deletions src/sage/rings/number_field/number_field_ideal_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
QQ = rational_field.RationalField()
ZZ = integer_ring.IntegerRing()


class NumberFieldFractionalIdeal_rel(NumberFieldFractionalIdeal):
"""
An ideal of a relative number field.
Expand Down Expand Up @@ -882,6 +883,7 @@ def valuation(self, p):
raise ValueError("p (= %s) must be an ideal in %s" % self.number_field())
return self.absolute_ideal().valuation(p.absolute_ideal())


def is_NumberFieldFractionalIdeal_rel(x):
"""
Return ``True`` if `x` is a fractional ideal of a relative number field.
Expand Down
5 changes: 5 additions & 0 deletions src/sage/rings/number_field/order_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@

#TODO I*u works when u lies in I.ring().number_field(), but u*I doesn't


def NumberFieldOrderIdeal(O, *args, **kwds):
r"""
Construct either a :class:`NumberFieldOrderIdeal_generic`
Expand Down Expand Up @@ -117,6 +118,7 @@ def NumberFieldOrderIdeal(O, *args, **kwds):
cls = NumberFieldOrderIdeal_generic
return cls(O, *args, **kwds)


class NumberFieldOrderIdeal_generic(Ideal_generic):
r"""
An ideal of a not necessarily maximal order in a number field.
Expand Down Expand Up @@ -269,6 +271,7 @@ def norm(self):
"""
return self.free_module().index_in(self.ring().free_module())


def _positive_sqrt(R, D):
r"""
Return the "positive" square root of `D` in `R`, which must be
Expand All @@ -292,6 +295,7 @@ def _positive_sqrt(R, D):
sqrtD, = (s for s in R(D).sqrt(all=True) if s.real() > 0 or s.imag() > 0)
return sqrtD


def _gens_from_bqf(O, Q):
r"""
Helper function to compute generators of the ideal associated to
Expand Down Expand Up @@ -354,6 +358,7 @@ def _gens_from_bqf(O, Q):
t = sqrtD if a < 0 else 1
return a*t, g*t


class NumberFieldOrderIdeal_quadratic(NumberFieldOrderIdeal_generic):
r"""
An ideal of a not necessarily maximal order in a *quadratic* number field.
Expand Down
6 changes: 6 additions & 0 deletions src/sage/rings/number_field/selmer_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
# A utility function to allow the same code to be used over QQ and
# over number fields:


def _ideal_generator(I):
r"""
Return the generator of a principal ideal.
Expand All @@ -77,6 +78,7 @@ def _ideal_generator(I):
except AttributeError:
return I.abs()


def _coords_in_C_p(I, C, p):
r"""
Return coordinates of the ideal ``I`` with respect to a basis of
Expand Down Expand Up @@ -130,6 +132,7 @@ def _coords_in_C_p(I, C, p):
return [(coords[i] // n) % p for i, n in p_indices]
raise ValueError("The {} power of {} is not principal".format(p.ordinal_str(),I))


def _coords_in_C_mod_p(I,C,p):
r"""
Return coordinates of the ideal ``I`` with respect to a basis of
Expand Down Expand Up @@ -181,6 +184,7 @@ def _coords_in_C_mod_p(I,C,p):
coords = C(I).exponents()
return [coords[i] % p for i in p_indices]


def _root_ideal(I, C, p):
r"""
Return a `p`-th root of an ideal with respect to the class group.
Expand Down Expand Up @@ -230,6 +234,7 @@ def _root_ideal(I, C, p):

return prod([gen ** wi for wi, gen in zip(w, cyclic_gens)], C.number_field().ideal(1))


def coords_in_U_mod_p(u, U, p):
r"""
Return coordinates of a unit ``u`` with respect to a basis of the
Expand Down Expand Up @@ -277,6 +282,7 @@ def coords_in_U_mod_p(u, U, p):
start = 1 - int(p.divides(U.zeta_order())) # 0 or 1
return [c % p for c in coords[start:]]


def basis_for_p_cokernel(S, C, p):
r"""
Return a basis for the group of ideals supported on ``S`` (mod
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/number_field/small_primes_of_degree_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@

from sage.rings.integer_ring import ZZ


class Small_primes_of_degree_one_iter():
r"""
Iterator that finds primes of a number field of absolute degree
Expand Down
5 changes: 5 additions & 0 deletions src/sage/rings/number_field/structure.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@

from sage.structure.unique_representation import UniqueRepresentation


class NumberFieldStructure(UniqueRepresentation):
r"""
Abstract base class encapsulating information about a number fields
Expand Down Expand Up @@ -136,6 +137,7 @@ def create_structure(self, field):
"""
raise NotImplementedError


class NameChange(NumberFieldStructure):
r"""
Structure for a number field created by a change in variable name.
Expand Down Expand Up @@ -179,6 +181,7 @@ def create_structure(self, field):
from . import maps
return maps.NameChangeMap(field, self.other), maps.NameChangeMap(self.other, field)


class AbsoluteFromRelative(NumberFieldStructure):
r"""
Structure for an absolute number field created from a relative number
Expand Down Expand Up @@ -218,6 +221,7 @@ def create_structure(self, field):
from . import maps
return maps.MapAbsoluteToRelativeNumberField(field, self.other), maps.MapRelativeToAbsoluteNumberField(self.other, field)


class RelativeFromAbsolute(NumberFieldStructure):
r"""
Structure for a relative number field created from an absolute number
Expand Down Expand Up @@ -292,6 +296,7 @@ def create_structure(self, field):

return field_to_other, other_to_field


class RelativeFromRelative(NumberFieldStructure):
r"""
Structure for a relative number field created from another relative number
Expand Down
1 change: 1 addition & 0 deletions src/sage/rings/number_field/totallyreal_rel.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ def integral_elements_in_box(K, C):

eps_global = 10**(-6)


class tr_data_rel:
r"""
This class encodes the data used in the enumeration of totally real
Expand Down
Loading

0 comments on commit 1d9ac17

Please sign in to comment.