Skip to content

simplify empty sets #39568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/sage/algebras/orlik_solomon.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ def one_basis(self):

sage: M = matroids.Wheel(3)
sage: OS = M.orlik_solomon_algebra(QQ)
sage: OS.one_basis() == frozenset([])
sage: OS.one_basis() == frozenset()
True
"""
return frozenset({})
Expand Down Expand Up @@ -347,7 +347,7 @@ def subset_image(self, S):
[[(1, 2), (1, 4), (2, 3), (3, 4)],
[(3, 5), (3, 6), (5, 6)]]
sage: OSMG = MG.orlik_solomon_algebra(QQ, ordering=s)
sage: OSMG.subset_image(frozenset([]))
sage: OSMG.subset_image(frozenset())
OS{}
sage: OSMG.subset_image(frozenset([(1,2),(3,4),(1,4),(2,3)]))
0
Expand Down Expand Up @@ -375,7 +375,7 @@ def subset_image(self, S):
[0, 3, 5], [1, 2, 4], [1, 2, 5], [1, 3, 4],
[1, 3, 5], [2, 3], [4, 5]]
sage: OSMG = MG.orlik_solomon_algebra(QQ)
sage: OSMG.subset_image(frozenset([]))
sage: OSMG.subset_image(frozenset())
OS{}
sage: OSMG.subset_image(frozenset([1, 2, 3]))
0
Expand All @@ -394,7 +394,7 @@ def subset_image(self, S):
sage: sorted([sorted(c) for c in MG.circuits()])
[[0, 1], [2, 3, 4]]
sage: OSMG = MG.orlik_solomon_algebra(QQ)
sage: OSMG.subset_image(frozenset([]))
sage: OSMG.subset_image(frozenset())
OS{}
sage: OSMG.subset_image(frozenset([1, 3, 4]))
-OS{0, 2, 3} + OS{0, 2, 4}
Expand Down
8 changes: 4 additions & 4 deletions src/sage/algebras/orlik_terao.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ def one_basis(self):

sage: M = matroids.Wheel(3)
sage: OT = M.orlik_terao_algebra(QQ)
sage: OT.one_basis() == frozenset([])
sage: OT.one_basis() == frozenset()
True
"""
return frozenset({})
Expand Down Expand Up @@ -391,7 +391,7 @@ def subset_image(self, S):
[[(1, 2), (1, 4), (2, 3), (3, 4)],
[(3, 5), (3, 6), (5, 6)]]
sage: OT = M.orlik_terao_algebra(QQ, ordering=s)
sage: OT.subset_image(frozenset([]))
sage: OT.subset_image(frozenset())
OT{}
sage: OT.subset_image(frozenset([(1,2),(3,4),(1,4),(2,3)]))
0
Expand Down Expand Up @@ -419,7 +419,7 @@ def subset_image(self, S):
[0, 3, 5], [1, 2, 4], [1, 2, 5], [1, 3, 4],
[1, 3, 5], [2, 3], [4, 5]]
sage: OT = M.orlik_terao_algebra()
sage: OT.subset_image(frozenset([]))
sage: OT.subset_image(frozenset())
OT{}
sage: OT.subset_image(frozenset([1, 2, 3]))
0
Expand All @@ -438,7 +438,7 @@ def subset_image(self, S):
sage: sorted([sorted(c) for c in M.circuits()])
[[0, 1], [2, 3, 4]]
sage: OT = M.orlik_terao_algebra(QQ)
sage: OT.subset_image(frozenset([]))
sage: OT.subset_image(frozenset())
OT{}
sage: OT.subset_image(frozenset([1, 3, 4]))
-OT{0, 2, 3} + OT{0, 2, 4}
Expand Down
5 changes: 2 additions & 3 deletions src/sage/calculus/desolvers.py
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ def desolve_system(des, vars, ics=None, ivar=None, algorithm='maxima'):

