Skip to content

Commit 1917078

Browse files
author
Release Manager
committed
gh-40993: fix one ugly code line in classical_geometries.py and a few minor pep8 changes ### 📝 Checklist - [x] The title is concise and informative. - [x] The description explains in detail what this PR is about. URL: #40993 Reported by: Frédéric Chapoton Reviewer(s): David Coudert
2 parents 797876d + 2ba305b commit 1917078

File tree

1 file changed

+7
-14
lines changed

1 file changed

+7
-14
lines changed

src/sage/graphs/generators/classical_geometries.py

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
88
The methods defined here appear in :mod:`sage.graphs.graph_generators`.
99
"""
10-
1110
# ****************************************************************************
1211
# Copyright (C) 2015 Sagemath project
1312
#
@@ -17,6 +16,7 @@
1716
# (at your option) any later version.
1817
# https://www.gnu.org/licenses/
1918
# ****************************************************************************
19+
from itertools import combinations
2020

2121
from sage.graphs.graph import Graph
2222
from sage.arith.misc import is_prime_power
@@ -190,7 +190,6 @@ def AffineOrthogonalPolarGraph(d, q, sign='+'):
190190
from sage.modules.free_module import VectorSpace
191191
from sage.matrix.constructor import Matrix
192192
from sage.libs.gap.libgap import libgap
193-
from itertools import combinations
194193

195194
M = Matrix(libgap.InvariantQuadraticForm(libgap.GeneralOrthogonalGroup(s, d, q))['matrix'])
196195
F = libgap.GF(q).sage()
@@ -583,7 +582,6 @@ def _polar_graph(m, q, g, intersection_size=None):
583582
Graph on 27 vertices
584583
"""
585584
from sage.libs.gap.libgap import libgap
586-
from itertools import combinations
587585
W = libgap.FullRowSpace(libgap.GF(q), m) # F_q^m
588586
B = libgap.Elements(libgap.Basis(W)) # the standard basis of W
589587
V = libgap.Orbit(g, B[0], libgap.OnLines) # orbit on isotropic points
@@ -709,7 +707,6 @@ def NonisotropicUnitaryPolarGraph(m, q):
709707
if not k:
710708
raise ValueError('q must be a prime power')
711709
from sage.libs.gap.libgap import libgap
712-
from itertools import combinations
713710
F = libgap.GF(q**2) # F_{q^2}
714711
W = libgap.FullRowSpace(F, m) # F_{q^2}^m
715712
B = libgap.Elements(libgap.Basis(W)) # the standard basis of W
@@ -1111,7 +1108,7 @@ def T2starGeneralizedQuadrangleGraph(q, dual=False, hyperoval=None, field=None,
11111108
raise RuntimeError("incorrect hyperoval")
11121109

11131110
L = [[y for y in z if y not in HO]
1114-
for z in [x for x in Theta.blocks() if len(HO.intersection(x)) == 1]]
1111+
for z in Theta.blocks() if len(HO.intersection(z)) == 1]
11151112

11161113
if dual:
11171114
G = IncidenceStructure(L).intersection_graph()
@@ -1203,7 +1200,6 @@ def HaemersGraph(q, hyperoval=None, hyperoval_matching=None, field=None, check_h
12031200
"""
12041201
from sage.modules.free_module_element import free_module_element as vector
12051202
from sage.rings.finite_rings.finite_field_constructor import GF
1206-
from itertools import combinations
12071203

12081204
p, k = is_prime_power(q, get_data=True)
12091205
if not k or p != 2:
@@ -1524,7 +1520,6 @@ def OrthogonalDualPolarGraph(e, d, q):
15241520
from sage.matrix.constructor import Matrix
15251521
from sage.modules.free_module import VectorSpace
15261522
from sage.rings.finite_rings.finite_field_constructor import GF
1527-
import itertools
15281523

15291524
def hashable(v):
15301525
v.set_immutable()
@@ -1595,15 +1590,13 @@ def hashable(v):
15951590
allIsoSubspaces = libgap.Orbit(permutation, isoSPointsInt, libgap.OnSets)
15961591

15971592
# number of projective points in a (d-1)-subspace
1598-
intersection_size = (q**(d-1) - 1) // (q-1)
1593+
intersection_size = (q**(d - 1) - 1) // (q - 1)
15991594

1600-
edges = []
16011595
n = len(allIsoSubspaces)
1602-
for i, j in itertools.combinations(range(n), 2):
1603-
if libgap.Size(libgap.Intersection(allIsoSubspaces[i],
1604-
allIsoSubspaces[j])) \
1605-
== intersection_size:
1606-
edges.append((i, j))
1596+
edges = [(i, j) for i, j in combinations(range(n), 2)
1597+
if libgap.Size(libgap.Intersection(allIsoSubspaces[i],
1598+
allIsoSubspaces[j]))
1599+
== intersection_size]
16071600

16081601
G = Graph(edges, format='list_of_edges')
16091602
G.name("Dual Polar Graph on Orthogonal group (%d, %d, %d)" % (e, m, q))

0 commit comments

Comments
 (0)