Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing some E502 (unnecessary backslash) in pyx files #35206

Merged
merged 2 commits into from
Mar 26, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,10 @@ cdef void deallocate_agcl_work_space(agcl_work_space *work_space):
cdef aut_gp_and_can_lab *get_aut_gp_and_can_lab(void *S,
PartitionStack *partition, int n,
bint (*all_children_are_equivalent)(PartitionStack *PS, void *S),
int (*refine_and_return_invariant)\
(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree),
int (*refine_and_return_invariant)(PartitionStack *PS, void *S,
int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2,
int degree),
bint canonical_label, StabilizerChain *input_group,
agcl_work_space *work_space_prealloc, aut_gp_and_can_lab *output_prealloc) except NULL:
"""
Expand Down
8 changes: 5 additions & 3 deletions src/sage/groups/perm_gps/partn_ref/canonical_augmentation.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,13 @@ cdef void deallocate_cgd(canonical_generator_data *cgd):
sig_free(cgd.parent_stack)
sig_free(cgd)


cdef iterator *setup_canonical_generator(int degree,
bint (*all_children_are_equivalent)(PartitionStack *PS, void *S),
int (*refine_and_return_invariant)\
(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree),
int (*refine_and_return_invariant)(PartitionStack *PS, void *S,
int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2,
int degree),
int (*generate_children)(void *, aut_gp_and_can_lab *, iterator *),
void *(*apply_augmentation)(void *, void *, void *, int *, bint *),
void (*free_object)(void *),
Expand Down
7 changes: 4 additions & 3 deletions src/sage/groups/perm_gps/partn_ref/double_coset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,10 @@ cdef void deallocate_dc_work_space(dc_work_space *work_space):

cdef int double_coset(void *S1, void *S2, PartitionStack *partition1, int *ordering2,
int n, bint (*all_children_are_equivalent)(PartitionStack *PS, void *S),
int (*refine_and_return_invariant)\
(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree),
int (*refine_and_return_invariant)(PartitionStack *PS, void *S,
int *cells_to_refine_by, int ctrb_len),
int (*compare_structures)(int *gamma_1, int *gamma_2, void *S1, void *S2,
int degree),
StabilizerChain *input_group,
dc_work_space *work_space_prealloc, int *isom) except -1:
"""
Expand Down
12 changes: 6 additions & 6 deletions src/sage/libs/mpmath/ext_impl.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1847,8 +1847,8 @@ cdef MPF_complex_pow_int(MPF *zre, MPF *zim, MPF *xre, MPF *xim, mpz_t n, MPopts
xret = MPF_to_tuple(xre)
ximt = MPF_to_tuple(xim)
from mpmath.libmp import mpc_pow_int
vr, vi = mpc_pow_int((xret, ximt), mpzi(n), \
opts.prec, rndmode_to_python(opts.rounding))
vr, vi = mpc_pow_int((xret, ximt), mpzi(n),
opts.prec, rndmode_to_python(opts.rounding))
MPF_set_tuple(zre, vr)
MPF_set_tuple(zim, vi)

Expand Down Expand Up @@ -1892,8 +1892,8 @@ cdef MPF_complex_pow_re(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *y, MPopts o
ximt = MPF_to_tuple(xim)
yret = MPF_to_tuple(y)
from mpmath.libmp import mpc_pow_mpf, fzero
vr, vi = mpc_pow_mpf((xret, ximt), yret, \
opts.prec, rndmode_to_python(opts.rounding))
vr, vi = mpc_pow_mpf((xret, ximt), yret,
opts.prec, rndmode_to_python(opts.rounding))
MPF_set_tuple(zre, vr)
MPF_set_tuple(zim, vi)

Expand All @@ -1910,8 +1910,8 @@ cdef MPF_complex_pow(MPF *zre, MPF *zim, MPF *xre, MPF *xim, MPF *yre, MPF *yim,
yret = MPF_to_tuple(yre)
yimt = MPF_to_tuple(yim)
from mpmath.libmp import mpc_pow
vr, vi = mpc_pow((xret,ximt), (yret,yimt), \
opts.prec, rndmode_to_python(opts.rounding))
vr, vi = mpc_pow((xret, ximt), (yret, yimt),
opts.prec, rndmode_to_python(opts.rounding))
MPF_set_tuple(zre, vr)
MPF_set_tuple(zim, vi)

Expand Down
8 changes: 5 additions & 3 deletions src/sage/libs/mpmath/ext_main.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2602,13 +2602,15 @@ def hypsum_internal(int p, int q, param_types, str ztype, coeffs, z,
sage: print(mp.hyp1f1(1,2,3))
6.36184564106256

TODO: convert mpf/mpc parameters to fixed-point numbers here
instead of converting to tuples within MPF_hypsum.
.. TODO::

convert mpf/mpc parameters to fixed-point numbers here
instead of converting to tuples within MPF_hypsum.
"""
cdef mpf f
cdef mpc c
c = mpc.__new__(mpc)
have_complex, magn = MPF_hypsum(&c.re, &c.im, p, q, param_types, \
have_complex, magn = MPF_hypsum(&c.re, &c.im, p, q, param_types,
ztype, coeffs, z, prec, wp, epsshift, magnitude_check, kwargs)
if have_complex:
v = c
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/mpmath/utils.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ cpdef normalize(long sign, Integer man, exp, long bc, long prec, str rnd):
res = PY_NEW(Integer)
if shift > 0:
if rnd == 'n':
if mpz_tstbit(man.value, shift-1) and (mpz_tstbit(man.value, shift)\
if mpz_tstbit(man.value, shift-1) and (mpz_tstbit(man.value, shift)
or (mpz_scan1(man.value, 0) < (shift-1))):
mpz_cdiv_q_2exp(res.value, man.value, shift)
else:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/libs/ntl/ntl_ZZ.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ cdef class ntl_ZZ():
v = str(v)
if not v:
v = '0'
if not ((v[0].isdigit() or v[0] == '-') and \
(v[1:-1].isdigit() or (len(v) <= 2)) and \
if not ((v[0].isdigit() or v[0] == '-') and
(v[1:-1].isdigit() or (len(v) <= 2)) and
(v[-1].isdigit() or (v[-1].lower() in ['l','r']))):
raise ValueError("invalid integer: %s" % v)
ccreadstr(self.x, v)
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/complex_mpc.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -313,8 +313,8 @@ cdef class MPComplexField_class(sage.rings.ring.Field):
try:
n = _mpc_rounding_modes.index(rnd)
except ValueError:
raise ValueError("rnd (=%s) must be of the form RNDxy"\
"where x and y are one of N, Z, U, D" % rnd)
raise ValueError("rnd (=%s) must be of the form RNDxy"
"where x and y are one of N, Z, U, D" % rnd)
self.__rnd = n
self.__rnd_str = rnd

Expand Down Expand Up @@ -1158,8 +1158,8 @@ cdef class MPComplexNumber(sage.structure.element.FieldElement):
TypeError: can...t convert complex to float; use abs(z)
"""
if mpfr_zero_p(self.value.im):
return mpfr_get_d(self.value.re,\
rnd_re((<MPComplexField_class>self._parent).__rnd))
return mpfr_get_d(self.value.re,
rnd_re((<MPComplexField_class>self._parent).__rnd))
else:
raise TypeError("can't convert complex to float; use abs(z)")

Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/integer_mod.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -779,14 +779,14 @@ cdef class IntegerMod_abstract(FiniteRingElement):
na = a_red.multiplicative_order()
nb = b_red.multiplicative_order()
if not na.divides(nb): # cannot be a power
raise ValueError(f"no logarithm of {self} found to base {b} modulo {self.modulus()}" \
raise ValueError(f"no logarithm of {self} found to base {b} modulo {self.modulus()}"
+ (f" (no solution modulo {q})" if q != self.modulus() else ""))

if p == 2 and e >= 3: # (ZZ/2^e)* is not cyclic; must not give unsolvable DLPs to Pari
try:
v = discrete_log(a_red, b_red, nb)
except ValueError:
raise ValueError(f"no logarithm of {self} found to base {b} modulo {self.modulus()}" \
raise ValueError(f"no logarithm of {self} found to base {b} modulo {self.modulus()}"
+ (f" (no solution modulo {q})" if q != self.modulus() else ""))
else:
try:
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/finite_rings/residue_field.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1579,8 +1579,8 @@ class ResidueFiniteField_prime_modn(ResidueField_generic, FiniteField_prime_modn
self._populate_coercion_lists_(coerce_list=coerce_list, convert_list=[ReductionMap(K, self, None, None, None, None)]) # could be special-cased a bit more.
else:
PBinv = PB**(-1)
self._populate_coercion_lists_(coerce_list=[IntegerMod_to_IntegerMod(GF(intp), self), Integer_to_IntegerMod(self), Int_to_IntegerMod(self), ResidueFieldHomomorphism_global(OK, self, to_vs, to_order, PB, PBinv)], \
convert_list=[ReductionMap(K, self, to_vs, to_order, PB, PBinv)])
self._populate_coercion_lists_(coerce_list=[IntegerMod_to_IntegerMod(GF(intp), self), Integer_to_IntegerMod(self), Int_to_IntegerMod(self), ResidueFieldHomomorphism_global(OK, self, to_vs, to_order, PB, PBinv)],
convert_list=[ReductionMap(K, self, to_vs, to_order, PB, PBinv)])

def _element_constructor_(self, x):
"""
Expand Down
13 changes: 7 additions & 6 deletions src/sage/rings/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2035,8 +2035,8 @@ cdef class RingHomomorphism_im_gens(RingHomomorphism):
"""
D = self.domain()
ig = self._im_gens
s = '\n'.join(['%s |--> %s'%(D.gen(i), ig[i]) for\
i in range(D.ngens())])
s = '\n'.join('{} |--> {}'.format(D.gen(i), ig[i])
for i in range(D.ngens()))
if s and self._base_map is not None:
s += '\nwith map of base ring'
return s
Expand Down Expand Up @@ -2866,21 +2866,22 @@ cdef class RingHomomorphism_from_quotient(RingHomomorphism):
"""
return hash(self.phi)

def _repr_defn(self):
def _repr_defn(self) -> str:
"""
Used internally for printing this function.

EXAMPLES::

sage: R.<x,y> = QQ[]; S.<xx,yy> = R.quo([x^2,y^2]); f = S.hom([yy,xx])
sage: R.<x,y> = QQ[]; S.<xx,yy> = R.quo([x^2,y^2])
sage: f = S.hom([yy,xx])
sage: print(f._repr_defn())
xx |--> yy
yy |--> xx
"""
D = self.domain()
ig = self.phi.im_gens()
return '\n'.join(['%s |--> %s'%(D.gen(i), ig[i]) for\
i in range(D.ngens())])
return '\n'.join('{} |--> {}'.format(D.gen(i), ig[i])
for i in range(D.ngens()))

cpdef Element _call_(self, x):
"""
Expand Down
23 changes: 11 additions & 12 deletions src/sage/rings/padics/padic_printing.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -483,18 +483,17 @@ cdef class pAdicPrinter_class(SageObject):
sage: P._sep()
'&'
"""

return pAdicPrinter, (self.ring, \
{'mode': self._print_mode(), \
'pos': self.pos, \
'ram_name': self.ram_name, \
'unram_name': self.unram_name, \
'var_name': self.var_name, \
'max_ram_terms': self.max_ram_terms, \
'max_unram_terms': self.max_unram_terms, \
'max_terse_terms': self.max_terse_terms, \
'sep':self.sep, \
'alphabet': self.alphabet, \
return pAdicPrinter, (self.ring,
{'mode': self._print_mode(),
'pos': self.pos,
'ram_name': self.ram_name,
'unram_name': self.unram_name,
'var_name': self.var_name,
'max_ram_terms': self.max_ram_terms,
'max_unram_terms': self.max_unram_terms,
'max_terse_terms': self.max_terse_terms,
'sep':self.sep,
'alphabet': self.alphabet,
'show_prec': self.show_prec})

def __richcmp__(self, other, op):
Expand Down
Loading