Skip to content

Commit f0a7ebb

Browse files
author
Release Manager
committed
Trac #34928: about error messages in categories/
namely changing those with a final dot to the common python style URL: https://trac.sagemath.org/34928 Reported by: chapoton Ticket author(s): Frédéric Chapoton Reviewer(s): Matthias Koeppe
2 parents f93e0a7 + ea0753d commit f0a7ebb

File tree

8 files changed

+51
-40
lines changed

8 files changed

+51
-40
lines changed

src/sage/arith/misc.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -559,7 +559,7 @@ def is_prime(n):
559559
if not isinstance(R, NumberField_generic):
560560
import warnings
561561
s = f'Testing primality in {R}, which is a field, ' \
562-
'hence the result will always be False. '
562+
'hence the result will always be False. '
563563
if R is QQ:
564564
s += 'To test whether n is a prime integer, use ' \
565565
'is_prime(ZZ(n)) or ZZ(n).is_prime(). '
@@ -568,6 +568,7 @@ def is_prime(n):
568568

569569
return ret
570570

571+
571572
def is_pseudoprime(n):
572573
r"""
573574
Test whether ``n`` is a pseudo-prime
@@ -2693,7 +2694,7 @@ def radical(n, *args, **kwds):
26932694
sage: radical(0)
26942695
Traceback (most recent call last):
26952696
...
2696-
ArithmeticError: Radical of 0 not defined.
2697+
ArithmeticError: radical of 0 is not defined
26972698
sage: K.<i> = QuadraticField(-1)
26982699
sage: radical(K(2))
26992700
i + 1

src/sage/categories/fields.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
r"""
33
Fields
44
"""
5-
#*****************************************************************************
5+
# ****************************************************************************
66
# Copyright (C) 2005 David Kohel <[email protected]>
77
# William Stein <[email protected]>
88
# 2008 Teresa Gomez-Diaz (CNRS) <[email protected]>
99
# 2008-2009 Nicolas M. Thiery <nthiery at users.sf.net>
1010
# 2012-2014 Julian Rueth <[email protected]>
1111
#
1212
# Distributed under the terms of the GNU General Public License (GPL)
13-
# http://www.gnu.org/licenses/
14-
#******************************************************************************
13+
# https://www.gnu.org/licenses/
14+
# *****************************************************************************
1515

1616
from sage.misc.lazy_attribute import lazy_class_attribute
1717
from sage.misc.lazy_import import LazyImport
@@ -22,6 +22,7 @@
2222

2323
from sage.structure.element import coerce_binop
2424

25+
2526
class Fields(CategoryWithAxiom):
2627
"""
2728
The category of (commutative) fields, i.e. commutative rings where
@@ -474,7 +475,7 @@ def _squarefree_decomposition_univariate_polynomial(self, f):
474475
if f.degree() == 0:
475476
return Factorization([], unit=f[0])
476477
if self.characteristic() != 0:
477-
raise NotImplementedError("square-free decomposition not implemented for this polynomial.")
478+
raise NotImplementedError("square-free decomposition not implemented for this polynomial")
478479

479480
factors = []
480481
cur = f

src/sage/categories/finite_posets.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,17 @@
99
- An *order ideal* (or *lower set*) of a poset `P` is a subset `S` of `P`
1010
such that if `x \leq y` and `y\in S` then `x\in S`.
1111
"""
12-
#*****************************************************************************
12+
# ****************************************************************************
1313
# Copyright (C) 2011 Nicolas M. Thiery <nthiery at users.sf.net>
1414
#
1515
# Distributed under the terms of the GNU General Public License (GPL)
16-
# http://www.gnu.org/licenses/
17-
#******************************************************************************
16+
# https://www.gnu.org/licenses/
17+
# *****************************************************************************
1818

1919
from sage.misc.abstract_method import abstract_method
2020
from sage.categories.category_with_axiom import CategoryWithAxiom
2121

22+
2223
class FinitePosets(CategoryWithAxiom):
2324
r"""
2425
The category of finite posets i.e. finite sets with a partial
@@ -1949,5 +1950,5 @@ def directed_subsets(self, direction):
19491950
[[]]
19501951
"""
19511952
if direction != 'up' and direction != 'down':
1952-
raise ValueError("Direction must be either 'up' or 'down'.")
1953+
raise ValueError("direction must be either 'up' or 'down'")
19531954
return self.antichains().map(lambda elements: self.directed_subset(elements, direction))

src/sage/categories/homset.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
from sage.structure.coerce_dict import TripleDict
8282
_cache = TripleDict(weak_values=True)
8383

84+
8485
def Hom(X, Y, category=None, check=True):
8586
"""
8687
Create the space of homomorphisms from X to Y in the category ``category``.
@@ -1141,16 +1142,15 @@ def identity(self):
11411142
sage: H.identity()
11421143
Traceback (most recent call last):
11431144
...
1144-
TypeError: Identity map only defined for endomorphisms. Try natural_map() instead.
1145+
TypeError: identity map only defined for endomorphisms; try natural_map() instead
11451146
sage: H.natural_map()
11461147
Natural morphism:
11471148
From: Integer Ring
11481149
To: Rational Field
11491150
"""
11501151
if self.is_endomorphism_set():
11511152
return morphism.IdentityMorphism(self)
1152-
else:
1153-
raise TypeError("Identity map only defined for endomorphisms. Try natural_map() instead.")
1153+
raise TypeError("identity map only defined for endomorphisms; try natural_map() instead")
11541154

11551155
def one(self):
11561156
"""

