Skip to content

Commit

Permalink
Change SetSystem representation
Browse files Browse the repository at this point in the history
  • Loading branch information
gmou3 committed Apr 29, 2024
1 parent c679e43 commit b257b66
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
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 @@ -1863,7 +1863,7 @@ cdef class BasisExchangeMatroid(Matroid):
sage: M = matroids.catalog.N1()
sage: M._characteristic_setsystem()
Iterator over a system of subsets
SetSystem of 23 sets over 10 elements
sage: len(M._characteristic_setsystem())
23
"""
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/circuits_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ cdef class CircuitsMatroid(Matroid):
sage: from sage.matroids.circuits_matroid import CircuitsMatroid
sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
sage: M.circuits()
Iterator over a system of subsets
SetSystem of 4 sets over 4 elements
sage: list(M.circuits(0))
[]
sage: sorted(M.circuits(3), key=str)
Expand Down Expand Up @@ -605,7 +605,7 @@ cdef class CircuitsMatroid(Matroid):
sage: from sage.matroids.circuits_matroid import CircuitsMatroid
sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
sage: M.nonspanning_circuits()
Iterator over a system of subsets
SetSystem of 0 sets over 4 elements
"""
cdef set NSC = set()
cdef int i
Expand Down
16 changes: 7 additions & 9 deletions src/sage/matroids/set_system.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,8 @@ isomorphism testing.
AUTHORS:
- Rudi Pendavingh, Stefan van Zwam (2013-04-01): initial version
Methods
=======
"""

# ****************************************************************************
# Copyright (C) 2013 Rudi Pendavingh <[email protected]>
# Copyright (C) 2013 Stefan van Zwam <[email protected]>
Expand All @@ -40,7 +38,7 @@ cdef class SetSystem:
sage: M = matroids.catalog.Fano()
sage: M.circuits()
Iterator over a system of subsets
SetSystem of 14 sets over 7 elements
To access the sets in this structure, simply iterate over them. The
simplest way must be::
Expand Down Expand Up @@ -75,7 +73,7 @@ cdef class SetSystem:
sage: from sage.matroids.set_system import SetSystem
sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]])
sage: S
Iterator over a system of subsets
SetSystem of 3 sets over 4 elements
"""
cdef long i
if not isinstance(groundset, tuple):
Expand Down Expand Up @@ -110,7 +108,7 @@ cdef class SetSystem:
sage: from sage.matroids.set_system import SetSystem
sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]])
sage: S
Iterator over a system of subsets
SetSystem of 3 sets over 4 elements
sage: sorted(S[1])
[3, 4]
sage: for s in S: print(sorted(s))
Expand Down Expand Up @@ -138,7 +136,7 @@ cdef class SetSystem:
sage: from sage.matroids.set_system import SetSystem
sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]])
sage: S
Iterator over a system of subsets
SetSystem of 3 sets over 4 elements
sage: len(S)
3
"""
Expand Down Expand Up @@ -196,9 +194,9 @@ cdef class SetSystem:
sage: from sage.matroids.set_system import SetSystem
sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]])
sage: repr(S) # indirect doctest
'Iterator over a system of subsets'
'SetSystem of 3 sets over 4 elements'
"""
return "Iterator over a system of subsets"
return f'SetSystem of {self._len} sets over {self._groundset_size} elements'

cdef copy(self):
cdef SetSystem S
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/union_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ cdef class MatroidUnion(Matroid):
{}
Matroid of rank 1 on 2 elements with 2 bases
sage: M.bases()
Iterator over a system of subsets
SetSystem of 2 sets over 5 elements
sage: list(M.circuits())
[frozenset({3, 4})]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matroids/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def setprint(X):
sage: from sage.matroids.advanced import setprint
sage: M = matroids.catalog.Fano().delete('efg')
sage: M.bases()
Iterator over a system of subsets
SetSystem of 3 sets over 4 elements
sage: setprint(M.bases())
[{'a', 'b', 'c'}, {'a', 'b', 'd'}, {'a', 'c', 'd'}]
Expand Down

0 comments on commit b257b66

Please sign in to comment.