Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use except? for _rank #2

Merged
merged 3 commits into from
Aug 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/sage/matroids/basis_exchange_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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) except -1
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)
Expand Down
2 changes: 1 addition & 1 deletion 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) except -1:
cpdef int _rank(self, frozenset F) except? -1:
"""
Compute the rank of a subset of the groundset.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/circuit_closures_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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) except -1
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)
Expand Down
2 changes: 1 addition & 1 deletion 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) except -1:
cpdef int _rank(self, frozenset X) except? -1:
"""
Return the rank of a set ``X``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/circuits_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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) except -1
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)
Expand Down
2 changes: 1 addition & 1 deletion 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) except -1:
cpdef int _rank(self, frozenset X) except? -1:
"""
Return the rank of a set ``X``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/flats_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cdef class FlatsMatroid(Matroid):
cdef object _L # lattice of flats
cpdef frozenset groundset(self)

cpdef int _rank(self, frozenset X) except -1
cpdef int _rank(self, frozenset X) except? -1
cpdef frozenset _closure(self, frozenset X)
cpdef bint _is_closed(self, frozenset X) noexcept

Expand Down
2 changes: 1 addition & 1 deletion 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) except -1:
cpdef int _rank(self, frozenset X) except? -1:
"""
Return the rank of a set ``X``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/graphic_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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) except -1
cpdef int _rank(self, frozenset X) except? -1
cpdef _vertex_stars(self)
cpdef _minor(self, contractions, deletions)
cpdef _has_minor(self, N, bint certificate=*)
Expand Down
2 changes: 1 addition & 1 deletion 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) except -1:
cpdef int _rank(self, frozenset X) except? -1:
"""
Return the rank of a set ``X``.

Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cdef class Matroid(SageObject):

# virtual methods
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X) except -1
cpdef int _rank(self, frozenset X) except? -1

# internal methods, assuming verified input
cpdef frozenset _max_independent(self, frozenset X)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -492,7 +492,7 @@ cdef class Matroid(SageObject):
"""
raise NotImplementedError("subclasses need to implement this")

cpdef int _rank(self, frozenset X) except -1:
cpdef int _rank(self, frozenset X) except? -1:
r"""
Return the rank of a set ``X``.

Expand Down Expand Up @@ -2339,7 +2339,7 @@ cdef class Matroid(SageObject):
TESTS::

sage: def r(X):
....: return -2
....: return -1
sage: M = Matroid(groundset=[0,1,2], rank_function=r)
sage: M.is_valid()
False
Expand Down
6 changes: 3 additions & 3 deletions src/sage/matroids/union_matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@ cdef class MatroidUnion(Matroid):
cdef list matroids
cdef frozenset _groundset
cpdef frozenset groundset(self)
cpdef int _rank(self, frozenset X) except -1
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) except -1
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) except -1
cpdef int _rank(self, frozenset X) except? -1
6 changes: 3 additions & 3 deletions src/sage/matroids/union_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ cdef class MatroidUnion(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X) except -1:
cpdef int _rank(self, frozenset X) except? -1:
r"""
Return the rank of a set ``X``.

Expand Down Expand Up @@ -195,7 +195,7 @@ cdef class MatroidSum(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X) except -1:
cpdef int _rank(self, frozenset X) except? -1:
r"""
Return the rank of a set ``X``.

Expand Down Expand Up @@ -290,7 +290,7 @@ cdef class PartitionMatroid(Matroid):
"""
return self._groundset

cpdef int _rank(self, frozenset X) except -1:
cpdef int _rank(self, frozenset X) except? -1:
r"""
Return the rank of a set ``X``.

Expand Down
Loading