Skip to content

Commit 067225e

Browse files
author
Release Manager
committed
sagemathgh-39390: `matroids/database_collections.py`: Single quotes Use single quotes consistently. Resolves some failures of `# optional - matroid_database` tests. URL: sagemath#39390 Reported by: gmou3 Reviewer(s):
2 parents bee1303 + dac1370 commit 067225e

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

src/sage/matroids/database_collections.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def AllMatroids(n, r=None, type='all'):
8585
Traceback (most recent call last):
8686
...
8787
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'):
8989
....: M
9090
Traceback (most recent call last):
9191
...
@@ -94,12 +94,12 @@ def AllMatroids(n, r=None, type='all'):
9494
....: M
9595
Traceback (most recent call last):
9696
...
97-
ValueError: The rank needs to be specified for type "unorientable"
97+
ValueError: The rank needs to be specified for type 'unorientable'
9898
sage: for M in matroids.AllMatroids(6, type='nice'):
9999
....: M
100100
Traceback (most recent call last):
101101
...
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()'
103103
attribute for the type to be supported.
104104
105105
REFERENCES:
@@ -130,7 +130,7 @@ def AllMatroids(n, r=None, type='all'):
130130
....: [ None, None, None, None, None, None, None, None, None, None, None, 1, 12],
131131
....: [ None, None, None, None, None, None, None, None, None, None, None, None, 1]
132132
....: ]
133-
sage: for r in range(0, 12 + 1): # long time
133+
sage: for r in range(0, 12 + 1): # long time
134134
....: for n in range(r, 12 + 1):
135135
....: if all[r][n] and all[r][n] < 1000:
136136
....: assert len(list(matroids.AllMatroids(n, r))) == all[r][n]
@@ -143,81 +143,81 @@ def AllMatroids(n, r=None, type='all'):
143143
....: [ None, None, None, 1, 2, 4, 9, 23, 68, 383, 5249, 232928, None],
144144
....: [ None, None, None, None, 1, 3, 11, 49, 617, 185981, None, None, None]
145145
....: ]
146-
sage: for r in range(0, 4 + 1): # long time
146+
sage: for r in range(0, 4 + 1): # long time
147147
....: for n in range(r, 12 + 1):
148148
....: 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'):
151151
....: assert M.is_valid() and M.is_simple()
152152
sage: unorientable = [
153153
....: [1, 3, 18, 201, 9413],
154154
....: [1, 34, 12284, None, None]
155155
....: ]
156-
sage: for r in range(0, 1 + 1): # long time
156+
sage: for r in range(0, 1 + 1): # long time
157157
....: for n in range(0, 4 + 1):
158158
....: 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'):
161161
....: assert M.is_valid()
162162
"""
163163
from sage.matroids.constructor import Matroid
164164
from sage.features.databases import DatabaseMatroids
165165
DatabaseMatroids().require()
166166
import matroid_database
167167

168-
if type != "all" and type != "unorientable":
168+
if type != 'all' and type != 'unorientable':
169169
try:
170-
getattr(Matroid(bases=[[1, 2], [1, 3]]), "is_" + type)
170+
getattr(Matroid(bases=[[1, 2], [1, 3]]), 'is_' + type)
171171
except AttributeError:
172172
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 +
175175
"type to be supported."
176176
)
177177

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)
180180

181181
if r is None:
182-
rng = range(0, n+1)
182+
rng = range(0, n + 1)
183183
else:
184-
rng = range(r, r+1)
184+
rng = range(r, r + 1)
185185

186186
for r in rng:
187-
if (r == 0 or r == n) and type != "unorientable":
187+
if (r == 0 or r == n) and type != 'unorientable':
188188
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':
191191
yield M
192192
else:
193-
f = getattr(M, "is_" + type)
193+
f = getattr(M, 'is_' + type)
194194
if f():
195195
yield M
196196
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'
199199

200-
matroids_bases = getattr(matroid_database, type_db + "_matroids_bases")
200+
matroids_bases = getattr(matroid_database, type_db + '_matroids_bases')
201201
try:
202202
matroids_bases(n, rp).__next__()
203203
except ValueError:
204204
raise ValueError(
205-
"(n=%s, r=%s, type=\"%s\")" % (n, r, type)
205+
"(n=%s, r=%s, type='%s')" % (n, r, type)
206206
+ " is not available in the database"
207207
)
208208

209209
cnt = 0
210210
for B in matroids_bases(n, rp):
211211
M = Matroid(groundset=range(n), bases=B)
212212

213-
if type != "unorientable" and n - r < r:
213+
if type != 'unorientable' and n - r < r:
214214
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':
217217
yield M
218218
cnt += 1
219219
else:
220-
f = getattr(M, "is_" + type)
220+
f = getattr(M, 'is_' + type)
221221
if f():
222222
yield M
223223
cnt += 1

0 commit comments

Comments
 (0)