Skip to content

Commit 72e4121

Browse files
committed
Remove noexcept-s and simplify __copy__ and __deepcopy__
1 parent 9cb3208 commit 72e4121

File tree

2 files changed

+18
-29
lines changed

2 files changed

+18
-29
lines changed

src/sage/matroids/flats_matroid.pxd

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,17 @@ cdef class FlatsMatroid(Matroid):
44
cdef frozenset _groundset # _E
55
cdef int _matroid_rank # _R
66
cdef dict _F # flats
7-
cpdef groundset(self) noexcept
8-
cpdef _rank(self, X) noexcept
9-
cpdef full_rank(self) noexcept
10-
cpdef _is_independent(self, F) noexcept
7+
cpdef groundset(self)
8+
cpdef _rank(self, X)
9+
cpdef full_rank(self)
10+
cpdef _is_independent(self, F)
1111

1212
# enumeration
13-
cpdef flats(self, k) noexcept
14-
cpdef whitney_numbers2(self) noexcept
13+
cpdef flats(self, k)
14+
cpdef whitney_numbers2(self)
1515

1616
# isomorphism
17-
cpdef _is_isomorphic(self, other, certificate=*) noexcept
17+
cpdef _is_isomorphic(self, other, certificate=*)
1818

1919
# verification
20-
cpdef is_valid(self) noexcept
20+
cpdef is_valid(self)

src/sage/matroids/flats_matroid.pyx

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ cdef class FlatsMatroid(Matroid):
8585
self._F[i].add(frozenset(F))
8686
self._matroid_rank = max(self._F, default=-1)
8787

88-
cpdef groundset(self) noexcept:
88+
cpdef groundset(self):
8989
"""
9090
Return the groundset of the matroid.
9191
@@ -102,7 +102,7 @@ cdef class FlatsMatroid(Matroid):
102102
"""
103103
return self._groundset
104104

105-
cpdef _rank(self, X) noexcept:
105+
cpdef _rank(self, X):
106106
"""
107107
Return the rank of a set ``X``.
108108
@@ -138,7 +138,7 @@ cdef class FlatsMatroid(Matroid):
138138

139139
# optional
140140

141-
cpdef full_rank(self) noexcept:
141+
cpdef full_rank(self):
142142
r"""
143143
Return the rank of the matroid.
144144
@@ -156,7 +156,7 @@ cdef class FlatsMatroid(Matroid):
156156
"""
157157
return self._matroid_rank
158158

159-
cpdef _is_isomorphic(self, other, certificate=False) noexcept:
159+
cpdef _is_isomorphic(self, other, certificate=False):
160160
"""
161161
Test if ``self`` is isomorphic to ``other``.
162162
@@ -286,12 +286,7 @@ cdef class FlatsMatroid(Matroid):
286286
sage: M.groundset() is N.groundset()
287287
True
288288
"""
289-
N = FlatsMatroid(groundset=[], flats={})
290-
N._groundset = self._groundset
291-
N._F = self._F
292-
N._matroid_rank = self._matroid_rank
293-
N.rename(self.get_custom_name())
294-
return N
289+
return self
295290

296291
def __deepcopy__(self, memo=None):
297292
"""
@@ -309,15 +304,9 @@ cdef class FlatsMatroid(Matroid):
309304
sage: M == N
310305
True
311306
sage: M.groundset() is N.groundset()
312-
False
307+
True
313308
"""
314-
if memo is None:
315-
memo = {}
316-
from copy import deepcopy
317-
# Since matroids are immutable, N cannot reference itself in correct code, so no need to worry about the recursion.
318-
N = FlatsMatroid(groundset=deepcopy(self._groundset, memo), flats=deepcopy(self._F, memo))
319-
N.rename(deepcopy(self.get_custom_name(), memo))
320-
return N
309+
return self
321310

322311
def __reduce__(self):
323312
"""
@@ -349,7 +338,7 @@ cdef class FlatsMatroid(Matroid):
349338

350339
# enumeration
351340

352-
cpdef flats(self, k) noexcept:
341+
cpdef flats(self, k):
353342
r"""
354343
Return the flats of the matroid of specified rank.
355344
@@ -394,7 +383,7 @@ cdef class FlatsMatroid(Matroid):
394383
for F in self._F[k]:
395384
yield F
396385

397-
cpdef whitney_numbers2(self) noexcept:
386+
cpdef whitney_numbers2(self):
398387
r"""
399388
Return the Whitney numbers of the second kind of the matroid.
400389
@@ -425,7 +414,7 @@ cdef class FlatsMatroid(Matroid):
425414

426415
# verification
427416

428-
cpdef is_valid(self) noexcept:
417+
cpdef is_valid(self):
429418
r"""
430419
Test if ``self`` obeys the matroid axioms.
431420

0 commit comments

Comments
 (0)