Skip to content
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

Fix some cannot #35007

Merged
merged 5 commits into from
Feb 24, 2023
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
2 changes: 1 addition & 1 deletion src/sage/combinat/alternating_sign_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -1197,7 +1197,7 @@ def _element_constructor_(self, asm, check=True):
if isinstance(asm, AlternatingSignMatrix):
if asm.parent() is self:
return asm
raise ValueError("Cannot convert between alternating sign matrices of different sizes")
raise ValueError("cannot convert between alternating sign matrices of different sizes")
try:
m = self._matrix_space(asm)
except (TypeError, ValueError):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/decorated_permutation.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def _element_constructor_(self, pi, check=True):
if isinstance(pi, DecoratedPermutation):
if pi.parent() is self:
return pi
raise ValueError("Cannot convert between decorated permutations of different sizes")
raise ValueError("cannot convert between decorated permutations of different sizes")

pi = tuple(pi)
if check and pi not in self:
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/derangements.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _element_constructor_(self, der):
if isinstance(der, Derangement):
if der.parent() is self:
return der
raise ValueError("Cannot convert %s to an element of %s" % (der, self))
raise ValueError("cannot convert %s to an element of %s" % (der, self))
return self.element_class(self, der)

Element = Derangement
Expand Down
4 changes: 2 additions & 2 deletions src/sage/data_structures/bounded_integer_sequences.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1212,7 +1212,7 @@ cdef class BoundedIntegerSequence:
sage: T+None
Traceback (most recent call last):
...
TypeError: Cannot concatenate bounded integer sequence and None
TypeError: cannot concatenate bounded integer sequence and None

TESTS:

Expand All @@ -1228,7 +1228,7 @@ cdef class BoundedIntegerSequence:
"""
cdef BoundedIntegerSequence myself, right, out
if other is None or self is None:
raise TypeError('Cannot concatenate bounded integer sequence and None')
raise TypeError('cannot concatenate bounded integer sequence and None')
myself = self # may result in a type error
right = other # --"--
if right.data.itembitsize != myself.data.itembitsize:
Expand Down
5 changes: 3 additions & 2 deletions src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -5251,8 +5251,8 @@ def from_palp_index(i):
elif o in range(65, 91):
i = o - 28
else:
raise ValueError('Cannot convert PALP index '
+ i + ' to number.')
raise ValueError('cannot convert PALP index '
+ i + ' to number')
return i
n = len(permutation)
domain = [from_palp_index(i) for i in permutation]
Expand All @@ -5261,6 +5261,7 @@ def from_palp_index(i):
S = SymmetricGroup(n)
return make_permgroup_element(S, domain)


def _read_nef_x_partitions(data):
r"""
Read all nef-partitions for one polytope from a string or an open
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/polyhedron/parent.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def convert_base_ring_Hrep(lstlst):
return self._element_constructor_polyhedron(polyhedron, mutable=mutable, **kwds)
if nargs == 1 and args[0] == 0:
return self.zero()
raise ValueError('Cannot convert to polyhedron object.')
raise ValueError('cannot convert to polyhedron object')

