From 0484b4d6fbb14543a3c9faf907e8b6240804a2a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20Chapoton?= Date: Sun, 2 Jun 2024 11:18:20 +0200 Subject: [PATCH] some care for blank lines (pep E30) in groups/ and numerical/ --- src/sage/groups/group.pyx | 1 - .../automorphism_group_canonical_label.pyx | 5 +++++ .../perm_gps/partn_ref/data_structures.pyx | 6 +++++- .../groups/perm_gps/partn_ref/double_coset.pyx | 2 ++ .../perm_gps/partn_ref/refinement_graphs.pyx | 7 ++++--- .../perm_gps/partn_ref/refinement_lists.pyx | 1 + .../perm_gps/partn_ref/refinement_matrices.pyx | 2 +- .../perm_gps/partn_ref/refinement_python.pyx | 3 +++ .../perm_gps/partn_ref/refinement_sets.pyx | 3 +++ .../perm_gps/partn_ref2/refinement_generic.pyx | 1 - src/sage/groups/perm_gps/permgroup_element.pyx | 7 ++++--- .../semimonomial_transformation.pyx | 1 + src/sage/numerical/backends/cvxopt_backend.pyx | 12 +++--------- .../numerical/backends/cvxopt_sdp_backend.pyx | 3 --- src/sage/numerical/backends/generic_backend.pyx | 5 ++--- .../numerical/backends/generic_sdp_backend.pyx | 4 +--- src/sage/numerical/backends/glpk_backend.pyx | 2 -- .../backends/interactivelp_backend.pyx | 1 - .../numerical/backends/matrix_sdp_backend.pyx | 6 +----- src/sage/numerical/backends/ppl_backend.pyx | 1 - src/sage/numerical/gauss_legendre.pyx | 17 +++++++++++------ src/sage/numerical/linear_functions.pyx | 5 +++-- src/sage/numerical/sdp.pyx | 8 ++------ 23 files changed, 52 insertions(+), 51 deletions(-) diff --git a/src/sage/groups/group.pyx b/src/sage/groups/group.pyx index 3f1fb92e756..0a62fa0f12e 100644 --- a/src/sage/groups/group.pyx +++ b/src/sage/groups/group.pyx @@ -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 ``+``). diff --git a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx index 022a5ed6f69..ef4a9fd42ad 100644 --- a/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx +++ b/src/sage/groups/perm_gps/partn_ref/automorphism_group_canonical_label.pyx @@ -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): """ @@ -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. @@ -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 = S1 cdef list MS2 = S2 @@ -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 @@ -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 diff --git a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx index 6f4d9b2b430..0e92dac7649 100644 --- a/src/sage/groups/perm_gps/partn_ref/data_structures.pyx +++ b/src/sage/groups/perm_gps/partn_ref/data_structures.pyx @@ -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. @@ -397,6 +398,7 @@ cdef list PS_singletons(PartitionStack * part): return l + def PS_represent(partition, splits): """ Demonstration and testing. @@ -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 @@ -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: diff --git a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx index 051e3f78fa4..fe5ae3e495d 100644 --- a/src/sage/groups/perm_gps/partn_ref/double_coset.pyx +++ b/src/sage/groups/perm_gps/partn_ref/double_coset.pyx @@ -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 @@ -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 diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx index 8ef23e81460..34c911c51bf 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx @@ -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 @@ -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}. @@ -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``. @@ -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 @@ -1054,8 +1058,6 @@ def get_orbits(list gens, int n): return list(orbit_dict.itervalues()) - - # Canonical augmentation from cpython.ref cimport * @@ -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: diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx index 00365bcbd3c..1681013060b 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_lists.pyx @@ -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 diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx index 7fa11c28343..ba8605a7284 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_matrices.pyx @@ -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 @@ -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`` diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx index 96e3497fe42..9408c620367 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_python.pyx @@ -333,6 +333,7 @@ cdef class PythonPartitionStack: cell = [] return partition + class PythonObjectWrapper: """ Instances of this class wrap a Python object and the refinement functions. @@ -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. @@ -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, diff --git a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx index 0f951e7e097..6b3344e81db 100644 --- a/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx +++ b/src/sage/groups/perm_gps/partn_ref/refinement_sets.pyx @@ -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 @@ -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 @@ -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. diff --git a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx index ff54ecdb023..668e8d55af5 100644 --- a/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx +++ b/src/sage/groups/perm_gps/partn_ref2/refinement_generic.pyx @@ -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 diff --git a/src/sage/groups/perm_gps/permgroup_element.pyx b/src/sage/groups/perm_gps/permgroup_element.pyx index db3751236bb..fbf3be5f72b 100644 --- a/src/sage/groups/perm_gps/permgroup_element.pyx +++ b/src/sage/groups/perm_gps/permgroup_element.pyx @@ -152,6 +152,7 @@ cdef extern from *: cdef int etuple_index_cmp(const void * a, const void * b) noexcept nogil: return (( a)[0] > ( b)[0]) - (( a)[0] < ( b)[0]) + def make_permgroup_element(G, x): r""" Return a :class:`PermutationGroupElement` given the permutation group @@ -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 @@ -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`. @@ -212,6 +215,7 @@ def is_PermutationGroupElement(x): """ return isinstance(x, PermutationGroupElement) + cdef class PermutationGroupElement(MultiplicativeGroupElement): r""" An element of a permutation group. @@ -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 @@ -1252,7 +1255,6 @@ cdef class PermutationGroupElement(MultiplicativeGroupElement): if is_Matrix(x): return x.with_permuted_rows(self) - def __mul__(left, right): r""" TESTS:: @@ -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 diff --git a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx index b59facdd3ce..013e27fa28a 100644 --- a/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx +++ b/src/sage/groups/semimonomial_transformations/semimonomial_transformation.pyx @@ -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 diff --git a/src/sage/numerical/backends/cvxopt_backend.pyx b/src/sage/numerical/backends/cvxopt_backend.pyx index d134d1736fc..b518a81ca3c 100644 --- a/src/sage/numerical/backends/cvxopt_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_backend.pyx @@ -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)): @@ -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]) @@ -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. @@ -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 @@ -702,7 +698,6 @@ cdef class CVXOPTBackend(GenericBackend): return self.prob_name self.prob_name = name - cpdef row(self, int i): """ Return a row @@ -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. diff --git a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx index 5a5cf2c11a2..badebf89bb3 100644 --- a/src/sage/numerical/backends/cvxopt_sdp_backend.pyx +++ b/src/sage/numerical/backends/cvxopt_sdp_backend.pyx @@ -56,7 +56,6 @@ cdef class CVXOPTSDPBackend(MatrixSDPBackend): "refinement":1 } self.answer = {} - cpdef int solve(self) except -1: """ Solve the problem. @@ -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. @@ -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 diff --git a/src/sage/numerical/backends/generic_backend.pyx b/src/sage/numerical/backends/generic_backend.pyx index 09a45ce6e3b..e4fc274ae61 100644 --- a/src/sage/numerical/backends/generic_backend.pyx +++ b/src/sage/numerical/backends/generic_backend.pyx @@ -809,7 +809,6 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef get_relative_objective_gap(self): r""" Return the relative objective gap of the best known solution. @@ -845,7 +844,6 @@ cdef class GenericBackend: """ raise NotImplementedError() - cpdef get_variable_value(self, int variable): """ Return the value of a variable given by the solver. @@ -1314,7 +1312,6 @@ cdef class GenericBackend: cp = copy(self) self._do_test_problem_data(tester, cp) - def _test_copy_does_not_share_data(self, **options): """ Test whether copy makes an independent copy of the backend. @@ -1587,8 +1584,10 @@ cdef class GenericBackend: tester.assertAlmostEqual(p.get_variable_value(0), 0.666666666667) tester.assertAlmostEqual(p.get_variable_value(1), 0.333333333333) + default_solver = None + def default_mip_solver(solver=None): """ Returns/sets the default MILP solver used by Sage diff --git a/src/sage/numerical/backends/generic_sdp_backend.pyx b/src/sage/numerical/backends/generic_sdp_backend.pyx index 1d84bddbad8..47fd89b9954 100644 --- a/src/sage/numerical/backends/generic_sdp_backend.pyx +++ b/src/sage/numerical/backends/generic_sdp_backend.pyx @@ -198,7 +198,6 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef add_linear_constraint(self, coefficients, name=None): """ Add a linear constraint. @@ -233,7 +232,6 @@ cdef class GenericSDPBackend: """ raise NotImplementedError() - cpdef add_linear_constraints(self, int number, names=None): """ Add constraints. @@ -618,9 +616,9 @@ cdef class GenericSDPBackend: raise NotImplementedError() - default_solver = None + def default_sdp_solver(solver=None): """ Return/set the default SDP solver used by Sage diff --git a/src/sage/numerical/backends/glpk_backend.pyx b/src/sage/numerical/backends/glpk_backend.pyx index 9f2c643f105..f1253f461b6 100644 --- a/src/sage/numerical/backends/glpk_backend.pyx +++ b/src/sage/numerical/backends/glpk_backend.pyx @@ -913,7 +913,6 @@ cdef class GLPKBackend(GenericBackend): sig_free(col_i) sig_free(col_values) - cpdef int solve(self) except -1: """ Solve the problem. @@ -1873,7 +1872,6 @@ cdef class GLPKBackend(GenericBackend): glp_copy_prob(p.lp, self.lp, 1) return p - cpdef solver_parameter(self, name, value=None): """ Return or define a solver parameter diff --git a/src/sage/numerical/backends/interactivelp_backend.pyx b/src/sage/numerical/backends/interactivelp_backend.pyx index 71f72d758b7..77c573d7996 100644 --- a/src/sage/numerical/backends/interactivelp_backend.pyx +++ b/src/sage/numerical/backends/interactivelp_backend.pyx @@ -557,7 +557,6 @@ cdef class InteractiveLPBackend: constraint_types, variable_types, problem_type, ring, objective_constant_term=d) - cpdef add_col(self, indices, coeffs): """ Add a column. diff --git a/src/sage/numerical/backends/matrix_sdp_backend.pyx b/src/sage/numerical/backends/matrix_sdp_backend.pyx index ca3e40204aa..3e923acabbc 100644 --- a/src/sage/numerical/backends/matrix_sdp_backend.pyx +++ b/src/sage/numerical/backends/matrix_sdp_backend.pyx @@ -128,12 +128,11 @@ cdef class MatrixSDPBackend(GenericSDPBackend): row.append( Matrix.zero(self.matrices_dim[i], self.matrices_dim[i]) ) else: row.append(0) - i+=1 + i += 1 self.col_name_var.append(name) self.objective_function.append(obj) return len(self.objective_function) - 1 - cpdef int add_variables(self, int n, names=None) except -1: """ Add ``n`` variables. @@ -316,7 +315,6 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.add_linear_constraint(zip(range(self.ncols()+1),[Matrix.zero(1,1) for i in range(self.ncols()+1)]), name=None if names is None else names[i]) - cpdef int ncols(self) noexcept: """ Return the number of columns/variables. @@ -353,7 +351,6 @@ cdef class MatrixSDPBackend(GenericSDPBackend): """ return len(self.matrices_dim) - cpdef bint is_maximization(self) noexcept: """ Test whether the problem is a maximization @@ -395,7 +392,6 @@ cdef class MatrixSDPBackend(GenericSDPBackend): self.name = name - cpdef row(self, int i): """ Return a row diff --git a/src/sage/numerical/backends/ppl_backend.pyx b/src/sage/numerical/backends/ppl_backend.pyx index 987842f728c..1e53c947c95 100644 --- a/src/sage/numerical/backends/ppl_backend.pyx +++ b/src/sage/numerical/backends/ppl_backend.pyx @@ -955,7 +955,6 @@ cdef class PPLBackend(GenericBackend): """ return (self.col_lower_bound[index], self.col_upper_bound[index]) - cpdef bint is_variable_binary(self, int index) noexcept: """ Test whether the given variable is of binary type. diff --git a/src/sage/numerical/gauss_legendre.pyx b/src/sage/numerical/gauss_legendre.pyx index fceda721c53..57d9050057e 100644 --- a/src/sage/numerical/gauss_legendre.pyx +++ b/src/sage/numerical/gauss_legendre.pyx @@ -38,12 +38,12 @@ AUTHORS: # https://www.gnu.org/licenses/ # **************************************************************************** -#as it turns out, computing the nodes can easily turn out to be more -#expensive than computing the integrals. So it's worth optimizing this. -#making the function into a cython routine helps a little bit. If we really -#want to we can optimize this further, probably to a point where -#we don't have to bother with node computation routines that have a better order -#than this naive approach (which is quadratic) +# as it turns out, computing the nodes can easily turn out to be more +# expensive than computing the integrals. So it's worth optimizing this. +# making the function into a cython routine helps a little bit. If we really +# want to we can optimize this further, probably to a point where +# we don't have to bother with node computation routines that have +# a better order than this naive approach (which is quadratic) from sage.libs.mpfr cimport * import math @@ -51,6 +51,7 @@ from sage.rings.real_mpfr import RealField from sage.misc.cachefunc import cached_function from sage.rings.real_mpfr cimport RealNumber, RealField_class + def nodes_uncached(degree, prec): r""" Compute the integration nodes and weights for the Gauss-Legendre quadrature @@ -160,6 +161,7 @@ def nodes_uncached(degree, prec): mpfr_clear(v) return nodes + @cached_function def nodes(degree, prec): r""" @@ -213,6 +215,7 @@ def nodes(degree, prec): """ return nodes_uncached(degree, prec) + def estimate_error(results, prec, epsilon): r""" Routine to estimate the error in a list of quadrature approximations. @@ -267,6 +270,7 @@ def estimate_error(results, prec, epsilon): e.append(D4.exp()) return max(e) + def integrate_vector_N(f, prec, N=3): r""" Integrate a one-argument vector-valued function numerically using Gauss-Legendre, @@ -315,6 +319,7 @@ def integrate_vector_N(f, prec, N=3): I += nodelist[i][1]*f(nodelist[i][0]) return I + def integrate_vector(f, prec, epsilon=None): r""" Integrate a one-argument vector-valued function numerically using Gauss-Legendre. diff --git a/src/sage/numerical/linear_functions.pyx b/src/sage/numerical/linear_functions.pyx index 9c7e10744f2..3063ba7101d 100644 --- a/src/sage/numerical/linear_functions.pyx +++ b/src/sage/numerical/linear_functions.pyx @@ -164,11 +164,12 @@ def is_LinearConstraint(x): """ return isinstance(x, LinearConstraint) -#***************************************************************************** + +# **************************************************************************** # # Factory functions for the parents to ensure uniqueness # -#***************************************************************************** +# **************************************************************************** @cached_function def LinearFunctionsParent(base_ring): diff --git a/src/sage/numerical/sdp.pyx b/src/sage/numerical/sdp.pyx index 8701ed22150..0d97a4341f7 100644 --- a/src/sage/numerical/sdp.pyx +++ b/src/sage/numerical/sdp.pyx @@ -517,8 +517,6 @@ cdef class SemidefiniteProgram(SageObject): Variables: x_0, x_1 """ - - if not name and self._first_variable_names: name = self._first_variable_names.pop(0) @@ -960,7 +958,6 @@ cdef class SemidefiniteProgram(SageObject): self._backend.solve() return self._backend.get_objective_value() - cpdef dual_variable(self, int i, sparse=False): """ The `i`-th dual variable. @@ -1206,6 +1203,7 @@ class SDPSolverException(RuntimeError): """ pass + cdef class SDPVariable(Element): r""" ``SDPVariable`` is a variable used by the class @@ -1249,7 +1247,6 @@ cdef class SDPVariable(Element): self._p = sdp self._name = name - def __getitem__(self, i): r""" Return the symbolic variable corresponding to the key. @@ -1276,10 +1273,9 @@ cdef class SDPVariable(Element): self._dict[i] = v return v - def _repr_(self): r""" - Returns a representation of self. + Return a representation of ``self``. EXAMPLES::