Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/sage/misc/c3_controlled.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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`::

Expand Down
2 changes: 1 addition & 1 deletion src/sage/modular/modform_hecketriangle/abstract_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
59 changes: 29 additions & 30 deletions src/sage/modular/modform_hecketriangle/abstract_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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``.

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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()
Expand All @@ -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)``.
Expand Down Expand Up @@ -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...
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)``.
Expand Down Expand Up @@ -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):
Expand Down
3 changes: 1 addition & 2 deletions src/sage/modular/modform_hecketriangle/constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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!
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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::
Expand Down Expand Up @@ -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
Expand All @@ -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::

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
Expand Down Expand Up @@ -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:

Expand Down Expand Up @@ -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()

Expand Down
39 changes: 17 additions & 22 deletions src/sage/modular/modform_hecketriangle/series_constructor.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,37 +210,32 @@ def J_inv_ZZ(self):
sage: MFSeriesConstructor(group=infinity, prec=3).J_inv_ZZ()
q^-1 + 3/8 + 69/1024*q + O(q^2)
"""

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)
)
F1 = lambda a, b: 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)
)

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(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
# J_inv_ZZ = ZZ(1) / ((q*Phi.exp()).reverse())

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

Expand Down
Loading