if len(des) == 1 and algorithm == "maxima":
return desolve_laplace(des[0], vars[0], ics=ics, ivar=ivar)
ivars = set([])
ivars = set()
for i, de in enumerate(des):
if not (isinstance(de, Expression) and de.is_relational()):
des[i] = de == 0
Expand Down Expand Up @@ -1440,11 +1440,10 @@ def desolve_system_rk4(des, vars, ics=None, ivar=None, end_points=None, step=0.1

- Robert Marik (10-2009)
"""

if ics is None:
raise ValueError("No initial conditions, specify with ics=[x0,y01,y02,...].")

ivars = set([])
ivars = set()

for de in des:
ivars = ivars.union(set(de.variables()))
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/root_system/pieri_factors.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ class PieriFactors_type_A_affine(PieriFactors_affine_type):

@staticmethod
def __classcall__(cls, W, min_length=0, max_length=infinity,
min_support=frozenset([]), max_support=None):
min_support=frozenset(), max_support=None):
r"""
TESTS::

Expand Down
2 changes: 1 addition & 1 deletion src/sage/doctest/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -606,7 +606,7 @@ def make_recording_dict(D, st, gt):
EXAMPLES::

sage: from sage.doctest.util import make_recording_dict
sage: D = make_recording_dict({'a':4,'d':42},set([]),set(['not_here']))
sage: D = make_recording_dict({'a':4,'d':42},set(),set(['not_here']))
sage: sorted(D.items())
[('a', 4), ('d', 42)]
sage: D.got
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -636,7 +636,7 @@ def result():
(len(cones), len(generating_cones)))
elif discard_faces:
cones = _discard_faces(cones)
ray_set = set([])
ray_set = set()
for cone in cones:
ray_set.update(cone.rays())
if rays: # Preserve the initial order of rays, if they were given
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hasse_diagram.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def default_face_constructor(atoms, coatoms, **kwds):
atoms = atoms.intersection(coatom_to_atoms[coatom])
H[atom] = (atoms, coatoms)
# 8: compute the set G of minimal sets in H
minimals = set([])
minimals = set()
while candidates:
candidate = candidates.pop()
atoms = H[candidate][0]
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperplane_arrangement/arrangement.py
Original file line number Diff line number Diff line change
Expand Up @@ -2199,7 +2199,7 @@ def poset_of_regions(self, B=None, numbered_labels=True):
while R:
# Transfer the "next step" to the "current step"
curTest = list(nextTest)
nextTest = set([])
nextTest = set()
# we want to test each region that we haven't hit yet
for r in R:
# Since it's graded, it suffices to look at the regions of the previous rank
Expand Down
5 changes: 2 additions & 3 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -3947,11 +3947,10 @@ def skeleton_points(self, k=1):
"""
if k >= self.dim():
return list(range(self.npoints()))
skeleton = set([])
skeleton = set()
for face in self.faces(dim=k):
skeleton.update(face.ambient_point_indices())
skeleton = sorted(skeleton)
return skeleton
return sorted(skeleton)

def skeleton_show(self, normal=None):
r"""Show the graph of one-skeleton of this polytope.
Expand Down
18 changes: 9 additions & 9 deletions src/sage/geometry/polyhedral_complex.py
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ def cells(self, subcomplex=None) -> dict:
for k in range(self._dim, -1, -1):
if k in maximal_cells:
if k not in cells:
cells[k] = set([])
cells[k] = set()
cells[k].update(maximal_cells[k])
if k in cells:
for cell in cells[k]:
Expand All @@ -382,7 +382,7 @@ def cells(self, subcomplex=None) -> dict:
covers[p] = []
covers[p].append(cell)
if (k-1) not in cells:
cells[k-1] = set([])
cells[k-1] = set()
cells[k-1].add(p)
self._face_poset = Poset(covers)
self._cells = cells
Expand Down Expand Up @@ -1055,7 +1055,7 @@ def is_subcomplex(self, other) -> bool:
"""
other_cells = other.cells()
for (d, stratum) in self.maximal_cells().items():
if not stratum.issubset(other_cells.get(d, set([]))):
if not stratum.issubset(other_cells.get(d, set())):
return False
return True

Expand Down Expand Up @@ -1594,9 +1594,9 @@ def is_convex(self) -> bool:
# After making sure that the affine hulls of the cells are the same,
# it does not matter that is not full dimensional.
boundaries = self.relative_boundary_cells()
vertices = set([])
rays = set([])
lines = set([])
vertices = set()
rays = set()
lines = set()
for cell in boundaries:
# it suffices to consider only vertices on the boundaries
# Note that a line (as polyhedron) has vertex too
Expand Down Expand Up @@ -2055,7 +2055,7 @@ def add_cell(self, cell):
for facet in c.facets():
p = facet.as_polyhedron()
if d not in cells:
cells[d] = set([])
cells[d] = set()
if p not in cells[d]:
cells[d].add(p)
covers[p] = [c]
Expand Down Expand Up @@ -2358,7 +2358,7 @@ def subdivide(self, make_simplicial=False,
if new_rays:
raise ValueError("rays/lines cannot be used for subdivision")
# bounded version of `fan.subdivide`; not require rational.
vertices = set([])
vertices = set()
if make_simplicial and not self.is_simplicial_complex():
for p in self.maximal_cell_iterator():
for v in p.vertices_list():
Expand Down Expand Up @@ -2390,7 +2390,7 @@ def subdivide(self, make_simplicial=False,
raise ValueError("new vertices cannot be used for subdivision")
# mimic :meth:`~sage.geometry.fan <RationalPolyhedralFan>.subdivide`
# but here we allow for non-pointed cones, and we subdivide them.
rays_normalized = set([])
rays_normalized = set()
self_rays = []
cones = []
for p in self.maximal_cell_iterator():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,7 @@ def YDeltaTrans(G, v):
# for as long as we generate new graphs.
P = PetersenGraph()

l = set([])
l = set()
l_new = [P.canonical_label().graph6_string()]

while l_new:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/generators/smallgraphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5642,7 +5642,7 @@ def pi_vec(x):
# Associate a matrix to every entry of W
int_to_matrix = {0: matrix.zero(45)}
for i in range(15):
vec = [frozenset([]), L[0, 0], L[1, 0], L[2, 0], L[3, 0]]
vec = [frozenset(), L[0, 0], L[1, 0], L[2, 0], L[3, 0]]
vec = f_pow(pi_vec, i % 3, vec)
vec = f_pow(sigma2, i % 5, vec)
int_to_matrix[i + 1] = N(vec)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_modn_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ cdef class Matrix_modn_sparse(Matrix_sparse):
cdef c_vector_modint* v

# Build a table that gives the nonzero positions in each column of right
nonzero_positions_in_columns = [set([]) for _ in range(right._ncols)]
nonzero_positions_in_columns = [set() for _ in range(right._ncols)]
cdef Py_ssize_t i, j, k
for i from 0 <= i < right._nrows:
v = &(right.rows[i])
Expand Down
2 changes: 1 addition & 1 deletion src/sage/matrix/matrix_rational_sparse.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ cdef class Matrix_rational_sparse(Matrix_sparse):
cdef mpq_vector* v

# Build a table that gives the nonzero positions in each column of right
nonzero_positions_in_columns = [set([]) for _ in range(right._ncols)]
nonzero_positions_in_columns = [set() for _ in range(right._ncols)]
cdef Py_ssize_t i, j, k
for i in range(right._nrows):
v = &(right._matrix[i])
Expand Down
4 changes: 2 additions & 2 deletions src/sage/matroids/dual_matroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ def _minor(self, contractions=None, deletions=None):
EXAMPLES::

sage: M = matroids.catalog.Vamos().dual()
sage: N = M._minor(contractions=set(['a']), deletions=set([]))
sage: N._minor(contractions=set([]), deletions=set(['b', 'c']))
sage: N = M._minor(contractions=set(['a']), deletions=set())
sage: N._minor(contractions=set(), deletions=set(['b', 'c']))
Dual of 'M / {'b', 'c'} \ {'a'}, where M is Vamos:
Matroid of rank 4 on 8 elements with circuit-closures
{3: {{'a', 'b', 'c', 'd'}, {'a', 'b', 'e', 'f'},
Expand Down
18 changes: 9 additions & 9 deletions src/sage/matroids/linear_matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1332,8 +1332,8 @@ cdef class LinearMatroid(BasisExchangeMatroid):
sage: M = Matroid(groundset='abcdefgh', ring=GF(5),
....: reduced_matrix=[[2, 1, 1, 0],
....: [1, 1, 0, 1], [1, 0, 1, 1], [0, 1, 1, 2]])
sage: N = M._minor(contractions=set(['a']), deletions=set([]))
sage: N._minor(contractions=set([]), deletions=set(['b', 'c']))
sage: N = M._minor(contractions=set(['a']), deletions=set())
sage: N._minor(contractions=set(), deletions=set(['b', 'c']))
Linear matroid of rank 3 on 5 elements represented over the Finite
Field of size 5
"""
Expand Down Expand Up @@ -2847,7 +2847,7 @@ cdef class LinearMatroid(BasisExchangeMatroid):
if sol:
if certificate:
(certX, certY) = cert_pair
cert = set([])
cert = set()
for x in certX:
cert.add(dX[x])
for y in certY:
Expand Down Expand Up @@ -3783,8 +3783,8 @@ cdef class BinaryMatroid(LinearMatroid):
EXAMPLES::

