Skip to content
This repository was archived by the owner on Feb 1, 2023. It is now read-only.

Commit 5958f5d

Browse files
author
Release Manager
committed
Trac #33452: adjust error messages in topology/
as in #33367 plus a few other details about https and pep8 URL: https://trac.sagemath.org/33452 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Matthias Koeppe
2 parents a791c09 + 1f63ba3 commit 5958f5d

12 files changed

+74
-75
lines changed

src/sage/topology/cell_complex.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
# as published by the Free Software Foundation; either version 2 of
4242
# the License, or (at your option) any later version.
4343
#
44-
# http://www.gnu.org/licenses/
44+
# https://www.gnu.org/licenses/
4545
########################################################################
4646

4747
from sage.structure.sage_object import SageObject
@@ -1002,7 +1002,7 @@ def cohomology_ring(self, base_ring=QQ):
10021002
sage: T.cohomology_ring()
10031003
Traceback (most recent call last):
10041004
...
1005-
ValueError: This simplicial complex must be immutable. Call set_immutable().
1005+
ValueError: this simplicial complex must be immutable; call set_immutable()
10061006
sage: T.set_immutable()
10071007
sage: T.cohomology_ring()
10081008
Cohomology ring of Simplicial complex with 9 vertices and
@@ -1226,5 +1226,3 @@ def _repr_(self):
12261226
else:
12271227
cells_string = " and 1 %s" % cell_name
12281228
return Name + " complex " + vertex_string + cells_string
1229-
1230-

src/sage/topology/cubical_complex.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -145,17 +145,17 @@ def __init__(self, data):
145145
try:
146146
Integer(x[0])
147147
except TypeError:
148-
raise ValueError("The interval %s is not of the correct form" % x)
148+
raise ValueError("the interval %s is not of the correct form" % x)
149149
if x[0] + 1 == x[1]:
150150
nondegenerate.append(i)
151151
elif x[0] != x[1]:
152-
raise ValueError("The interval %s is not of the correct form" % x)
152+
raise ValueError("the interval %s is not of the correct form" % x)
153153
new_data.append(tuple(x))
154154
elif len(x) == 1:
155155
y = tuple(x)
156156
new_data.append(y+y)
157157
elif len(x) != 1:
158-
raise ValueError("The interval %s is not of the correct form" % x)
158+
raise ValueError("the interval %s is not of the correct form" % x)
159159
i += 1
160160
self.__tuple = tuple(new_data)
161161
self.__nondegenerate = nondegenerate
@@ -356,10 +356,10 @@ def face(self, n, upper=True):
356356
sage: C.face(3)
357357
Traceback (most recent call last):
358358
...
359-
ValueError: Can only compute the nth face if 0 <= n < dim.
359+
ValueError: can only compute the nth face if 0 <= n < dim
360360
"""
361361
if n < 0 or n >= self.dimension():
362-
raise ValueError("Can only compute the nth face if 0 <= n < dim.")
362+
raise ValueError("can only compute the nth face if 0 <= n < dim")
363363
idx = self.nondegenerate_intervals()[n]
364364
t = self.__tuple
365365
if upper:
@@ -456,7 +456,7 @@ def _compare_for_gluing(self, other):
456456
"""
457457
d = self.dimension()
458458
if d != other.dimension():
459-
raise ValueError("Cubes must be of the same dimension.")
459+
raise ValueError("cubes must be of the same dimension")
460460
insert_self = []
461461
insert_other = []
462462
translate = []
@@ -847,7 +847,7 @@ class :class:`Cube`, or lists or tuples suitable for conversion to
847847
sage: S1.join(S1)
848848
Traceback (most recent call last):
849849
...
850-
NotImplementedError: Joins are not implemented for cubical complexes.
850+
NotImplementedError: joins are not implemented for cubical complexes
851851
852852
Therefore, neither are cones or suspensions.
853853
"""
@@ -1065,7 +1065,7 @@ def cells(self, subcomplex=None):
10651065
if subcomplex not in self._cells:
10661066
if subcomplex is not None and subcomplex.dimension() > -1:
10671067
if not subcomplex.is_subcomplex(self):
1068-
raise ValueError("The 'subcomplex' is not actually a subcomplex.")
1068+
raise ValueError("the 'subcomplex' is not actually a subcomplex")
10691069
# Cells is the dictionary of cells in self but not in
10701070
# subcomplex, indexed by dimension
10711071
Cells = {}
@@ -1381,9 +1381,9 @@ def join(self, other):
13811381
sage: C1.join(C1)
13821382
Traceback (most recent call last):
13831383
...
1384-
NotImplementedError: Joins are not implemented for cubical complexes.
1384+
NotImplementedError: joins are not implemented for cubical complexes
13851385
"""
1386-
raise NotImplementedError("Joins are not implemented for cubical complexes.")
1386+
raise NotImplementedError("joins are not implemented for cubical complexes")
13871387

