diff --git a/src/sage/misc/c3_controlled.pyx b/src/sage/misc/c3_controlled.pyx index 5787505313c..518e321c197 100644 --- a/src/sage/misc/c3_controlled.pyx +++ b/src/sage/misc/c3_controlled.pyx @@ -155,7 +155,7 @@ class as its bases. However, this would have several drawbacks: point of truth for calculating the bases of each class. - It increases the complexity of the calculation of the MRO with - ``C3``. For example, for a linear hierachy of classes, the + ``C3``. For example, for a linear hierarchy of classes, the complexity goes from `O(n^2)` to `O(n^3)` which is not acceptable. - It increases the complexity of inspecting the classes. For example, @@ -913,7 +913,7 @@ cpdef tuple C3_sorted_merge(list lists, key=identity): tailsets[-1].add(key(heads[-1])) heads[-1] = O elif O != heads[-1]: - assert O_key not in tailsets[-1], "C3 should not have choosen this O" + assert O_key not in tailsets[-1], "C3 should not have chosen this O" # Use a heap or something for fast sorted insertion? # Since Python uses TimSort, that's probably not so bad. tails[-1].append(O) @@ -992,7 +992,7 @@ class HierarchyElement(object, metaclass=ClasscallMetaclass): EXAMPLES: See the introduction of this module :mod:`sage.misc.c3_controlled` - for many examples. Here we consider a large example, originaly + for many examples. Here we consider a large example, originally taken from the hierarchy of categories above :class:`HopfAlgebrasWithBasis`:: diff --git a/src/sage/modular/modform_hecketriangle/abstract_ring.py b/src/sage/modular/modform_hecketriangle/abstract_ring.py index f1f0efad596..b0bf6a850a3 100644 --- a/src/sage/modular/modform_hecketriangle/abstract_ring.py +++ b/src/sage/modular/modform_hecketriangle/abstract_ring.py @@ -1793,7 +1793,7 @@ def EisensteinSeries(self, k=None): - ``k`` -- A non-negative even integer, namely the weight. If ``k=None`` (default) then the weight of ``self`` - is choosen if ``self`` is homogeneous and the + is chosen if ``self`` is homogeneous and the weight is possible, otherwise ``k=0`` is set. OUTPUT: diff --git a/src/sage/modular/modform_hecketriangle/abstract_space.py b/src/sage/modular/modform_hecketriangle/abstract_space.py index 719d8847f31..c60e2b0c4f7 100644 --- a/src/sage/modular/modform_hecketriangle/abstract_space.py +++ b/src/sage/modular/modform_hecketriangle/abstract_space.py @@ -697,7 +697,7 @@ def weight_parameters(self): # l2 = num % ZZ(2) # l1 = ((num-l2)/ZZ(2)).numerator() # TODO: The correct generalization seems (l1,l2) = (0,num) - l2 = ZZ(0) + l2 = ZZ.zero() l1 = num else: l2 = num % n @@ -769,7 +769,7 @@ def aut_factor(self, gamma, t): return aut_f @cached_method - def F_simple(self, order_1=ZZ(0)): + def F_simple(self, order_1=ZZ.zero()): r""" Return a (the most) simple normalized element of ``self`` corresponding to the weight parameters ``l1=self._l1`` and @@ -836,7 +836,7 @@ def F_simple(self, order_1=ZZ(0)): return new_space(rat) - def Faber_pol(self, m, order_1=ZZ(0), fix_d=False, d_num_prec=None): + def Faber_pol(self, m, order_1=ZZ.zero(), fix_d=False, d_num_prec=None): r""" Return the ``m``'th Faber polynomial of ``self``. @@ -986,7 +986,7 @@ def Faber_pol(self, m, order_1=ZZ(0), fix_d=False, d_num_prec=None): return fab_pol.polynomial() # very similar to Faber_pol: faber_pol(q)=Faber_pol(d*q) - def faber_pol(self, m, order_1=ZZ(0), fix_d=False, d_num_prec=None): + def faber_pol(self, m, order_1=ZZ.zero(), fix_d=False, d_num_prec=None): r""" If ``n=infinity`` a non-trivial order of ``-1`` can be specified through the parameter ``order_1`` (default: 0). Otherwise it is ignored. @@ -1127,7 +1127,7 @@ def faber_pol(self, m, order_1=ZZ(0), fix_d=False, d_num_prec=None): return fab_pol.polynomial() - def F_basis_pol(self, m, order_1=ZZ(0)): + def F_basis_pol(self, m, order_1=ZZ.zero()): r""" Returns a polynomial corresponding to the basis element of the corresponding space of weakly holomorphic forms of @@ -1229,7 +1229,7 @@ def F_basis_pol(self, m, order_1=ZZ(0)): return rat - def F_basis(self, m, order_1=ZZ(0)): + def F_basis(self, m, order_1=ZZ.zero()): r""" Returns a weakly holomorphic element of ``self`` (extended if necessarily) determined by the property that @@ -1357,11 +1357,11 @@ def _canonical_min_exp(self, min_exp, order_1): order_1 = max(order_1, 0) if (self.hecke_n() != infinity): - order_1 = ZZ(0) + order_1 = ZZ.zero() return (min_exp, order_1) - def quasi_part_gens(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0)): + def quasi_part_gens(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ.zero()): r""" Return a basis in ``self`` of the subspace of (quasi) weakly holomorphic forms which satisfy the specified properties on @@ -1372,7 +1372,7 @@ def quasi_part_gens(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0)): - ``r`` -- An integer or ``None`` (default), indicating the desired power of ``E2`` If ``r=None`` then all possible powers (``r``) are - choosen. + chosen. - ``min_exp`` -- An integer giving a lower bound for the first non-trivial Fourier coefficient of the @@ -1499,14 +1499,14 @@ def quasi_part_gens(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0)): max_numerator_weight = self._weight - 4*n/(n-2)*min_exp + 4 # If r is not specified we gather all generators for all possible r's - if (r is None): + if r is None: gens = [] - for rnew in range(ZZ(0), QQ(max_numerator_weight/ZZ(2)).floor() + 1): + for rnew in range(QQ(max_numerator_weight/ZZ(2)).floor() + 1): gens += self.quasi_part_gens(r=rnew, min_exp=min_exp, max_exp=max_exp, order_1=order_1) return gens r = ZZ(r) - if (r < 0 or 2*r > max_numerator_weight): + if r < 0 or 2*r > max_numerator_weight: return [] E2 = self.E2() @@ -1526,7 +1526,7 @@ def quasi_part_gens(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0)): return gens - def quasi_part_dimension(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0)): + def quasi_part_dimension(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ.zero()): r""" Return the dimension of the subspace of ``self`` generated by ``self.quasi_part_gens(r, min_exp, max_exp, order_1)``. @@ -1590,10 +1590,10 @@ def quasi_part_dimension(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0 (min_exp, order_1) = self._canonical_min_exp(min_exp, order_1) # For modular forms spaces the quasi parts are all zero except for r=0 - if (self.is_modular()): - r = ZZ(0) - if (r != 0): - return ZZ(0) + if self.is_modular(): + r = ZZ.zero() + if r != 0: + return ZZ.zero() # The lower bounds on the powers of f_inf and E4 determine # how large powers of E2 we can fit in... @@ -1604,12 +1604,12 @@ def quasi_part_dimension(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0 max_numerator_weight = self._weight - 4*n/(n-2)*min_exp + 4 # If r is not specified we calculate the total dimension over all possible r's - if (r is None): - return sum([self.quasi_part_dimension(r=rnew, min_exp=min_exp, max_exp=max_exp, order_1=order_1) for rnew in range(ZZ(0), QQ(max_numerator_weight/ZZ(2)).floor() + 1)]) + if r is None: + return sum([self.quasi_part_dimension(r=rnew, min_exp=min_exp, max_exp=max_exp, order_1=order_1) for rnew in range(QQ(max_numerator_weight/ZZ(2)).floor() + 1)]) r = ZZ(r) if (r < 0 or 2*r > max_numerator_weight): - return ZZ(0) + return ZZ.zero() k = self._weight - QQ(2*r) ep = self._ep * (-1)**r @@ -1625,13 +1625,13 @@ def quasi_part_dimension(self, r=None, min_exp=0, max_exp=infinity, order_1=ZZ(0 if (max_exp == infinity): max_exp = order_inf elif (max_exp < min_exp): - return ZZ(0) + return ZZ.zero() else: max_exp = min(ZZ(max_exp), order_inf) - return max(ZZ(0), max_exp - min_exp + 1) + return max(ZZ.zero(), max_exp - min_exp + 1) - def construct_form(self, laurent_series, order_1=ZZ(0), check=True, rationalize=False): + def construct_form(self, laurent_series, order_1=ZZ.zero(), check=True, rationalize=False): r""" Tries to construct an element of self with the given Fourier expansion. The assumption is made that the specified Fourier @@ -1755,7 +1755,7 @@ def construct_form(self, laurent_series, order_1=ZZ(0), check=True, rationalize= return el @cached_method - def _quasi_form_matrix(self, min_exp=0, order_1=ZZ(0), incr_prec_by=0): + def _quasi_form_matrix(self, min_exp=0, order_1=ZZ.zero(), incr_prec_by=0): r""" Return a base change matrix which transforms coordinate vectors with respect to a certain basis into a vector corresponding to @@ -1866,7 +1866,7 @@ def _quasi_form_matrix(self, min_exp=0, order_1=ZZ(0), incr_prec_by=0): return A - def required_laurent_prec(self, min_exp=0, order_1=ZZ(0)): + def required_laurent_prec(self, min_exp=0, order_1=ZZ.zero()): r""" Return an upper bound for the required precision for Laurent series to uniquely determine a corresponding (quasi) form in ``self`` with the given @@ -1913,7 +1913,7 @@ def required_laurent_prec(self, min_exp=0, order_1=ZZ(0)): return self._quasi_form_matrix(min_exp=min_exp, order_1=order_1).dimensions()[0] + min_exp - def construct_quasi_form(self, laurent_series, order_1=ZZ(0), check=True, rationalize=False): + def construct_quasi_form(self, laurent_series, order_1=ZZ.zero(), check=True, rationalize=False): r""" Try to construct an element of self with the given Fourier expansion. The assumption is made that the specified Fourier @@ -2072,7 +2072,7 @@ def construct_quasi_form(self, laurent_series, order_1=ZZ(0), check=True, ration return el @cached_method - def q_basis(self, m=None, min_exp=0, order_1=ZZ(0)): + def q_basis(self, m=None, min_exp=0, order_1=ZZ.zero()): r""" Try to return a (basis) element of ``self`` with a Laurent series of the form ``q^m + O(q^N)``, where ``N=self.required_laurent_prec(min_exp)``. @@ -2380,10 +2380,9 @@ def _an_element_(self): sage: el O(q^5) """ - # this seems ok, so might as well leave it as is for everything - return self(ZZ(0)) - #return self.F_simple() + return self(ZZ.zero()) + # return self.F_simple() @cached_method def dimension(self): diff --git a/src/sage/modular/modform_hecketriangle/constructor.py b/src/sage/modular/modform_hecketriangle/constructor.py index 309a024c43a..0f40b4e4a35 100644 --- a/src/sage/modular/modform_hecketriangle/constructor.py +++ b/src/sage/modular/modform_hecketriangle/constructor.py @@ -67,12 +67,11 @@ def rational_type(f, n=ZZ(3), base_ring=ZZ): - ``analytic_type`` -- The :class:`AnalyticType` of `f`. - For the zero function the degree `(0, 1)` is choosen. + For the zero function the degree `(0, 1)` is chosen. This function is (heavily) used to determine the type of elements and to check if the element really is contained in its parent. - EXAMPLES:: sage: from sage.modular.modform_hecketriangle.constructor import rational_type diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py index c2938e444a0..cc88da2542e 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_group_element.py @@ -1074,7 +1074,7 @@ def primitive_part(self, method="cf"): is +- the identity (to correct the sign) and ``power = self.primitive_power()``. - The primitive part itself is choosen such that it cannot be + The primitive part itself is chosen such that it cannot be written as a non-trivial power of another element. It is a generator of the stabilizer of the corresponding (attracting) fixed point. @@ -1167,7 +1167,7 @@ def reduce(self, primitive=True): If ``self`` is elliptic (or +- the identity) the result is never reduced (by definition). Instead a more canonical conjugation representative of ``self`` (resp. it's - primitive part) is choosen. + primitive part) is chosen. Warning: The case ``n=infinity`` is not verified at all and probably wrong! @@ -1379,7 +1379,8 @@ def primitive_power(self, method="cf"): return j elif two*j == G.n(): return j - # for the cases fom here on the sign has to be adjusted to the + # for the cases from here on the sign has to be adjusted + # to the # sign of self (in self._block_decomposition_data()) elif two*j == -G.n(): return -j @@ -1433,7 +1434,7 @@ def block_length(self, primitive=False): An integer. For hyperbolic elements a non-negative integer. For parabolic elements a negative sign corresponds to taking the inverse. For elliptic elements a (non-trivial) integer - with minimal absolute value is choosen. For +- the identity + with minimal absolute value is chosen. For +- the identity element ``0`` is returned. EXAMPLES:: @@ -2956,7 +2957,7 @@ def fixed_points(self, embedded=False, order="default"): - ``embedded`` -- If ``True``, the fixed points are embedded into ``AlgebraicRealField`` resp. ``AlgebraicField``. Default: ``False``. - - ``order`` -- If ``order="none"`` the fixed points are choosen + - ``order`` -- If ``order="none"`` the fixed points are chosen and ordered according to a fixed formula. If ``order="sign"`` the fixed points are always ordered @@ -2979,9 +2980,9 @@ def fixed_points(self, embedded=False, order="default"): ``AlgebraicField`` is returned. Otherwise an element of a relative field extension over the base field of (the parent of) ``self`` is returned. - Warning: Relative field extensions don't support default embeddings. + Warning: Relative field extensions do not support default embeddings. So the correct embedding (which is the positive resp. imaginary positive - one) has to be choosen. + one) has to be chosen. EXAMPLES:: diff --git a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py index 17ee69ec123..aea71efb49e 100644 --- a/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py +++ b/src/sage/modular/modform_hecketriangle/hecke_triangle_groups.py @@ -122,7 +122,7 @@ def _repr_(self): sage: HeckeTriangleGroup(10) Hecke triangle group for n = 10 """ - return "Hecke triangle group for n = {}".format(self._n) + return f"Hecke triangle group for n = {self._n}" def _latex_(self): r""" @@ -1261,7 +1261,7 @@ def list_discriminants(self, D, primitive=True, hyperbolic=True, incomplete=Fals - ``incomplete`` -- If ``True`` (default: ``False``) then all (also higher) discriminants which were gathered so far are listed - (however there might be missing discriminants inbetween). + (however there might be missing discriminants in between). OUTPUT: @@ -1412,7 +1412,7 @@ def rational_period_functions(self, k, D): if not ZZ(2).divides(k): raise TypeError except TypeError: - raise ValueError("k={} has to be an even integer!".format(k)) + raise ValueError(f"k={k} has to be an even integer!") z = PolynomialRing(self.base_ring(), 'z').gen() diff --git a/src/sage/modular/modform_hecketriangle/series_constructor.py b/src/sage/modular/modform_hecketriangle/series_constructor.py index b44f41a09a0..462cc273459 100644 --- a/src/sage/modular/modform_hecketriangle/series_constructor.py +++ b/src/sage/modular/modform_hecketriangle/series_constructor.py @@ -115,10 +115,9 @@ def __init__(self, group, prec): sage: MFSeriesConstructor(group=infinity) Power series constructor for Hecke modular forms for n=+Infinity with (basic series) precision 10 """ - self._group = group self._prec = prec - self._series_ring = PowerSeriesRing(QQ,'q',default_prec=self._prec) + self._series_ring = PowerSeriesRing(QQ, 'q', default_prec=self._prec) def _repr_(self): r""" @@ -147,7 +146,6 @@ def group(self): sage: MFSeriesConstructor(group=4).group() Hecke triangle group for n = 4 """ - return self._group def hecke_n(self): @@ -160,7 +158,6 @@ def hecke_n(self): sage: MFSeriesConstructor(group=4).hecke_n() 4 """ - return self._group.n() def prec(self): @@ -175,7 +172,6 @@ def prec(self): sage: MFSeriesConstructor(group=5, prec=20).prec() 20 """ - return self._prec @cached_method @@ -193,9 +189,9 @@ def J_inv_ZZ(self): .. TODO:: - The functions that are used in this implementation are - products of hypergeometric series with other, elementary, - functions. Implement them and clean up this representation. + The functions that are used in this implementation are + products of hypergeometric series with other, elementary, + functions. Implement them and clean up this representation. EXAMPLES:: @@ -210,29 +206,27 @@ def J_inv_ZZ(self): sage: MFSeriesConstructor(group=infinity, prec=3).J_inv_ZZ() q^-1 + 3/8 + 69/1024*q + O(q^2) """ + def F1(a, b): + return self._series_ring( + [ZZ.zero()] + + [rising_factorial(a, k) * rising_factorial(b, k) / (ZZ(k).factorial())**2 + * sum(ZZ.one()/(a+j) + ZZ.one()/(b+j) - ZZ(2)/ZZ(1+j) + for j in range(k)) + for k in range(1, self._prec + 1) + ], + ZZ(self._prec + 1) + ) + + def F(a, b, c): + return self._series_ring( + [rising_factorial(a, k) * rising_factorial(b, k) / rising_factorial(c, k) / ZZ(k).factorial() + for k in range(self._prec + 1)], + ZZ(self._prec + 1) + ) - F1 = lambda a,b: self._series_ring( - [ ZZ(0) ] - + [ - rising_factorial(a,k) * rising_factorial(b,k) / (ZZ(k).factorial())**2 - * sum(ZZ(1)/(a+j) + ZZ(1)/(b+j) - ZZ(2)/ZZ(1+j) - for j in range(ZZ(0),ZZ(k)) - ) - for k in range(ZZ(1), ZZ(self._prec+1)) - ], - ZZ(self._prec+1) - ) - - F = lambda a,b,c: self._series_ring( - [ - rising_factorial(a,k) * rising_factorial(b,k) / rising_factorial(c,k) / ZZ(k).factorial() - for k in range(ZZ(0), ZZ(self._prec+1)) - ], - ZZ(self._prec+1) - ) a = self._group.alpha() b = self._group.beta() - Phi = F1(a,b) / F(a,b,ZZ(1)) + Phi = F1(a, b) / F(a, b, ZZ.one()) q = self._series_ring.gen() # the current implementation of power series reversion is slow @@ -240,7 +234,7 @@ def J_inv_ZZ(self): temp_f = (q*Phi.exp()).polynomial() new_f = temp_f.revert_series(temp_f.degree()+1) - J_inv_ZZ = ZZ(1) / (new_f + O(q**(temp_f.degree()+1))) + J_inv_ZZ = ZZ.one() / (new_f + O(q**(temp_f.degree()+1))) return J_inv_ZZ diff --git a/src/sage/modular/modform_hecketriangle/subspace.py b/src/sage/modular/modform_hecketriangle/subspace.py index aa16edabc04..692fcbfc9ec 100644 --- a/src/sage/modular/modform_hecketriangle/subspace.py +++ b/src/sage/modular/modform_hecketriangle/subspace.py @@ -59,7 +59,7 @@ def ModularFormsSubSpace(*args, **kwargs): r""" Create a modular forms subspace generated by the supplied arguments if possible. Instead of a list of generators also multiple input arguments can be used. - If ``reduce=True`` then the corresponding ambient space is choosen as small as possible. + If ``reduce=True`` then the corresponding ambient space is chosen as small as possible. If no subspace is available then the ambient space is returned. EXAMPLES:: @@ -147,7 +147,7 @@ def __init__(self, ambient_space, basis, check): elements of ``ambient_space``. - ``check`` -- If ``True`` (default) then a maximal linearly - independent subset of ``basis`` is choosen. Otherwise + independent subset of ``basis`` is chosen. Otherwise it is assumed that ``basis`` is linearly independent. OUTPUT: @@ -230,7 +230,7 @@ def _repr_(self): # If we list the basis the representation usually gets too long... # return "Subspace with basis {} of {}".format([v.as_ring_element() for v in self.basis()], self._ambient_space) - return "Subspace of dimension {} of {}".format(len(self._basis), self._ambient_space) + return f"Subspace of dimension {len(self._basis)} of {self._ambient_space}" def change_ring(self, new_base_ring): r"""