def _element_constructor_polyhedron(self, polyhedron, **kwds):
"""
Expand Down
8 changes: 4 additions & 4 deletions src/sage/libs/giac/giac.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ cdef class Pygen(GiacMethods_base):
return result

else:
raise TypeError("Cannot convert non giac integers to Integer")
raise TypeError("cannot convert non giac integers to Integer")


def _rational_(self,Z=None):
Expand All @@ -1434,7 +1434,7 @@ cdef class Pygen(GiacMethods_base):
# giac _RAT_
return ZZ(self.numer()) / ZZ(self.denom())
else:
raise TypeError("Cannot convert non giac _FRAC_ to QQ")
raise TypeError("cannot convert non giac _FRAC_ to QQ")


def sage(self):
Expand Down Expand Up @@ -1736,7 +1736,7 @@ cdef class Pygen(GiacMethods_base):
sig_off()
return result
else:
raise TypeError("Cannot convert non _INT_ giac gen")
raise TypeError("cannot convert non _INT_ giac gen")


property _double: # immediate double (type _DOUBLE_)
Expand All @@ -1750,7 +1750,7 @@ cdef class Pygen(GiacMethods_base):
sig_off()
return result
else:
raise TypeError("Cannot convert non _DOUBLE_ giac gen")
raise TypeError("cannot convert non _DOUBLE_ giac gen")

property help:
def __get__(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/pari/convert_sage.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@ cpdef set_integer_from_gen(Integer self, Gen x):
break
elif paritype == t_PADIC:
if x._valp() < 0:
raise TypeError("Cannot convert p-adic with negative valuation to an integer")
raise TypeError("cannot convert p-adic with negative valuation to an integer")
# Lifting a PADIC yields an integer
x = x.lift()
break
Expand Down
2 changes: 1 addition & 1 deletion src/sage/libs/singular/function.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ cdef class SingularFunction(SageObject):
dummy_ring = PolynomialRing(QQ, "dummy", implementation="singular") # seems a reasonable default
ring = dummy_ring
if not (isinstance(ring, MPolynomialRing_libsingular) or isinstance(ring, NCPolynomialRing_plural)):
raise TypeError("Cannot call Singular function '%s' with ring parameter of type '%s'"%(self._name,type(ring)))
raise TypeError("cannot call Singular function '%s' with ring parameter of type '%s'" % (self._name,type(ring)))
return call_function(self, args, ring, interruptible, attributes)

def _instancedoc_(self):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/modules/vector_rational_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement):
mpq_set_z(a.value, (<Integer>left).value)
else:
# should not happen
raise TypeError("Cannot convert %s to %s" % (type(left).__name__, Rational.__name__))
raise TypeError("cannot convert %s to %s" % (type(left).__name__, Rational.__name__))
z = self._new_c()
cdef Py_ssize_t i
for i in range(self._degree):
Expand All @@ -343,7 +343,7 @@ cdef class Vector_rational_dense(free_module_element.FreeModuleElement):
mpq_set_z(a.value, (<Integer>right).value)
else:
# should not happen
raise TypeError("Cannot convert %s to %s" % (type(right).__name__, Rational.__name__))
raise TypeError("cannot convert %s to %s" % (type(right).__name__, Rational.__name__))
z = self._new_c()
cdef Py_ssize_t i
for i in range(self._degree):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/asymptotic/asymptotic_ring.py
Original file line number Diff line number Diff line change
Expand Up @@ -4158,9 +4158,9 @@ def _element_constructor_(self, data, simplify=True, convert=True):

elif is_PowerSeriesRing(P):
raise NotImplementedError(
'Cannot convert %s from the %s to an asymptotic expansion '
'cannot convert %s from the %s to an asymptotic expansion '
'in %s, since growths at other points than +oo are not yet '
'supported.' % (data, P, self))
'supported' % (data, P, self))
# Delete lines above as soon as we can deal with growths
# other than the that at going to +oo.
from sage.rings.infinity import PlusInfinity
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/integer.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
sage: ZZ(pari(Qp(11)(11^-7)))
Traceback (most recent call last):
...
TypeError: Cannot convert p-adic with negative valuation to an integer
TypeError: cannot convert p-adic with negative valuation to an integer

Test converting a list with a very large base::

Expand Down Expand Up @@ -640,7 +640,7 @@ cdef class Integer(sage.structure.element.EuclideanDomainElement):
if n == x:
mpz_set_pylong(self.value, n)
else:
raise TypeError("Cannot convert non-integral float to integer")
raise TypeError("cannot convert non-integral float to integer")

elif isinstance(x, pari_gen):
global set_integer_from_gen
Expand Down
8 changes: 4 additions & 4 deletions src/sage/rings/number_field/number_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -8063,7 +8063,7 @@ def _coerce_from_other_number_field(self, x):
sage: L(a)
Traceback (most recent call last):
...
ValueError: Cannot convert a to Number Field in b with defining polynomial x^3 - 4*x + 1 with b = 1.860805853111704? (using the specified embeddings)
ValueError: cannot convert a to Number Field in b with defining polynomial x^3 - 4*x + 1 with b = 1.860805853111704? (using the specified embeddings)

Subfields automatically come with an embedding::

Expand Down Expand Up @@ -8156,7 +8156,7 @@ def _coerce_from_other_number_field(self, x):
f = x.minpoly()
ys = f.roots(ring=K, multiplicities=False)
if not ys:
raise ValueError("Cannot convert %s to %s (regardless of embeddings)" % (x, K))
raise ValueError("cannot convert %s to %s (regardless of embeddings)" % (x, K))

# Define a function are_roots_equal to determine whether two
# roots of f are equal. A simple a == b does not suffice for
Expand Down Expand Up @@ -8213,7 +8213,7 @@ def _coerce_from_other_number_field(self, x):
emb_y = y.polynomial()(Kgen)
if are_roots_equal(emb_x, emb_y):
return y
raise ValueError("Cannot convert %s to %s (using the specified embeddings)" % (x, K))
raise ValueError("cannot convert %s to %s (using the specified embeddings)" % (x, K))

def _coerce_map_from_(self, R):
"""
Expand Down Expand Up @@ -11220,7 +11220,7 @@ def _coerce_from_other_cyclotomic_field(self, x, only_canonical=False):
if z == x:
return self.zeta(m)**(r+1)
z *= y
raise TypeError("Cannot coerce %s into %s" % (x, self))
raise TypeError("cannot coerce %s into %s" % (x, self))
return self._element_class(self, x)