src/sage/categories/map.pyx

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,15 @@ AUTHORS:
1111
- Sebastian Oehms (2019-01-19): :meth:`section` added to :class:`FormalCompositeMap`.
1212
See :trac:`27081`.
1313
"""
14-
15-
#*****************************************************************************
14+
# ****************************************************************************
1615
# Copyright (C) 2008 Robert Bradshaw <[email protected]>
1716
#
1817
# This program is free software: you can redistribute it and/or modify
1918
# it under the terms of the GNU General Public License as published by
2019
# the Free Software Foundation, either version 2 of the License, or
2120
# (at your option) any later version.
22-
# http://www.gnu.org/licenses/
23-
#*****************************************************************************
21+
# https://www.gnu.org/licenses/
22+
# ****************************************************************************
2423

2524
from . import homset
2625
import weakref
@@ -52,6 +51,7 @@ def unpickle_map(_class, parent, _dict, _slots):
5251
mor.__dict__ = _dict
5352
return mor
5453

54+
5555
def is_Map(x):
5656
"""
5757
Auxiliary function: Is the argument a map?
@@ -66,6 +66,7 @@ def is_Map(x):
6666
"""
6767
return isinstance(x, Map)
6868

69+
6970
cdef class Map(Element):
7071
"""
7172
Basic class for all maps.
@@ -1214,7 +1215,7 @@ cdef class Map(Element):
12141215
sage: psi^2
12151216
Traceback (most recent call last):
12161217
...
1217-
TypeError: self must be an endomorphism.
1218+
TypeError: self must be an endomorphism
12181219
12191220
sage: K.<a> = NumberField(x^4 - 5*x + 5)
12201221
sage: C5.<z> = CyclotomicField(5)
@@ -1230,7 +1231,7 @@ cdef class Map(Element):
12301231
Defn: z |--> 3/11*a^3 + 4/11*a^2 + 9/11*a - 14/11
12311232
"""
12321233
if self.domain() is not self._codomain and n != 1 and n != -1:
1233-
raise TypeError("self must be an endomorphism.")
1234+
raise TypeError("self must be an endomorphism")
12341235
if n == 0:
12351236
from sage.categories.morphism import IdentityMorphism
12361237
return IdentityMorphism(self._parent)
@@ -1870,7 +1871,7 @@ cdef class FormalCompositeMap(Map):
18701871
sage: c2.is_injective()
18711872
Traceback (most recent call last):
18721873
...
1873-
NotImplementedError: Not enough information to deduce injectivity.
1874+
NotImplementedError: not enough information to deduce injectivity
18741875
18751876
If the first map is surjective and the second map is not injective,
18761877
then the composition is not injective::
@@ -1911,7 +1912,7 @@ cdef class FormalCompositeMap(Map):
19111912
if all(f.is_surjective() for f in injectives):
19121913
return False
19131914

1914-
raise NotImplementedError("Not enough information to deduce injectivity.")
1915+
raise NotImplementedError("not enough information to deduce injectivity")
19151916

19161917
def is_surjective(self):
19171918
"""
@@ -1953,7 +1954,7 @@ cdef class FormalCompositeMap(Map):
19531954
....: V2.hom(Matrix([[1], [1]]), V1)).is_surjective()
19541955
Traceback (most recent call last):
19551956
...
1956-
NotImplementedError: Not enough information to deduce surjectivity.
1957+
NotImplementedError: not enough information to deduce surjectivity
19571958
"""
19581959
try:
19591960
# we try the category first
@@ -1977,7 +1978,7 @@ cdef class FormalCompositeMap(Map):
19771978
if all(f.is_injective() for f in surjectives):
19781979
return False
19791980

1980-
raise NotImplementedError("Not enough information to deduce surjectivity.")
1981+
raise NotImplementedError("not enough information to deduce surjectivity")
19811982

19821983
def domains(self):
19831984
"""

src/sage/categories/posets.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
r"""
22
Posets
33
"""
4-
#*****************************************************************************
4+
# ****************************************************************************
55
# Copyright (C) 2011 Nicolas M. Thiery <nthiery at users.sf.net>
66
#
77
# Distributed under the terms of the GNU General Public License (GPL)
8-
# http://www.gnu.org/licenses/
9-
#******************************************************************************
10-
8+
# https://www.gnu.org/licenses/
9+
# *****************************************************************************
1110
from sage.misc.cachefunc import cached_method
1211
from sage.misc.abstract_method import abstract_method
1312
from sage.misc.lazy_import import LazyImport
1413
from sage.categories.category import Category
1514
from sage.categories.sets_cat import Sets
1615