13881388
# Use * to mean 'join':
13891389
# __mul__ = join
@@ -1405,10 +1405,10 @@ def cone(self):
14051405
sage: C1.cone()
14061406
Traceback (most recent call last):
14071407
...
1408-
NotImplementedError: Cones are not implemented for cubical complexes.
1408+
NotImplementedError: cones are not implemented for cubical complexes
14091409
"""
1410-
#return self.join(cubical_complexes.Cube(0))
1411-
raise NotImplementedError("Cones are not implemented for cubical complexes.")
1410+
# return self.join(cubical_complexes.Cube(0))
1411+
raise NotImplementedError("cones are not implemented for cubical complexes")
14121412

14131413
def suspension(self, n=1):
14141414
r"""
@@ -1430,7 +1430,7 @@ def suspension(self, n=1):
14301430
sage: C1.suspension()
14311431
Traceback (most recent call last):
14321432
...
1433-
NotImplementedError: Suspensions are not implemented for cubical complexes.
1433+
NotImplementedError: suspensions are not implemented for cubical complexes
14341434
"""
14351435
# if n<0:
14361436
# raise ValueError, "n must be non-negative."
@@ -1439,7 +1439,7 @@ def suspension(self, n=1):
14391439
# if n==1:
14401440
# return self.join(cubical_complexes.Sphere(0))
14411441
# return self.suspension().suspension(int(n-1))
1442-
raise NotImplementedError("Suspensions are not implemented for cubical complexes.")
1442+
raise NotImplementedError("suspensions are not implemented for cubical complexes")
14431443

14441444
def product(self, other):
14451445
r"""
@@ -1562,7 +1562,7 @@ def connected_sum(self, other):
15621562
# C x 0 and C x 1, putting in its place (its boundary) x (0,1).
15631563
if not (self.is_pure() and other.is_pure() and
15641564
self.dimension() == other.dimension()):
1565-
raise ValueError("Complexes are not pure of the same dimension.")
1565+
raise ValueError("complexes are not pure of the same dimension")
15661566

15671567
self_facets = list(self.maximal_cells())
15681568
other_facets = list(other.maximal_cells())
@@ -1939,6 +1939,7 @@ def Cube(self, n):
19391939
if n == 0:
19401940
return CubicalComplex([Cube([[0]])])
19411941
else:
1942-
return CubicalComplex([Cube([[0,1]]*n)])
1942+
return CubicalComplex([Cube([[0, 1]] * n)])
1943+
19431944

19441945
cubical_complexes = CubicalComplexExamples()