sage: M = matroids.catalog.Fano()
sage: N = M._minor(contractions=set(['a']), deletions=set([]))
sage: N._minor(contractions=set([]), deletions=set(['b', 'c']))
sage: N = M._minor(contractions=set(['a']), deletions=set())
sage: N._minor(contractions=set(), deletions=set(['b', 'c']))
Binary matroid of rank 2 on 4 elements, type (0, 6)
"""
self._move_current_basis(contractions, deletions)
Expand Down Expand Up @@ -4720,8 +4720,8 @@ cdef class TernaryMatroid(LinearMatroid):
EXAMPLES::

sage: M = matroids.catalog.P8()
sage: N = M._minor(contractions=set(['a']), deletions=set([]))
sage: N._minor(contractions=set([]), deletions=set(['b', 'c']))
sage: N = M._minor(contractions=set(['a']), deletions=set())
sage: N._minor(contractions=set(), deletions=set(['b', 'c']))
Ternary matroid of rank 3 on 5 elements, type 0-
"""
self._move_current_basis(contractions, deletions)
Expand Down Expand Up @@ -5488,8 +5488,8 @@ cdef class QuaternaryMatroid(LinearMatroid):
EXAMPLES::

sage: M = matroids.catalog.Q10() # needs sage.rings.finite_rings
sage: N = M._minor(contractions=set(['a']), deletions=set([])) # needs sage.rings.finite_rings
sage: N._minor(contractions=set([]), deletions=set(['b', 'c'])) # needs sage.rings.finite_rings
sage: N = M._minor(contractions=set(['a']), deletions=set()) # needs sage.rings.finite_rings
sage: N._minor(contractions=set(), deletions=set(['b', 'c'])) # needs sage.rings.finite_rings
Quaternary matroid of rank 4 on 7 elements
"""
self._move_current_basis(contractions, deletions)
Expand Down
Loading
Loading