@@ -85,7 +85,7 @@ def AllMatroids(n, r=None, type='all'):
85
85
Traceback (most recent call last):
86
86
...
87
87
ValueError: (n=10, r=4, type='all') is not available in the database
88
- sage: for M in matroids.AllMatroids(12, 3, " unorientable" ):
88
+ sage: for M in matroids.AllMatroids(12, 3, ' unorientable' ):
89
89
....: M
90
90
Traceback (most recent call last):
91
91
...
@@ -94,12 +94,12 @@ def AllMatroids(n, r=None, type='all'):
94
94
....: M
95
95
Traceback (most recent call last):
96
96
...
97
- ValueError: The rank needs to be specified for type " unorientable"
97
+ ValueError: The rank needs to be specified for type ' unorientable'
98
98
sage: for M in matroids.AllMatroids(6, type='nice'):
99
99
....: M
100
100
Traceback (most recent call last):
101
101
...
102
- AttributeError: The type " nice" is not available. There needs to be an " is_nice()"
102
+ AttributeError: The type ' nice' is not available. There needs to be an ' is_nice()'
103
103
attribute for the type to be supported.
104
104
105
105
REFERENCES:
@@ -130,7 +130,7 @@ def AllMatroids(n, r=None, type='all'):
130
130
....: [ None, None, None, None, None, None, None, None, None, None, None, 1, 12],
131
131
....: [ None, None, None, None, None, None, None, None, None, None, None, None, 1]
132
132
....: ]
133
- sage: for r in range(0, 12 + 1): # long time
133
+ sage: for r in range(0, 12 + 1): # long time
134
134
....: for n in range(r, 12 + 1):
135
135
....: if all[r][n] and all[r][n] < 1000:
136
136
....: assert len(list(matroids.AllMatroids(n, r))) == all[r][n]
@@ -143,81 +143,81 @@ def AllMatroids(n, r=None, type='all'):
143
143
....: [ None, None, None, 1, 2, 4, 9, 23, 68, 383, 5249, 232928, None],
144
144
....: [ None, None, None, None, 1, 3, 11, 49, 617, 185981, None, None, None]
145
145
....: ]
146
- sage: for r in range(0, 4 + 1): # long time
146
+ sage: for r in range(0, 4 + 1): # long time
147
147
....: for n in range(r, 12 + 1):
148
148
....: if simple[r][n] and simple[r][n] < 1000:
149
- ....: assert len(list(matroids.AllMatroids(n, r, " simple" ))) == simple[r][n]
150
- ....: for M in matroids.AllMatroids(n, r, " simple" ):
149
+ ....: assert len(list(matroids.AllMatroids(n, r, ' simple' ))) == simple[r][n]
150
+ ....: for M in matroids.AllMatroids(n, r, ' simple' ):
151
151
....: assert M.is_valid() and M.is_simple()
152
152
sage: unorientable = [
153
153
....: [1, 3, 18, 201, 9413],
154
154
....: [1, 34, 12284, None, None]
155
155
....: ]
156
- sage: for r in range(0, 1 + 1): # long time
156
+ sage: for r in range(0, 1 + 1): # long time
157
157
....: for n in range(0, 4 + 1):
158
158
....: if unorientable[r][n] and unorientable[r][n] < 1000:
159
- ....: assert len(list(matroids.AllMatroids(n+7, r+3, " unorientable" ))) == unorientable[r][n]
160
- ....: for M in matroids.AllMatroids(n+7, r+3, " unorientable" ):
159
+ ....: assert len(list(matroids.AllMatroids(n+7, r+3, ' unorientable' ))) == unorientable[r][n]
160
+ ....: for M in matroids.AllMatroids(n+7, r+3, ' unorientable' ):
161
161
....: assert M.is_valid()
162
162
"""
163
163
from sage .matroids .constructor import Matroid
164
164
from sage .features .databases import DatabaseMatroids
165
165
DatabaseMatroids ().require ()
166
166
import matroid_database
167
167
168
- if type != " all" and type != " unorientable" :
168
+ if type != ' all' and type != ' unorientable' :
169
169
try :
170
- getattr (Matroid (bases = [[1 , 2 ], [1 , 3 ]]), " is_" + type )
170
+ getattr (Matroid (bases = [[1 , 2 ], [1 , 3 ]]), ' is_' + type )
171
171
except AttributeError :
172
172
raise AttributeError (
173
- "The type \" %s \" is not available. " % type +
174
- "There needs to be an \" is_%s()\" attribute for the " % type +
173
+ "The type '%s' is not available. " % type +
174
+ "There needs to be an ' is_%s()' attribute for the " % type +
175
175
"type to be supported."
176
176
)
177
177
178
- if r is None and type == " unorientable" :
179
- raise ValueError ("The rank needs to be specified for type \" %s \" " % type )
178
+ if r is None and type == ' unorientable' :
179
+ raise ValueError ("The rank needs to be specified for type '%s' " % type )
180
180
181
181
if r is None :
182
- rng = range (0 , n + 1 )
182
+ rng = range (0 , n + 1 )
183
183
else :
184
- rng = range (r , r + 1 )
184
+ rng = range (r , r + 1 )
185
185
186
186
for r in rng :
187
- if (r == 0 or r == n ) and type != " unorientable" :
187
+ if (r == 0 or r == n ) and type != ' unorientable' :
188
188
M = Matroid (groundset = range (n ), bases = [range (r )])
189
- M .rename (type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 ) + "_#" + "0" + ": " + repr (M ))
190
- if type == " all" :
189
+ M .rename (type + '_n' + str (n ).zfill (2 ) + '_r' + str (r ).zfill (2 ) + '_#' + '0' + ': ' + repr (M ))
190
+ if type == ' all' :
191
191
yield M
192
192
else :
193
- f = getattr (M , " is_" + type )
193
+ f = getattr (M , ' is_' + type )
194
194
if f ():
195
195
yield M
196
196
else :
197
- rp = min (r , n - r ) if (type != " unorientable" ) else r
198
- type_db = " all" if (type != " unorientable" ) else " unorientable"
197
+ rp = min (r , n - r ) if (type != ' unorientable' ) else r
198
+ type_db = ' all' if (type != ' unorientable' ) else ' unorientable'
199
199
200
- matroids_bases = getattr (matroid_database , type_db + " _matroids_bases" )
200
+ matroids_bases = getattr (matroid_database , type_db + ' _matroids_bases' )
201
201
try :
202
202
matroids_bases (n , rp ).__next__ ()
203
203
except ValueError :
204
204
raise ValueError (
205
- "(n=%s, r=%s, type=\" %s \" )" % (n , r , type )
205
+ "(n=%s, r=%s, type='%s' )" % (n , r , type )
206
206
+ " is not available in the database"
207
207
)
208
208
209
209
cnt = 0
210
210
for B in matroids_bases (n , rp ):
211
211
M = Matroid (groundset = range (n ), bases = B )
212
212
213
- if type != " unorientable" and n - r < r :
213
+ if type != ' unorientable' and n - r < r :
214
214
M = M .dual ()
215
- M .rename (type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 ) + "_#" + str (cnt ) + ": " + repr (M ))
216
- if type == " all" or type == " unorientable" :
215
+ M .rename (type + '_n' + str (n ).zfill (2 ) + '_r' + str (r ).zfill (2 ) + '_#' + str (cnt ) + ': ' + repr (M ))
216
+ if type == ' all' or type == ' unorientable' :
217
217
yield M
218
218
cnt += 1
219
219
else :
220
- f = getattr (M , " is_" + type )
220
+ f = getattr (M , ' is_' + type )
221
221
if f ():
222
222
yield M
223
223
cnt += 1
0 commit comments