Skip to content

Commit

Permalink
Add noexcept in matroids and set for cython 3.0.11 compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
kiwifb committed Aug 12, 2024
1 parent e042294 commit c4d3b66
Show file tree
Hide file tree
Showing 20 changed files with 100 additions and 100 deletions.
8 changes: 4 additions & 4 deletions src/sage/matroids/basis_exchange_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -46,19 +46,19 @@ cdef class BasisExchangeMatroid(Matroid):
cpdef _move_current_basis(self, X, Y)

cpdef frozenset _max_independent(self, frozenset F)
cpdef int _rank(self, frozenset F)
cpdef int _rank(self, frozenset F) noexcept
cpdef frozenset _circuit(self, frozenset F)
cpdef frozenset _fundamental_circuit(self, frozenset B, e)
cpdef frozenset _closure(self, frozenset F)

cpdef frozenset _max_coindependent(self, frozenset F)
cpdef int _corank(self, frozenset F)
cpdef int _corank(self, frozenset F) noexcept
cpdef frozenset _cocircuit(self, frozenset F)
cpdef frozenset _fundamental_cocircuit(self, frozenset B, e)
cpdef frozenset _coclosure(self, frozenset F)

cpdef frozenset _augment(self, frozenset X, frozenset Y)
cpdef bint _is_independent(self, frozenset F)
cpdef bint _is_independent(self, frozenset F) noexcept

cpdef list whitney_numbers2(self)
cdef _whitney_numbers2_rec(self, object f_vec, bitset_t* flats, bitset_t* todo, long elt, long rnk)
Expand Down Expand Up @@ -90,6 +90,6 @@ cdef class BasisExchangeMatroid(Matroid):
cpdef _is_isomorphism(self, other, morphism)
cdef bint __is_isomorphism(self, BasisExchangeMatroid other, morphism) noexcept

cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept

cdef bint nxksrd(bitset_s *b, long n, long k, bint succ) noexcept
8 changes: 4 additions & 4 deletions src/sage/matroids/basis_exchange_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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):
cpdef int _rank(self, frozenset F) noexcept:
"""
Compute the rank of a subset of the groundset.
Expand Down Expand Up @@ -796,7 +796,7 @@ cdef class BasisExchangeMatroid(Matroid):
self.__max_coindependent(self._output, self._input)
return self.__unpack(self._output)

cpdef int _corank(self, frozenset F):
cpdef int _corank(self, frozenset F) noexcept:
"""
Return the corank of a set.
Expand Down Expand Up @@ -940,7 +940,7 @@ cdef class BasisExchangeMatroid(Matroid):
self.__augment(self._output, self._input, self._input2)
return self.__unpack(self._output)

cpdef bint _is_independent(self, frozenset F):
cpdef bint _is_independent(self, frozenset F) noexcept:
"""
Test if input is independent.
Expand Down Expand Up @@ -2231,7 +2231,7 @@ cdef class BasisExchangeMatroid(Matroid):

return self._characteristic_setsystem()._isomorphism(other._characteristic_setsystem(), PS, PO) is not None

cpdef bint is_valid(self):
cpdef bint is_valid(self) noexcept:
r"""
Test if the data obey the matroid axioms.
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/basis_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cdef class BasisMatroid(BasisExchangeMatroid):

cdef reset_current_basis(self)

cpdef bint _is_basis(self, frozenset X)
cpdef bint _is_basis(self, frozenset X) noexcept

cpdef bases_count(self)
cpdef SetSystem bases(self)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/basis_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ cdef class BasisMatroid(BasisExchangeMatroid):

# a function that is very efficient for this class

cpdef bint _is_basis(self, frozenset X):
cpdef bint _is_basis(self, frozenset X) noexcept:
"""
Test if input is a basis.
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/circuit_closures_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ cdef class CircuitClosuresMatroid(Matroid):
cdef dict _circuit_closures # _CC
cdef int _matroid_rank # _R
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) noexcept
cpdef full_rank(self)
cpdef bint _is_independent(self, frozenset F)
cpdef bint _is_independent(self, frozenset F) noexcept
cpdef frozenset _max_independent(self, frozenset F)
cpdef frozenset _circuit(self, frozenset F)
cpdef dict circuit_closures(self)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/circuit_closures_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ cdef class CircuitClosuresMatroid(Matroid):
"""
return frozenset(self._groundset)

cpdef int _rank(self, frozenset X):
cpdef int _rank(self, frozenset X) noexcept:
"""
Return the rank of a set ``X``.
Expand Down Expand Up @@ -221,7 +221,7 @@ cdef class CircuitClosuresMatroid(Matroid):
"""
return self._matroid_rank

