Skip to content

Commit

Permalink
sagemathgh-38132: some care for blank lines (pep E30) in groups/ and …
Browse files Browse the repository at this point in the history
…numerical/

    
fixing pycodestyle warning for blank lines in pyx files in `groups` and
`numerical` folders

### 📝 Checklist

- [x] The title is concise and informative.
- [x] The description explains in detail what this PR is about.
    
URL: sagemath#38132
Reported by: Frédéric Chapoton
Reviewer(s): Matthias Köppe
  • Loading branch information
Release Manager committed Jun 7, 2024
2 parents 5af73d3 + 0484b4d commit 961d06c
Show file tree
Hide file tree
Showing 23 changed files with 52 additions and 51 deletions.
1 change: 0 additions & 1 deletion src/sage/groups/group.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,6 @@ cdef class Group(Parent):
"""
return self.order() == 1


def is_multiplicative(self):
r"""
Return ``True`` if the group operation is given by ``*`` (rather than ``+``).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ cdef int refine_and_return_invariant_trivial(PartitionStack *PS, void *S, int *c
cdef int compare_structures_trivial(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept:
return 0


def test_get_aut_gp_and_can_lab_trivially(int n=6,
list partition=[[0,1,2],[3,4],[5]], canonical_label=True, base=False):
"""
Expand Down Expand Up @@ -171,6 +172,7 @@ def test_get_aut_gp_and_can_lab_trivially(int n=6,
PS_dealloc(part)
deallocate_agcl_output(output)


def test_intersect_parabolic_with_alternating(int n=9, list partition=[[0,1,2],[3,4],[5,6,7,8]]):
"""
A test for nontrivial input group in computing automorphism groups.
Expand Down Expand Up @@ -212,6 +214,7 @@ def test_intersect_parabolic_with_alternating(int n=9, list partition=[[0,1,2],[
SC_dealloc(group)
deallocate_agcl_output(output)


cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degree) noexcept:
cdef list MS1 = <list> S1
cdef list MS2 = <list> S2
Expand All @@ -222,6 +225,7 @@ cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degre
return j
return 0


def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]):
"""
Given a group G generated by the given generators, defines a map from the
Expand Down Expand Up @@ -293,6 +297,7 @@ def coset_rep(list perm=[0,1,2,3,4,5], list gens=[[1,2,3,4,5,0]]):
sig_free(c_perm)
return label


cdef aut_gp_and_can_lab *allocate_agcl_output(int n) noexcept:
r"""
Allocate an instance of the aut_gp_and_can_lab struct of degree n. This can
Expand Down
6 changes: 5 additions & 1 deletion src/sage/groups/perm_gps/partn_ref/data_structures.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,10 @@ cdef OP_string(OrbitPartition *OP):
for i in range(OP.degree):
s += " "
j = OP_find(OP, i)
s += "%d -> %d"%(i, j)
s += "%d -> %d" % (i, j)
return s


def OP_represent(int n, merges, perm):
"""
Demonstration and testing.
Expand Down Expand Up @@ -397,6 +398,7 @@ cdef list PS_singletons(PartitionStack * part):

return l


def PS_represent(partition, splits):
"""
Demonstration and testing.
Expand Down Expand Up @@ -1209,6 +1211,7 @@ cdef bint SC_is_giant(int n, int num_perms, int *perms, float p, bitset_t suppor
sig_free(perm)
return False


def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain, bint test_contains):
"""
Test that the permutation group generated by list perms in L of degree n
Expand Down Expand Up @@ -1612,6 +1615,7 @@ def SC_test_list_perms(list L, int n, int limit, bint gap, bint limit_complain,
SC_dealloc(SCCC)
SC_dealloc(SC_nb)


# Functions

cdef int sort_by_function(PartitionStack *PS, int start, int *degrees) noexcept:
Expand Down
2 changes: 2 additions & 0 deletions src/sage/groups/perm_gps/partn_ref/double_coset.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ cdef int compare_perms(int *gamma_1, int *gamma_2, void *S1, void *S2, int degre
return j
return 0


def coset_eq(list perm1=[0,1,2,3,4,5], list perm2=[1,2,3,4,5,0], list gens=[[1,2,3,4,5,0]]):
"""
Given a group G generated by the given generators, tests whether the given
Expand Down Expand Up @@ -199,6 +200,7 @@ def coset_eq(list perm1=[0,1,2,3,4,5], list perm2=[1,2,3,4,5,0], list gens=[[1,2
sig_free(isomorphism)
return x


cdef dc_work_space *allocate_dc_work_space(int n) noexcept:
r"""
Allocates work space for the double_coset function. It can be
Expand Down
7 changes: 4 additions & 3 deletions src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,7 @@ def search_tree(G_in, partition, lab=True, dig=False, dict_rep=False, certificat
else:
return tuple(return_tuple)


cdef int refine_by_degree(PartitionStack *PS, void *S, int *cells_to_refine_by, int ctrb_len) noexcept:
r"""
Refine the input partition by checking degrees of vertices to the given
Expand Down Expand Up @@ -746,6 +747,7 @@ cdef inline int degree(PartitionStack *PS, CGraph G, int entry, int cell_index,
break
return num_arcs


def all_labeled_graphs(n):
"""
Return all labeled graphs on n vertices {0,1,...,n-1}.
Expand Down Expand Up @@ -948,6 +950,7 @@ def orbit_partition(gamma, list_perm=False):
i[j] = 0
return l


def coarsest_equitable_refinement(CGraph G, list partition, bint directed):
"""
Return the coarsest equitable refinement of ``partition`` for ``G``.
Expand Down Expand Up @@ -1012,6 +1015,7 @@ def coarsest_equitable_refinement(CGraph G, list partition, bint directed):

return eq_part


def get_orbits(list gens, int n):
"""
Compute orbits given a list of generators of a permutation group, in list
Expand Down Expand Up @@ -1054,8 +1058,6 @@ def get_orbits(list gens, int n):
return list(orbit_dict.itervalues())




# Canonical augmentation
from cpython.ref cimport *

Expand Down Expand Up @@ -1386,7 +1388,6 @@ def generate_dense_graphs_edge_addition(int n, bint loops, G=None, depth=None,
return number



# Dense graphs: adding vertices

# This implements an augmentation scheme as follows:
Expand Down
1 change: 1 addition & 0 deletions src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def is_isomorphic(self, other):
sig_free(output)
return output_py


cdef bint all_list_children_are_equivalent(PartitionStack *PS, void *S) noexcept:
return 0

Expand Down
2 changes: 1 addition & 1 deletion src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,6 @@ cdef class MatrixStruct:

PS_dealloc(part)


def automorphism_group(self):
"""
Return a list of generators of the automorphism group, along with its
Expand Down Expand Up @@ -296,6 +295,7 @@ cdef int compare_matrices(int *gamma_1, int *gamma_2, void *S1, void *S2, int de
cdef bint all_matrix_children_are_equivalent(PartitionStack *PS, void *S) noexcept:
return 0


def random_tests(n=10, nrows_max=50, ncols_max=50, nsymbols_max=10, perms_per_matrix=5, density_range=(.1,.9)):
"""
Test to make sure that ``C(gamma(M)) == C(M)`` for random permutations ``gamma``
Expand Down
3 changes: 3 additions & 0 deletions src/sage/groups/perm_gps/partn_ref/refinement_python.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ cdef class PythonPartitionStack:
cell = []
return partition


class PythonObjectWrapper:
"""
Instances of this class wrap a Python object and the refinement functions.
Expand Down Expand Up @@ -368,6 +369,7 @@ class PythonObjectWrapper:
self.rari_fn = rari_fn
self.cs_fn = cs_fn


cdef bint all_children_are_equivalent_python(PartitionStack *PS, void *S) noexcept:
"""
Python conversion of all_children_are_equivalent function.
Expand Down Expand Up @@ -398,6 +400,7 @@ cdef int compare_structures_python(int *gamma_1, int *gamma_2, void *S1, void *S
cdef list gamma_2_py = [gamma_2[i] for i from 0 <= i < degree]
return S1_obj.cs_fn(gamma_1_py, gamma_2_py, S1_obj.obj, S2_obj.obj, degree)


def aut_gp_and_can_lab_python(S, partition, n,
all_children_are_equivalent,
refine_and_return_invariant,
Expand Down
3 changes: 3 additions & 0 deletions src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ def set_stab_py(generators, sett, relab=False):
return stab_gens, relabeling
return stab_gens


cdef aut_gp_and_can_lab *set_stab(StabilizerChain *supergroup, subset *sett, bint relab) noexcept:
r"""
Compute the set stabilizer of ``sett`` within ``supergroup``. (Note that
Expand All @@ -200,6 +201,7 @@ cdef aut_gp_and_can_lab *set_stab(StabilizerChain *supergroup, subset *sett, bin
return NULL
return output


def sets_isom_py(generators, set1, set2):
r"""
Compute whether ``set1`` and ``set2`` are isomorphic under the action of
Expand Down Expand Up @@ -424,6 +426,7 @@ def sets_isom_py(generators, set1, set2):
sig_free(isom)
return output_py


cdef int sets_isom(StabilizerChain *supergroup, subset *set1, subset *set2, int *isom) except -1:
r"""
Underlying C function for testing two sets for isomorphism.
Expand Down
1 change: 0 additions & 1 deletion src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,6 @@ cdef class PartitionRefinement_generic:
"""
return self._is_candidate_initialized and self._known_automorphisms.has_empty_intersection(self._part)


###########################################################################
# These functions are used to produce some latex output:
# it writes the actual node
Expand Down
7 changes: 4 additions & 3 deletions src/sage/groups/perm_gps/permgroup_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ cdef extern from *:
cdef int etuple_index_cmp(const void * a, const void * b) noexcept nogil:
return ((<int *> a)[0] > (<int *> b)[0]) - ((<int *> a)[0] < (<int *> b)[0])


def make_permgroup_element(G, x):
r"""
Return a :class:`PermutationGroupElement` given the permutation group
Expand All @@ -172,6 +173,7 @@ def make_permgroup_element(G, x):
domain = FiniteEnumeratedSet(range(1, len(x)+1))
return make_permgroup_element_v2(G, x, domain)


def make_permgroup_element_v2(G, x, domain):
r"""
Return a :class:`PermutationGroupElement` given the permutation group
Expand Down Expand Up @@ -199,6 +201,7 @@ def make_permgroup_element_v2(G, x, domain):
G._domain_from_gap = {i+1: key for i, key in enumerate(domain)}
return G.element_class(x, G, check=False)


def is_PermutationGroupElement(x):
r"""
Return ``True`` if ``x`` is a :class:`PermutationGroupElement`.
Expand All @@ -212,6 +215,7 @@ def is_PermutationGroupElement(x):
"""
return isinstance(x, PermutationGroupElement)


cdef class PermutationGroupElement(MultiplicativeGroupElement):
r"""
An element of a permutation group.
Expand Down Expand Up @@ -791,7 +795,6 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):

i = j + 1


def __reduce__(self):
r"""
Return a function and its arguments needed to create this
Expand Down Expand Up @@ -1252,7 +1255,6 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
if isinstance(x, Matrix):
return x.with_permuted_rows(self)


def __mul__(left, right):
r"""
TESTS::
Expand Down Expand Up @@ -1696,7 +1698,6 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement):
sig_free(seen)
return 1 - 2*(cycle_len_sum % 2) # == (-1)^cycle_len


def orbit(self, n, bint sorted=True):
r"""
Return the orbit of the integer `n` under this group
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def _inverse(f, R):
g *= f
return g


cdef class SemimonomialTransformation(MultiplicativeGroupElement):
r"""
An element in the semimonomial group over a ring `R`. See
Expand Down
12 changes: 3 additions & 9 deletions src/sage/numerical/backends/cvxopt_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -497,10 +497,10 @@ cdef class CVXOPTBackend(GenericBackend):
from cvxopt import matrix, solvers
h = []

#for the equation bounds
# for the equation bounds
for eq_index in range(self.nrows()):
h.append(self.row_upper_bound[eq_index])
#upper bound is already in G
# upper bound is already in G
if self.row_lower_bound[eq_index] is not None:
h.append(-1 * self.row_lower_bound[eq_index])
for cindex in range(len(self.G_matrix)):
Expand All @@ -509,9 +509,7 @@ cdef class CVXOPTBackend(GenericBackend):
else:
self.G_matrix[cindex].append(0)



#for the upper bounds (if there are any)
# for the upper bounds (if there are any)
for i in range(len(self.col_upper_bound)):
if self.col_upper_bound[i] is not None:
h.append(self.col_upper_bound[i])
Expand Down Expand Up @@ -563,7 +561,6 @@ cdef class CVXOPTBackend(GenericBackend):
raise MIPSolverException("CVXOPT: Terminated early due to numerical difficulties or because the maximum number of iterations was reached.")
return 0


cpdef get_objective_value(self):
"""
Return the value of the objective function.
Expand Down Expand Up @@ -659,7 +656,6 @@ cdef class CVXOPTBackend(GenericBackend):
"""
return len(self.row_upper_bound)


cpdef bint is_maximization(self) noexcept:
"""
Test whether the problem is a maximization
Expand Down Expand Up @@ -702,7 +698,6 @@ cdef class CVXOPTBackend(GenericBackend):
return self.prob_name
self.prob_name = name


cpdef row(self, int i):
"""
Return a row
Expand Down Expand Up @@ -740,7 +735,6 @@ cdef class CVXOPTBackend(GenericBackend):
index += 1
return (idx, coeff)


cpdef row_bounds(self, int index):
"""
Return the bounds of a specific constraint.
Expand Down
3 changes: 0 additions & 3 deletions src/sage/numerical/backends/cvxopt_sdp_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend):
"refinement":1 }
self.answer = {}


cpdef int solve(self) except -1:
"""
Solve the problem.
Expand Down Expand Up @@ -161,7 +160,6 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend):
raise SDPSolverException("CVXOPT: Terminated early due to numerical difficulties or because the maximum number of iterations was reached.")
return 0


cpdef get_objective_value(self):
"""
Return the value of the objective function.
Expand Down Expand Up @@ -358,7 +356,6 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend):
assert(n == self.answer['ss'][i].size[1]) # must be square matrix
return Matrix(n, n, list(self.answer['ss'][i]), sparse=sparse)


cpdef solver_parameter(self, name, value=None):
"""
Return or define a solver parameter
Expand Down
Loading

0 comments on commit 961d06c

Please sign in to comment.