Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trac #33744: Compute bases/circuits in MatroidUnion
It appears there is a bug computing the bases and circuits of a `MatroidUnion`. {{{ sage: k, h, n = 4, 3, 5 sage: M1 = matroids.Uniform(k-1, h) sage: M2 = Matroid(bases = [frozenset({3}),frozenset({4})]) sage: M = M1.union(M2); M Matroid of rank 4 on 5 elements as matroid union of Matroid of rank 3 on 3 elements with circuit-closures {} Matroid of rank 1 on 2 elements with 2 bases sage: M.bases() sage: M.bases() ------------------------------------------------------------------------ --- TypeError Traceback (most recent call last) <ipython-input-48-a32efdfad611> in <module> ----> 1 M.bases() ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/matroid.pyx in sage.matroids.matroid.Matroid.bases (build/cythonized/sage/matroids/matroid.c:21764)() 2615 return res 2616 -> 2617 cpdef bases(self): 2618 r""" 2619 Return the list of bases of the matroid. ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/matroid.pyx in sage.matroids.matroid.Matroid.bases (build/cythonized/sage/matroids/matroid.c:21661)() 2643 res = SetSystem(list(self.groundset())) 2644 for X in combinations(self.groundset(), self.full_rank()): -> 2645 if self._rank(X) == len(X): 2646 res.append(X) 2647 return res ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/union_matroid.pyx in sage.matroids.union_matroid.MatroidUnion._rank (build/cythonized/sage/matroids/union_matroid.c:3080)() 90 summands = [] 91 for e in self.matroids: ---> 92 summands.append(e.delete(e.groundset()-X)) 93 sum_matroid = MatroidSum(summands) 94 d = {} TypeError: unsupported operand type(s) for -: 'frozenset' and 'tuple' sage: M.circuits() ------------------------------------------------------------------------ --- TypeError Traceback (most recent call last) <ipython-input-47-8adfde621a57> in <module> ----> 1 M.circuits() ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/matroid.pyx in sage.matroids.matroid.Matroid.circuits (build/cythonized/sage/matroids/matroid.c:19192)() 2370 # enumeration 2371 -> 2372 cpdef circuits(self): 2373 """ 2374 Return the list of circuits of the matroid. ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/matroid.pyx in sage.matroids.matroid.Matroid.circuits (build/cythonized/sage/matroids/matroid.c:18928)() 2393 """ 2394 C = set() -> 2395 for B in self.bases(): 2396 C.update([self._circuit(B.union(set([e]))) 2397 for e in self.groundset().difference(B)]) ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/matroid.pyx in sage.matroids.matroid.Matroid.bases (build/cythonized/sage/matroids/matroid.c:21661)() 2643 res = SetSystem(list(self.groundset())) 2644 for X in combinations(self.groundset(), self.full_rank()): -> 2645 if self._rank(X) == len(X): 2646 res.append(X) 2647 return res ~/Applications/sage/local/var/lib/sage/venv-python3.9/lib/python3.9 /site-packages/sage/matroids/union_matroid.pyx in sage.matroids.union_matroid.MatroidUnion._rank (build/cythonized/sage/matroids/union_matroid.c:3080)() 90 summands = [] 91 for e in self.matroids: ---> 92 summands.append(e.delete(e.groundset()-X)) 93 sum_matroid = MatroidSum(summands) 94 d = {} TypeError: unsupported operand type(s) for -: 'frozenset' and 'tuple' }}} URL: https://trac.sagemath.org/33744 Reported by: tkarn Ticket author(s): Trevor K. Karn Reviewer(s): Travis Scrimshaw
- Loading branch information