diff --git a/src/sage/coding/codecan/codecan.pyx b/src/sage/coding/codecan/codecan.pyx index 79898ee30ce..47311e16260 100644 --- a/src/sage/coding/codecan/codecan.pyx +++ b/src/sage/coding/codecan/codecan.pyx @@ -608,7 +608,7 @@ cdef class PartitionRefinementLinearCode(PartitionRefinement_generic): self._init_partition_stack(P) self._init_point_hyperplane_incidence() - self._start_Sn_backtrack() #start the main computation + self._start_Sn_backtrack() # start the main computation # up to now, we just computed the permutational part of the group action # compute the other components of the transporter diff --git a/src/sage/data_structures/bounded_integer_sequences.pyx b/src/sage/data_structures/bounded_integer_sequences.pyx index 1b23b5ed8a7..44635ad2364 100644 --- a/src/sage/data_structures/bounded_integer_sequences.pyx +++ b/src/sage/data_structures/bounded_integer_sequences.pyx @@ -1205,7 +1205,7 @@ cdef class BoundedIntegerSequence: if other is None or self is None: raise TypeError('cannot concatenate bounded integer sequence and None') myself = self # may result in a type error - right = other # --"-- + right = other # --"-- if right.data.itembitsize != myself.data.itembitsize: raise ValueError("can only concatenate bounded integer sequences of compatible bounds") out = BoundedIntegerSequence.__new__(BoundedIntegerSequence, 0, None) diff --git a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx index fb3b268b0df..1da1efc2bd7 100644 --- a/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx +++ b/src/sage/dynamics/arithmetic_dynamics/projective_ds_helper.pyx @@ -132,7 +132,7 @@ cpdef _fast_possible_periods(self, return_points=False): for r in rvalues: periods.add(period*r) points_periods.append([P_proj, period*r]) - if p == 2 or p == 3: #need e=1 for N=1, QQ + if p == 2 or p == 3: # need e=1 for N=1, QQ periods.add(period*r*p) points_periods.append([P_proj, period*r*p]) else: @@ -141,7 +141,7 @@ cpdef _fast_possible_periods(self, return_points=False): periods.add(period*r*p) points_periods.append([P_proj, period*r]) points_periods.append([P_proj, period*r*p]) - if p == 2: #need e=3 for N>1, QQ + if p == 2: # need e=3 for N>1, QQ periods.add(period*r*4) points_periods.append([P_proj, period*r*4]) periods.add(period*r*8) diff --git a/src/sage/libs/lcalc/lcalc_Lfunction.pyx b/src/sage/libs/lcalc/lcalc_Lfunction.pyx index 061a388e618..f1173543ab1 100644 --- a/src/sage/libs/lcalc/lcalc_Lfunction.pyx +++ b/src/sage/libs/lcalc/lcalc_Lfunction.pyx @@ -491,7 +491,7 @@ cdef class Lfunction_I(Lfunction): cdef void _init_fun(self, char *NAME, int what_type, dirichlet_coeff, long long Period, double q, c_Complex w, int A, double *g, c_Complex *l, int n_poles, c_Complex *p, c_Complex *r) noexcept: cdef int N = len(dirichlet_coeff) cdef Integer tmpi - cdef int * coeffs = new_ints(N+1) #lcalc ignores 0the coefficient + cdef int * coeffs = new_ints(N+1) # lcalc ignores 0th coefficient for i from 0 <= i< N by 1: tmpi=Integer(dirichlet_coeff[i]) coeffs[i+1] = mpz_get_si(tmpi.value) @@ -628,9 +628,9 @@ cdef class Lfunction_D(Lfunction): cdef int i cdef RealNumber tmpr cdef int N = len(dirichlet_coeff) - cdef double * coeffs = new_doubles(N+1)#lcalc ignores 0th position - for i from 0 <= i< N by 1: - tmpr=RRR(dirichlet_coeff[i]) + cdef double * coeffs = new_doubles(N+1) # lcalc ignores 0th position + for i in range(N): + tmpr = RRR(dirichlet_coeff[i]) coeffs[i+1] = mpfr_get_d(tmpr.value, MPFR_RNDN) self.thisptr=new_c_Lfunction_D(NAME, what_type, N, coeffs, Period, q, w, A, g, l, n_poles, p, r) del_doubles(coeffs) diff --git a/src/sage/libs/mpmath/ext_impl.pyx b/src/sage/libs/mpmath/ext_impl.pyx index 97f135d7219..fdbbfa80a3a 100644 --- a/src/sage/libs/mpmath/ext_impl.pyx +++ b/src/sage/libs/mpmath/ext_impl.pyx @@ -1261,7 +1261,7 @@ cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts): bneg = MPF_sgn(b) <= 0 if apos: # real part - MPF_hypot(&t, a, b, wpopts) #t = abs(a+bi) + a + MPF_hypot(&t, a, b, wpopts) # t = abs(a+bi) + a MPF_add(&t, &t, a, wpopts) MPF_set(&u, &t) mpz_sub_ui(u.exp, u.exp, 1) # u = t / 2 @@ -1276,10 +1276,10 @@ cdef MPF_complex_sqrt(MPF *c, MPF *d, MPF *a, MPF *b, MPopts opts): MPF_sub(&t, &t, a, wpopts) MPF_set(&u, &t) mpz_sub_ui(u.exp, u.exp, 1) # u = t / 2 - MPF_sqrt(d, &u, opts) # im = sqrt(u) + MPF_sqrt(d, &u, opts) # im = sqrt(u) mpz_add_ui(t.exp, t.exp, 1) # t = 2*t MPF_sqrt(&u, &t, wpopts) # u = sqrt(t) - MPF_div(c, &v, &u, opts) # re = b / u + MPF_div(c, &v, &u, opts) # re = b / u if bneg: MPF_neg(c, c) MPF_neg(d, d) diff --git a/src/sage/libs/mpmath/ext_main.pyx b/src/sage/libs/mpmath/ext_main.pyx index 96d5e9ff828..11ccfc701d2 100644 --- a/src/sage/libs/mpmath/ext_main.pyx +++ b/src/sage/libs/mpmath/ext_main.pyx @@ -386,7 +386,7 @@ cdef MPopts global_opts global_context = None cdef class Context: - cdef public mpf, mpc, constant #, def_mp_function + cdef public mpf, mpc, constant # , def_mp_function cdef public trap_complex cdef public pretty diff --git a/src/sage/libs/ntl/ntl_ZZ_pX.pyx b/src/sage/libs/ntl/ntl_ZZ_pX.pyx index 4082db003b4..f7e69c52128 100644 --- a/src/sage/libs/ntl/ntl_ZZ_pX.pyx +++ b/src/sage/libs/ntl/ntl_ZZ_pX.pyx @@ -957,7 +957,7 @@ cdef class ntl_ZZ_pX(): sage: f.derivative() [7 0 19] """ - cdef ntl_ZZ_pX r = self._new() #restores context + cdef ntl_ZZ_pX r = self._new() # restores context sig_on() ZZ_pX_diff(r.x, self.x) sig_off() diff --git a/src/sage/matrix/matrix0.pyx b/src/sage/matrix/matrix0.pyx index 28c990d0954..c0d9f93e804 100644 --- a/src/sage/matrix/matrix0.pyx +++ b/src/sage/matrix/matrix0.pyx @@ -3605,14 +3605,14 @@ cdef class Matrix(sage.structure.element.Matrix): [-4 -5 2] [ 3 4 5] """ - self.check_row_bounds_and_mutability(i,i) + self.check_row_bounds_and_mutability(i, i) if r < 0 or r >= A.nrows(): raise IndexError("invalid row") # this function exists just because it is useful for modular symbols presentations. cdef Py_ssize_t l l = 0 for k in cols: - self.set_unsafe(i,l,-A.get_unsafe(r,k)) #self[i,l] = -A[r,k] + self.set_unsafe(i, l, -A.get_unsafe(r, k)) # self[i,l] = -A[r,k] l += 1 def reverse_rows_and_columns(self): diff --git a/src/sage/matrix/matrix_double_dense.pyx b/src/sage/matrix/matrix_double_dense.pyx index d3fcde93fec..714edb22b32 100644 --- a/src/sage/matrix/matrix_double_dense.pyx +++ b/src/sage/matrix/matrix_double_dense.pyx @@ -340,7 +340,7 @@ cdef class Matrix_double_dense(Matrix_numpy_dense): import scipy import scipy.linalg from numpy.linalg import LinAlgError - try: ## Standard error reporting for Sage. + try: # Standard error reporting for Sage. M._matrix_numpy = scipy.linalg.inv(self._matrix_numpy) except LinAlgError: raise ZeroDivisionError("input matrix must be nonsingular") diff --git a/src/sage/misc/c3_controlled.pyx b/src/sage/misc/c3_controlled.pyx index 76445ff4dfb..81f66f0c680 100644 --- a/src/sage/misc/c3_controlled.pyx +++ b/src/sage/misc/c3_controlled.pyx @@ -624,11 +624,11 @@ def C3_merge(list lists): cdef bint next_item_found while nbheads: - for i in range(nbheads): # from 0 <= i < nbheads: + for i in range(nbheads): O = heads[i] # Does O appear in none of the tails? ``all(O not in tail for tail in tailsets)`` next_item_found = True - for j in range(nbheads): #from 0 <= j < nbheads: + for j in range(nbheads): if j == i: continue tailset = tailsets[j] @@ -640,7 +640,7 @@ def C3_merge(list lists): # Clear O from other heads, removing the line altogether # if the tail is already empty. # j goes down so that ``del heads[j]`` does not screw up the numbering - for j in range(nbheads-1, -1, -1): # from nbheads > j >= 0: + for j in range(nbheads-1, -1, -1): if heads[j] == O: # is O tail = tails[j] if tail: @@ -860,7 +860,7 @@ cpdef tuple C3_sorted_merge(list lists, key=identity): # Find the position of the largest head which will become the next item max_i = 0 max_key = key(heads[0]) - for i in range(1, nbheads): #from 1 <= i < nbheads: + for i in range(1, nbheads): O = heads[i] O_key = key(O) if O_key > max_key: @@ -870,14 +870,14 @@ cpdef tuple C3_sorted_merge(list lists, key=identity): # Find all the bad choices max_bad = None - for i in range(max_i): #from 0 <= i < max_i: + for i in range(max_i): O = heads[i] # Does O appear in none of the tails? O_key = key(O) # replace the closure # if any(O_key in tailsets[j] for j in range(nbheads) if j != i): continue cont = False - for j from 0<=j j >= 0: + for j in range(nbheads-1, -1, -1): if heads[j] == max_value: tail = tails[j] if tail: @@ -1053,7 +1053,7 @@ class HierarchyElement(object, metaclass=ClasscallMetaclass): [, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , <... 'object'>] """ @staticmethod - def __classcall__(cls, value, succ, key = None): + def __classcall__(cls, value, succ, key=None): """ EXAMPLES:: diff --git a/src/sage/misc/function_mangling.pyx b/src/sage/misc/function_mangling.pyx index 4e94e29e8cb..79e508f19b8 100644 --- a/src/sage/misc/function_mangling.pyx +++ b/src/sage/misc/function_mangling.pyx @@ -132,16 +132,16 @@ cdef class ArgumentFixer: else: self._default_tuple = tuple(defaults) - #code = f.__code__ + # code = f.__code__ self.f = f self._ndefault = len(defaults) if classmethod: - self._nargs = len(arg_names)-1 #code.co_argcount-1 - self._arg_names = tuple(arg_names[1:]) #code.co_varnames[1:self._nargs+1] + self._nargs = len(arg_names)-1 # code.co_argcount-1 + self._arg_names = tuple(arg_names[1:]) # code.co_varnames[1:self._nargs+1] else: - self._nargs = len(arg_names) #code.co_argcount - self._arg_names = tuple(arg_names) #code.co_varnames[:self._nargs] + self._nargs = len(arg_names) # code.co_argcount + self._arg_names = tuple(arg_names) # code.co_varnames[:self._nargs] self._classmethod = classmethod cdef dict default_map diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index 4c51803b5f9..14c60dc3167 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -40,7 +40,7 @@ cdef class CVXOPTBackend(GenericBackend): Mixed Integer Program (no objective, 0 variables, 0 constraints) """ - cdef list objective_function #c_matrix + cdef list objective_function # c_matrix cdef list G_matrix cdef str prob_name cdef bint is_maximize @@ -65,7 +65,7 @@ cdef class CVXOPTBackend(GenericBackend): sage: p = get_solver(solver='CVXOPT') """ - self.objective_function = [] #c_matrix in the example for cvxopt + self.objective_function = [] # c_matrix in the example for cvxopt self.G_matrix = [] self.prob_name = '' self.obj_constant_term = 0 @@ -79,12 +79,12 @@ cdef class CVXOPTBackend(GenericBackend): self.row_name_var = [] self.col_name_var = [] - self.param = {"show_progress":False, - "maxiters":100, - "abstol":1e-7, - "reltol":1e-6, - "feastol":1e-7, - "refinement":0 } + self.param = {"show_progress": False, + "maxiters": 100, + "abstol": 1e-7, + "reltol": 1e-6, + "feastol": 1e-7, + "refinement": 0} self.answer = {} if maximization: self.set_sense(+1) diff --git a/src/sage/plot/plot3d/shapes.pyx b/src/sage/plot/plot3d/shapes.pyx index 6dcf6564714..48369a64a07 100644 --- a/src/sage/plot/plot3d/shapes.pyx +++ b/src/sage/plot/plot3d/shapes.pyx @@ -1162,14 +1162,14 @@ class Text(PrimitiveObject): [[['select atomno = 1', 'color atom [102,102,255]', 'label "Hi"']], [['select atomno = 2', 'color atom [102,102,255]', 'label "Bye"']]] """ - cen = (0,0,0) + cen = (0, 0, 0) if render_params.transform is not None: cen = render_params.transform.transform_point(cen) render_params.atom_list.append(cen) atom_no = len(render_params.atom_list) return ['select atomno = %s' % atom_no, self.get_texture().jmol_str("atom"), - 'label "%s"' % self.string] #.replace('\n', '|')] + 'label "%s"' % self.string] # .replace('\n', '|')] def threejs_repr(self, render_params): r""" diff --git a/src/sage/rings/complex_mpfr.pyx b/src/sage/rings/complex_mpfr.pyx index 415dd00c78f..bec9978401e 100644 --- a/src/sage/rings/complex_mpfr.pyx +++ b/src/sage/rings/complex_mpfr.pyx @@ -1917,10 +1917,10 @@ cdef class ComplexNumber(sage.structure.element.FieldElement): mpfr_mul(t1, self.__im, self.__im, rnd) mpfr_add(t0, t0, t1, rnd) # now t0 is the norm - mpfr_div(x.__re, self.__re, t0, rnd) # x.__re = self.__re/norm + mpfr_div(x.__re, self.__re, t0, rnd) # x.__re = self.__re/norm mpfr_neg(t1, self.__im, rnd) - mpfr_div(x.__im, t1, t0, rnd) # x.__im = -self.__im/norm + mpfr_div(x.__im, t1, t0, rnd) # x.__im = -self.__im/norm mpfr_clear(t0) mpfr_clear(t1) diff --git a/src/sage/rings/padics/padic_printing.pyx b/src/sage/rings/padics/padic_printing.pyx index 2ac90a5d0f2..c0988388066 100644 --- a/src/sage/rings/padics/padic_printing.pyx +++ b/src/sage/rings/padics/padic_printing.pyx @@ -1401,7 +1401,7 @@ cdef class pAdicPrinter_class(SageObject): return s else: count += 1 - if count == max_unram_terms: #this will never trigger if max_unram_terms == -1 + if count == max_unram_terms: # this will never trigger if max_unram_terms == -1 newj = len(L) - 1 while L[newj] == 0: newj -= 1 @@ -1424,7 +1424,7 @@ cdef class pAdicPrinter_class(SageObject): return s else: count += 1 - if count == max_unram_terms: #this will never trigger if max_unram_terms == -1 + if count == max_unram_terms: # this will never trigger if max_unram_terms == -1 newj = 0 while L[newj] == 0: newj += 1 diff --git a/src/sage/rings/polynomial/polynomial_element.pyx b/src/sage/rings/polynomial/polynomial_element.pyx index 9470d56686c..b14346e367b 100644 --- a/src/sage/rings/polynomial/polynomial_element.pyx +++ b/src/sage/rings/polynomial/polynomial_element.pyx @@ -10185,7 +10185,7 @@ cdef class Polynomial(CommutativePolynomial): """ # __getitem__ already returns a polynomial!! # We must not have check=False, since 0 must not have _coeffs = [0]. - return self._parent(self[:n])#, check=False) + return self._parent(self[:n]) # , check=False) cdef _inplace_truncate(self, long prec): return self.truncate(prec) diff --git a/src/sage/rings/polynomial/weil/weil_polynomials.pyx b/src/sage/rings/polynomial/weil/weil_polynomials.pyx index 516cf641d2e..e2dd7bd04e7 100755 --- a/src/sage/rings/polynomial/weil/weil_polynomials.pyx +++ b/src/sage/rings/polynomial/weil/weil_polynomials.pyx @@ -303,13 +303,13 @@ class WeilPolynomials_iter(): coefflist.append(j) modlist.append(k) # Remove cofactor from initial coefficients - if num_cofactor == 1: #cofactor x + sqrt(q) + if num_cofactor == 1: # cofactor x + sqrt(q) for i in range(1, len(coefflist)): coefflist[i] -= coefflist[i-1]*q.sqrt() - elif num_cofactor == 2: #cofactor x + sqrt(q) + elif num_cofactor == 2: # cofactor x + sqrt(q) for i in range(1, len(coefflist)): coefflist[i] += coefflist[i-1]*q.sqrt() - elif num_cofactor == 3: #cofactor x^2 - q + elif num_cofactor == 3: # cofactor x^2 - q for i in range(2, len(coefflist)): coefflist[i] += coefflist[i-2]*q # Asymmetrize initial coefficients diff --git a/src/sage/rings/power_series_ring_element.pyx b/src/sage/rings/power_series_ring_element.pyx index a30091c9cd8..34e84ddbc5f 100644 --- a/src/sage/rings/power_series_ring_element.pyx +++ b/src/sage/rings/power_series_ring_element.pyx @@ -2915,7 +2915,7 @@ def _solve_linear_de(R, N, L, a, b, f0): g = _solve_linear_de(R, N, L2, a, b, f0) term1 = R(g) # we must not have check=False, since otherwise [..., 0, 0] is not stripped - term2 = R(a[:L]) #, check=False) + term2 = R(a[:L]) # , check=False) product = (term1 * term2).list() # todo: perhaps next loop could be made more efficient diff --git a/src/sage/stats/time_series.pyx b/src/sage/stats/time_series.pyx index 3b36f04ab9b..e4845126012 100644 --- a/src/sage/stats/time_series.pyx +++ b/src/sage/stats/time_series.pyx @@ -2024,7 +2024,7 @@ cdef class TimeSeries: sage: v [20.0000, -3.0000, 4.5000, -2.0000] """ - cnumpy.import_array() #This must be called before using the numpy C/api or you will get segfault + cnumpy.import_array() # This must be called before using the numpy C/api or you will get segfault cdef cnumpy.npy_intp dims[1] dims[0] = self._length cdef cnumpy.ndarray n = cnumpy.PyArray_SimpleNewFromData(1, dims, cnumpy.NPY_DOUBLE, self._values) diff --git a/src/sage/structure/element.pyx b/src/sage/structure/element.pyx index ca851192acb..5f1db5de82b 100644 --- a/src/sage/structure/element.pyx +++ b/src/sage/structure/element.pyx @@ -625,7 +625,7 @@ cdef class Element(SageObject): D = self.__dict__ except AttributeError: return res - for k,v in D.iteritems(): + for k, v in D.iteritems(): try: setattr(res, k, v) except AttributeError: @@ -711,7 +711,7 @@ cdef class Element(SageObject): AssertionError: self.an_element() is not in self """ tester = self._tester(**options) - SageObject._test_category(self, tester = tester) + SageObject._test_category(self, tester=tester) category = self.category() # Tests that self inherits methods from the categories if can_assign_class(self): @@ -760,13 +760,13 @@ cdef class Element(SageObject): # 100% sure we indeed call the operators == and !=, whatever # the version of Python is (see #11236) tester.assertTrue(self == self, - LazyFormat("broken equality: %s == itself is False")%self) + LazyFormat("broken equality: %s == itself is False") % self) tester.assertFalse(self == None, - LazyFormat("broken equality: %s == None")%self) + LazyFormat("broken equality: %s == None") % self) tester.assertFalse(self != self, - LazyFormat("broken non-equality: %s != itself")%self) + LazyFormat("broken non-equality: %s != itself") % self) tester.assertTrue(self != None, - LazyFormat("broken non-equality: %s is not != None")%self) + LazyFormat("broken non-equality: %s is not != None") % self) def parent(self, x=None): """ @@ -959,9 +959,9 @@ cdef class Element(SageObject): if self._is_atomic(): s = repr(self) else: - s = "(%s)"%repr(self) + s = "(%s)" % repr(self) if no_space: - return s.replace(' ','') + return s.replace(' ', '') return s def _latex_coeff_repr(self): @@ -972,7 +972,7 @@ cdef class Element(SageObject): if self._is_atomic(): return s else: - return "\\left(%s\\right)"%s + return "\\left(%s\\right)" % s def _is_atomic(self): """ @@ -1032,7 +1032,7 @@ cdef class Element(SageObject): try: zero = self._parent.zero() except Exception: - return True # by convention + return True # by convention return self != zero @@ -2434,14 +2434,15 @@ cdef class ModuleElement(Element): Scalar multiplication for module elements with the module element on the left and the scalar on the right. - Returning None indicates that this action is not implemented here. + Returning ``None`` indicates that this action is not implemented here. """ return None ################################################## # Other properties ################################################## - def order(self): ### DO NOT OVERRIDE THIS!!! Instead, override additive_order. + def order(self): + # DO NOT OVERRIDE THIS!!! Instead, override additive_order. """ Return the additive order of ``self``. """ @@ -3101,26 +3102,27 @@ cdef class CommutativeRingElement(RingElement): # First we test some generic conditions: try: if x.is_zero(): - return True # everything divides 0 + return True # everything divides 0 except (AttributeError, NotImplementedError): pass try: if self.is_zero(): - return False # 0 divides nothing else + return False # 0 divides nothing else except (AttributeError, NotImplementedError): pass try: if self.is_unit(): - return True # units divide everything + return True # units divide everything except (AttributeError, NotImplementedError): pass try: if self.is_one(): - return True # 1 divides everything - # (is_unit() may not be implemented) + return True + # 1 divides everything + # (is_unit() may not be implemented) except (AttributeError, NotImplementedError): pass @@ -3132,7 +3134,7 @@ cdef class CommutativeRingElement(RingElement): raise NotImplementedError else: - #Different parents, use coercion + # Different parents, use coercion a, b = coercion_model.canonical_coercion(self, x) return a.divides(b) @@ -3205,7 +3207,6 @@ cdef class CommutativeRingElement(RingElement): from sage.rings.ideal import Ideal_generic if not isinstance(I, Ideal_generic) or not I.ring() is self._parent: I = self._parent.ideal(I) - #raise TypeError, "I = %s must be an ideal in %s"%(I, self.parent()) return I.reduce(self) ################################################## @@ -3353,8 +3354,8 @@ cdef class CommutativeRingElement(RingElement): ... ValueError: trying to take square root of non-square 1/(x^2 - 3) with extend = False """ - #This code is very general, it works for all integral domains that have the - #is_square(root = True) option + # This code is very general, it works for all integral domains that have the + # is_square(root = True) option from sage.categories.integral_domains import IntegralDomains P = self._parent @@ -3364,15 +3365,15 @@ cdef class CommutativeRingElement(RingElement): if P not in IntegralDomains(): raise NotImplementedError('sqrt() with all=True is only implemented for integral domains, not for %s' % P) if P.characteristic()==2 or sq_rt==0: - #0 has only one square root, and in characteristic 2 everything also has only 1 root - return [ sq_rt ] - return [ sq_rt, -sq_rt ] + # 0 has only one square root, and in characteristic 2 everything also has only 1 root + return [sq_rt] + return [sq_rt, -sq_rt] return sq_rt - #from now on we know that self is not a square + # from now on we know that self is not a square if P not in IntegralDomains(): raise NotImplementedError('sqrt() of non squares is only implemented for integral domains, not for %s' % P) if not extend: - #all square roots of a non-square should be an empty list + # all square roots of a non-square should be an empty list if all: return [] raise ValueError('trying to take square root of non-square %s with extend = False' % self) @@ -3385,8 +3386,8 @@ cdef class CommutativeRingElement(RingElement): sq_rt = PY.quotient(y**2-self, names = name)(y) if all: if P.characteristic() == 2: - return [ sq_rt ] - return [ sq_rt, -sq_rt ] + return [sq_rt] + return [sq_rt, -sq_rt] return sq_rt ############################################## @@ -3703,7 +3704,7 @@ cdef class Vector(ModuleElementWithMutability): raise bin_op_exception('*', left, right) cpdef _pairwise_product_(Vector left, Vector right): - raise TypeError("unsupported operation for '%s' and '%s'"%(parent(left), parent(right))) + raise TypeError("unsupported operation for '%s' and '%s'" % (parent(left), parent(right))) def __truediv__(self, right): """ @@ -3779,7 +3780,7 @@ cdef class Vector(ModuleElementWithMutability): """ V = magma(self._parent) v = [x._magma_init_(magma) for x in self.list()] - return '%s![%s]'%(V.name(), ','.join(v)) + return '%s![%s]' % (V.name(), ','.join(v)) def is_Vector(x): @@ -4576,7 +4577,7 @@ cpdef canonical_coercion(x, y): [1 0], [0 1] ) """ - return coercion_model.canonical_coercion(x,y) + return coercion_model.canonical_coercion(x, y) cpdef bin_op(x, y, op):