Skip to content

Commit

Permalink
sagemathgh-38907: Format function headers around = and ,
Browse files Browse the repository at this point in the history
    
A PEP8 sweep mostly of function headers around equal signs and commas.

An illustration of the type of changes:
From
```
def f(x = 0,y):
```
to
```
def f(x=0, y):
```

I am in the awkward position of announcing the abundance of such
PEP8-malformations, thousands of which remain in functions calls. I may
do a follow-up PR addressing those.
    
URL: sagemath#38907
Reported by: gmou3
Reviewer(s): Martin Rubey
  • Loading branch information
Release Manager committed Nov 14, 2024
2 parents 1b8ac9c + 2c21f54 commit 813f2b5
Show file tree
Hide file tree
Showing 305 changed files with 3,760 additions and 3,760 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class FermionicGhostsLieConformalAlgebra(GradedLieConformalAlgebra):
sage: R.structure_coefficients()
Finite family {('a', 'c'): ((0, K),), ('b', 'd'): ((0, K),), ('c', 'a'): ((0, K),), ('d', 'b'): ((0, K),)}
"""
def __init__(self,R,ngens=2,names=None,index_set=None):
def __init__(self, R, ngens=2, names=None, index_set=None):
"""
Initialize ``self``.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/algebras/orlik_terao.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ class OrlikTeraoInvariantAlgebra(FiniteDimensionalInvariantModule):
defines the action we want, but since the groundset is `\{0,1,2\}`
we first add `1` and then subtract `1`::
sage: def on_groundset(g,x):
sage: def on_groundset(g, x):
....: return g(x+1)-1
Now that we have defined an action we can create the invariant, and
Expand Down Expand Up @@ -625,7 +625,7 @@ def __init__(self, R, M, G, action_on_groundset=None, *args, **kwargs):
....: [0,0,-1,0,-1,-1]])
sage: M = Matroid(A);
sage: G = SymmetricGroup(6)
sage: def on_groundset(g,x): return g(x+1)-1
sage: def on_groundset(g, x): return g(x+1)-1
sage: import __main__; __main__.on_groundset = on_groundset
sage: OTG = M.orlik_terao_algebra(QQ, invariant = (G,on_groundset))
sage: TestSuite(OTG).run()
Expand Down Expand Up @@ -687,7 +687,7 @@ def construction(self):
sage: A = matrix([[1,1,0],[-1,0,1],[0,-1,-1]])
sage: M = Matroid(A)
sage: G = SymmetricGroup(3)
sage: def on_groundset(g,x):
sage: def on_groundset(g, x):
....: return g(x+1)-1
sage: OTG = M.orlik_terao_algebra(QQ, invariant=(G,on_groundset))
sage: OTG.construction() is None
Expand Down Expand Up @@ -718,7 +718,7 @@ def _basis_action(self, g, f):
sage: M.groundset()
frozenset({0, 1, 2})
sage: G = SymmetricGroup(3)
sage: def on_groundset(g,x):
sage: def on_groundset(g, x):
....: return g(x+1)-1
sage: OTG = M.orlik_terao_algebra(QQ, invariant=(G,on_groundset))
sage: def act(g):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/steenrod/steenrod_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2533,7 +2533,7 @@ def an_element(self):
return self.monomial(((1, 2),))
return self.term(((), (((1,2), 1),)), GF(p)(p-1))

def pst(self,s,t):
def pst(self, s, t):
r"""
The Margolis element `P^s_t`.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/steenrod/steenrod_algebra_bases.py
Original file line number Diff line number Diff line change
Expand Up @@ -887,7 +887,7 @@ def degree_dictionary(n, basis):
deg = 2**s * (2**t - 1)
return dict

def sorting_pair(s,t,basis): # pair used for sorting the basis
def sorting_pair(s, t, basis): # pair used for sorting the basis
if basis.find('wood') >= 0 and basis.find('z') >= 0:
return (-s-t,-s)
elif basis.find('wood') >= 0 or basis.find('wall') >= 0 or \
Expand Down
10 changes: 5 additions & 5 deletions src/sage/algebras/steenrod/steenrod_algebra_mult.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@
# Milnor, p=2


def milnor_multiplication(r,s):
def milnor_multiplication(r, s):
r"""
Product of Milnor basis elements r and s at the prime 2.
Expand Down Expand Up @@ -372,7 +372,7 @@ def multinomial(list):
# Milnor, p odd