src/sage/topology/delta_complex.py

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -308,7 +308,7 @@ def store_bdry(simplex, faces):
308308
new_data[dim] = []
309309
for x in data:
310310
if not isinstance(x, Simplex):
311-
raise TypeError("Each key in the data dictionary must be a simplex.")
311+
raise TypeError("each key in the data dictionary must be a simplex")
312312
old_data_by_dim[x.dimension()].append(x)
313313
old_delayed = {}
314314
for dim in range(dimension, -1, -1):
@@ -338,7 +338,7 @@ def store_bdry(simplex, faces):
338338
current[bdry] = store_bdry(bdry, bdry.faces())
339339
new_data[dim].append(current[bdry])
340340
else:
341-
raise ValueError("In the data dictionary, there is a value which is a simplex not already in the dictionary. This is not allowed.")
341+
raise ValueError("in the data dictionary, there is a value which is a simplex not already in the dictionary")
342342
elif isinstance(bdry, (list, tuple)):
343343
# case 2
344344
# boundary is a list or tuple
@@ -367,8 +367,8 @@ def store_bdry(simplex, faces):
367367
faces = new_data[d-1]
368368
for j in range(d+1):
369369
if not all(faces[s[j]][i] == faces[s[i]][j-1] for i in range(j)):
370-
msg = "Simplicial identity d_i d_j = d_{j-1} d_i fails"
371-
msg += " for j=%s, in dimension %s"%(j,d)
370+
msg = "simplicial identity d_i d_j = d_{j-1} d_i fails"
371+
msg += " for j=%s, in dimension %s" % (j, d)
372372
raise ValueError(msg)
373373
# self._cells_dict: dictionary indexed by dimension d: for
374374
# each d, have list or tuple of simplices, and for each
@@ -557,7 +557,7 @@ def cells(self, subcomplex=None):
557557
cells[d] = [None]*l # get rid of all cells
558558
return cells
559559
else:
560-
raise ValueError("This is not a subcomplex of self.")
560+
raise ValueError("this is not a subcomplex of self")
561561
else:
562562
subcomplex_cells = subcomplex._is_subcomplex_of[self]
563563
for d in range(0, max(subcomplex_cells.keys())+1):
@@ -919,7 +919,7 @@ def suspension(self, n=1):
919919
{0: 0, 1: 0, 2: 0, 3: Z}
920920
"""
921921
if n<0:
922-
raise ValueError("n must be non-negative.")
922+
raise ValueError("n must be non-negative")
923923
if n==0:
924924
return self
925925
if n==1:
@@ -1156,7 +1156,7 @@ def connected_sum(self, other):
11561156
Z x Z x C2
11571157
"""
11581158
if not self.dimension() == other.dimension():
1159-
raise ValueError("Complexes are not of the same dimension.")
1159+
raise ValueError("complexes are not of the same dimension")
11601160
dim = self.dimension()
11611161
# Look at the last simplex in the list of top-dimensional
11621162
# simplices for each complex. If there are identifications on
@@ -1487,9 +1487,9 @@ def barycentric_subdivision(self):
14871487
sage: K.barycentric_subdivision()
14881488
Traceback (most recent call last):
14891489
...
1490-
NotImplementedError: Barycentric subdivisions are not implemented for Delta complexes.
1490+
NotImplementedError: barycentric subdivisions are not implemented for Delta complexes
14911491
"""
1492-
raise NotImplementedError("Barycentric subdivisions are not implemented for Delta complexes.")
1492+
raise NotImplementedError("barycentric subdivisions are not implemented for Delta complexes")
14931493

14941494
def n_chains(self, n, base_ring=None, cochains=False):
14951495
r"""
@@ -1666,7 +1666,8 @@ def Torus(self):
16661666
sage: delta_complexes.Torus().homology(1)
16671667
Z x Z
16681668
"""
1669-
return DeltaComplex(( ((),), ((0,0), (0,0), (0,0)), ((1,2,0), (0, 2, 1))))
1669+
return DeltaComplex((((),), ((0, 0), (0, 0), (0, 0)),
1670+
((1, 2, 0), (0, 2, 1))))
16701671

16711672
def RealProjectivePlane(self):
16721673
r"""
@@ -1687,7 +1688,8 @@ def RealProjectivePlane(self):
16871688
sage: P.cohomology(dim=2, base_ring=GF(2))
16881689
Vector space of dimension 1 over Finite Field of size 2
16891690
"""
1690-
return DeltaComplex(( ((), ()), ((1,0), (1,0), (0,0)), ((1,0,2), (0,1,2))))
1691+
return DeltaComplex((((), ()), ((1, 0), (1, 0), (0, 0)),
1692+
((1, 0, 2), (0, 1, 2))))
16911693

16921694
def KleinBottle(self):
16931695
r"""
@@ -1701,7 +1703,8 @@ def KleinBottle(self):
17011703
sage: delta_complexes.KleinBottle()
17021704
Delta complex with 1 vertex and 7 simplices
17031705
"""
1704-
return DeltaComplex(( ((),), ((0,0), (0,0), (0,0)), ((1,2,0), (0, 1, 2))))
1706+
return DeltaComplex((((),), ((0, 0), (0, 0), (0, 0)),
1707+
((1, 2, 0), (0, 1, 2))))
17051708

17061709
def Simplex(self, n):
17071710
r"""
@@ -1770,8 +1773,9 @@ def SurfaceOfGenus(self, g, orientable=True):
17701773
else:
17711774
X = delta_complexes.RealProjectivePlane()
17721775
S = X
1773-
for i in range(g-1):
1776+
for i in range(g - 1):
17741777
S = S.connected_sum(X)
17751778
return S
17761779

1780+
17771781
delta_complexes = DeltaComplexExamples()

src/sage/topology/filtered_simplicial_complex.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,4 +735,3 @@ def _simplicial_(self):
735735
Simplicial complex with vertex set (0, 1, 2, 3) and facets {(0, 1, 2), (0, 2, 3)}
736736
"""
737737
return SimplicialComplex(self._filtration_dict)
738-

src/sage/topology/simplicial_complex.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -119,17 +119,17 @@
119119
sage: hash(S)
120120
Traceback (most recent call last):
121121
...
122-
ValueError: This simplicial complex must be immutable. Call set_immutable().
122+
ValueError: this simplicial complex must be immutable; call set_immutable()
123123
sage: S = SimplicialComplex([[1,4], [2,4]])
124124
sage: S.set_immutable()
125125
sage: S.add_face([1,3])
126126
Traceback (most recent call last):
127127
...
128-
ValueError: This simplicial complex is not mutable
128+
ValueError: this simplicial complex is not mutable
129129
sage: S.remove_face([1,3])
130130
Traceback (most recent call last):
131131
...
132-
ValueError: This simplicial complex is not mutable
132+
ValueError: this simplicial complex is not mutable
133133
sage: hash(S) == hash(S)
134134
True
135135
@@ -1134,7 +1134,7 @@ def __hash__(self):
11341134
sage: hash(S)
11351135
Traceback (most recent call last):
11361136
...
1137-
ValueError: This simplicial complex must be immutable. Call set_immutable().
1137+
ValueError: this simplicial complex must be immutable; call set_immutable()
11381138
sage: S.set_immutable()
11391139
sage: hash(S) == hash(S)
11401140
True
@@ -1145,7 +1145,7 @@ def __hash__(self):
11451145
True
11461146
"""
11471147
if not self._is_immutable:
1148-
raise ValueError("This simplicial complex must be immutable. Call set_immutable().")
1148+
raise ValueError("this simplicial complex must be immutable; call set_immutable()")
11491149
return hash(frozenset(self._facets))
11501150