def _coerce_from_gap(self, x):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/polynomial/multi_polynomial_ideal.py
Original file line number Diff line number Diff line change
Expand Up @@ -2187,7 +2187,7 @@ def transformed_basis(self, algorithm="gwalk", other_ring=None, singular=singula
return PolynomialSequence(nR, sorted([nR(f) for f in nIs],reverse=True), immutable=True)

else:
raise TypeError("Cannot convert basis with given algorithm")
raise TypeError("cannot convert basis with given algorithm")

@handle_AA_and_QQbar
def elimination_ideal(self, variables, algorithm=None, *args, **kwds):
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/polynomial_element.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -8027,11 +8027,11 @@ cdef class Polynomial(CommutativeAlgebraElement):
sage: f.roots(RR)
Traceback (most recent call last):
...
TypeError: Cannot evaluate symbolic expression to a numeric value.
TypeError: cannot evaluate symbolic expression to a numeric value
sage: f.roots(CC)
Traceback (most recent call last):
...
TypeError: Cannot evaluate symbolic expression to a numeric value.
TypeError: cannot evaluate symbolic expression to a numeric value

We can find roots of polynomials defined over `\ZZ` or `\QQ`
over the `p`-adics, see :trac:`15422`::
Expand Down
4 changes: 2 additions & 2 deletions src/sage/rings/polynomial/polynomial_real_mpfr_dense.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,12 @@ cdef class PolynomialRealDense(Polynomial):
sage: PolynomialRealDense(RR['x'], [1,a])
Traceback (most recent call last):
...
TypeError: Cannot evaluate symbolic expression to a numeric value.
TypeError: cannot evaluate symbolic expression to a numeric value
sage: R.<x> = SR[]
sage: (x-a).change_ring(RR)
Traceback (most recent call last):
...
TypeError: Cannot evaluate symbolic expression to a numeric value.
TypeError: cannot evaluate symbolic expression to a numeric value
sage: sig_on_count()
0

Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/real_double.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,7 @@ cdef class RealDoubleElement(FieldElement):
sage: ZZ(RDF(-2345.67))
Traceback (most recent call last):
...
TypeError: Cannot convert non-integral float to integer
TypeError: cannot convert non-integral float to integer
"""
return Integer(self._value)

Expand Down
4 changes: 3 additions & 1 deletion src/sage/rings/real_mpfi.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -5356,7 +5356,8 @@ def __create__RealIntervalField_version0(prec, sci_not):
"""
return RealIntervalField(prec, sci_not)

## Keep all old versions!!!

# Keep all old versions!!!
def __create__RealIntervalFieldElement_version0(parent, x, base=10):
"""
For pickling.
Expand All @@ -5368,6 +5369,7 @@ def __create__RealIntervalFieldElement_version0(parent, x, base=10):
"""
return RealIntervalFieldElement(parent, x, base=base)


def __create__RealIntervalFieldElement_version1(parent, lower, upper):
"""
For pickling.
Expand Down
24 changes: 12 additions & 12 deletions src/sage/rings/real_mpfr.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2247,7 +2247,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
100000000000000000
"""
if not mpfr_number_p(self.value):
raise ValueError('Cannot convert infinity or NaN to Sage Integer')
raise ValueError('cannot convert infinity or NaN to Sage Integer')

cdef Integer z = Integer()
mpfr_get_z(z.value, self.value, MPFR_RNDZ)
Expand Down Expand Up @@ -3236,7 +3236,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
<... 'int'>
"""
if not mpfr_number_p(self.value):
raise ValueError('Cannot convert infinity or NaN to Python int')
raise ValueError('cannot convert infinity or NaN to Python int')

cdef Integer z = Integer()
mpfr_get_z(z.value, self.value, MPFR_RNDZ)
Expand Down Expand Up @@ -3352,7 +3352,7 @@ cdef class RealNumber(sage.structure.element.RingElement):
# as subject-to-change.

if mpfr_nan_p(self.value) or mpfr_inf_p(self.value):
raise ValueError('Cannot convert NaN or infinity to Pari float')
raise ValueError('cannot convert NaN or infinity to Pari float')

# wordsize for PARI
cdef unsigned long wordsize = sizeof(long)*8
Expand Down Expand Up @@ -3678,14 +3678,14 @@ cdef class RealNumber(sage.structure.element.RingElement):
sage: RR('nan').simplest_rational()
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
sage: RR('-infinity').simplest_rational()
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
"""
if not mpfr_number_p(self.value):
raise ValueError('Cannot convert NaN or infinity to rational number')
raise ValueError('cannot convert NaN or infinity to rational number')

if mpfr_zero_p(self.value):
return Rational(0)
Expand Down Expand Up @@ -3784,23 +3784,23 @@ cdef class RealNumber(sage.structure.element.RingElement):
sage: RR('nan').nearby_rational(max_denominator=1000)
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
sage: RR('nan').nearby_rational(max_error=0.01)
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
sage: RR(oo).nearby_rational(max_denominator=1000)
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
sage: RR(oo).nearby_rational(max_error=0.01)
Traceback (most recent call last):
...
ValueError: Cannot convert NaN or infinity to rational number
ValueError: cannot convert NaN or infinity to rational number
"""

if not mpfr_number_p(self.value):
raise ValueError('Cannot convert NaN or infinity to rational number')
raise ValueError('cannot convert NaN or infinity to rational number')

if ((max_error is None and max_denominator is None) or
(max_error is not None and max_denominator is not None)):
Expand Down Expand Up @@ -6105,7 +6105,7 @@ def create_RealField(*args, **kwds):
See http://trac.sagemath.org/24511 for details.
Real Field with 53 bits of precision
"""
#deprecation has already been imported in this file
# deprecation has already been imported in this file
deprecation(24511, "Please import create_RealField from sage.rings.real_field")
from sage.rings.real_field import create_RealField as cr
return cr(*args, **kwds)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/rings/universal_cyclotomic_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ def to_cyclotomic_field(self, R=None):
sage: CF(E(5)) # indirect doctest
Traceback (most recent call last):
...
TypeError: Cannot coerce zeta5 into Cyclotomic Field of order 7 and
TypeError: cannot coerce zeta5 into Cyclotomic Field of order 7 and
degree 6

sage: CF = CyclotomicField(10)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/schemes/generic/ambient_space.py
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ def dimension_absolute(self):
base = self.base_scheme()
if base.is_noetherian():
return self.dimension_relative() + base.dimension()
raise NotImplementedError("Cannot compute the dimension of this scheme.")
raise NotImplementedError("cannot compute the dimension of this scheme")

dimension = dimension_absolute

Expand Down
2 changes: 1 addition & 1 deletion src/sage/structure/coerce_maps.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ cdef class NamedConvertMap(Map):
print(type(x), x)
print(type(C), C)
print(self.method_name)
raise TypeError("Cannot coerce {} to {}".format(x, C))
raise TypeError(f"cannot coerce {x} to {C}")
cdef Map m
cdef Element e = method(C)
if e is None:
Expand Down
Loading