Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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: 2 additions & 4 deletions src/sage/rings/padics/padic_ZZ_pX_CA_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -332,10 +332,8 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
x = Rational(x)
elif x.type() == 't_POLMOD' or x.type == 't_POL':
# This code doesn't check to see if the primes are the same.
L = []
x = x.lift().lift()
for i from 0 <= i <= x.poldegree():
L.append(Integer(x.polcoef(i)))
L = [Integer(x.polcoef(i)) for i in range(x.poldegree() + 1)]
x = L
else:
raise TypeError("unsupported coercion from pari: only p-adics, integers, rationals, polynomials and pol_mods allowed")
Expand Down Expand Up @@ -1300,7 +1298,7 @@ cdef class pAdicZZpXCAElement(pAdicZZpXElement):
# checks to see if the residue of self's unit is in the prime field.
if self.prime_pow.e == 1:
unit = self.unit_part()
for i from 1 <= i <= ZZ_pX_deg(unit.value):
for i in range(1, ZZ_pX_deg(unit.value) + 1):
if not ZZ_divide_test(ZZ_p_rep(ZZ_pX_coeff(unit.value, i)), self.prime_pow.pow_ZZ_tmp(1)[0]):
raise ValueError("in order to raise to a p-adic exponent, base must reduce to an element of F_p mod the uniformizer")
# compute the "level"
Expand Down
6 changes: 2 additions & 4 deletions src/sage/rings/padics/padic_ZZ_pX_CR_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,8 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement):
x = Rational(x)
elif x.type() == 't_POLMOD' or x.type == 't_POL':
# This code doesn't check to see if the primes are the same.
L = []
x = x.lift().lift()
for i from 0 <= i <= x.poldegree():
L.append(Integer(x.polcoef(i)))
L = [Integer(x.polcoef(i)) for i in range(x.poldegree() + 1)]
x = L
else:
raise TypeError("unsupported coercion from pari: only p-adics, integers, rationals, polynomials and pol_mods allowed")
Expand Down Expand Up @@ -1974,7 +1972,7 @@ cdef class pAdicZZpXCRElement(pAdicZZpXElement):
raise NotImplementedError("negative valuation exponents not yet supported")
# checks to see if the residue of self.unit is in the prime field.
if self.prime_pow.e == 1:
for i from 1 <= i <= ZZ_pX_deg(self.unit):
for i in range(ZZ_pX_deg(self.unit) + 1):
if not ZZ_divide_test(ZZ_p_rep(ZZ_pX_coeff(self.unit, i)), self.prime_pow.pow_ZZ_tmp(1)[0]):
raise ValueError("in order to raise to a p-adic exponent, base must reduce to an element of F_p mod the uniformizer")
# compute the "level"
Expand Down
4 changes: 1 addition & 3 deletions src/sage/rings/padics/padic_ZZ_pX_FM_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,8 @@ cdef class pAdicZZpXFMElement(pAdicZZpXElement):
x = Rational(x)
elif x.type() == 't_POLMOD' or x.type == 't_POL':
# This code doesn't check to see if the primes are the same.
L = []
x = x.lift().lift()
for i from 0 <= i <= x.poldegree():
L.append(Integer(x.polcoef(i)))
L = [Integer(x.polcoef(i)) for i in range(x.poldegree() + 1)]
x = L
else:
raise TypeError("unsupported coercion from pari: only p-adics, integers, rationals, polynomials and pol_mods allowed")
Expand Down
18 changes: 9 additions & 9 deletions src/sage/rings/padics/padic_ZZ_pX_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -296,18 +296,18 @@ cdef class pAdicZZpXElement(pAdicExtElement):
#print(printer)

