Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
first run of futurize -w -f raise
Browse files Browse the repository at this point in the history
  • Loading branch information
wluebbe committed Apr 3, 2014
1 parent 12bbca0 commit 3279bdc
Show file tree
Hide file tree
Showing 504 changed files with 3,169 additions and 3,205 deletions.
4 changes: 2 additions & 2 deletions src/bin/sage-num-threads.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,14 @@ def parse_jobs_from_MAKE(MAKE, unlimited=999999):
(j,num) = re.subn(r'^(.* )?(-j *|--jobs(=(?=[0-9])| +))([0-9]*)( .*?)?$', r'\4', MAKE, count=1)
if num < 1:
# No replacement done, i.e. no -j option found
raise KeyError, "No number of jobs specified"
raise KeyError("No number of jobs specified")
elif j == "":
# j is empty: unlimited number of jobs! :-)
j = unlimited
else:
j = int(j)
if j <= 0:
raise ValueError, "Non-positive value specified for -j"
raise ValueError("Non-positive value specified for -j")

# Next, find the value of -l
# If it is specified, use this as an upper bound on j
Expand Down
2 changes: 1 addition & 1 deletion src/doc/common/inventory_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def removed_method_error(self):
This is just for making sure that some writer methods are indeed
deactivated.
"""
raise RuntimeError, "This function shouldn't be called in \"%s\" builder"%(self.name)
raise RuntimeError("This function shouldn't be called in \"%s\" builder"%(self.name))

copy_image_files = removed_method_error
copy_download_files = removed_method_error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -633,7 +633,7 @@ def maximal_ideal(self):
ValueError: algebra is not local
"""
if self.degree() == 0:
raise ValueError, "the zero algebra is not local"
raise ValueError("the zero algebra is not local")
if not(self.is_unitary() and self.is_commutative()
and (self._assume_associative or self.is_associative())):
raise TypeError("algebra must be unitary, commutative and associative")
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/free_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ def create_key(self,base_ring, arg1=None, arg2=None,
else:
raise TypeError
except (TypeError, NotImplementedError) as msg:
raise NotImplementedError, "The letterplace implementation is not available for the free algebra you requested"
raise NotImplementedError("The letterplace implementation is not available for the free algebra you requested")
if PolRing is not None:
if degrees is None:
return (PolRing,)
Expand Down
16 changes: 8 additions & 8 deletions src/sage/algebras/quatalg/quaternion_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -1321,7 +1321,7 @@ def __init__(self, A, basis, check=True):
# has rank 4
V = A.base_ring()**4
if V.span([ V(x.coefficient_tuple()) for x in basis]).dimension() != 4:
raise ValueError, "basis must have rank 4"
raise ValueError("basis must have rank 4")

# The additional checks will work over QQ and over number fields,
# but we can't actually do much with an order defined over a number
Expand All @@ -1332,13 +1332,13 @@ def __init__(self, A, basis, check=True):
v = M.solve_left(V([1,0,0,0]))

if v.denominator() != 1:
raise ValueError, "lattice must contain 1"
raise ValueError("lattice must contain 1")

# check if multiplicatively closed
M1 = basis_for_quaternion_lattice(basis)
M2 = basis_for_quaternion_lattice(list(basis) + [ x*y for x in basis for y in basis])
if M1 != M2:
raise ValueError, "given lattice must be a ring"
raise ValueError("given lattice must be a ring")

if A.base_ring() != QQ: # slow code over number fields (should eventually use PARI's nfhnf)
O = None
Expand All @@ -1352,13 +1352,13 @@ def __init__(self, A, basis, check=True):
v = M.solve_left(V([1,0,0,0]))

if any([ not a in O for a in v]):
raise ValueError, "lattice must contain 1"
raise ValueError("lattice must contain 1")

# check if multiplicatively closed
Y = matrix(QQ, 16, 4, [ (x*y).coefficient_tuple() for x in basis for y in basis])
X = M.solve_left(Y)
if any([ not a in O for x in X for a in x ]):
raise ValueError, "given lattice must be a ring"
raise ValueError("given lattice must be a ring")

self.__basis = basis
self.__quaternion_algebra = A
Expand Down Expand Up @@ -2857,15 +2857,15 @@ def maxord_solve_aux_eq(a, b, p):
... assert mod(1 - a*y^2 - b*z^2 + a*b*w^2, 4) == 0
"""
if p != ZZ(2):
raise NotImplementedError, "Algorithm only implemented over ZZ at the moment"
raise NotImplementedError("Algorithm only implemented over ZZ at the moment")

v_a = a.valuation(p)
v_b = b.valuation(p)

if v_a != 0:
raise RuntimeError, "a must have v_p(a)=0"
raise RuntimeError("a must have v_p(a)=0")
if v_b != 0 and v_b != 1:
raise RuntimeError, "b must have v_p(b) in {0,1}"
raise RuntimeError("b must have v_p(b) in {0,1}")

R = ZZ.quo(ZZ(4))
lut = {
Expand Down
2 changes: 1 addition & 1 deletion src/sage/algebras/steenrod/steenrod_algebra.py
Original file line number Diff line number Diff line change
Expand Up @@ -2895,7 +2895,7 @@ def top_class(self):
True
"""
if not self.is_finite():
raise ValueError, "the algebra is not finite dimensional"
raise ValueError("the algebra is not finite dimensional")
p = self.prime()
# we create the top class in the Milnor basis version
AM = SteenrodAlgebra(basis='milnor', p=p)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/affine_weyl_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def affine_grassmannian_to_core(self):
from sage.combinat.partition import Partition
from sage.combinat.core import Core
if not self.is_affine_grassmannian() or not self.parent().cartan_type().letter == 'A':
raise ValueError, "Error! this only works on type 'A' affine Grassmannian elements"
raise ValueError("Error! this only works on type 'A' affine Grassmannian elements")
out = Partition([])
rword = self.reduced_word()
kp1 = self.parent().n
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/algebra_ideals.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def __init__(self, A):
"""
from sage.algebras.algebra import is_Algebra
if not is_Algebra(A): # A not in Algebras() ?
raise TypeError, "A (=%s) must be an algebra"%A
raise TypeError("A (=%s) must be an algebra"%A)
Category_ideal.__init__(self, A)

def algebra(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/algebra_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def __init__(self, A):
"""
from sage.categories.commutative_algebras import CommutativeAlgebras
if not hasattr(A, "base_ring") or not A in CommutativeAlgebras(A.base_ring()):
raise TypeError, "A (=%s) must be a commutative algebra"%A
raise TypeError("A (=%s) must be a commutative algebra"%A)
Category_module.__init__(self, A)

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/algebras_with_basis.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ def __invert__(self):
if len(mcs) == 1 and one in mcs:
return self.parent()( ~mcs[ one ] )
else:
raise ValueError, "cannot invert self (= %s)"%self
raise ValueError("cannot invert self (= %s)"%self)


class CartesianProducts(CartesianProductsCategory):
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def __init__(self, s=None):
self._label = s
self.__repr_object_names = s
else:
raise TypeError, "Argument string must be a string."
raise TypeError("Argument string must be a string.")
self.__class__ = dynamic_class("%s_with_category"%self.__class__.__name__,
(self.__class__, self.subcategory_class, ),
cache = False, reduction = None,
Expand Down Expand Up @@ -1545,7 +1545,7 @@ def meet(categories):
"""
categories = tuple(categories)
if len(categories) == 0:
raise ValueError, "The meet of an empty list of categories is not implemented"
raise ValueError("The meet of an empty list of categories is not implemented")
result = categories[0]
for category in categories[1:]:
result = result._meet_(category)
Expand Down Expand Up @@ -1894,7 +1894,7 @@ def base(self):
for C in self._all_super_categories_proper:
if isinstance(C,Category_over_base):
return C.base()
raise AttributeError, "This hom category has no base"
raise AttributeError("This hom category has no base")

def super_categories(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/classical_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def character(self, R=None):
if R == None:
R = WeylCharacterRing(self.cartan_type())
if not R.cartan_type() == self.cartan_type():
raise ValueError, "Weyl character ring does not have the right Cartan type"
raise ValueError("Weyl character ring does not have the right Cartan type")
assert R.basis().keys() == self.weight_lattice_realization()

return R.sum_of_monomials( x.weight() for x in self.highest_weight_vectors() )
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/commutative_algebra_ideals.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def __init__(self, A):
from sage.algebras.algebra import is_Algebra
from sage.rings.commutative_ring import is_CommutativeRing
if not (is_Algebra(A) and is_CommutativeRing(A)):
raise TypeError, "A (=%s) must be a commutative algebra"%A
raise TypeError("A (=%s) must be a commutative algebra"%A)
Category_in_ambient.__init__(self, A)

def algebra(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/commutative_ring_ideals.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, R):
sage: TestSuite(CommutativeRingIdeals(ZZ)).run()
"""
if R not in CommutativeRings():
raise TypeError, "R (=%s) must be a commutative ring"%R
raise TypeError("R (=%s) must be a commutative ring"%R)
Category_ideal.__init__(self, R)

def super_categories(self):
Expand Down
30 changes: 15 additions & 15 deletions src/sage/categories/coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,7 +386,7 @@ def simple_reflection(self, i):
"""
if not i in self.index_set():
raise ValueError, "%s is not in the Dynkin node set %s"%(i,self.index_set())
raise ValueError("%s is not in the Dynkin node set %s"%(i,self.index_set()))
return self.one().apply_simple_reflection(i) # don't care about left/right

@cached_method
Expand Down Expand Up @@ -487,7 +487,7 @@ def simple_projection(self, i, side = 'right', length_increasing = True, toward_
"""
if not (i in self.index_set() or i == 0):
raise ValueError, "%s is not 0 and not in the Dynkin node set %s"%(i, self.index_set())
raise ValueError("%s is not 0 and not in the Dynkin node set %s"%(i, self.index_set()))
if toward_max is not None:
deprecation("the toward_max option of CoxeterGroups.ParentMethods.simple_projection is deprecated; please use length_increasing instead", 'Sage Version 5.0')
length_increasing = toward_max
Expand Down Expand Up @@ -723,11 +723,11 @@ def has_descent(self, i, side = 'right', positive=False):
:meth:`.has_left_descent` and :meth:`.has_right_descent`.
"""
if not isinstance(positive, bool):
raise TypeError, "%s is not a boolean"%(bool)
raise TypeError("%s is not a boolean"%(bool))
if side == 'right':
return self.has_right_descent(i) != positive
if side != 'left':
raise ValueError, "%s is neither 'right' nor 'left'"%(side)
raise ValueError("%s is neither 'right' nor 'left'"%(side))
return self.has_left_descent(i) != positive

# @abstract_method(optional = True)
Expand Down Expand Up @@ -1657,7 +1657,7 @@ def bruhat_le(self, other):
"""
if not have_same_parent(self, other):
raise TypeError, "%s and %s do not have the same parent"%(self, other)
raise TypeError("%s and %s do not have the same parent"%(self, other))
# could first compare the length, when that information is cheap
desc = other.first_descent()
if desc is not None:
Expand Down Expand Up @@ -1721,7 +1721,7 @@ def weak_le(self, other, side = 'right'):
... assert u.permutohedron_lequal(v, side='left') == P4toW(u).weak_le(P4toW(v), side='left')
"""
if not have_same_parent(self, other):
raise TypeError, "%s and %s do not have the same parent"%(self,other)
raise TypeError("%s and %s do not have the same parent"%(self,other))
# could first compare the length, when that information is cheap
prefix_side = 'left' if side == 'right' else 'right'

Expand Down Expand Up @@ -1821,10 +1821,10 @@ def apply_demazure_product(self, element, side = 'right', length_increasing = Tr
if isinstance(element, (tuple)):
element = [x for x in element]
if not isinstance(element, (list)):
raise TypeError, "Bad Coxeter group element input: %s"%(element)
raise TypeError("Bad Coxeter group element input: %s"%(element))
I = self.parent().index_set()
if not all(i in I for i in element):
raise ValueError, "%s does not have all its members in the index set of the %s"%(element, self.parent())
raise ValueError("%s does not have all its members in the index set of the %s"%(element, self.parent()))
# the copy is so that if we need to reverse the list, the original will not
# get reversed
the_word = copy(element)
Expand Down Expand Up @@ -1862,10 +1862,10 @@ def min_demazure_product_greater(self, element):
# else require that ``element`` is a list or tuple of index_set elements
else:
if not isinstance(element, (tuple,list)):
raise TypeError, "Bad Coxeter group element input: %s"%(element)
raise TypeError("Bad Coxeter group element input: %s"%(element))
I = self.parent().index_set()
if not all(i in I for i in element):
raise ValueError, "%s does not have all its members in the index set of the %s"%(element, self.parent())
raise ValueError("%s does not have all its members in the index set of the %s"%(element, self.parent()))
the_word = element
for i in the_word:
if self.has_descent(i, side = 'left'):
Expand Down Expand Up @@ -1911,11 +1911,11 @@ def deodhar_factor_element(self, w, index_set):
"""

if self != self.coset_representative(index_set):
raise ValueError, "%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(self.reduced_word(),index_set)
raise ValueError("%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(self.reduced_word(),index_set))
if w != w.coset_representative(index_set):
raise ValueError, "%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(w.reduced_word(),index_set)
raise ValueError("%s is not of minimum length in its coset for the parabolic subgroup with index set %s"%(w.reduced_word(),index_set))
if not self.bruhat_le(w):
raise ValueError, "Must have %s <= %s"%(self.reduced_word(), w.reduced_word())
raise ValueError("Must have %s <= %s"%(self.reduced_word(), w.reduced_word()))
if w.is_one():
return w
i = w.first_descent(side = 'left')
Expand Down Expand Up @@ -1960,7 +1960,7 @@ def deodhar_lift_up(self, w, index_set):
vmin = self.coset_representative(index_set)
wmin = w.coset_representative(index_set)
if not vmin.bruhat_le(wmin):
raise ValueError, "Must have %s <= %s mod the parabolic subgroup with index set %s"%(self.reduced_word(), w.reduced_word(), index_set)
raise ValueError("Must have %s <= %s mod the parabolic subgroup with index set %s"%(self.reduced_word(), w.reduced_word(), index_set))
vJ = vmin.inverse() * self
dsp = vmin.deodhar_factor_element(wmin,index_set)
return wmin * vJ.min_demazure_product_greater(dsp)
Expand Down Expand Up @@ -1996,7 +1996,7 @@ def deodhar_lift_down(self, w, index_set):
vmin = self.coset_representative(index_set)
wmin = w.coset_representative(index_set)
if not wmin.bruhat_le(vmin):
raise ValueError, "Must have %s <= %s mod the parabolic subgroup with index set %s"%(w.reduced_word(), self.reduced_word(), index_set)
raise ValueError("Must have %s <= %s mod the parabolic subgroup with index set %s"%(w.reduced_word(), self.reduced_word(), index_set))

vJ = vmin.inverse() * self
dsp = wmin.deodhar_factor_element(vmin,index_set)
Expand Down
6 changes: 3 additions & 3 deletions src/sage/categories/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -427,7 +427,7 @@ def morphism(b):
if d is not None:
return d
else:
raise ValueError, "This is not a morphism!"
raise ValueError("This is not a morphism!")
#now we know that b is hw
return g(b)

Expand All @@ -448,7 +448,7 @@ def morphism(b):
eigx = getattr(morphism[x], f_string)([automorphism(i) for k in range(similarity_factor[i])])
if bool(eix is None) != bool(eigx is None):
# This is not a crystal morphism!
raise ValueError, "This is not a morphism!" #, print("x="x,"g(x)="g(x),"i="i)
raise ValueError("This is not a morphism!") #, print("x="x,"g(x)="g(x),"i="i)
if (eix is not None) and (eix not in known):
todo.add(eix)
known.add(eix)
Expand Down Expand Up @@ -1158,7 +1158,7 @@ def to_lowest_weight(self, index_set = None):
from sage.categories.highest_weight_crystals import HighestWeightCrystals
if index_set is None:
if HighestWeightCrystals() not in self.parent().categories():
raise ValueError, "This is not a highest weight crystals!"
raise ValueError("This is not a highest weight crystals!")
index_set = self.index_set()
for i in index_set:
next = self.f(i)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/categories/enumerated_sets.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ def __iter__(self):
elif self.list != self._list_default:
return self._iterator_from_list()
else:
raise NotImplementedError, "iterator called but not implemented"
raise NotImplementedError("iterator called but not implemented")

def cardinality(self):
"""
Expand All @@ -237,7 +237,7 @@ def cardinality(self):
...
NotImplementedError: unknown cardinality
"""
raise NotImplementedError, "unknown cardinality"
raise NotImplementedError("unknown cardinality")

def list(self):
"""
Expand All @@ -254,7 +254,7 @@ def list(self):
...
NotImplementedError: unknown cardinality
"""
raise NotImplementedError, "unknown cardinality"
raise NotImplementedError("unknown cardinality")
_list_default = list # needed by the check system.


Expand Down Expand Up @@ -334,7 +334,7 @@ def _unrank_from_iterator(self, r):
if counter == r:
return u
counter += 1
raise ValueError, "the value must be between %s and %s inclusive"%(0,counter-1)
raise ValueError("the value must be between %s and %s inclusive"%(0,counter-1))
unrank = _unrank_from_iterator

def _rank_from_iterator(self, x):
Expand Down Expand Up @@ -542,7 +542,7 @@ def random_element(self):
...
NotImplementedError: unknown cardinality
"""
raise NotImplementedError, "unknown cardinality"
raise NotImplementedError("unknown cardinality")

def map(self, f, name=None):
r"""
Expand Down
Loading

0 comments on commit 3279bdc

Please sign in to comment.