cpdef bint _is_independent(self, frozenset F):
cpdef bint _is_independent(self, frozenset F) noexcept:
"""
Test if input is independent.
Expand Down
8 changes: 4 additions & 4 deletions src/sage/matroids/circuits_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ cdef class CircuitsMatroid(Matroid):
cdef list _sorted_C_lens
cdef bint _nsc_defined
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) noexcept
cpdef full_rank(self)
cpdef bint _is_independent(self, frozenset X)
cpdef bint _is_independent(self, frozenset X) noexcept
cpdef frozenset _max_independent(self, frozenset X)
cpdef frozenset _circuit(self, frozenset X)
cpdef frozenset _closure(self, frozenset X)
Expand All @@ -27,11 +27,11 @@ cdef class CircuitsMatroid(Matroid):

# properties
cpdef girth(self)
cpdef bint is_paving(self)
cpdef bint is_paving(self) noexcept

# isomorphism and relabeling
cpdef _is_isomorphic(self, other, certificate=*)
cpdef relabel(self, mapping)

# verification
cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept
8 changes: 4 additions & 4 deletions src/sage/matroids/circuits_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ cdef class CircuitsMatroid(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X):
cpdef int _rank(self, frozenset X) noexcept:
"""
Return the rank of a set ``X``.
Expand Down Expand Up @@ -140,7 +140,7 @@ cdef class CircuitsMatroid(Matroid):
"""
return self._matroid_rank

cpdef bint _is_independent(self, frozenset X):
cpdef bint _is_independent(self, frozenset X) noexcept:
"""
Test if input is independent.
Expand Down Expand Up @@ -850,7 +850,7 @@ cdef class CircuitsMatroid(Matroid):
from sage.rings.infinity import infinity
return min(self._k_C, default=infinity)

cpdef bint is_paving(self):
cpdef bint is_paving(self) noexcept:
"""
Return if ``self`` is paving.
Expand All @@ -869,7 +869,7 @@ cdef class CircuitsMatroid(Matroid):

# verification

cpdef bint is_valid(self):
cpdef bint is_valid(self) noexcept:
r"""
Test if ``self`` obeys the matroid axioms.
Expand Down
6 changes: 3 additions & 3 deletions src/sage/matroids/flats_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ cdef class FlatsMatroid(Matroid):
cdef object _L # lattice of flats
cpdef frozenset groundset(self)

cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) noexcept
cpdef frozenset _closure(self, frozenset X)
cpdef bint _is_closed(self, frozenset X)
cpdef bint _is_closed(self, frozenset X) noexcept

cpdef full_rank(self)

Expand All @@ -24,4 +24,4 @@ cdef class FlatsMatroid(Matroid):
cpdef relabel(self, mapping)

# verification
cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept
6 changes: 3 additions & 3 deletions src/sage/matroids/flats_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ cdef class FlatsMatroid(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X):
cpdef int _rank(self, frozenset X) noexcept:
"""
Return the rank of a set ``X``.
Expand Down Expand Up @@ -191,7 +191,7 @@ cdef class FlatsMatroid(Matroid):
if f >= X:
return f

cpdef bint _is_closed(self, frozenset X):
cpdef bint _is_closed(self, frozenset X) noexcept:
"""
Test if input is a closed set.
Expand Down Expand Up @@ -539,7 +539,7 @@ cdef class FlatsMatroid(Matroid):

# verification

cpdef bint is_valid(self):
cpdef bint is_valid(self) noexcept:
r"""
Test if ``self`` obeys the matroid axioms.
Expand Down
14 changes: 7 additions & 7 deletions src/sage/matroids/graphic_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ cdef class GraphicMatroid(Matroid):
cdef dict _vertex_map
cdef dict _groundset_edge_map
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X)
cpdef int _rank(self, frozenset X) noexcept
cpdef _vertex_stars(self)
cpdef _minor(self, contractions, deletions)
cpdef _has_minor(self, N, bint certificate=*)
cpdef int _corank(self, frozenset X)
cpdef bint _is_circuit(self, frozenset X)
cpdef int _corank(self, frozenset X) noexcept
cpdef bint _is_circuit(self, frozenset X) noexcept
cpdef frozenset _closure(self, frozenset X)
cpdef frozenset _max_independent(self, frozenset X)
cpdef frozenset _max_coindependent(self, frozenset X)
cpdef frozenset _circuit(self, frozenset X)
cpdef frozenset _coclosure(self, frozenset X)
cpdef bint _is_closed(self, frozenset X)
cpdef bint _is_closed(self, frozenset X) noexcept
cpdef _is_isomorphic(self, other, certificate=*)
cpdef _isomorphism(self, other)
cpdef bint is_valid(self)
cpdef bint is_graphic(self)
cpdef bint is_regular(self)
cpdef bint is_valid(self) noexcept
cpdef bint is_graphic(self) noexcept
cpdef bint is_regular(self) noexcept
cpdef graph(self)
cpdef vertex_map(self)
cpdef list groundset_to_edges(self, X)
Expand Down
14 changes: 7 additions & 7 deletions src/sage/matroids/graphic_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ cdef class GraphicMatroid(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X):
cpdef int _rank(self, frozenset X) noexcept:
"""
Return the rank of a set ``X``.
Expand Down Expand Up @@ -625,7 +625,7 @@ cdef class GraphicMatroid(Matroid):
N = N.regular_matroid()
return M._has_minor(N, certificate=certificate)