if self.prime_pow.e == 1:
for j from 0 <= j < self.prime_pow.prec_cap:
for j in range(self.prime_pow.prec_cap):
ans.append([])
for i from 0 <= i < self.prime_pow.deg:
for i in range(self.prime_pow.deg):
ZZ_coeff.x = ZZ_p_rep(ZZ_pX_coeff(shifter, i))
ZZ_to_mpz(coeff.value, &ZZ_coeff.x)
L = printer.base_p_list(coeff, pos)
for j from 0 <= j < prec:
for j in range(prec):
if j < len(L):
ans[j].append(L[j])
else:
ans[j].append(zero)
for j from 0 <= j < prec:
for j in range(prec):
while ans[j]:
if ans[j][-1] == 0:
ans[j].pop()
Expand All @@ -322,7 +322,7 @@ cdef class pAdicZZpXElement(pAdicExtElement):
# It's important that one doesn't normalize in between shifting (for capped relative elements):
# _const_term doesn't normalize and thus we pick up the zeros
# since we're throwing away leading zeros, it doesn't matter if we start normalized or not.
for j from 0 <= j < self.prime_pow.e:
for j in range(self.prime_pow.e):
list_elt = PY_NEW(Integer)
if i + j == prec:
break
Expand Down Expand Up @@ -655,7 +655,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
pshift_z = ntl_ZZ.__new__(ntl_ZZ)
pshift_z.x = elt.prime_pow.pow_ZZ_tmp(-mpz_get_si((<Integer>min_val).value))[0]
pshift_m = elt.prime_pow.pow_Integer(-mpz_get_si((<Integer>min_val).value))
for i from 0 <= i < len(L):
for i in range(len(L)):
if isinstance(L[i], ntl_ZZ):
L[i] = ntl_ZZ_p(L[i]*pshift_z, ctx)
elif isinstance(L[i], (Integer, Rational, int)):
Expand All @@ -670,7 +670,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
pshift_z = ntl_ZZ.__new__(ntl_ZZ)
pshift_z.x = elt.prime_pow.pow_ZZ_tmp(mpz_get_ui((<Integer>min_val).value))[0]
pshift_m = elt.prime_pow.pow_Integer(mpz_get_ui((<Integer>min_val).value))
for i from 0 <= i < len(L):
for i in range(len(L)):
if isinstance(L[i], ntl_ZZ):
ZZ_div(tmp, (<ntl_ZZ>L[i]).x, pshift_z.x)
py_tmp = ntl_ZZ.__new__(ntl_ZZ)
Expand All @@ -688,7 +688,7 @@ cdef preprocess_list(pAdicZZpXElement elt, L):
py_tmp.x = tmp
L[i] = ntl_ZZ_p(py_tmp, ctx)
else:
for i from 0 <= i < len(L):
for i in range(len(L)):
if isinstance(L[i], (ntl_ZZ, Integer, Rational, int)):
L[i] = ntl_ZZ_p(L[i], ctx)
elif (isinstance(L[i], pAdicGenericElement) and L[i]._is_base_elt(elt.prime_pow.prime)) or isinstance(L[i], IntegerMod_abstract) or (L[i].modulus_context() is not ctx):
Expand Down Expand Up @@ -754,7 +754,7 @@ cdef find_val_aprec(PowComputer_ext pp, L):
min_val = big
min_aprec = big
total_type = two # we begin by defaulting to the list elements being integers
for i from 0 <= i < len(L):
for i in range(len(L)):
cur_val, cur_aprec, cur_type = get_val_prec(pp, L[i])
#return "a","b","c"
# proc_type == 0 indicates something with finite precision
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/padics/padic_printing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1173,7 +1173,7 @@ cdef class pAdicPrinter_class(SageObject):
else:
pk = Integer(1)
integral = True
for i from 0 <= i < len(L):
for i in range(len(L)):
if L[i] != "":
a = Integer(L[i])
if not pos and 2*a > pn:
Expand Down Expand Up @@ -1220,7 +1220,7 @@ cdef class pAdicPrinter_class(SageObject):
if self.unram_name is None:
raise RuntimeError("need to have specified a name for the unramified variable")
L, ellipsis = self._truncate_list(L, self.max_ram_terms, [])
for i from 0 <= i < len(L):
for i in range(len(L)):
unram_name = self.latex_unram_name if do_latex else self.unram_name
term = self._print_unram_term(L[i], do_latex, unram_name, self.max_unram_terms, 0, 0)
if len(term) > 0:
Expand Down Expand Up @@ -1393,7 +1393,7 @@ cdef class pAdicPrinter_class(SageObject):
cdef Py_ssize_t j, newj
cdef long exp, count = 0
if increasing:
for j from 0 <= j < len(L):
for j in range(len(L)):
exp = j + expshift
if L[j] != 0:
if max_unram_terms == 0:
Expand Down Expand Up @@ -1480,7 +1480,7 @@ cdef class pAdicPrinter_class(SageObject):
cdef Py_ssize_t j
cdef long exp
if increasing:
for j from 0 <= j < len(L):
for j in range(len(L)):
exp = j + expshift
s = self._print_term_of_poly(s, L[j], do_latex, polyname, exp)
else:
Expand Down
Loading