16+
1717
class Posets(Category):
1818
r"""
1919
The category of posets i.e. sets with a partial order structure.
@@ -326,12 +326,20 @@ def directed_subset(self, elements, direction):
326326
[3, 7, 8, 9, 10, 11, 12, 13, 14, 15]
327327
sage: B.directed_subset([7, 10], 'down')
328328
[0, 1, 2, 3, 4, 5, 6, 7, 8, 10]
329+
330+
TESTS::
331+
332+
sage: B = posets.BooleanLattice(3)
333+
sage: B.directed_subset([3, 1], 'banana')
334+
Traceback (most recent call last):
335+
...
336+
ValueError: direction must be either 'up' or 'down'
329337
"""
330338
if direction == 'up':
331339
return self.order_filter(elements)
332340
if direction == 'down':
333341
return self.order_ideal(elements)
334-
raise ValueError("Direction must be either 'up' or 'down'.")
342+
raise ValueError("direction must be either 'up' or 'down'")
335343

336344
def principal_order_ideal(self, x):
337345
r"""

src/sage/categories/pushout.py

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
"""
22
Coercion via construction functors
33
"""
4-
54
# ****************************************************************************
65
# Copyright (C) 2007-2014 Robert Bradshaw
76
# 2007-2018 David Roe
@@ -1293,10 +1292,9 @@ def _apply_functor_to_morphism(self, f):
12931292
sage: R.construction()[0](f) # indirect doctest
12941293
Traceback (most recent call last):
12951294
...
1296-
NotImplementedError: Morphisms for infinite polynomial rings are not implemented yet.
1297-
1295+
NotImplementedError: morphisms for infinite polynomial rings are not implemented yet
12981296
"""
1299-
raise NotImplementedError("Morphisms for infinite polynomial rings are not implemented yet.")
1297+
raise NotImplementedError("morphisms for infinite polynomial rings are not implemented yet")
13001298

13011299
def _apply_functor(self, R):
13021300
"""
@@ -3025,7 +3023,7 @@ def merge(self, other):
30253023
# quotient by I would result in the trivial ring/group/...
30263024
# Rather than create the zero ring, we claim they can't be merged
30273025
# TODO: Perhaps this should be detected at a higher level...
3028-
raise TypeError("Trivial quotient intersection.")
3026+
raise TypeError("trivial quotient intersection")
30293027
# GF(p) has a coercion from Integers(p). Hence, merging should
30303028
# yield a field if either self or other yields a field.
30313029
return QuotientFunctor(I, names=self.names, as_field=as_field,
@@ -4734,10 +4732,10 @@ def type_to_parent(P):
47344732
sage: type_to_parent(list)
47354733
Traceback (most recent call last):
47364734
...
4737-
TypeError: Not a scalar type.
4735+
TypeError: not a scalar type
47384736
"""
47394737
from sage.structure.coerce import py_scalar_parent
47404738
parent = py_scalar_parent(P)
47414739
if parent is None:
4742-
raise TypeError("Not a scalar type.")
4740+
raise TypeError("not a scalar type")
47434741
return parent

src/sage/categories/unique_factorization_domains.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,20 @@
11
r"""
22
Unique factorization domains
33
"""
4-
#*****************************************************************************
4+
# ****************************************************************************
55
# Copyright (C) 2008 Teresa Gomez-Diaz (CNRS) <[email protected]>
66
#
77
# Distributed under the terms of the GNU General Public License (GPL)
8-
# http://www.gnu.org/licenses/
9-
#******************************************************************************
8+
# https://www.gnu.org/licenses/
9+
# *****************************************************************************
1010

1111
from sage.misc.lazy_attribute import lazy_class_attribute
1212
from sage.misc.misc_c import prod
1313
from sage.categories.category_singleton import Category_singleton
1414
from sage.categories.category_singleton import Category_contains_method_by_parent_class
1515
from sage.categories.gcd_domains import GcdDomains
1616

17+
1718
class UniqueFactorizationDomains(Category_singleton):
1819
"""
1920
The category of (constructive) unique factorization domains.
@@ -242,7 +243,7 @@ def radical(self, *args, **kwds):
242243
sage: Integer(0).radical()
243244
Traceback (most recent call last):
244245
...
245-
ArithmeticError: Radical of 0 not defined.
246+
ArithmeticError: radical of 0 is not defined
246247
247248
The next example shows how to compute the radical of a number,
248249
assuming no prime > 100000 has exponent > 1 in the factorization::
@@ -259,7 +260,7 @@ def radical(self, *args, **kwds):
259260
10
260261
"""
261262
if self.is_zero():
262-
raise ArithmeticError("Radical of 0 not defined.")
263+
raise ArithmeticError("radical of 0 is not defined")
263264
try:
264265
decomp = self.squarefree_decomposition()
265266
except AttributeError:

0 commit comments

Comments
 (0)