From 0221d153cbe80750305a0216a60c83e009d1d5ca Mon Sep 17 00:00:00 2001 From: Giorgos Mousa Date: Sat, 8 Nov 2025 13:00:10 +0200 Subject: [PATCH] `Matroid._max_independent`: Fix call of `_rank` Bug reported in https://github.com/passagemath/passagemath/issues/1783. --- src/sage/matroids/matroid.pyx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index b2516a81cde..54265ca5452 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -637,12 +637,19 @@ cdef class Matroid(SageObject): True sage: all(M.is_dependent(X.union([y])) for y in M.groundset() if y not in X) True + + TESTS:: + + sage: M = matroids.catalog.R10() + sage: M1M = M.direct_sum(M) + sage: Matroid(M1M, regular=True) # indirect doctest + Regular matroid of rank 10 on 20 elements with 26244 bases """ cdef list res = [] cdef int r = 0 for e in X: res.append(e) - if self._rank(res) > r: + if self._rank(frozenset(res)) > r: r += 1 else: res.pop()