cpdef int _corank(self, frozenset X):
cpdef int _corank(self, frozenset X) noexcept:
"""
Return the corank of the set `X` in the matroid.
Expand Down Expand Up @@ -653,7 +653,7 @@ cdef class GraphicMatroid(Matroid):
DS_vertices.union(u, v)
return len(X) - (DS_vertices.number_of_subsets() - Integer(1))

cpdef bint _is_circuit(self, frozenset X):
cpdef bint _is_circuit(self, frozenset X) noexcept:
"""
Test if input is a circuit.
Expand Down Expand Up @@ -918,7 +918,7 @@ cdef class GraphicMatroid(Matroid):
g.add_edge(e)
return frozenset(XX)

cpdef bint _is_closed(self, frozenset X):
cpdef bint _is_closed(self, frozenset X) noexcept:
"""
Test if input is a closed set.
Expand Down Expand Up @@ -1093,7 +1093,7 @@ cdef class GraphicMatroid(Matroid):
"""
return self.is_isomorphic(other, certificate=True)[1]

cpdef bint is_valid(self):
cpdef bint is_valid(self) noexcept:
"""
Test if the data obey the matroid axioms.
Expand All @@ -1110,7 +1110,7 @@ cdef class GraphicMatroid(Matroid):
"""
return True

cpdef bint is_graphic(self):
cpdef bint is_graphic(self) noexcept:
r"""
Return if ``self`` is graphic.
Expand All @@ -1124,7 +1124,7 @@ cdef class GraphicMatroid(Matroid):
"""
return True

cpdef bint is_regular(self):
cpdef bint is_regular(self) noexcept:
r"""
Return if ``self`` is regular.
Expand Down
16 changes: 8 additions & 8 deletions src/sage/matroids/linear_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
cpdef _is_3connected_shifting(self, certificate=*)
cpdef _is_4connected_shifting(self, certificate=*)

cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept

cdef class BinaryMatroid(LinearMatroid):
cdef tuple _b_invariant, _b_partition
Expand Down Expand Up @@ -91,8 +91,8 @@ cdef class BinaryMatroid(LinearMatroid):
cpdef _fast_isom_test(self, other)
cpdef relabel(self, mapping)

cpdef bint is_graphic(self)
cpdef bint is_valid(self)
cpdef bint is_graphic(self) noexcept
cpdef bint is_valid(self) noexcept


cdef class TernaryMatroid(LinearMatroid):
Expand Down Expand Up @@ -122,7 +122,7 @@ cdef class TernaryMatroid(LinearMatroid):
cpdef _fast_isom_test(self, other)
cpdef relabel(self, mapping)

cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept

cdef class QuaternaryMatroid(LinearMatroid):
cdef object _x_zero, _x_one
Expand All @@ -149,7 +149,7 @@ cdef class QuaternaryMatroid(LinearMatroid):
cpdef _fast_isom_test(self, other)
cpdef relabel(self, mapping)

cpdef bint is_valid(self)
cpdef bint is_valid(self) noexcept

cdef class RegularMatroid(LinearMatroid):
cdef _bases_count, _r_invariant
Expand All @@ -172,6 +172,6 @@ cdef class RegularMatroid(LinearMatroid):
cpdef has_line_minor(self, k, hyperlines=*, certificate=*)
cpdef _linear_extension_chains(self, F, fundamentals=*)

cpdef bint is_regular(self)
cpdef bint is_graphic(self)
cpdef bint is_valid(self)
cpdef bint is_regular(self) noexcept
cpdef bint is_graphic(self) noexcept
cpdef bint is_valid(self) noexcept
Loading

0 comments on commit c4d3b66

Please sign in to comment.