11511151
def __eq__(self, right):
@@ -1903,7 +1903,7 @@ def suspension(self, n=1, is_mutable=True):
19031903
(0, 1, 2, 3, 4, 5, 6, 7)
19041904
"""
19051905
if n < 0:
1906-
raise ValueError("n must be non-negative.")
1906+
raise ValueError("n must be non-negative")
19071907
if n == 0:
19081908
return self
19091909
if n == 1:
@@ -2555,7 +2555,7 @@ def add_face(self, face):
25552555
sage: X.add_face([0,1])
25562556
"""
25572557
if self._is_immutable:
2558-
raise ValueError("This simplicial complex is not mutable")
2558+
raise ValueError("this simplicial complex is not mutable")
25592559

25602560
vertex_to_index = self._translation_to_numeric()
25612561

@@ -2673,7 +2673,7 @@ def remove_face(self, face, check=False):
26732673
Simplicial complex with vertex set (1, 2, 3) and facets {(3,), (1, 2)}
26742674
"""
26752675
if self._is_immutable:
2676-
raise ValueError("This simplicial complex is not mutable")
2676+
raise ValueError("this simplicial complex is not mutable")
26772677

26782678
getindex = self._translation_to_numeric().__getitem__
26792679
simplex = Simplex(sorted(face, key=getindex))
@@ -3165,7 +3165,6 @@ def is_shellable(self, certificate=False):
31653165
it.append(iter(set(facets)))
31663166
continue
31673167

3168-
31693168
# The shelling condition is precisely that intersection is
31703169
# a pure complex of one dimension less and stop if this fails
31713170
common = set(F).intersection(set(cur_complex.vertices()))

src/sage/topology/simplicial_complex_examples.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -390,8 +390,10 @@ def RealProjectivePlane():
390390
[2, 3, 5], [2, 4, 5]],
391391
name='Minimal triangulation of the real projective plane')
392392

393+
393394
ProjectivePlane = RealProjectivePlane
394395

396+
395397
def KleinBottle():
396398
"""
397399
A minimal triangulation of the Klein bottle, as presented for example
@@ -436,7 +438,7 @@ def SurfaceOfGenus(g, orientable=True):
436438
"""
437439
if g == 0:
438440
if not orientable:
439-
raise ValueError("No non-orientable surface of genus zero.")
441+
raise ValueError("no non-orientable surface of genus zero")
440442
else:
441443
return Sphere(2)
442444
if orientable:
@@ -490,7 +492,7 @@ def MooreSpace(q):
490492
Triangulation of the mod 8 Moore space
491493
"""
492494
if q <= 1:
493-
raise ValueError("The mod q Moore space is only defined if q is at least 2")
495+
raise ValueError("the mod q Moore space is only defined if q is at least 2")
494496
if q == 2:
495497
return RealProjectivePlane()
496498
facets = []

src/sage/topology/simplicial_complex_homset.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
4242
"""
4343

44-
#*****************************************************************************
44+
# ****************************************************************************
4545
# Copyright (C) 2009 D. Benjamin Antieau <[email protected]>
4646
#
4747
# Distributed under the terms of the GNU General Public License (GPL)
@@ -53,9 +53,9 @@
5353
# See the GNU General Public License for more details; the full text
5454
# is available at:
5555
#
56-
# http://www.gnu.org/licenses/
56+
# https://www.gnu.org/licenses/
5757
#
58-
#*****************************************************************************
58+
# ****************************************************************************
5959

6060
import sage.categories.homset
6161
from .simplicial_complex_morphism import SimplicialComplexMorphism
@@ -193,4 +193,3 @@ def an_element(self):
193193
raise TypeError("there are no morphisms from a non-empty simplicial complex to an empty simplicial complex")
194194
f = {x: i for x in X_vertices}
195195
return SimplicialComplexMorphism(f, self._domain, self._codomain)
196-

0 commit comments

Comments
 (0)