rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
def mangle_neg(vals): """ Returns the product of all values in vals, with the result nonnegative if any of the values is nonnegative. EXAMPLES:: sage: from sage.plot.contour_plot import mangle_neg sage: mangle_neg([-1.2, -0.74, -2.56, -1.01]) -2.29601280000000 sage: mangle_neg([-1.2, 0.0, -2.56]) 0.000000000000000 s... | def equify(f): """ Returns the equation rewritten as a symbolic function to give negative values when True, positive when False. EXAMPLES:: sage: from sage.plot.contour_plot import equify sage: var('x, y') (x, y) sage: equify(x^2 < 2) x^2 - 2 sage: equify(x^2 > 2) -x^2 + 2 sage: equify(x*y > 1) -x*y + 1 sage: equify(... | b660176b0ce484abd89fe9d40eb554712a6a9e5b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b660176b0ce484abd89fe9d40eb554712a6a9e5b/contour_plot.py | |
sage: homchain(C2, generators=True, base_ring=GF(2))[2] | sage: homchain(C2, generators=True, base_ring=GF(2))[2] | def homchain(complex=None, **kwds): r""" Compute the homology of a chain complex using the CHomP program ``homchain``. :param complex: a chain complex :param generators: if True, also return list of generators :type generators: boolean; optional, default False :param verbose: if True, print helpful messages as the com... | 42a66b2b444310b2eb500ed66fcf7eecc0422e5d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/42a66b2b444310b2eb500ed66fcf7eecc0422e5d/chomp.py |
sage: M=E.modular_symbol() | def modular_symbol(self, sign=1, use_eclib = False, normalize = "L_ratio"): r""" Return the modular symbol associated to this elliptic curve, with given sign and base ring. This is the map that sends `r/s` to a fixed multiple of the integral of `2 \pi i f(z) dz` from `\infty` to `r/s`, normalized so that all values of... | c925a747f27f250286840397a8a76d418d54c5e0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/c925a747f27f250286840397a8a76d418d54c5e0/ell_rational_field.py | |
1/5 | 2/5 | def modular_symbol(self, sign=1, use_eclib = False, normalize = "L_ratio"): r""" Return the modular symbol associated to this elliptic curve, with given sign and base ring. This is the map that sends `r/s` to a fixed multiple of the integral of `2 \pi i f(z) dz` from `\infty` to `r/s`, normalized so that all values of... | c925a747f27f250286840397a8a76d418d54c5e0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/c925a747f27f250286840397a8a76d418d54c5e0/ell_rational_field.py |
if options['labels']: | if options.get('labels', False): | def _render_on_subplot(self, subplot): """ TESTS: | b8f1482102fdad41bf6ccadb60d23d37518592c4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b8f1482102fdad41bf6ccadb60d23d37518592c4/contour_plot.py |
if options['colorbar']: | if options.get('colorbar', False): | def _render_on_subplot(self, subplot): """ TESTS: | b8f1482102fdad41bf6ccadb60d23d37518592c4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b8f1482102fdad41bf6ccadb60d23d37518592c4/contour_plot.py |
dict(contours=[-1e307, 0, 1e307], cmap=cmap, fill=True, labels=False, **options))) | dict(contours=[-1e307, 0, 1e307], cmap=cmap, fill=True, **options))) | def region_plot(f, xrange, yrange, plot_points, incol, outcol, bordercol, borderstyle, borderwidth,**options): r""" ``region_plot`` takes a boolean function of two variables, `f(x,y)` and plots the region where f is True over the specified ``xrange`` and ``yrange`` as demonstrated below. ``region_plot(f, (xmin, xmax),... | b8f1482102fdad41bf6ccadb60d23d37518592c4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b8f1482102fdad41bf6ccadb60d23d37518592c4/contour_plot.py |
contours=[0], cmap=[bordercol], fill=False, labels=False, **options))) | contours=[0], cmap=[bordercol], fill=False, **options))) | def region_plot(f, xrange, yrange, plot_points, incol, outcol, bordercol, borderstyle, borderwidth,**options): r""" ``region_plot`` takes a boolean function of two variables, `f(x,y)` and plots the region where f is True over the specified ``xrange`` and ``yrange`` as demonstrated below. ``region_plot(f, (xmin, xmax),... | b8f1482102fdad41bf6ccadb60d23d37518592c4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b8f1482102fdad41bf6ccadb60d23d37518592c4/contour_plot.py |
'Sphere center 1.0 2.0 3.0 Rad 0.015 texture84' | 'Sphere center 1.0 2.0 3.0 Rad 0.015 texture85' | def tachyon_repr(self, render_params): """ Returns representation of the point suitable for plotting using the Tachyon ray tracer. | 11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe/shapes2.py |
['g obj_1', 'usemtl texture86'] | ['g obj_1', 'usemtl texture87'] | def obj_repr(self, render_params): """ Returns complete representation of the point as a sphere. | 11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe/shapes2.py |
'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture126' | 'FCylinder base 1.0 0.0 0.0 apex 0.999950000417 0.00999983333417 0.0001 rad 0.005 texture127' | def tachyon_repr(self, render_params): """ Returns representation of the line suitable for plotting using the Tachyon ray tracer. | 11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/11ca8f7d7f9d46936b93b319c8a8dd01d19ba3fe/shapes2.py |
more planar areas get fewer triangles, and areas with higher curvature get more triangles | more planar areas get fewer triangles, and areas with higher curvature get more triangles. | def get_colors(self, list): """ Parameters: list: an iterable collection of values which can be cast into colors -- typically an RGB triple, or an RGBA 4-tuple Returns: a list of single parameters which can be passed into the set_color method of the Triangle or SmoothTriangle objects generated by this factory. TESTS:... | 6013792e38d03cb0b7cb7f6ef213d010ef509c24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/6013792e38d03cb0b7cb7f6ef213d010ef509c24/tri_plot.py |
def tamagawa_product(self): | def tamagawa_product_bsd(self): | def tamagawa_product(self): r""" Given an elliptic curve `E` over a number field `K`, this function returns the integer `C(E/K)` that appears in the Birch and Swinnerton-Dyer conjecture accounting for the local information at finite places. If the model is a global minimal model then `C(E/K)` is simply the product of t... | 73136fe88017b1ada2ab43235edd1ad9bf1f056d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/73136fe88017b1ada2ab43235edd1ad9bf1f056d/ell_number_field.py |
sage: E.tamagawa_product() | sage: E.tamagawa_product_bsd() | def tamagawa_product(self): r""" Given an elliptic curve `E` over a number field `K`, this function returns the integer `C(E/K)` that appears in the Birch and Swinnerton-Dyer conjecture accounting for the local information at finite places. If the model is a global minimal model then `C(E/K)` is simply the product of t... | 73136fe88017b1ada2ab43235edd1ad9bf1f056d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/73136fe88017b1ada2ab43235edd1ad9bf1f056d/ell_number_field.py |
sage: E.tamagawa_product() | sage: E.tamagawa_product_bsd() | def tamagawa_product(self): r""" Given an elliptic curve `E` over a number field `K`, this function returns the integer `C(E/K)` that appears in the Birch and Swinnerton-Dyer conjecture accounting for the local information at finite places. If the model is a global minimal model then `C(E/K)` is simply the product of t... | 73136fe88017b1ada2ab43235edd1ad9bf1f056d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/73136fe88017b1ada2ab43235edd1ad9bf1f056d/ell_number_field.py |
sage: E.tamagawa_product() | sage: E.tamagawa_product_bsd() | def tamagawa_product(self): r""" Given an elliptic curve `E` over a number field `K`, this function returns the integer `C(E/K)` that appears in the Birch and Swinnerton-Dyer conjecture accounting for the local information at finite places. If the model is a global minimal model then `C(E/K)` is simply the product of t... | 73136fe88017b1ada2ab43235edd1ad9bf1f056d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/73136fe88017b1ada2ab43235edd1ad9bf1f056d/ell_number_field.py |
sage: E2 Elliptic Curve defined by y^2 + a*x*y + (a+1)*y = x^3 + (a+1)*x^2 + (12289755603565800754*a-75759141535687466985)*x + (51556320144761417221790307379*a-317814501841918807353201512829) over Number Field in a with defining polynomial x^2 - 38 | sage: E2 Elliptic Curve defined by y^2 + a*x*y + (a+1)*y = x^3 + (a+1)*x^2 + (368258520200522046806318444*a-2270097978636731786720859345)*x + (8456608930173478039472018047583706316424*a-52130038506793883217874390501829588391299) over Number Field in a with defining polynomial x^2 - 38 | def global_minimal_model(self, proof = None): r""" Returns a model of self that is integral, minimal at all primes. .. note:: | 73136fe88017b1ada2ab43235edd1ad9bf1f056d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/73136fe88017b1ada2ab43235edd1ad9bf1f056d/ell_number_field.py |
if P.eval("%s %s %s"%(self.name(), P._equality_symbol(), other.name())) == P._true_symbol(): return 0 elif P.eval("%s %s %s"%(self.name(), P._lessthan_symbol(), other.name())) == P._true_symbol(): return -1 elif P.eval("%s %s %s"%(self.name(), P._greaterthan_symbol(), other.name())) == P._true_symbol(): return 1 | try: if P.eval("%s %s %s"%(self.name(), P._equality_symbol(), other.name())) == P._true_symbol(): return 0 except RuntimeError: pass try: if P.eval("%s %s %s"%(self.name(), P._lessthan_symbol(), other.name())) == P._true_symbol(): return -1 except RuntimeError: pass try: if P.eval("%s %s %s"%(self.name(), P._greatertha... | def __cmp__(self, other): P = self.parent() if P.eval("%s %s %s"%(self.name(), P._equality_symbol(), other.name())) == P._true_symbol(): return 0 elif P.eval("%s %s %s"%(self.name(), P._lessthan_symbol(), other.name())) == P._true_symbol(): return -1 elif P.eval("%s %s %s"%(self.name(), P._greaterthan_symbol(), other.n... | 2e1bd8a9c675146382b9cf26349d31bfda47d003 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/2e1bd8a9c675146382b9cf26349d31bfda47d003/expect.py |
To see a list of all word constructors, type "words." and then | To see a list of all word constructors, type ``words.`` and then | def __new__(cls, *args, **kwds): r""" TEST: sage: from sage.combinat.words.word_generators import ChristoffelWord_Lower sage: w = ChristoffelWord_Lower(1,0); w doctest:1: DeprecationWarning: ChristoffelWord_Lower is deprecated, use LowerChristoffelWord instead word: 1 """ from sage.misc.misc import deprecation deprecat... | 8ae40e9030bcff28af0df21427285ba0771de00e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/8ae40e9030bcff28af0df21427285ba0771de00e/word_generators.py |
approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z` is a good approximation to an algebraic number of degree less than `degree`. You can specify the number of known bits or digits with ``known_bits=k`` or ``known_digits=k``; Pari is t... | approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z` is a good approximation to an algebraic number of degree less than `degree`. You can specify the number of known bits or digits of `z` with ``known_bits=k`` or ``known_digits=k``. PA... | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
- ``height_bound`` - an integer (default ``None``) specifying the maximum | - ``height_bound`` - an integer (default: ``None``) specifying the maximum | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
- ``proof`` - a boolean (default ``False``), requres height_bound to be set | - ``proof`` - a boolean (default: ``False``), requires height_bound to be set | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
This example involves a complex number. :: | This example involves a complex number:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
This example involves a `p`-adic number. :: | This example involves a `p`-adic number:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
compute a 200-bit approximation to sqrt(2) which is wrong in the 33'rd bit. :: | compute a 200-bit approximation to `sqrt(2)` which is wrong in the 33'rd bit:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
Using the ``height_bound`` and ``proof`` parameters, we can see that `pi` is not the root of an integer polynomial of degree at most 5 and coefficients bounded above by 10. :: | Using the ``height_bound`` and ``proof`` parameters, we can see that `pi` is not the root of an integer polynomial of degree at most 5 and coefficients bounded above by 10:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
For stronger results, we need more precicion. :: | For stronger results, we need more precicion:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
We can also use ``proof=True`` to get positive results. :: | We can also use ``proof=True`` to get positive results:: | def algdep(z, degree, known_bits=None, use_bits=None, known_digits=None, use_digits=None, height_bound=None, proof=False): """ Returns a polynomial of degree at most `degree` which is approximately satisfied by the number `z`. Note that the returned polynomial need not be irreducible, and indeed usually won't be if `z`... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
- ``bound (default 1024)`` - int: highest power to test. | - ``bound (default: 1024)`` - int: highest power to test. | def is_pseudoprime_small_power(n, bound=1024, get_data=False): r""" Return True if `n` is a small power of a pseudoprime, and False otherwise. The result is *NOT* proven correct - *this IS a pseudo-primality test!*. If `get_data` is set to true and `n = p^d`, for a pseudoprime `p` and power `d`, return [(p, d)]. IN... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
- ``verbose`` - integer (default 0); pari's debug | - ``verbose`` - integer (default: 0); PARI's debug | 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 ... | b5ed948d4508215af6091ab48ef3eea7f0de520e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b5ed948d4508215af6091ab48ef3eea7f0de520e/arith.py |
Construct a module with basis from the data in ``x`` | Construct a module with basis from the data in ``x``. | def _call_(self, x): """ Construct a module with basis from the data in ``x`` | b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec/modules_with_basis.py |
Returns whether this category is abelian | Returns whether this category is abelian. | def is_abelian(self): """ Returns whether this category is abelian | b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec/modules_with_basis.py |
With the ``zero`` argument, one can define affine morphisms: | With the ``zero`` argument, one can define affine morphisms:: | def module_morphism(self, on_basis = None, diagonal = None, triangular = None, **keywords): r""" Constructs morphisms by linearity | b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec/modules_with_basis.py |
Or more generaly any ring admitting a coercion map from the base ring: | Or more generaly any ring admitting a coercion map from the base ring:: | def module_morphism(self, on_basis = None, diagonal = None, triangular = None, **keywords): r""" Constructs morphisms by linearity | b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/b81c41b31dec6d44ca0e9b75a053f7eb7e6bfeec/modules_with_basis.py |
""" Returns the image `\{f(x) x in self\}` of this combinatorial | r""" Returns the image `\{f(x) | x \in \text{self}\}` of this combinatorial | def map(self, f, name=None): """ Returns the image `\{f(x) x in self\}` of this combinatorial class by `f`, as a combinatorial class. | 081fd2f20970496191385069834a2dbd6ffcf30b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/081fd2f20970496191385069834a2dbd6ffcf30b/combinat.py |
def map(self, f, name=None): """ Returns the image `\{f(x) x in self\}` of this combinatorial class by `f`, as a combinatorial class. | 081fd2f20970496191385069834a2dbd6ffcf30b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/081fd2f20970496191385069834a2dbd6ffcf30b/combinat.py | ||
def map(self, f, name=None): """ Returns the image `\{f(x) x in self\}` of this combinatorial class by `f`, as a combinatorial class. | 081fd2f20970496191385069834a2dbd6ffcf30b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/081fd2f20970496191385069834a2dbd6ffcf30b/combinat.py | ||
... __metaclass__ = sage.structure.unique_representation.ClasscallMetaclass | ... __metaclass__ = ClasscallMetaclass | def __call__(cls, *args, **options): """ This method implements ``cls(<some arguments>)``. | 38f1953eb1bc8beb3d6794700189392834dc7526 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/38f1953eb1bc8beb3d6794700189392834dc7526/classcall_metaclass.py |
... print "calling call_cls" | ... print "calling classcall" | ... def __classcall__(cls): | 38f1953eb1bc8beb3d6794700189392834dc7526 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/38f1953eb1bc8beb3d6794700189392834dc7526/classcall_metaclass.py |
calling call_cls | calling classcall | ... def __init__(self): | 38f1953eb1bc8beb3d6794700189392834dc7526 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/38f1953eb1bc8beb3d6794700189392834dc7526/classcall_metaclass.py |
try: | if '__classcall_private__' in cls.__dict__: return cls.__classcall_private__(cls, *args, **options) elif hasattr(cls, "__classcall__"): | ... def __init__(self): | 38f1953eb1bc8beb3d6794700189392834dc7526 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/38f1953eb1bc8beb3d6794700189392834dc7526/classcall_metaclass.py |
except AttributeError: | else: | ... def __init__(self): | 38f1953eb1bc8beb3d6794700189392834dc7526 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/38f1953eb1bc8beb3d6794700189392834dc7526/classcall_metaclass.py |
def taylor(f, v, a, n): | def taylor(f, *args): | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24/functional.py |
through `(x - a)^n`. | through `(x - a)^n`. Functions in more variables are also supported. | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24/functional.py |
- ``v`` - variable - ``a`` - number - ``n`` - integer | - ``*args`` - the following notation is supported - ``x, a, n`` - variable, point, degree - ``(x, a), (y, b), ..., n`` - variables with points, degree of polynomial | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24/functional.py |
return f.taylor(v=v,a=a,n=n) | return f.taylor(*args) | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/ab8ae6b33bfea5b0d0c3557743c3db2669ab4f24/functional.py |
Digraph on 6 vertices | Hasse diagram of a poset containing 6 elements | def hasse_diagram(self): """ Returns the Hasse_diagram of the poset as a Sage DiGraph object. EXAMPLES:: sage: Q = Poset({5:[2,3], 1:[3,4], 2:[0], 3:[0], 4:[0]}) sage: Q.hasse_diagram() Digraph on 6 vertices | edf8a61dc2f562f33eac78fa6117330d84ccf3f8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/edf8a61dc2f562f33eac78fa6117330d84ccf3f8/posets.py |
_vars = str(self.gen()) | _vars = '(%s)'%self.gen() | def _singular_init_(self, singular=singular_default): """ Return a newly created Singular ring matching this ring. """ if not can_convert_to_singular(self): raise TypeError, "no conversion of this ring to a Singular ring defined" if self.ngens()==1: _vars = str(self.gen()) if "*" in _vars: # 1.000...000*x _vars = _var... | 7abd35414445a03150024b58a97a672a459ffc7f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/7abd35414445a03150024b58a97a672a459ffc7f/polynomial_singular_interface.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. | 644fe21760dee35aeb3eed2dc035465241845f68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/644fe21760dee35aeb3eed2dc035465241845f68/toric_variety.py |
polynomial = polynomial.lift() | polynomial = S(polynomial.lift()) | def is_homogeneous(self, polynomial): r""" Check if ``polynomial`` is homogeneous. | 644fe21760dee35aeb3eed2dc035465241845f68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/644fe21760dee35aeb3eed2dc035465241845f68/toric_variety.py |
Return a list of primary ideals (and their associated primes) such that their intersection is `I` = ``self``. | Return a list of the associated primes of primary ideals of which the intersection is `I` = ``self``. | def associated_primes(self, algorithm='sy'): r""" Return a list of primary ideals (and their associated primes) such that their intersection is `I` = ``self``. An ideal `Q` is called primary if it is a proper ideal of the ring `R` and if whenever `ab \in Q` and `a \not\in Q` then `b^n \in Q` for some `n \in \ZZ`. If ... | eaa2961d43f4b6c2394686351467844a1f52123b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/eaa2961d43f4b6c2394686351467844a1f52123b/multi_polynomial_ideal.py |
def associated_primes(self, algorithm='sy'): r""" Return a list of primary ideals (and their associated primes) such that their intersection is `I` = ``self``. An ideal `Q` is called primary if it is a proper ideal of the ring `R` and if whenever `ab \in Q` and `a \not\in Q` then `b^n \in Q` for some `n \in \ZZ`. If ... | eaa2961d43f4b6c2394686351467844a1f52123b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/eaa2961d43f4b6c2394686351467844a1f52123b/multi_polynomial_ideal.py | ||
- ``list`` - a list of primary ideals and their associated primes [(primary ideal, associated prime), ...] | - ``list`` - a list of associated primes | def associated_primes(self, algorithm='sy'): r""" Return a list of primary ideals (and their associated primes) such that their intersection is `I` = ``self``. An ideal `Q` is called primary if it is a proper ideal of the ring `R` and if whenever `ab \in Q` and `a \not\in Q` then `b^n \in Q` for some `n \in \ZZ`. If ... | eaa2961d43f4b6c2394686351467844a1f52123b /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/eaa2961d43f4b6c2394686351467844a1f52123b/multi_polynomial_ideal.py |
- ``alphabet`` - (default: (1,2)) any container that is suitable to build an instance of OrderedAlphabet (list, tuple, str, ...) | - ``alphabet`` - (default: (1,2)) an iterable of two positive integers | def KolakoskiWord(self, alphabet=(1,2)): r""" Returns the Kolakoski word over the given alphabet and starting with the first letter of the alphabet. | 400b38ded71c12be2a85d073791943be1f1b633f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/400b38ded71c12be2a85d073791943be1f1b633f/word_generators.py |
[1] William Kolakoski, proposal 5304, American Mathematical Monthly 72 (1965), 674; for a partial solution, see "Self Generating Runs," by Necdet Üçoluk, Amer. Math. Mon. 73 (1966), 681-2. """ try: a = int(alphabet[0]) b = int(alphabet[1]) if a <=0 or b <= 0 or a == b: raise ValueError, 'The alphabet (=%s) must consist... | - [1] William Kolakoski, proposal 5304, American Mathematical Monthly 72 (1965), 674; for a partial solution, see "Self Generating Runs," by Necdet Üçoluk, Amer. Math. Mon. 73 (1966), 681-2. """ a, b = alphabet if a not in ZZ or a <= 0 or b not in ZZ or b <= 0 or a == b: msg = 'The alphabet (=%s) must consist of two di... | def KolakoskiWord(self, alphabet=(1,2)): r""" Returns the Kolakoski word over the given alphabet and starting with the first letter of the alphabet. | 400b38ded71c12be2a85d073791943be1f1b633f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/400b38ded71c12be2a85d073791943be1f1b633f/word_generators.py |
This can be very helpful in showing certain features of plots. :: | This can be very helpful in showing certain features of plots. :: | sage: def maple_leaf(t): | 4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f/plot.py |
of `pi`. | of `\pi`. | sage: def maple_leaf(t): | 4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f/plot.py |
for best style in that case. | for best style in that case. :: sage: plot(arcsin(x),(x,-1,1),ticks=[None,pi/6],tick_formatter=["latex",pi]) | sage: def maple_leaf(t): | 4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f/plot.py |
sage: plot(arcsin(x),(x,-1,1),ticks=[None,pi/6],tick_formatter=["latex",pi]) | sage: def maple_leaf(t): | 4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/4bf203f4b6fbaee8c9a3c4a15f10b47ff3fc396f/plot.py | |
class _python_object_alphabet(object): | class _python_object_alphabet(UniqueRepresentation): | def __contains__(self, x): """ Returns True if x is contained in self. | dfd7438162af5481bc11ae9ec8b226d7b93fd255 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/dfd7438162af5481bc11ae9ec8b226d7b93fd255/words.py |
self.__modulus = ntl_ZZ_pEContext(ntl_ZZ_pX(list(base_ring.polynomial()), p)) | self._modulus = ntl_ZZ_pEContext(ntl_ZZ_pX(list(base_ring.polynomial()), p)) | def __init__(self, base_ring, name="x", sparse=False, element_class=None, implementation=None): """ TESTS: sage: from sage.rings.polynomial.polynomial_ring import PolynomialRing_field as PRing sage: R = PRing(QQ, 'x'); R Univariate Polynomial Ring in x over Rational Field sage: type(R.gen()) <class 'sage.rings.polynomi... | f812bf5e39f469853f7ca700db86ba4ec881eb70 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/f812bf5e39f469853f7ca700db86ba4ec881eb70/polynomial_ring.py |
def taylor(f, v, a, n): | def taylor(f, *args): | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | 7fbd75a895857c84661707037a30614fd415a6ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/7fbd75a895857c84661707037a30614fd415a6ec/functional.py |
through `(x - a)^n`. | through `(x - a)^n`. Functions in more variables are also supported. | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | 7fbd75a895857c84661707037a30614fd415a6ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/7fbd75a895857c84661707037a30614fd415a6ec/functional.py |
- ``v`` - variable - ``a`` - number - ``n`` - integer | - ``*args`` - the following notation is supported - ``x, a, n`` - variable, point, degree - ``(x, a), (y, b), ..., n`` - variables with points, degree of polynomial | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | 7fbd75a895857c84661707037a30614fd415a6ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/7fbd75a895857c84661707037a30614fd415a6ec/functional.py |
return f.taylor(v=v,a=a,n=n) | return f.taylor(*args) | def taylor(f, v, a, n): """ Expands self in a truncated Taylor or Laurent series in the variable `v` around the point `a`, containing terms through `(x - a)^n`. INPUT: - ``v`` - variable - ``a`` - number - ``n`` - integer EXAMPLES:: sage: var('x,k,n') (x, k, n) sage: taylor (sqrt (1 - k^2*sin(x)^2), x, 0, 6)... | 7fbd75a895857c84661707037a30614fd415a6ec /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/7fbd75a895857c84661707037a30614fd415a6ec/functional.py |
img = self(letter) | img = self.image(letter) | def is_identity(self): r""" Returns ``True`` if ``self`` is the identity morphism. EXAMPLES:: | 5d8048250ec66e6463a8a751e7a6d3fb7cc645ea /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/5d8048250ec66e6463a8a751e7a6d3fb7cc645ea/morphism.py |
This function is equivalent to the plot command with the options | This function is equivalent to the :func:`plot` command with the options | def polar_plot(funcs, *args, **kwds): r""" ``polar_plot`` takes a single function or a list or tuple of functions and plots them with polar coordinates in the given domain. This function is equivalent to the plot command with the options ``polar=True`` and ``aspect_ratio=1``. For more help on options, see the document... | cbc1d8cba1f82b16e60be9992a4d67cc91e7a630 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/cbc1d8cba1f82b16e60be9992a4d67cc91e7a630/plot.py |
see the documentation for plot. | see the documentation for :func:`plot`. | def polar_plot(funcs, *args, **kwds): r""" ``polar_plot`` takes a single function or a list or tuple of functions and plots them with polar coordinates in the given domain. This function is equivalent to the plot command with the options ``polar=True`` and ``aspect_ratio=1``. For more help on options, see the document... | cbc1d8cba1f82b16e60be9992a4d67cc91e7a630 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/cbc1d8cba1f82b16e60be9992a4d67cc91e7a630/plot.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. | c95ed2859f349f6452b8ba0530606e743e85c200 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/c95ed2859f349f6452b8ba0530606e743e85c200/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. | c95ed2859f349f6452b8ba0530606e743e85c200 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/c95ed2859f349f6452b8ba0530606e743e85c200/polyhedra.py |
This is called "massaging" in [CB07]_. | This is called "massaging" in [CBJ07]_. | def eliminate_linear_variables(self, maxlength=3, skip=lambda lm,tail: False): """ Return a new system where "linear variables" are eliminated. | c41a2f4270f509fbf794a7c0d541c172f5f35d2c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/c41a2f4270f509fbf794a7c0d541c172f5f35d2c/mpolynomialsystem.py |
- ``e`` - A Composition | - ``e`` - a composition | def LyndonWords(e=None, k=None): """ Returns the combinatorial class of Lyndon words. A Lyndon word `w` is a word that is lexicographically less than all of its rotations. Equivalently, whenever `w` is split into two non-empty substrings, `w` is lexicographically less than the right substring. INPUT: - no input at ... | 002f2aa08c5b8456abdd382fa28d7a53a760212d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/002f2aa08c5b8456abdd382fa28d7a53a760212d/lyndon_word.py |
A combinatorial class of Lyndon words | A combinatorial class of Lyndon words. | def LyndonWords(e=None, k=None): """ Returns the combinatorial class of Lyndon words. A Lyndon word `w` is a word that is lexicographically less than all of its rotations. Equivalently, whenever `w` is split into two non-empty substrings, `w` is lexicographically less than the right substring. INPUT: - no input at ... | 002f2aa08c5b8456abdd382fa28d7a53a760212d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/002f2aa08c5b8456abdd382fa28d7a53a760212d/lyndon_word.py |
verification that the input data represent a lyndon word. | verification that the input data represent a Lyndon word. | def __init__(self, data, check=True): r""" Construction of a Lyndon word. | 002f2aa08c5b8456abdd382fa28d7a53a760212d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/002f2aa08c5b8456abdd382fa28d7a53a760212d/lyndon_word.py |
a lyndon word | A Lyndon word. | def __init__(self, data, check=True): r""" Construction of a Lyndon word. | 002f2aa08c5b8456abdd382fa28d7a53a760212d /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/002f2aa08c5b8456abdd382fa28d7a53a760212d/lyndon_word.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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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 examp... | 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`` -- (defaul... | 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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
table), we are likely to get some random-looking string :: | table), we are likely to get some random-looking 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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
... precisely what we deserved :-) INPUT: One among the following: - ``string`` -- a string from which the Huffman encoding should be created - ``frequencies`` -- a dictionary associating its frequency or its number of occurrences to each letter of the alphabet. | This does not look like our original string. Instead of using frequency, we can assign weights to each alphabetic symbol:: sage: from sage.coding.source_coding.huffman import Huffman sage: T = {"a":45, "b":13, "c":12, "d":16, "e":9, "f":5} sage: H = Huffman(table=T) sage: L = ["deaf", "bead", "fab", "bee"] sage: E = ... | 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'... | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
def __init__(self, string = None, frequencies = None): r""" Constructor for Huffman INPUT: One among the following: - ``string`` -- a string from which the Huffman encoding should be created - ``frequencies`` -- a dictionary associating its frequency or its number of occurrences to each letter of the alphabet. EXA... | def __init__(self, string=None, table=None): r""" Constructor for Huffman. See the docstring of this class for full documentation. EXAMPLES:: sage: from sage.coding.source_coding.huffman import Huffman sage: str = "Sage is my most favorite general purpose computer algebra system" sage: h = Huffman(str) TESTS: If b... | def __init__(self, string = None, frequencies = None): r""" Constructor for Huffman | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
ValueError: Exactly one of `string` or `frequencies` parameters must be defined """ | ValueError: Exactly one of 'string' and 'table' cannot be None. """ if (string is not None) and (table is not None): raise ValueError( "Exactly one of 'string' and 'table' cannot be None.") | def __init__(self, string = None, frequencies = None): r""" Constructor for Huffman | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
if sum([string is not None, frequencies is not None]) != 1: raise ValueError("Exactly one of `string` or `frequencies` parameters must be defined") | self._tree = None self._index = None | def __init__(self, string = None, frequencies = None): r""" Constructor for Huffman | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
elif frequencies is not None: self._build_code(frequencies) def _build_code_from_tree(self, tree, d, prefix=''): r""" Builds the code corresponding to a given tree and prefix | elif table is not None: self._build_code(table) def _build_code_from_tree(self, tree, d, prefix): r""" Builds the Huffman code corresponding to a given tree and prefix. | def __init__(self, string = None, frequencies = None): r""" Constructor for Huffman | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
EXAMPLE:: | EXAMPLES:: | def _build_code_from_tree(self, tree, d, prefix=''): r""" Builds the code corresponding to a given tree and prefix | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
sage: h._build_code_from_tree(h._tree, d) """ | sage: h._build_code_from_tree(h._tree, d, prefix="") """ | def _build_code_from_tree(self, tree, d, prefix=''): r""" Builds the code corresponding to a given tree and prefix | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
self._build_code_from_tree(tree[0], d, prefix=prefix+'0') self._build_code_from_tree(tree[1], d, prefix=prefix+'1') | self._build_code_from_tree(tree[0], d, prefix="".join([prefix, "0"])) self._build_code_from_tree(tree[1], d, prefix="".join([prefix, "1"])) | def _build_code_from_tree(self, tree, d, prefix=''): r""" Builds the code corresponding to a given tree and prefix | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | Constructs a Huffman code corresponding to an alphabet with the given weight table. INPUT: - ``dic`` -- a dictionary that associates to each symbol of an alphabet a numeric value. If we consider the frequency of each alphabetic symbol, then ``dic`` is considered as the frequency table of the alphabet with each numeri... | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py | ||
index = dic.items() | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py | |
for i,(e,w) in enumerate(index): heappush(heap, (w, i) ) while len(heap)>=2: (w1, i1) = heappop(heap) (w2, i2) = heappop(heap) heappush(heap, (w1+w2,[i1,i2])) | for i, (s, w) in enumerate(dic.items()): heappush(heap, (w, i)) for i in range(1, len(dic)): weight_a, node_a = heappop(heap) weight_b, node_b = heappop(heap) heappush(heap, (weight_a + weight_b, [node_a, node_b])) | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
self._build_code_from_tree(self._tree, d) self._index = dict([(i,e) for i,(e,w) in enumerate(index)]) self._character_to_code = dict([(e,d[i]) for i,(e,w) in enumerate(index)]) | self._build_code_from_tree(self._tree, d, prefix="") self._index = dict((i, s) for i, (s, w) in enumerate(dic.items())) self._character_to_code = dict( (s, d[i]) for i, (s, w) in enumerate(dic.items())) | def _build_code(self, dic): r""" Returns a Huffman code for each one of the given elements. INPUT: - ``dic`` (dictionary) -- associates to each letter of the alphabet a frequency or a number of occurrences. | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
Returns an encoding of the given string based on the current encoding table INPUT: - ``string`` (string) EXAMPLE: This is how a string is encoded then decoded :: | Encode the given string based on the current encoding table. INPUT: - ``string`` -- a string of symbols over an alphabet. OUTPUT: - A Huffman encoding of ``string``. EXAMPLES: This is how a string is encoded and then decoded:: | def encode(self, string): r""" Returns an encoding of the given string based on the current encoding table | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
def encode(self, string): r""" Returns an encoding of the given string based on the current encoding table | d36ada9fa8d1207afa7f17ab966193d7d807e471 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9890/d36ada9fa8d1207afa7f17ab966193d7d807e471/huffman.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.