def milnor_multiplication_odd(m1,m2,p):
def milnor_multiplication_odd(m1, m2, p):
r"""
Product of Milnor basis elements defined by m1 and m2 at the odd prime p.
Expand Down Expand Up @@ -568,7 +568,7 @@ def milnor_multiplication_odd(m1,m2,p):
return result


def multinomial_odd(list,p):
def multinomial_odd(list, p):
r"""
Multinomial coefficient of list, mod p.
Expand Down Expand Up @@ -635,7 +635,7 @@ def multinomial_odd(list,p):
# Adem relations, Serre-Cartan basis, admissible sequences


def binomial_mod2(n,k):
def binomial_mod2(n, k):
r"""
The binomial coefficient `\binom{n}{k}`, computed mod 2.
Expand Down Expand Up @@ -665,7 +665,7 @@ def binomial_mod2(n,k):
return 0


def binomial_modp(n,k,p):
def binomial_modp(n, k, p):
r"""
The binomial coefficient `\binom{n}{k}`, computed mod `p`.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/arith/misc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4171,7 +4171,7 @@ def multinomial_coefficients(m, n):
return r


def kronecker_symbol(x,y):
def kronecker_symbol(x, y):
"""
The Kronecker symbol `(x|y)`.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/arith/multi_modular.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -196,11 +196,11 @@ cdef class MultiModularBasis_base():
while True:
if len(known_primes) >= self._num_primes:
raise RuntimeError("there are not enough primes in the interval [%s, %s] to complete this multimodular computation" % (self._l_bound, self._u_bound))
p = random_prime(self._u_bound, lbound =self._l_bound)
p = random_prime(self._u_bound, lbound=self._l_bound)
if p not in known_primes:
return p

def extend_with_primes(self, plist, partial_products = None, check=True):
def extend_with_primes(self, plist, partial_products=None, check=True):
"""
Extend the stored list of moduli with the given primes in ``plist``.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/calculus/integration.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ def monte_carlo_integral(func, xl, xu, size_t calls, algorithm='plain',
(4.0, 0.0)
sage: monte_carlo_integral(lambda u,v: u*v, [0,0], [2,2], 10000) # abs tol 0.1
(4.0, 0.0)
sage: def f(x1,x2,x3,x4): return x1*x2*x3*x4
sage: def f(x1, x2, x3, x4): return x1*x2*x3*x4
sage: monte_carlo_integral(f, [0,0], [2,2], 1000, params=[0.6,2]) # abs tol 0.2
(4.8, 0.0)
Expand All @@ -522,7 +522,7 @@ def monte_carlo_integral(func, xl, xu, size_t calls, algorithm='plain',
ValueError: The function to be integrated depends on 2 variables (x, y),
and so cannot be integrated in 3 dimensions. Please fix additional
variables with the 'params' argument
sage: def f(x,y): return x*y
sage: def f(x, y): return x*y
sage: monte_carlo_integral(f, [0,0,0], [2,2,2], 100)
Traceback (most recent call last):
...
Expand Down
4 changes: 2 additions & 2 deletions src/sage/calculus/ode.pxd
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cdef class ode_system:
cdef int c_j(self,double , double *, double *,double *) noexcept
cdef int c_j(self, double , double *, double *, double *) noexcept

cdef int c_f(self,double t, double* , double* ) noexcept
cdef int c_f(self, double t, double* , double* ) noexcept
4 changes: 2 additions & 2 deletions src/sage/calculus/ode.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -313,11 +313,11 @@ class ode_solver():
from sage.libs.gsl.all cimport *
cdef class van_der_pol(sage.calculus.ode.ode_system):
cdef int c_f(self,double t, double *y,double *dydt):
cdef int c_f(self, double t, double *y, double *dydt):
dydt[0]=y[1]
dydt[1]=-y[0]-1000*y[1]*(y[0]*y[0]-1)
return GSL_SUCCESS
cdef int c_j(self, double t,double *y,double *dfdy,double *dfdt):
cdef int c_j(self, double t, double *y, double *dfdy, double *dfdt):
dfdy[0]=0
dfdy[1]=1.0
dfdy[2]=-2.0*1000*y[0]*y[1]-1.0
Expand Down
4 changes: 2 additions & 2 deletions src/sage/calculus/riemann.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ ctypedef np.complex128_t COMPLEX_T

cdef FLOAT_T PI = pi
cdef FLOAT_T TWOPI = 2*PI
cdef COMPLEX_T I = complex(0,1)
cdef COMPLEX_T I = complex(0, 1)

cdef class Riemann_Map:
r"""
Expand Down Expand Up @@ -1263,7 +1263,7 @@ cpdef complex_to_spiderweb(np.ndarray[COMPLEX_T, ndim = 2] z_values,
return rgb


cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim = 2] z_values):
cpdef complex_to_rgb(np.ndarray[COMPLEX_T, ndim=2] z_values):
r"""
Convert from a (Numpy) array of complex numbers to its corresponding
matrix of RGB values. For internal use of :meth:`~Riemann_Map.plot_colored`
Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
::
sage: def christoffel(i,j,k,vars,g):
sage: def christoffel(i, j, k, vars, g):
....: s = 0
....: ginv = g^(-1)
....: for l in range(g.nrows()):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/calculus/transforms/dwt.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -103,11 +103,11 @@ cdef class DiscreteWaveletTransform(GSLDoubleArray):
"""
Discrete wavelet transform class.
"""
def __cinit__(self,size_t n,size_t stride, wavelet_type, size_t wavelet_k):
def __cinit__(self, size_t n, size_t stride, wavelet_type, size_t wavelet_k):
self.wavelet = NULL
self.workspace = NULL

def __init__(self,size_t n,size_t stride, wavelet_type, size_t wavelet_k):
def __init__(self, size_t n, size_t stride, wavelet_type, size_t wavelet_k):
if not is2pow(n):
raise NotImplementedError("discrete wavelet transform only implemented when n is a 2-power")
GSLDoubleArray.__init__(self,n,stride)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/calculus/var.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ def function(s, **kwds):
sage: foo(x).conjugate()
2*x
sage: def deriv(self, *args,**kwds): print("{} {}".format(args, kwds)); return args[kwds['diff_param']]^2
sage: def deriv(self, *args, **kwds): print("{} {}".format(args, kwds)); return args[kwds['diff_param']]^2
sage: foo = function("foo", nargs=2, derivative_func=deriv)
sage: foo(x,y).derivative(y)
(x, y) {'diff_param': 1}
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ class Category(UniqueRepresentation, SageObject):
....: pass
....:
....: class ElementMethods:# holds the generic operations on elements
....: def gcd(x,y):
....: def gcd(x, y):
....: # Euclid algorithms
....: pass
....:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/category_with_axiom.py
Original file line number Diff line number Diff line change
Expand Up @@ -1695,7 +1695,7 @@ class ``Sets.Finite``), or in a separate file (typically in a class
)


def uncamelcase(s,separator=" "):
def uncamelcase(s, separator=" "):
"""
EXAMPLES::
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/classical_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -328,11 +328,11 @@ def __iter__(self):
sage: fb4 = lambda a,b,c,d: crystals.Tableaux(['B',4],shape=[a+b+c+d,b+c+d,c+d,d])
sage: fd4 = lambda a,b,c,d: crystals.Tableaux(['D',4],shape=[a+b+c+d,b+c+d,c+d,d])
sage: fd5 = lambda a,b,c,d,e: crystals.Tableaux(['D',5],shape=[a+b+c+d+e,b+c+d+e,c+d+e,d+e,e])
sage: def fd4spinplus(a,b,c,d):
sage: def fd4spinplus(a, b, c, d):
....: C = crystals.Tableaux(['D',4],shape=[a+b+c+d,b+c+d,c+d,d])
....: D = crystals.SpinsPlus(['D',4])
....: return crystals.TensorProduct(C,D,generators=[[C[0],D[0]]])
sage: def fb3spin(a,b,c):
sage: def fb3spin(a, b, c):
....: C = crystals.Tableaux(['B',3],shape=[a+b+c,b+c,c])
....: D = crystals.Spins(['B',3])
....: return crystals.TensorProduct(C,D,generators=[[C[0],D[0]]])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -1177,7 +1177,7 @@ def plot(self, **options):
sage: print(C.plot())
Graphics object consisting of 17 graphics primitives
"""
return self.digraph().plot(edge_labels=True,vertex_size=0,**options)
return self.digraph().plot(edge_labels=True, vertex_size=0, **options)

def plot3d(self, **options):
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/discrete_valuation.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ def is_unit(self):
"""
return self.valuation() == 0

def gcd(self,other):
def gcd(self, other):
"""
Return the greatest common divisor of ``self`` and ``other``,
normalized so that it is a power of the distinguished
Expand All @@ -209,7 +209,7 @@ def gcd(self,other):
else:
return self.parent().uniformizer() ** val

def lcm(self,other):
def lcm(self, other):
"""
Return the least common multiple of ``self`` and ``other``,
normalized so that it is a power of the distinguished
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

class DistributiveMagmasAndAdditiveMagmas(CategoryWithAxiom):
"""
The category of sets `(S,+,*)` with `*` distributing on `+`.
The category of sets `(S, +, *)` with `*` distributing on `+`.
This is similar to a ring, but `+` and `*` are only required to be
(additive) magmas.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/categories/finite_dimensional_modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ def annihilator_basis(self, S, action=operator.mul, side='right'):
sage: # needs sage.graphs sage.modules
sage: x,y,a,b = F.basis()
sage: def scalar(u,v):
sage: def scalar(u, v):
....: return vector([sum(u[i]*v[i] for i in F.basis().keys())])
sage: F.annihilator_basis([x + y, a + b], scalar)
(x - y, a - b)
Expand Down Expand Up @@ -496,7 +496,7 @@ def twisted_invariant_module(self, G, chi,
sage: # needs sage.combinat sage.groups sage.modules
sage: M = CombinatorialFreeModule(QQ, [1,2,3])
sage: G = SymmetricGroup(3)
sage: def action(g,x): return(M.term(g(x))) # permute coordinates
sage: def action(g, x): return(M.term(g(x))) # permute coordinates
sage: T = M.twisted_invariant_module(G, [2,0,-1],
....: action_on_basis=action)
sage: import __main__; __main__.action = action
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def ngens(self):
"""
return len(self.gens())

def gen(self,i):
def gen(self, i):
r"""
The ``i``-th generator of this Lie conformal algebra.
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/group_algebras.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def coproduct_on_basis(self, g):
g = self.term(g)
return tensor([g, g])

def antipode_on_basis(self,g):
def antipode_on_basis(self, g):
r"""
Return the antipode of the element ``g`` of the basis.
Expand All @@ -263,7 +263,7 @@ def antipode_on_basis(self,g):
"""
return self.term(~g)

def counit_on_basis(self,g):
def counit_on_basis(self, g):
r"""
Return the counit of the element ``g`` of the basis.
Expand All @@ -283,7 +283,7 @@ def counit_on_basis(self,g):
"""
return self.base_ring().one()

def counit(self,x):
def counit(self, x):
r"""
Return the counit of the element ``x`` of the group
algebra.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/magmas_and_additive_magmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

class MagmasAndAdditiveMagmas(Category_singleton):
"""
The category of sets `(S,+,*)` with an additive operation '+' and
The category of sets `(S, +, *)` with an additive operation '+' and
a multiplicative operation `*`
EXAMPLES::
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/modules_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -1395,7 +1395,7 @@ def random_element(self, n=2):
we can find a random element in a trivial module::
sage: class Foo(CombinatorialFreeModule): # needs sage.modules
....: def _element_constructor_(self,x):
....: def _element_constructor_(self, x):
....: if x in self:
....: return x
....: else:
Expand Down Expand Up @@ -2535,7 +2535,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
and `f` the bilinear morphism `(a,b) \mapsto b \otimes a`
from `A \times B` to `B \otimes A`::
sage: def f(a,b):
sage: def f(a, b):
....: return tensor([b,a])
Now, calling applying `f` on `a \otimes b` returns the same
Expand Down Expand Up @@ -2564,7 +2564,7 @@ def apply_multilinear_morphism(self, f, codomain=None):
Mind the `0` in the sums above; otherwise `f` would
not return `0` in `\ZZ`::
sage: def f(a,b):
sage: def f(a, b):
....: return sum(a.coefficients()) * sum(b.coefficients())
sage: type(f(A.zero(), B.zero())) # needs sage.modules
<... 'int'>
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/morphism.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -619,7 +619,7 @@ cdef class SetMorphism(Morphism):
sage: from sage.categories.morphism import SetMorphism
sage: R.<x> = QQ[]
sage: def foo(x,*args,**kwds):
sage: def foo(x, *args, **kwds):
....: print('foo called with {} {}'.format(args, kwds))
....: return x
sage: f = SetMorphism(Hom(R,R,Rings()), foo)
Expand Down
Loading

0 comments on commit 813f2b5

Please sign in to comment.