diff --git a/src/sage/matroids/basis_exchange_matroid.pxd b/src/sage/matroids/basis_exchange_matroid.pxd index 915119ef2b8..06c0c2cabb2 100644 --- a/src/sage/matroids/basis_exchange_matroid.pxd +++ b/src/sage/matroids/basis_exchange_matroid.pxd @@ -46,7 +46,7 @@ cdef class BasisExchangeMatroid(Matroid): cpdef _move_current_basis(self, X, Y) cpdef frozenset _max_independent(self, frozenset F) - cpdef int _rank(self, frozenset F) noexcept + cpdef int _rank(self, frozenset F) except -1 cpdef frozenset _circuit(self, frozenset F) cpdef frozenset _fundamental_circuit(self, frozenset B, e) cpdef frozenset _closure(self, frozenset F) diff --git a/src/sage/matroids/basis_exchange_matroid.pyx b/src/sage/matroids/basis_exchange_matroid.pyx index d6f4899008b..422d9c71d90 100644 --- a/src/sage/matroids/basis_exchange_matroid.pyx +++ b/src/sage/matroids/basis_exchange_matroid.pyx @@ -652,7 +652,7 @@ cdef class BasisExchangeMatroid(Matroid): self.__max_independent(self._output, self._input) return self.__unpack(self._output) - cpdef int _rank(self, frozenset F) noexcept: + cpdef int _rank(self, frozenset F) except -1: """ Compute the rank of a subset of the groundset. diff --git a/src/sage/matroids/circuit_closures_matroid.pxd b/src/sage/matroids/circuit_closures_matroid.pxd index 191f83b2251..2fe5629477c 100644 --- a/src/sage/matroids/circuit_closures_matroid.pxd +++ b/src/sage/matroids/circuit_closures_matroid.pxd @@ -5,7 +5,7 @@ cdef class CircuitClosuresMatroid(Matroid): cdef dict _circuit_closures # _CC cdef int _matroid_rank # _R cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cpdef full_rank(self) cpdef bint _is_independent(self, frozenset F) noexcept cpdef frozenset _max_independent(self, frozenset F) diff --git a/src/sage/matroids/circuit_closures_matroid.pyx b/src/sage/matroids/circuit_closures_matroid.pyx index 41b77628d48..d075792a2f4 100644 --- a/src/sage/matroids/circuit_closures_matroid.pyx +++ b/src/sage/matroids/circuit_closures_matroid.pyx @@ -179,7 +179,7 @@ cdef class CircuitClosuresMatroid(Matroid): """ return frozenset(self._groundset) - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: """ Return the rank of a set ``X``. diff --git a/src/sage/matroids/circuits_matroid.pxd b/src/sage/matroids/circuits_matroid.pxd index 3c1b03439a6..7fa37c8cebe 100644 --- a/src/sage/matroids/circuits_matroid.pxd +++ b/src/sage/matroids/circuits_matroid.pxd @@ -9,7 +9,7 @@ cdef class CircuitsMatroid(Matroid): cdef list _sorted_C_lens cdef bint _nsc_defined cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cpdef full_rank(self) cpdef bint _is_independent(self, frozenset X) noexcept cpdef frozenset _max_independent(self, frozenset X) diff --git a/src/sage/matroids/circuits_matroid.pyx b/src/sage/matroids/circuits_matroid.pyx index 4320076a541..fed8db3dd47 100644 --- a/src/sage/matroids/circuits_matroid.pyx +++ b/src/sage/matroids/circuits_matroid.pyx @@ -100,7 +100,7 @@ cdef class CircuitsMatroid(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: """ Return the rank of a set ``X``. diff --git a/src/sage/matroids/flats_matroid.pxd b/src/sage/matroids/flats_matroid.pxd index 41b7379a28b..926cce035f2 100644 --- a/src/sage/matroids/flats_matroid.pxd +++ b/src/sage/matroids/flats_matroid.pxd @@ -8,7 +8,7 @@ cdef class FlatsMatroid(Matroid): cdef object _L # lattice of flats cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cpdef frozenset _closure(self, frozenset X) cpdef bint _is_closed(self, frozenset X) noexcept diff --git a/src/sage/matroids/flats_matroid.pyx b/src/sage/matroids/flats_matroid.pyx index 35feab0dc61..369ae137b0a 100644 --- a/src/sage/matroids/flats_matroid.pyx +++ b/src/sage/matroids/flats_matroid.pyx @@ -114,7 +114,7 @@ cdef class FlatsMatroid(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: """ Return the rank of a set ``X``. diff --git a/src/sage/matroids/graphic_matroid.pxd b/src/sage/matroids/graphic_matroid.pxd index 01d8bcc597e..32c243267ff 100644 --- a/src/sage/matroids/graphic_matroid.pxd +++ b/src/sage/matroids/graphic_matroid.pxd @@ -7,7 +7,7 @@ cdef class GraphicMatroid(Matroid): cdef dict _vertex_map cdef dict _groundset_edge_map cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cpdef _vertex_stars(self) cpdef _minor(self, contractions, deletions) cpdef _has_minor(self, N, bint certificate=*) diff --git a/src/sage/matroids/graphic_matroid.pyx b/src/sage/matroids/graphic_matroid.pyx index 133328d81e0..b332897abeb 100644 --- a/src/sage/matroids/graphic_matroid.pyx +++ b/src/sage/matroids/graphic_matroid.pyx @@ -238,7 +238,7 @@ cdef class GraphicMatroid(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: """ Return the rank of a set ``X``. diff --git a/src/sage/matroids/matroid.pxd b/src/sage/matroids/matroid.pxd index 8418f04c707..fd38cd0b249 100644 --- a/src/sage/matroids/matroid.pxd +++ b/src/sage/matroids/matroid.pxd @@ -9,7 +9,7 @@ cdef class Matroid(SageObject): # virtual methods cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 # internal methods, assuming verified input cpdef frozenset _max_independent(self, frozenset X) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 7846771c488..30ea73f1326 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -492,7 +492,7 @@ cdef class Matroid(SageObject): """ raise NotImplementedError("subclasses need to implement this") - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: r""" Return the rank of a set ``X``. @@ -513,8 +513,9 @@ cdef class Matroid(SageObject): sage: M = sage.matroids.matroid.Matroid() sage: M._rank(frozenset([0, 1, 2])) - NotImplementedError: subclasses need to implement this + Traceback (most recent call last): ... + NotImplementedError: subclasses need to implement this """ raise NotImplementedError("subclasses need to implement this") @@ -2338,7 +2339,7 @@ cdef class Matroid(SageObject): TESTS:: sage: def r(X): - ....: return -1 + ....: return -2 sage: M = Matroid(groundset=[0,1,2], rank_function=r) sage: M.is_valid() False diff --git a/src/sage/matroids/union_matroid.pxd b/src/sage/matroids/union_matroid.pxd index d92b47ad27a..10d995e28c5 100644 --- a/src/sage/matroids/union_matroid.pxd +++ b/src/sage/matroids/union_matroid.pxd @@ -5,16 +5,16 @@ cdef class MatroidUnion(Matroid): cdef list matroids cdef frozenset _groundset cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cdef class MatroidSum(Matroid): cdef list summands cdef frozenset _groundset cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 cdef class PartitionMatroid(Matroid): cdef dict p cdef frozenset _groundset cpdef frozenset groundset(self) - cpdef int _rank(self, frozenset X) noexcept + cpdef int _rank(self, frozenset X) except -1 diff --git a/src/sage/matroids/union_matroid.pyx b/src/sage/matroids/union_matroid.pyx index c58d86a3cc1..54b57434565 100644 --- a/src/sage/matroids/union_matroid.pyx +++ b/src/sage/matroids/union_matroid.pyx @@ -66,7 +66,7 @@ cdef class MatroidUnion(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: r""" Return the rank of a set ``X``. @@ -195,7 +195,7 @@ cdef class MatroidSum(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: r""" Return the rank of a set ``X``. @@ -290,7 +290,7 @@ cdef class PartitionMatroid(Matroid): """ return self._groundset - cpdef int _rank(self, frozenset X) noexcept: + cpdef int _rank(self, frozenset X) except -1: r""" Return the rank of a set ``X``. diff --git a/src/sage/sets/disjoint_set.pxd b/src/sage/sets/disjoint_set.pxd index 6448df33eba..4d981718568 100644 --- a/src/sage/sets/disjoint_set.pxd +++ b/src/sage/sets/disjoint_set.pxd @@ -19,8 +19,8 @@ cdef class DisjointSet_class(SageObject): cpdef number_of_subsets(self) cdef class DisjointSet_of_integers(DisjointSet_class): - cpdef int find(self, int i) noexcept - cpdef void union(self, int i, int j) noexcept + cpdef int find(self, int i) except -1 + cpdef void union(self, int i, int j) except * cpdef root_to_elements_dict(self) cpdef element_to_root_dict(self) cpdef to_digraph(self) diff --git a/src/sage/sets/disjoint_set.pyx b/src/sage/sets/disjoint_set.pyx index 6e2900ca6ff..02cf77fbdd7 100644 --- a/src/sage/sets/disjoint_set.pyx +++ b/src/sage/sets/disjoint_set.pyx @@ -448,7 +448,7 @@ cdef class DisjointSet_of_integers(DisjointSet_class): for i, parent in enumerate(l): self.union(parent, i) - cpdef int find(self, int i) noexcept: + cpdef int find(self, int i) except -1: r""" Return the representative of the set that ``i`` currently belongs to. @@ -479,8 +479,9 @@ cdef class DisjointSet_of_integers(DisjointSet_class): sage: [e.find(i) for i in range(5)] [0, 1, 1, 1, 1] sage: e.find(2**10) - ValueError: i must be between 0 and 4 (1024 given) + Traceback (most recent call last): ... + ValueError: i must be between 0 and 4 (1024 given) .. NOTE:: @@ -492,7 +493,7 @@ cdef class DisjointSet_of_integers(DisjointSet_class): raise ValueError('i must be between 0 and %s (%s given)' % (card - 1, i)) return OP_find(self._nodes, i) - cpdef void union(self, int i, int j) noexcept: + cpdef void union(self, int i, int j) except *: r""" Combine the set of ``i`` and the set of ``j`` into one. @@ -520,8 +521,9 @@ cdef class DisjointSet_of_integers(DisjointSet_class): sage: d {{0, 1, 2, 4}, {3}} sage: d.union(1, 5) - ValueError: j must be between 0 and 4 (5 given) + Traceback (most recent call last): ... + ValueError: j must be between 0 and 4 (5 given) .. NOTE::