rem
stringlengths
1
322k
add
stringlengths
0
2.05M
context
stringlengths
4
228k
meta
stringlengths
156
215
raise ValueError, "%s is not a valid perfect matching: there are some repetitions"%p
raise ValueError, ("%s is not a valid perfect matching:\n" "there are some repetitions"%p)
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
506975ec24f2b785477b1f0c809db5be7b8d366e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/506975ec24f2b785477b1f0c809db5be7b8d366e/perfect_matching.py
or isinstance(p,sage.combinat.permutation.Permutation_class)):
or isinstance(p,Permutation_class)):
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
506975ec24f2b785477b1f0c809db5be7b8d366e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/506975ec24f2b785477b1f0c809db5be7b8d366e/perfect_matching.py
s="The permutation p (= %s) is not a fixpoint-free involution"%p raise ValueError,s
raise ValueError, ("The permutation p (= %s) is not a " "fixed point free involution"%p)
def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct our object.
506975ec24f2b785477b1f0c809db5be7b8d366e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/506975ec24f2b785477b1f0c809db5be7b8d366e/perfect_matching.py
if n == 1: return 1 for p in [2, 3, 5]: if n%p == 0: return p if bound == None: bound = n dif = [6, 4, 2, 4, 2, 4, 6, 2] m = 7; i = 1 while m <= bound and m*m <= n: if n%m == 0: return m m += dif[i%8] i += 1 return n
if bound is None: return ZZ(n).trial_division() else: return ZZ(n).trial_division(bound)
def trial_division(n, bound=None): """ Return the smallest prime divisor <= bound of the positive integer n, or n if there is no such prime. If the optional argument bound is omitted, then bound <= n. INPUT: - ``n`` - a positive integer - ``bound`` - (optional) a positive integer OUTPUT: - ``int`` - a prime p=bound that divides n, or n if there is no such prime. EXAMPLES:: sage: trial_division(15) 3 sage: trial_division(91) 7 sage: trial_division(11) 11 sage: trial_division(387833, 300) 387833 sage: # 300 is not big enough to split off a sage: # factor, but 400 is. sage: trial_division(387833, 400) 389 """ if n == 1: return 1 for p in [2, 3, 5]: if n%p == 0: return p if bound == None: bound = n dif = [6, 4, 2, 4, 2, 4, 6, 2] m = 7; i = 1 while m <= bound and m*m <= n: if n%m == 0: return m m += dif[i%8] i += 1 return n
1909947ff6cd628f3224b7a8721bb081a16527c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/1909947ff6cd628f3224b7a8721bb081a16527c1/arith.py
if n < 10000000000000: return factorization.Factorization(__factor_using_trial_division(n), unit)
def factor(n, proof=None, int_=False, algorithm='pari', verbose=0, **kwds): """ Returns the factorization of n. The result depends on the type of n. If n is an integer, factor returns the factorization of the integer n as an object of type Factorization. If n is not an integer, ``n.factor(proof=proof, **kwds)`` gets called. See ``n.factor??`` for more documentation in this case. .. warning:: This means that applying factor to an integer result of a symbolic computation will not factor the integer, because it is considered as an element of a larger symbolic ring. EXAMPLE:: sage: f(n)=n^2 sage: is_prime(f(3)) False sage: factor(f(3)) 9 INPUT: - ``n`` - an nonzero integer - ``proof`` - bool or None (default: None) - ``int_`` - bool (default: False) whether to return answers as Python ints - ``algorithm`` - string - ``'pari'`` - (default) use the PARI c library - ``'kash'`` - use KASH computer algebra system (requires the optional kash package be installed) - ``'magma'`` - use Magma (requires magma be installed) - ``verbose`` - integer (default 0); pari's debug variable is set to this; e.g., set to 4 or 8 to see lots of output during factorization. OUTPUT: factorization of n The qsieve and ecm commands give access to highly optimized implementations of algorithms for doing certain integer factorization problems. These implementations are not used by the generic factor command, which currently just calls PARI (note that PARI also implements sieve and ecm algorithms, but they aren't as optimized). Thus you might consider using them instead for certain numbers. The factorization returned is an element of the class :class:`~sage.structure.factorization.Factorization`; see Factorization?? for more details, and examples below for usage. A Factorization contains both the unit factor (+1 or -1) and a sorted list of (prime, exponent) pairs. The factorization displays in pretty-print format but it is easy to obtain access to the (prime,exponent) pairs and the unit, to recover the number from its factorization, and even to multiply two factorizations. See examples below. EXAMPLES:: sage: factor(500) 2^2 * 5^3 sage: factor(-20) -1 * 2^2 * 5 sage: f=factor(-20) sage: list(f) [(2, 2), (5, 1)] sage: f.unit() -1 sage: f.value() -20 :: sage: factor(-500, algorithm='kash') # optional - kash -1 * 2^2 * 5^3 :: sage: factor(-500, algorithm='magma') # optional - magma -1 * 2^2 * 5^3 :: sage: factor(0) Traceback (most recent call last): ... ArithmeticError: Prime factorization of 0 not defined. sage: factor(1) 1 sage: factor(-1) -1 sage: factor(2^(2^7)+1) 59649589127497217 * 5704689200685129054721 Sage calls PARI's factor, which has proof False by default. Sage has a global proof flag, set to True by default (see :mod:`sage.structure.proof.proof`, or proof.[tab]). To override the default, call this function with proof=False. :: sage: factor(3^89-1, proof=False) 2 * 179 * 1611479891519807 * 5042939439565996049162197 :: sage: factor(2^197 + 1) # takes a long time (e.g., 3 seconds!) 3 * 197002597249 * 1348959352853811313 * 251951573867253012259144010843 Any object which has a factor method can be factored like this:: sage: K.<i> = QuadraticField(-1) sage: factor(122+454*i) (-i) * (3*i - 2) * (4*i + 1) * (i + 1)^3 * (2*i + 1)^3 To access the data in a factorization:: sage: f = factor(420); f 2^2 * 3 * 5 * 7 sage: [x for x in f] [(2, 2), (3, 1), (5, 1), (7, 1)] sage: [p for p,e in f] [2, 3, 5, 7] sage: [e for p,e in f] [2, 1, 1, 1] sage: [p^e for p,e in f] [4, 3, 5, 7] """ if not isinstance(n, (int,long, integer.Integer)): # this happens for example if n = x**2 + y**2 + 2*x*y try: return n.factor(proof=proof, **kwds) except AttributeError: raise TypeError, "unable to factor n" except TypeError: # just in case factor method doesn't have a proof option. try: return n.factor(**kwds) except AttributeError: raise TypeError, "unable to factor n" #n = abs(n) n = ZZ(n) if n < 0: unit = ZZ(-1) n = -n else: unit = ZZ(1) if n == 0: raise ArithmeticError, "Prime factorization of 0 not defined." if n == 1: return factorization.Factorization([], unit) #if n < 10000000000: return __factor_using_trial_division(n) if algorithm == 'pari': return factorization.Factorization(__factor_using_pari(n, int_=int_, debug_level=verbose, proof=proof), unit) elif algorithm in ['kash', 'magma']: if algorithm == 'kash': from sage.interfaces.all import kash as I else: from sage.interfaces.all import magma as I F = I.eval('Factorization(%s)'%n) i = F.rfind(']') + 1 F = F[:i] F = F.replace("<","(").replace(">",")") F = eval(F) if not int_: F = [(ZZ(a), ZZ(b)) for a,b in F] return factorization.Factorization(F, unit) else: raise ValueError, "Algorithm is not known"
1909947ff6cd628f3224b7a8721bb081a16527c1 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/1909947ff6cd628f3224b7a8721bb081a16527c1/arith.py
img = self(letter)
img = self.image(letter)
def is_identity(self): r""" Returns ``True`` if ``self`` is the identity morphism.
a02ef8734bf7def52aae8584f83e57b8d08f22b2 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/a02ef8734bf7def52aae8584f83e57b8d08f22b2/morphism.py
if polynomial not in self.coordinate_ring():
S = self.coordinate_ring() try: polynomial = S(polynomial) except TypeError:
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
efd25a3ebdf406120dec50c4c26fe9f3351fe4f7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/efd25a3ebdf406120dec50c4c26fe9f3351fe4f7/toric_variety.py
polynomial = polynomial.lift()
polynomial = S(polynomial.lift())
def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous.
efd25a3ebdf406120dec50c4c26fe9f3351fe4f7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/efd25a3ebdf406120dec50c4c26fe9f3351fe4f7/toric_variety.py
Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
Returns the intermediate shape of the pm diagram (inner shape plus positions of plusses)
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
6c0695d12431335aa2bfe89584352810a25e3ee9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/6c0695d12431335aa2bfe89584352810a25e3ee9/kirillov_reshetikhin.py
p = p + [0,0]
p = p + [0 for i in range(self.n)]
def intermediate_shape(self): """ Returns the intermediate shape of the pm diagram (innner shape plus positions of plusses)
6c0695d12431335aa2bfe89584352810a25e3ee9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/6c0695d12431335aa2bfe89584352810a25e3ee9/kirillov_reshetikhin.py
([0], [0])
([0], [])
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
66553ffc1b1efb77e8a1bb1e26d0ad20bc27d613 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/66553ffc1b1efb77e8a1bb1e26d0ad20bc27d613/generic_graph.py
return [s],[s]
return [s],[]
def blocks_and_cut_vertices(self): """ Computes the blocks and cut vertices of the graph. In the case of a digraph, this computation is done on the underlying graph.
66553ffc1b1efb77e8a1bb1e26d0ad20bc27d613 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/66553ffc1b1efb77e8a1bb1e26d0ad20bc27d613/generic_graph.py
f_l_dict = {(None,None):[(tuple([x]),tuple(self._vertex_face_indexset([x])))
f_l_dict = {(None,tuple(range(self.n_Hrepresentation()))):[(tuple([x]),tuple(self._vertex_face_indexset([x])))
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
4a7ca14d8f9d7917c5ad12ea9248edc9b905a5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/4a7ca14d8f9d7917c5ad12ea9248edc9b905a5a9/polyhedra.py
tuple(range(self.n_Hrepresentation()))))
None))
def face_lattice(self): """ Computes the face-lattice poset. Elements are tuples of (vertices, facets) - i.e. this keeps track of both the vertices in each face, and all the facets containing them.
4a7ca14d8f9d7917c5ad12ea9248edc9b905a5a9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/4a7ca14d8f9d7917c5ad12ea9248edc9b905a5a9/polyhedra.py
Computes the matching polynomial of the graph G. The algorithm used is a recursive one, based on the following observation: - If e is an edge of G, G' is the result of deleting the edge e, and G'' is the result of deleting each vertex in e, then the matching polynomial of G is equal to that of G' minus that of G''.
Computes the matching polynomial of the graph `G`. If `p(G, k)` denotes the number of `k`-matchings (matchings with `k` edges) in `G`, then the matching polynomial is defined as [Godsil93]_: .. MATH:: \mu(x)=\sum_{k \geq 0} (-1)^k p(G,k) x^{n-2k}
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
4c721a892902bc64cad5d959527b136a5da04e86 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/4c721a892902bc64cad5d959527b136a5da04e86/graph.py
- ``complement`` - (default: True) whether to use a simple formula to compute the matching polynomial from that of the graphs complement
- ``complement`` - (default: ``True``) whether to use Godsil's duality theorem to compute the matching polynomial from that of the graphs complement (see ALGORITHM).
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
4c721a892902bc64cad5d959527b136a5da04e86 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/4c721a892902bc64cad5d959527b136a5da04e86/graph.py
NOTE: The ``complement`` option uses matching polynomials of complete graphs, which are cached. So if you are crazy enough to try computing the matching polynomial on a graph with millions of vertices, you might not want to use this option, since it will end up caching millions of polynomials of degree in the millions.
def matching_polynomial(self, complement=True, name=None): """ Computes the matching polynomial of the graph G.
4c721a892902bc64cad5d959527b136a5da04e86 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/4c721a892902bc64cad5d959527b136a5da04e86/graph.py
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U
sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU
def _repr_(self): """ The printing representation of self.
93d00d87298094b75a6c29b10f58d2febbb42793 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/93d00d87298094b75a6c29b10f58d2febbb42793/free_module.py
sage: V = VectorSpace(QQ,5,sparse=True) sage: U = V.submodule([ V.gen(i) - V.gen(0) for i in range(1,5) ]) sage: print U
sage: VV = VectorSpace(QQ,5,sparse=True) sage: UU = VV.submodule([ VV.gen(i) - VV.gen(0) for i in range(1,5) ]) sage: print UU
def _repr_(self): """ The default printing representation of self.
93d00d87298094b75a6c29b10f58d2febbb42793 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/93d00d87298094b75a6c29b10f58d2febbb42793/free_module.py
- ``triangular`` a boolean (default: False)
- ``triangular`` - "upper" or "lower" or None - "upper": if the `leading_support()` of the image of `F(i)` is `i`, or - "lower": if the `trailing_support()` of the image of `F(i)` is `i`.
def module_morphism(self, on_basis = None, diagonal = None, triangular = None, **keywords): r""" Constructs morphisms by linearity
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, ``cmp(x,y)``, can be provided. This should return a negative value if `x < y`, `0` if `x == y` and a positive value if `x > y`.
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, ``cmp(x,y)``, can be provided. This should return a negative value if `x < y`, `0` if `x == y` and a positive value if `x > y`.
def leading_item(self, cmp=None): r""" Returns the pair ``(k, c)`` where ``c`` * (the basis elt. indexed by ``k``) is the leading term of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
def leading_monomial(self, cmp=None): r""" Returns the leading monomial of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
def leading_coefficient(self, cmp=None): r""" Returns the leading coefficient of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
maximal. Note that this may not be the term which actually appears first when ``self`` is printed. If the default term ordering is not what is desired, a comparison function, cmp(x,y), can be provided.
def leading_term(self, cmp=None): r""" Returns the leading term of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
def trailing_item(self, cmp=None): r""" Returns the pair ``(c, k)`` where ``c*self.parent().monomial(k)`` is the trailing term of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
def trailing_monomial(self, cmp=None): r""" Returns the trailing monomial of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
def trailing_coefficient(self, cmp=None): r""" Returns the trailing coefficient of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
minimal. Note that this may not be the term which actually appears last when ``self`` is printed. If the default term ordering is not what is desired, a comparison function cmp(x,y), can be provided.
def trailing_term(self, cmp=None): r""" Returns the trailing term of ``self``.
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
implements operations on elements of tensor products of Hopf algebras
implements operations on elements of tensor products of modules with basis
def extra_super_categories(self): """ EXAMPLES::
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
- ``domain`` - a modules with basis `F` - ``codomain`` - a modules with basis `G` (defaults to `F`)
- ``domain`` - a module with basis `F` - ``codomain`` - a module with basis `G` (defaults to `F`)
sage: def phi_on_basis(i): return Y.monomial(abs(i))
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
elements of `G`
elements of `G` which describes the morphism
sage: def phi_on_basis(i): return Y.monomial(abs(i))
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
J\mapsto I` with the folowing property: for any `j\in J` the function ``inverse_on_support`` should returns a `i\in I` such that the leading term of ``on_basis(i)`` is `j` if there exists such a `i` or ``None`` if not.
J\mapsto I` with the following property: for any `j\in J`, `r(j)` should return an `i\in I` such that the leading term of ``on_basis(i)`` is `j` if there exists such a `i` or ``None`` if not.
sage: def phi_on_basis(i): return Y.monomial(abs(i))
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
AssertionError: morphims is not triangular on 1
AssertionError: morphism is not triangular on 1
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
AssertionError: morphims is not untriangular on 1
AssertionError: morphism is not untriangular on 1
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
LazyFormat("morphims is not untriangular on %s")%(x))
LazyFormat("morphism is not untriangular on %s")%(x))
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
LazyFormat("morphims is not triangular on %s")%(x))
LazyFormat("morphism is not triangular on %s")%(x))
def _test_triangular(self, **options): """ Tests that ``self`` is actually triangular
af11dfe919a0b487f6e716e60a01a0379a53e463 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/af11dfe919a0b487f6e716e60a01a0379a53e463/modules_with_basis.py
Mtrans = Matrix(k, 2, M2)*M1inv
Mtrans = Matrix(k, 2, M2)*Maux*M1inv assert Mtrans[1][0] in N
def is_Gamma0_equivalent(self, other, N, Transformation=False): r""" Checks if cusps ``self`` and ``other`` are `\Gamma_0(N)`- equivalent.
a02baf9d13bfb8ae48b58758ffddff1b6984bb15 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/a02baf9d13bfb8ae48b58758ffddff1b6984bb15/cusps_nf.py
Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
Returns the Hasse invariant of this elliptic curve. OUTPUT: The Hasse invariant of this elliptic curve, as an element of the base field. This is only defined over fields of positive characteristic, and is an element of the field which is zero if and only if the curve is supersingular. Over a field of characteristic zero, where the Hasse invariant is undefined, a ``ValueError`` is returned.
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
00919aca0a5b8b25eb1f25b0bc8015a983875bee /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/00919aca0a5b8b25eb1f25b0bc8015a983875bee/ell_field.py
return self.a2()+self.a1()**2
return self.b2() elif p == 5: return self.c4() elif p == 7: return -self.c6()
def hasse_invariant(self): r""" Returns the Hasse invariant of an elliptic curve over a field of positive characteristic, which is an element of the field.
00919aca0a5b8b25eb1f25b0bc8015a983875bee /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/00919aca0a5b8b25eb1f25b0bc8015a983875bee/ell_field.py
cones = tuple(tuple(new_fan_rays.index(cone_polytope.vertex(v)) for v in range(cone_polytope.nvertices() - 1))
cones = tuple(tuple(sorted(new_fan_rays.index(cone_polytope.vertex(v)) for v in range(cone_polytope.nvertices() - 1)))
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
53c47f6547ed2825820604f44bf9468604c2ef0f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/53c47f6547ed2825820604f44bf9468604c2ef0f/fan.py
for cone, polytope in zip(fan.generating_cones(), cone_polytopes): cone._lattice_polytope = polytope
def _subdivide_palp(self, new_rays, verbose): r""" Subdivide ``self`` adding ``new_rays`` one by one.
53c47f6547ed2825820604f44bf9468604c2ef0f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/53c47f6547ed2825820604f44bf9468604c2ef0f/fan.py
def parse_deps(self, filename, verify=True):
def parse_deps(self, filename, ext_module, verify=True):
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
if filename[-4:] not in ('.pyx', '.pxd', '.pxi'):
if not is_cython_file(filename):
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
for idir in CYTHON_INCLUDE_DIRS: new_path = os.path.normpath(idir + base_dependency_name)
for idir in ext_module.include_dirs + CYTHON_INCLUDE_DIRS + include_dirs + extra_include_dirs: new_path = os.path.normpath(idir + '/' + base_dependency_name)
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
if path[-2:] != '.h': raise IOError, "could not find dependency %s included in %s."%(path, filename)
msg = 'could not find dependency %s included in %s.'%(path, filename) if is_cython_file(filename): raise IOError, msg else: warnings.warn(msg+' I will assume it is a system C/C++ header.')
def parse_deps(self, filename, verify=True): """ Open a Cython file and extract all of its dependencies.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
def immediate_deps(self, filename):
def immediate_deps(self, filename, ext_module):
def immediate_deps(self, filename): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
self._deps[filename] = self.parse_deps(filename)
self._deps[filename] = self.parse_deps(filename, ext_module)
def immediate_deps(self, filename): """ Returns a list of files directly referenced by this file. """ if (filename not in self._deps or self.timestamp(filename) < self._last_parse[filename]): self._deps[filename] = self.parse_deps(filename) self._last_parse[filename] = self.timestamp(filename) return self._deps[filename]
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
def all_deps(self, filename, path=None):
def all_deps(self, filename, ext_module, path=None):
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
for f in self.immediate_deps(filename):
for f in self.immediate_deps(filename, ext_module):
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
deps.update(self.all_deps(f, path))
deps.update(self.all_deps(f, ext_module, path))
def all_deps(self, filename, path=None): """ Returns all files directly or indirectly referenced by this file.
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
def newest_dep(self, filename):
def newest_dep(self, filename, ext_module):
def newest_dep(self, filename): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
for f in self.all_deps(filename):
for f in self.all_deps(filename, ext_module):
def newest_dep(self, filename): """ Returns the most recently modified file that filename depends on, along with its timestamp. """ nfile = filename ntime = self.timestamp(filename) for f in self.all_deps(filename): if self.timestamp(f) > ntime: nfile = f ntime = self.timestamp(f) return nfile, ntime
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
dep_file, dep_time = deps.newest_dep(f)
dep_file, dep_time = deps.newest_dep(f,m)
def compile_command_list(ext_modules, deps): """ Computes a list of commands needed to compile and link the extension modules given in 'ext_modules' """ queue_compile_high = [] queue_compile_med = [] queue_compile_low = [] for m in ext_modules: new_sources = [] for f in m.sources: if f.endswith('.pyx'): dep_file, dep_time = deps.newest_dep(f) dest_file = "%s/%s"%(SITE_PACKAGES, f) dest_time = deps.timestamp(dest_file) if dest_time < dep_time: if dep_file == f: print "Building modified file %s."%f queue_compile_high.append([compile_command, (f,m)]) elif dep_file == (f[:-4] + '.pxd'): print "Building %s because it depends on %s."%(f, dep_file) queue_compile_med.append([compile_command, (f,m)]) else: print "Building %s because it depends on %s."%(f, dep_file) queue_compile_low.append([compile_command, (f,m)]) new_sources.append(process_filename(f, m)) m.sources = new_sources return queue_compile_high + queue_compile_med + queue_compile_low
031b02486f3aa60bbe6ec46c81307116288d5734 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/031b02486f3aa60bbe6ec46c81307116288d5734/setup.py
- ``legend_*`` - all the options valid for :meth:`set_legend_options` prefixed with 'legend_'
- ``legend_*`` - all the options valid for :meth:`set_legend_options` prefixed with ``legend_``
def show(self, **kwds): """ Show this graphics image with the default image viewer.
a0df834220102bf467dbfeceb037a622a91e77dd /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/a0df834220102bf467dbfeceb037a622a91e77dd/plot.py
sage: import operator
def derivative(self, ex, operator): """ EXAMPLES::
ee7089955f50de0b72b5ffc6bb539e38bec10f0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/ee7089955f50de0b72b5ffc6bb539e38bec10f0c/expression_conversions.py
sage: a = function('f', x).diff(x); a
sage: f = function('f') sage: a = f(x).diff(x); a
def derivative(self, ex, operator): """ EXAMPLES::
ee7089955f50de0b72b5ffc6bb539e38bec10f0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/ee7089955f50de0b72b5ffc6bb539e38bec10f0c/expression_conversions.py
sage: b = function('f', x).diff(x).diff(x)
sage: b = f(x).diff(x, x)
def derivative(self, ex, operator): """ EXAMPLES::
ee7089955f50de0b72b5ffc6bb539e38bec10f0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/ee7089955f50de0b72b5ffc6bb539e38bec10f0c/expression_conversions.py
args = ex.args()
args = ex.operands()
def derivative(self, ex, operator): """ EXAMPLES::
ee7089955f50de0b72b5ffc6bb539e38bec10f0c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/ee7089955f50de0b72b5ffc6bb539e38bec10f0c/expression_conversions.py
EXAMPLES:
EXAMPLES::
def overlap_partition(self, other, delay=0, p=None, involution=None) : r""" Returns the partition of the alphabet induced by the overlap of self and other with the given delay.
00735ad72bef5212475bba51cf8ccb87f508a3dc /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/00735ad72bef5212475bba51cf8ccb87f508a3dc/word.py
""" Enumerates projective, rational points on scheme X of height up to bound B.
r""" Enumerates projective, rational points on scheme ``X`` of height up to bound ``B``.
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound
- ``X`` - a scheme or set of abstract rational points of a scheme; - ``B`` - a positive integer bound.
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- a list containing the projective points of X of height up to B, sorted.
- a list containing the projective points of ``X`` of height up to ``B``, sorted.
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
[(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)]
[(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)]
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
of projective space to see if they lie on X.
of projective space to see if they lie on ``X``.
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
John Cremona and Charlie Turner (06-2010)
- John Cremona and Charlie Turner (06-2010)
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)]) pts =[] for c in cartesian_product_iterator([srange(-B,B+1) for _ in range(n+1)]): if gcd(c)==1 and c>zero:
n = X.codomain().ambient_space().ngens() zero = (0,) * n pts = [] for c in cartesian_product_iterator([srange(-B,B+1) for _ in range(n)]): if gcd(c) == 1 and c > zero:
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
except:
except TypeError:
def enum_projective_rational_field(X,B): """ Enumerates projective, rational points on scheme X of height up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme. - ``B`` - a positive integer bound OUTPUT: - a list containing the projective points of X of height up to B, sorted. EXAMPLES:: sage: P.<X,Y,Z> = ProjectiveSpace(2,QQ) sage: C = P.subscheme([X+Y-Z]) sage: from sage.schemes.generic.rational_point import enum_projective_rational_field sage: enum_projective_rational_field(C(QQ),6) [(-5 : 6 : 1), (-4 : 5 : 1), (-3 : 4 : 1), (-2 : 3 : 1), (-3/2 : 5/2 : 1), (-1 : 1 : 0), (-1 : 2 : 1), (-2/3 : 5/3 : 1), (-1/2 : 3/2 : 1), (-1/3 : 4/3 : 1), (-1/4 : 5/4 : 1), (-1/5 : 6/5 : 1), (0 : 1 : 1), (1/6 : 5/6 : 1), (1/5 : 4/5 : 1), (1/4 : 3/4 : 1), (1/3 : 2/3 : 1), (2/5 : 3/5 : 1), (1/2 : 1/2 : 1), (3/5 : 2/5 : 1), (2/3 : 1/3 : 1), (3/4 : 1/4 : 1), (4/5 : 1/5 : 1), (5/6 : 1/6 : 1), (1 : 0 : 1), (6/5 : -1/5 : 1), (5/4 : -1/4 : 1), (4/3 : -1/3 : 1), (3/2 : -1/2 : 1), (5/3 : -2/3 : 1), (2 : -1 : 1), (5/2 : -3/2 : 1), (3 : -2 : 1), (4 : -3 : 1), (5 : -4 : 1), (6 : -5 : 1)] sage: enum_projective_rational_field(C,6) == enum_projective_rational_field(C(QQ),6) True :: sage: P3.<W,X,Y,Z> = ProjectiveSpace(3,QQ) sage: enum_projective_rational_field(P3,1) [(-1 : -1 : -1 : 1), (-1 : -1 : 0 : 1), (-1 : -1 : 1 : 0), (-1 : -1 : 1 : 1), (-1 : 0 : -1 : 1), (-1 : 0 : 0 : 1), (-1 : 0 : 1 : 0), (-1 : 0 : 1 : 1), (-1 : 1 : -1 : 1), (-1 : 1 : 0 : 0), (-1 : 1 : 0 : 1), (-1 : 1 : 1 : 0), (-1 : 1 : 1 : 1), (0 : -1 : -1 : 1), (0 : -1 : 0 : 1), (0 : -1 : 1 : 0), (0 : -1 : 1 : 1), (0 : 0 : -1 : 1), (0 : 0 : 0 : 1), (0 : 0 : 1 : 0), (0 : 0 : 1 : 1), (0 : 1 : -1 : 1), (0 : 1 : 0 : 0), (0 : 1 : 0 : 1), (0 : 1 : 1 : 0), (0 : 1 : 1 : 1), (1 : -1 : -1 : 1), (1 : -1 : 0 : 1), (1 : -1 : 1 : 0), (1 : -1 : 1 : 1), (1 : 0 : -1 : 1), (1 : 0 : 0 : 0), (1 : 0 : 0 : 1), (1 : 0 : 1 : 0), (1 : 0 : 1 : 1), (1 : 1 : -1 : 1), (1 : 1 : 0 : 0), (1 : 1 : 0 : 1), (1 : 1 : 1 : 0), (1 : 1 : 1 : 1)] ALGORITHM: We just check all possible projective points in correct dimension of projective space to see if they lie on X. AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 zero=tuple([0 for _ in range(n+1)])
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B.
Enumerates affine rational points on scheme ``X`` (defined over `\QQ`) up to bound ``B``.
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound
- ``X`` - a scheme or set of abstract rational points of a scheme; - ``B`` - a positive integer bound.
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- a list containing the affine points of X of height up to B, sorted.
- a list containing the affine points of ``X`` of height up to ``B``, sorted.
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010)
AUTHORS: - David R. Kohel <[email protected]>: original version. - Charlie Turner (06-2010): small adjustments.
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ]
Q = range(1, B + 1) R = [ 0 ] + [ s*k for k in range(1, B+1) for s in [1, -1] ]
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
P = [ 0 for _ in range(n) ]
P = [0] * n
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
except:
except TypeError:
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
[ iters[j].next() for j in range(n) ]
for it in iters: it.next()
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0)
def enum_affine_rational_field(X,B): """ Enumerates affine rational points on scheme X (defined over `\QQ`) up to bound B. INPUT: - ``X`` - a scheme or set of abstract rational points of a scheme - ``B`` - a positive integer bound OUTPUT: - a list containing the affine points of X of height up to B, sorted. EXAMPLES:: sage: A.<x,y,z> = AffineSpace(3,QQ) sage: from sage.schemes.generic.rational_point import enum_affine_rational_field sage: enum_affine_rational_field(A(QQ),1) [(-1, -1, -1), (-1, -1, 0), (-1, -1, 1), (-1, 0, -1), (-1, 0, 0), (-1, 0, 1), (-1, 1, -1), (-1, 1, 0), (-1, 1, 1), (0, -1, -1), (0, -1, 0), (0, -1, 1), (0, 0, -1), (0, 0, 0), (0, 0, 1), (0, 1, -1), (0, 1, 0), (0, 1, 1), (1, -1, -1), (1, -1, 0), (1, -1, 1), (1, 0, -1), (1, 0, 0), (1, 0, 1), (1, 1, -1), (1, 1, 0), (1, 1, 1)] :: sage: A.<w,x,y,z> = AffineSpace(4,QQ) sage: S = A.subscheme([x^2-y*z+3,w^3+z+y^2]) sage: enum_affine_rational_field(S(QQ),2) [] sage: enum_affine_rational_field(S(QQ),3) [(-2, 0, -3, -1)] :: sage: A.<x,y> = AffineSpace(2,QQ) sage: C = Curve(x^2+y-x) sage: enum_affine_rational_field(C,10) [(-2, -6), (-1, -2), (0, 0), (1, 0), (2, -2), (3, -6)] AUTHOR: David R. Kohel <[email protected]> (small adjustments by Charlie Turner 06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens() if X.value_ring() is ZZ: Q = [ 1 ] else: # rational field Q = [ k+1 for k in range(B) ] R = [ 0 ] + [ s*k for k in range(1,B+1) for s in [1,-1] ] pts = [] P = [ 0 for _ in range(n) ] m = ZZ(0) try: pts.append(X(P)) except: pass iters = [ iter(R) for _ in range(n) ] [ iters[j].next() for j in range(n) ] i = 0 while i < n: try: a = ZZ(iters[i].next()) m = m.gcd(a) P[i] = a for b in Q: if m.gcd(b) == 1: try: pts.append(X([ num/b for num in P ])) except: pass i = 0 m = ZZ(0) except StopIteration: iters[i] = iter(R) # reset P[i] = iters[i].next() # reset P[i] to 0 and increment i += 1 pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
Enumerates projective points on scheme X defined over a finite field
Enumerates projective points on scheme ``X`` defined over a finite field.
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme
- ``X`` - a scheme defined over a finite field or a set of abstract rational points of such a scheme.
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
- a list containing the projective points of X over the finite field, sorted
- a list containing the projective points of ``X`` over the finite field, sorted.
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010)
.. WARNING:: If ``X`` is defined over an infinite field, this code will not finish! AUTHORS: - John Cremona and Charlie Turner (06-2010).
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
except:
except TypeError:
def enum_projective_finite_field(X): """ Enumerates projective points on scheme X defined over a finite field INPUT: - ``X`` - a scheme defined over a finite field or set of abstract rational points of such a scheme OUTPUT: - a list containing the projective points of X over the finite field, sorted EXAMPLES:: sage: F = GF(53) sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: from sage.schemes.generic.rational_point import enum_projective_finite_field sage: len(enum_projective_finite_field(P(F))) 2863 sage: 53^2+53+1 2863 :: sage: F = GF(9,'a') sage: P.<X,Y,Z> = ProjectiveSpace(2,F) sage: C = Curve(X^3-Y^3+Z^2*Y) sage: enum_projective_finite_field(C(F)) [(0 : 0 : 1), (0 : 1 : 1), (0 : 2 : 1), (1 : 1 : 0), (a + 1 : 2*a : 1), (a + 1 : 2*a + 1 : 1), (a + 1 : 2*a + 2 : 1), (2*a + 2 : a : 1), (2*a + 2 : a + 1 : 1), (2*a + 2 : a + 2 : 1)] :: sage: F = GF(5) sage: P2F.<X,Y,Z> = ProjectiveSpace(2,F) sage: enum_projective_finite_field(P2F) [(0 : 0 : 1), (0 : 1 : 0), (0 : 1 : 1), (0 : 2 : 1), (0 : 3 : 1), (0 : 4 : 1), (1 : 0 : 0), (1 : 0 : 1), (1 : 1 : 0), (1 : 1 : 1), (1 : 2 : 1), (1 : 3 : 1), (1 : 4 : 1), (2 : 0 : 1), (2 : 1 : 0), (2 : 1 : 1), (2 : 2 : 1), (2 : 3 : 1), (2 : 4 : 1), (3 : 0 : 1), (3 : 1 : 0), (3 : 1 : 1), (3 : 2 : 1), (3 : 3 : 1), (3 : 4 : 1), (4 : 0 : 1), (4 : 1 : 0), (4 : 1 : 1), (4 : 2 : 1), (4 : 3 : 1), (4 : 4 : 1)] ALGORITHM: Checks all points in projective space to see if they lie on X. NOTE: Warning:if X given as input is defined over an infinite field then this code will not finish! AUTHORS: John Cremona and Charlie Turner (06-2010) """ if is_Scheme(X): X = X(X.base_ring()) n = X.codomain().ambient_space().ngens()-1 F = X.value_ring() pts = [] for k in range(n+1): for c in cartesian_product_iterator([F for _ in range(k)]): try: pts.append(X(list(c)+[1]+[0]*(n-k))) except: pass pts.sort() return pts
7437114fd97818d63a9f0b766fecf0fb34f4f16c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7437114fd97818d63a9f0b766fecf0fb34f4f16c/rational_point.py
return matrix_space.MatrixSpace(ring, n, n, sparse).identity_matrix()
return matrix_space.MatrixSpace(ring, n, n, sparse)(1)
def identity_matrix(ring, n=0, sparse=False): r""" Return the `n \times n` identity matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = identity_matrix(QQ, 2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = identity_matrix(2); M [1 0] [0 1] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Integer Ring sage: M = identity_matrix(3, sparse=True); M [1 0 0] [0 1 0] [0 0 1] sage: M.parent() Full MatrixSpace of 3 by 3 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): n = ring ring = rings.ZZ return matrix_space.MatrixSpace(ring, n, n, sparse).identity_matrix()
5867b3c6276b57244559fd7541b14eaa9e59e477 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/5867b3c6276b57244559fd7541b14eaa9e59e477/constructor.py
return matrix_space.MatrixSpace(ring, nrows, ncols, sparse).zero_matrix()
return matrix_space.MatrixSpace(ring, nrows, ncols, sparse)(0)
def zero_matrix(ring, nrows, ncols=None, sparse=False): r""" Return the `nrows \times ncols` zero matrix over the given ring. The default ring is the integers. EXAMPLES:: sage: M = zero_matrix(QQ, 2); M [0 0] [0 0] sage: M.parent() Full MatrixSpace of 2 by 2 dense matrices over Rational Field sage: M = zero_matrix(2, 3); M [0 0 0] [0 0 0] sage: M.parent() Full MatrixSpace of 2 by 3 dense matrices over Integer Ring sage: M = zero_matrix(3, 1, sparse=True); M [0] [0] [0] sage: M.parent() Full MatrixSpace of 3 by 1 sparse matrices over Integer Ring """ if isinstance(ring, (int, long, rings.Integer)): nrows, ncols = (ring, nrows) ring = rings.ZZ return matrix_space.MatrixSpace(ring, nrows, ncols, sparse).zero_matrix()
5867b3c6276b57244559fd7541b14eaa9e59e477 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/5867b3c6276b57244559fd7541b14eaa9e59e477/constructor.py
ValueError: polys (=[x - y, x*y]) must be homogeneous of the same degree
ValueError: polys (=[x - y, x*y]) must be of the same degree sage: H([x-1, x*y+x]) Traceback (most recent call last): ... ValueError: polys (=[x - 1, x*y + x]) must be homogeneous
def _repr_defn(self): """ This function is used internally for printing.
10f92cffa05831b8a8e3caae116d9e284ca861b6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/10f92cffa05831b8a8e3caae116d9e284ca861b6/morphism.py
deg = self.defining_polynomials()[0].degree() for poly in self.defining_polynomials(): if (poly.degree() != deg) or not poly.is_homogeneous(): raise ValueError, "polys (=%s) must be homogeneous of the same degree"%polys
polys = self.defining_polynomials() try: d = polys[0].degree() except AttributeError: polys = [f.lift() for f in polys] if not all([f.is_homogeneous() for f in polys]): raise ValueError, "polys (=%s) must be homogeneous"%polys degs = [f.degree() for f in polys] if not all([d==degs[0] for d in degs[1:]]): raise ValueError, "polys (=%s) must be of the same degree"%polys
def __init__(self, parent, polys, check=True): SchemeMorphism_on_points.__init__(self, parent, polys, check) if check: # morphisms from projective space are always given by # homogeneous polynomials of the same degree deg = self.defining_polynomials()[0].degree() for poly in self.defining_polynomials(): if (poly.degree() != deg) or not poly.is_homogeneous(): raise ValueError, "polys (=%s) must be homogeneous of the same degree"%polys
10f92cffa05831b8a8e3caae116d9e284ca861b6 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/10f92cffa05831b8a8e3caae116d9e284ca861b6/morphism.py
except:
except MIPSolverException:
def edge_coloring(g, value_only=False, vizing=False, hex_colors=False, log=0): r""" Properly colors the edges of a graph. See the URL http://en.wikipedia.org/wiki/Edge_coloring for further details on edge coloring. INPUT: - ``g`` -- a graph. - ``value_only`` -- (default: ``False``): - When set to ``True``, only the chromatic index is returned. - When set to ``False``, a partition of the edge set into matchings is returned if possible. - ``vizing`` -- (default: ``False``): - When set to ``True``, tries to find a `\Delta + 1`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. - When set to ``False``, tries to find a `\Delta`-edge-coloring, where `\Delta` is equal to the maximum degree in the graph. If impossible, tries to find and returns a `\Delta + 1`-edge-coloring. This implies that ``value_only=False``. - ``hex_colors`` -- (default: ``False``) when set to ``True``, the partition returned is a dictionary whose keys are colors and whose values are the color classes (ideal for plotting). - ``log`` -- (default: ``0``) as edge-coloring is an `NP`-complete problem, this function may take some time depending on the graph. Use ``log`` to define the level of verbosity you wantfrom the linear program solver. By default ``log=0``, meaning that there will be no message printed by the solver. OUTPUT: In the following, `\Delta` is equal to the maximum degree in the graph ``g``. - If ``vizing=True`` and ``value_only=False``, return a partition of the edge set into `\Delta + 1` matchings. - If ``vizing=False`` and ``value_only=True``, return the chromatic index. - If ``vizing=False`` and ``value_only=False``, return a partition of the edge set into the minimum number of matchings. - If ``vizing=True`` and ``value_only=True``, should return something, but mainly you are just trying to compute the maximum degree of the graph, and this is not the easiest way. By Vizing's theorem, a graph has a chromatic index equal to `\Delta` or to `\Delta + 1`. .. NOTE:: In a few cases, it is possible to find very quickly the chromatic index of a graph, while it remains a tedious job to compute a corresponding coloring. For this reason, ``value_only = True`` can sometimes be much faster, and it is a bad idea to compute the whole coloring if you do not need it ! EXAMPLE:: sage: from sage.graphs.graph_coloring import edge_coloring sage: g = graphs.PetersenGraph() sage: edge_coloring(g, value_only=True) # optional - requires GLPK or CBC 4 Complete graphs are colored using the linear-time round-robin coloring:: sage: from sage.graphs.graph_coloring import edge_coloring sage: len(edge_coloring(graphs.CompleteGraph(20))) 19 """ from sage.numerical.mip import MixedIntegerLinearProgram from sage.plot.colors import rainbow from sage.numerical.mip import MIPSolverException if g.is_clique(): if value_only: return g.order()-1 if g.order() % 2 == 0 else g.order() vertices = g.vertices() r = round_robin(g.order()) classes = [[] for v in g] if g.order() % 2 == 0 and not vizing: classes.pop() for (u, v, c) in r.edge_iterator(): classes[c].append((vertices[u], vertices[v])) if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes if value_only and g.is_overfull(): return max(g.degree())+1 p = MixedIntegerLinearProgram(maximization=True) color = p.new_variable(dim=2) obj = {} k = max(g.degree()) # reorders the edge if necessary... R = lambda x: x if (x[0] <= x[1]) else (x[1], x[0]) # Vizing's coloring uses Delta + 1 colors if vizing: value_only = False k += 1 # A vertex can not have two incident edges with the same color. [p.add_constraint( sum([color[R(e)][i] for e in g.edges_incident(v, labels=False)]), max=1) for v in g.vertex_iterator() for i in xrange(k)] # an edge must have a color [p.add_constraint(sum([color[R(e)][i] for i in xrange(k)]), max=1, min=1) for e in g.edge_iterator(labels=False)] # anything is good as an objective value as long as it is satisfiable e = g.edge_iterator(labels=False).next() p.set_objective(color[R(e)][0]) p.set_binary(color) try: if value_only: p.solve(objective_only=True, log=log) else: chi = p.solve(log=log) except: if value_only: return k + 1 else: # if the coloring with Delta colors fails, tries Delta + 1 return edge_coloring(g, vizing=True, hex_colors=hex_colors, log=log) if value_only: return k # Builds the color classes color = p.get_values(color) classes = [[] for i in xrange(k)] [classes[i].append(e) for e in g.edge_iterator(labels=False) for i in xrange(k) if color[R(e)][i] == 1] # if needed, builds a dictionary from the color classes adding colors if hex_colors: return dict(zip(rainbow(len(classes)), classes)) else: return classes
188d42e47344cfb921672f992048ca37394acd8a /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/188d42e47344cfb921672f992048ca37394acd8a/graph_coloring.py
AUTHORS: - Robert Bradshaw (2007-10): numerical algorithm - Robert Bradshaw (2008-10): algebraic algorithm
def minpoly(ex, var='x', algorithm=None, bits=None, degree=None, epsilon=0): r""" Return the minimal polynomial of self, if possible. INPUT: - ``var`` - polynomial variable name (default 'x') - ``algorithm`` - 'algebraic' or 'numerical' (default both, but with numerical first) - ``bits`` - the number of bits to use in numerical approx - ``degree`` - the expected algebraic degree - ``epsilon`` - return without error as long as f(self) epsilon, in the case that the result cannot be proven. All of the above parameters are optional, with epsilon=0, bits and degree tested up to 1000 and 24 by default respectively. The numerical algorithm will be faster if bits and/or degree are given explicitly. The algebraic algorithm ignores the last three parameters. OUTPUT: The minimal polynomial of self. If the numerical algorithm is used then it is proved symbolically when epsilon=0 (default). If the minimal polynomial could not be found, two distinct kinds of errors are raised. If no reasonable candidate was found with the given bit/degree parameters, a ``ValueError`` will be raised. If a reasonable candidate was found but (perhaps due to limits in the underlying symbolic package) was unable to be proved correct, a ``NotImplementedError`` will be raised. ALGORITHM: Two distinct algorithms are used, depending on the algorithm parameter. By default, the numerical algorithm is attempted first, then the algebraic one. Algebraic: Attempt to evaluate this expression in QQbar, using cyclotomic fields to resolve exponential and trig functions at rational multiples of pi, field extensions to handle roots and rational exponents, and computing compositums to represent the full expression as an element of a number field where the minimal polynomial can be computed exactly. The bits, degree, and epsilon parameters are ignored. Numerical: Computes a numerical approximation of ``self`` and use PARI's algdep to get a candidate minpoly `f`. If `f(\mathtt{self})`, evaluated to a higher precision, is close enough to 0 then evaluate `f(\mathtt{self})` symbolically, attempting to prove vanishing. If this fails, and ``epsilon`` is non-zero, return `f` if and only if `f(\mathtt{self}) < \mathtt{epsilon}`. Otherwise raise a ``ValueError`` (if no suitable candidate was found) or a ``NotImplementedError`` (if a likely candidate was found but could not be proved correct). EXAMPLES: First some simple examples:: sage: sqrt(2).minpoly() x^2 - 2 sage: minpoly(2^(1/3)) x^3 - 2 sage: minpoly(sqrt(2) + sqrt(-1)) x^4 - 2*x^2 + 9 sage: minpoly(sqrt(2)-3^(1/3)) x^6 - 6*x^4 + 6*x^3 + 12*x^2 + 36*x + 1 Works with trig and exponential functions too. :: sage: sin(pi/3).minpoly() x^2 - 3/4 sage: sin(pi/7).minpoly() x^6 - 7/4*x^4 + 7/8*x^2 - 7/64 sage: minpoly(exp(I*pi/17)) x^16 - x^15 + x^14 - x^13 + x^12 - x^11 + x^10 - x^9 + x^8 - x^7 + x^6 - x^5 + x^4 - x^3 + x^2 - x + 1 Here we verify it gives the same result as the abstract number field. :: sage: (sqrt(2) + sqrt(3) + sqrt(6)).minpoly() x^4 - 22*x^2 - 48*x - 23 sage: K.<a,b> = NumberField([x^2-2, x^2-3]) sage: (a+b+a*b).absolute_minpoly() x^4 - 22*x^2 - 48*x - 23 The minpoly function is used implicitly when creating number fields:: sage: x = var('x') sage: eqn = x^3 + sqrt(2)*x + 5 == 0 sage: a = solve(eqn, x)[0].rhs() sage: QQ[a] Number Field in a with defining polynomial x^6 + 10*x^3 - 2*x^2 + 25 Here we solve a cubic and then recover it from its complicated radical expansion. :: sage: f = x^3 - x + 1 sage: a = f.solve(x)[0].rhs(); a -1/2*(I*sqrt(3) + 1)*(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) - 1/6*(-I*sqrt(3) + 1)/(1/18*sqrt(3)*sqrt(23) - 1/2)^(1/3) sage: a.minpoly() x^3 - x + 1 Note that simplification may be necessary to see that the minimal polynomial is correct. :: sage: a = sqrt(2)+sqrt(3)+sqrt(5) sage: f = a.minpoly(); f x^8 - 40*x^6 + 352*x^4 - 960*x^2 + 576 sage: f(a) ((((sqrt(2) + sqrt(3) + sqrt(5))^2 - 40)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 352)*(sqrt(2) + sqrt(3) + sqrt(5))^2 - 960)*(sqrt(2) + sqrt(3) + sqrt(5))^2 + 576 sage: f(a).expand() 0 Here we show use of the ``epsilon`` parameter. That this result is actually exact can be shown using the addition formula for sin, but maxima is unable to see that. :: sage: a = sin(pi/5) sage: a.minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^4 - 5/4*x^2 + 5/16 (epsilon 0.00000000000000e-1) sage: f = a.minpoly(algorithm='numerical', epsilon=1e-100); f x^4 - 5/4*x^2 + 5/16 sage: f(a).numerical_approx(100) 0.00000000000000000000000000000 The degree must be high enough (default tops out at 24). :: sage: a = sqrt(3) + sqrt(2) sage: a.minpoly(algorithm='numerical', bits=100, degree=3) Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (100 bits, degree 3). sage: a.minpoly(algorithm='numerical', bits=100, degree=10) x^4 - 10*x^2 + 1 There is a difference between algorithm='algebraic' and algorithm='numerical':: sage: cos(pi/33).minpoly(algorithm='algebraic') x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 sage: cos(pi/33).minpoly(algorithm='numerical') Traceback (most recent call last): ... NotImplementedError: Could not prove minimal polynomial x^10 + 1/2*x^9 - 5/2*x^8 - 5/4*x^7 + 17/8*x^6 + 17/16*x^5 - 43/64*x^4 - 43/128*x^3 + 3/64*x^2 + 3/128*x + 1/1024 (epsilon ...) Sometimes it fails, as it must given that some numbers aren't algebraic:: sage: sin(1).minpoly(algorithm='numerical') Traceback (most recent call last): ... ValueError: Could not find minimal polynomial (1000 bits, degree 24). .. note:: Of course, failure to produce a minimal polynomial does not necessarily indicate that this number is transcendental. AUTHORS: - Robert Bradshaw (2007-10): numerical algorithm - Robert Bradshaw (2008-10): algebraic algorithm """ if algorithm is None or algorithm.startswith('numeric'): bits_list = [bits] if bits else [100,200,500,1000] degree_list = [degree] if degree else [2,4,8,12,24] for bits in bits_list: a = ex.numerical_approx(bits) check_bits = int(1.25 * bits + 80) aa = ex.numerical_approx(check_bits) for degree in degree_list: f = QQ[var](algdep(a, degree)) # TODO: use the known_bits parameter? # If indeed we have found a minimal polynomial, # it should be accurate to a much higher precision. error = abs(f(aa)) dx = ~RR(Integer(1) << (check_bits - degree - 2)) expected_error = abs(f.derivative()(CC(aa))) * dx if error < expected_error: # Degree might have been an over-estimate, factor because we want (irreducible) minpoly. ff = f.factor() for g, e in ff: lead = g.leading_coefficient() if lead != 1: g = g / lead expected_error = abs(g.derivative()(CC(aa))) * dx error = abs(g(aa)) if error < expected_error: # See if we can prove equality exactly if g(ex).simplify_trig().simplify_radical() == 0: return g # Otherwise fall back to numerical guess elif epsilon and error < epsilon: return g elif algorithm is not None: raise NotImplementedError, "Could not prove minimal polynomial %s (epsilon %s)" % (g, RR(error).str(no_sci=False)) if algorithm is not None: raise ValueError, "Could not find minimal polynomial (%s bits, degree %s)." % (bits, degree) if algorithm is None or algorithm == 'algebraic': from sage.rings.all import QQbar return QQ[var](QQbar(ex).minpoly()) raise ValueError, "Unknown algorithm: %s" % algorithm
79dac1caa595004ce2ee368f13d1ae74f555c29b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/79dac1caa595004ce2ee368f13d1ae74f555c29b/calculus.py
AUTHORS: - Golam Mortuza Hossain (2009-06-15)
def _limit_latex_(self, f, x, a): r""" Return latex expression for limit of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _limit_latex_ sage: var('x,a') (x, a) sage: f = function('f',x) sage: _limit_latex_(0, f, x, a) '\\lim_{x \\to a}\\, f\\left(x\\right)' sage: latex(limit(f, x=oo)) \lim_{x \to +\infty}\, f\left(x\right) AUTHORS: - Golam Mortuza Hossain (2009-06-15) """ return "\\lim_{%s \\to %s}\\, %s"%(latex(x), latex(a), latex(f))
79dac1caa595004ce2ee368f13d1ae74f555c29b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/79dac1caa595004ce2ee368f13d1ae74f555c29b/calculus.py
AUTHORS: - Golam Mortuza Hossain (2009-06-22)
def _laplace_latex_(self, *args): r""" Return LaTeX expression for Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _laplace_latex_ sage: var('s,t') (s, t) sage: f = function('f',t) sage: _laplace_latex_(0,f,t,s) '\\mathcal{L}\\left(f\\left(t\\right), t, s\\right)' sage: latex(laplace(f, t, s)) \mathcal{L}\left(f\left(t\right), t, s\right) AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
79dac1caa595004ce2ee368f13d1ae74f555c29b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/79dac1caa595004ce2ee368f13d1ae74f555c29b/calculus.py
AUTHORS: - Golam Mortuza Hossain (2009-06-22)
def _inverse_laplace_latex_(self, *args): r""" Return LaTeX expression for inverse Laplace transform of a symbolic function. EXAMPLES:: sage: from sage.calculus.calculus import _inverse_laplace_latex_ sage: var('s,t') (s, t) sage: F = function('F',s) sage: _inverse_laplace_latex_(0,F,s,t) '\\mathcal{L}^{-1}\\left(F\\left(s\\right), s, t\\right)' sage: latex(inverse_laplace(F,s,t)) \mathcal{L}^{-1}\left(F\left(s\right), s, t\right) AUTHORS: - Golam Mortuza Hossain (2009-06-22) """ return "\\mathcal{L}^{-1}\\left(%s\\right)"%(', '.join([latex(x) for x in args]))
79dac1caa595004ce2ee368f13d1ae74f555c29b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/79dac1caa595004ce2ee368f13d1ae74f555c29b/calculus.py
libraries=['polybori','pboriCudd', 'groebner', 'gd', 'png', 'm4ri'],
libraries=['polybori','pboriCudd', 'groebner', 'gd', 'png12', 'm4ri'],
def uname_specific(name, value, alternative): if name in os.uname()[0]: return value else: return alternative
bad104d772119429241e8249fe746d8887d913c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/bad104d772119429241e8249fe746d8887d913c0/module_list.py
Return the frequency table corresponding to the given string.
Return the frequency table corresponding to the given string.
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
- ``string`` -- a string EXAMPLE::
- ``string`` -- a string of symbols over some alphabet. OUTPUT: - A table of frequency of each unique symbol in ``string``. If ``string`` is an empty string, return an empty table. EXAMPLES: The frequency table of a non-empty string::
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2}
sage: str = "Stop counting my characters!" sage: T = sorted(frequency_table(str).items()) sage: for symbol, code in T: ... print symbol, code ... 3 ! 1 S 1 a 2 c 3 e 1 g 1 h 1 i 1 m 1 n 2 o 2 p 1 r 2 s 1 t 3 u 1 y 1 The frequency of an empty string:: sage: frequency_table("") {}
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
for l in string: d[l] = d.get(l,0) + 1
for s in string: d[s] = d.get(s, 0) + 1
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
class Huffman():
class Huffman(SageObject):
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
Huffman Encoding This class implements the basic functionalities of Huffman's encoding. It can build a Huffman code from a given string, or from the information of a dictionary associating to each key (the elements of the alphabet) a weight (most of the time, a probability value or a number of occurrences). For example ::
This class implements the basic functionalities of Huffman codes. It can build a Huffman code from a given string, or from the information of a dictionary associating to each key (the elements of the alphabet) a weight (most of the time, a probability value or a number of occurrences). INPUT: - ``string`` -- (default: ``None``) a string from which the Huffman encoding should be created. - ``table`` -- (default: ``None``) a dictionary that associates to each symbol of an alphabet a numeric value. If we consider the frequency of each alphabetic symbol, then ``table`` is considered as the frequency table of the alphabet with each numeric (non-negative integer) value being the number of occurrences of a symbol. The numeric values can also represent weights of the symbols. In that case, the numeric values are not necessarily integers, but can be real numbers. In general, we refer to ``table`` as a weight table. Exactly one of ``string`` and ``table`` cannot be ``None``. In order to construct a Huffman code for an alphabet, we use exactly one of the following methods: ``string`` to the constructor of this class. Based on the input string, a frequency table is constructed that contains the frequency of each unique symbol in ``string``. The alphabet in question is then all the unique symbols in ``string``. A significant implication of this is that any subsequent string that we want to encode must contain only symbols that can be found in ``string``. table to the constructor of this class. The table ``table`` can be a table of frequency or a table of weights. Examples::
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
We could have obtained the same result by "training" the Huffman code on the following table of frequency ::
We can obtain the same result by "training" the Huffman code with the following table of frequency::
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
sage: h2 = Huffman(frequencies = ft) Once ``h1`` has been trained, and hence possesses an encoding code,
sage: h2 = Huffman(table=ft) Once ``h1`` has been trained, and hence possesses an encoding table,
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py
Which can be decoded the following way::
We can decode the above encoded string in the following way::
def frequency_table(string): r""" Return the frequency table corresponding to the given string. INPUT: - ``string`` -- a string EXAMPLE:: sage: from sage.coding.source_coding.huffman import frequency_table sage: str = "Sage is my most favorite general purpose computer algebra system" sage: frequency_table(str) {'a': 5, ' ': 9, 'c': 1, 'b': 1, 'e': 8, 'g': 3, 'f': 1, 'i': 2, 'm': 4, 's': 5, 'o': 4, 'n': 1, 'p': 3, 'S': 1, 'r': 5, 'u': 2, 't': 4, 'v': 1, 'y': 2, 'l': 2} """ d = {} for l in string: d[l] = d.get(l,0) + 1 return d
08cf8218c91d92b4dcb4602a7135f1d9d706af1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/08cf8218c91d92b4dcb4602a7135f1d9d706af1e/huffman.py