rem stringlengths 1 322k | add stringlengths 0 2.05M | context stringlengths 4 228k | meta stringlengths 156 215 |
|---|---|---|---|
is_ray.__doc__ = Vrepresentation.is_ray.__doc__ | def is_ray(self): """ Tests if this object is a ray. Always True by construction. | 58a962fefc201dcfd3e2e47df0f7b0e2cedced92 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/58a962fefc201dcfd3e2e47df0f7b0e2cedced92/polyhedra.py | |
is_line.__doc__ = Vrepresentation.is_line.__doc__ | def is_line(self): """ Tests if the object is a line. By construction it must be. | 58a962fefc201dcfd3e2e47df0f7b0e2cedced92 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/58a962fefc201dcfd3e2e47df0f7b0e2cedced92/polyhedra.py | |
Returns the identity projection. | Returns the identity projection of the polyhedron. | def identity(self): """ Returns the identity projection. | 58a962fefc201dcfd3e2e47df0f7b0e2cedced92 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/58a962fefc201dcfd3e2e47df0f7b0e2cedced92/polyhedra.py |
identity.__doc__ = projection_func_identity.__doc__ | def identity(self): """ Returns the identity projection. | 58a962fefc201dcfd3e2e47df0f7b0e2cedced92 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/58a962fefc201dcfd3e2e47df0f7b0e2cedced92/polyhedra.py | |
- ``algorithm`` - string (default: 'gmp') - ``'gmp'`` - use the GMP C-library factorial function - ``'pari'`` - use PARI's factorial function | - ``algorithm`` - string (default: 'gmp'): - ``'gmp'`` - use the GMP C-library factorial function - ``'pari'`` - use PARI's factorial function | def factorial(n, algorithm='gmp'): r""" Compute the factorial of `n`, which is the product `1\cdot 2\cdot 3 \cdots (n-1)\cdot n`. INPUT: - ``n`` - an integer - ``algorithm`` - string (default: 'gmp') - ``'gmp'`` - use the GMP C-library factorial function - ``'pari'`` - use PARI's factorial function OUTPUT: an... | 8cdf5e032fbf03e3ba6bed3d1fbcb1c171370d1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/8cdf5e032fbf03e3ba6bed3d1fbcb1c171370d1e/arith.py |
modulo `m\*n`. | modulo `m*n`. | def crt(a,b,m=None,n=None): r""" Use the Chinese Remainder Theorem to find some `x` such that `x=a \bmod m` and `x=b \bmod n`. Note that `x` is only well-defined modulo `m\*n`. EXAMPLES:: sage: crt(2, 1, 3, 5) -4 sage: crt(13,20,100,301) -2087 You can also use upper case:: sage: c = CRT(2,3, 3, 5); c 8 sage: c % 3 ... | 8cdf5e032fbf03e3ba6bed3d1fbcb1c171370d1e /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/8cdf5e032fbf03e3ba6bed3d1fbcb1c171370d1e/arith.py |
sage: region_plot([y>0, x>0, x^2+y^2<1], (-1.1, 1.1), (-1.1, 1.1), plot_points = 400).show(aspect_ratio=1) | sage: region_plot([y>0, x>0, x^2+y^2<1], (x,-1.1, 1.1), (y,-1.1, 1.1), plot_points = 400).show(aspect_ratio=1) | def region_plot(f, xrange, yrange, plot_points, incol, outcol, bordercol, borderstyle, borderwidth): 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), (ymin, ym... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
variables = reduce(lambda g1, g2: g1.union(g2), [set(g.variables()) for g in f], set([])) f = [equify(g, variables) for g in f] | f = [equify(g) for g in f] | def region_plot(f, xrange, yrange, plot_points, incol, outcol, bordercol, borderstyle, borderwidth): 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), (ymin, ym... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
def equify(f, variables = None): | def equify(f): | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
x |--> x^2 - 2 | x^2 - 2 | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
x |--> -x^2 + 2 | -x^2 + 2 | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
(x, y) |--> -x*y + 1 sage: equify(y > 0, (x,y)) (x, y) |--> -y | -x*y + 1 sage: equify(y > 0) -y | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
if variables == None: variables = f.variables() | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py | |
s = symbolic_expression(f.rhs() - f.lhs()).function(*variables) return s | return symbolic_expression(f.rhs() - f.lhs()) | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
s = symbolic_expression(f.lhs() - f.rhs()).function(*variables) return s | return symbolic_expression(f.lhs() - f.rhs()) | def equify(f, variables = None): """ 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 |--> x^2 - 2 sage: equify(x^2 > 2) x |--> -x^2 + 2 sage: equify... | 15f84735cfff3b4b3bd19bc07056647b6e202dd7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/15f84735cfff3b4b3bd19bc07056647b6e202dd7/contour_plot.py |
- Oscar Lazo, William Cauchois (2009-2010): Adding coordinate transformations | - Oscar Lazo, William Cauchois, Jason Grout (2009-2010): Adding coordinate transformations | sage: def f(x,y): return math.exp(x/5)*math.cos(y) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
class _CoordTrans(object): | class _Coordinates(object): | sage: def f(x,y): return math.exp(x/5)*math.cos(y) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
Sub-classes must implement the ``gen_transform`` method which, given | Sub-classes must implement the :meth:`transform` method which, given | sage: def f(x,y): return math.exp(x/5)*math.cos(y) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
def __init__(self, indep_var, dep_vars): | def __init__(self, dep_var, indep_vars): | sage: def f(x,y): return math.exp(x/5)*math.cos(y) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``indep_var`` - The independent variable (the function value will be | - ``dep_var`` - The dependent variable (the function value will be | def __init__(self, indep_var, dep_vars): """ INPUT: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``dep_vars`` - A list of dependent variables (the parameters will be | - ``indep_vars`` - A list of independent variables (the parameters will be | def __init__(self, indep_var, dep_vars): """ INPUT: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: from sage.plot.plot3d.plot3d import _CoordTrans sage: _CoordTrans('y', ['x']) Unknown coordinate system (y in terms of x) """ if hasattr(self, 'all_vars'): if set(self.all_vars) != set(dep_vars + [indep_var]): raise ValueError, 'not all variables were specified for ' + \ 'this coordinate system' self.indep_var = ... | sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates as arb sage: x,y,z=var('x,y,z') sage: c=arb((x+z,y*z,z), z, (x,y)) sage: c._name 'Arbitrary Coordinates' """ return self.__class__.__name__ def transform(self, **kwds): """ Return the transformation for this coordinate system in terms of the | def __init__(self, indep_var, dep_vars): """ INPUT: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
def to_cartesian(self, func, params): | def to_cartesian(self, func, params=None): | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``params`` - The parameters of func. Correspond to the dependent | - ``params`` - The parameters of func. Corresponds to the dependent | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans | sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: T = _ArbCoordTrans((x + y, x - y, z), z) sage: f(x, y) = x * y | sage: T = _ArbitraryCoordinates((x + y, x - y, z), z,[x,y]) sage: f(x, y) = 2*x+y | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
[x + y, x - y, x*y] """ | (x + y, x - y, 2*x + y) sage: [h(1,2) for h in T.to_cartesian(lambda x,y: 2*x+y)] [3, -1, 4] """ | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
if any([is_Expression(func), is_RealNumber(func), is_Integer(func)]): return self.gen_transform(**{ self.indep_var: func, self.dep_vars[0]: params[0], self.dep_vars[1]: params[1] | if params is not None and (is_Expression(func) or is_RealNumber(func) or is_Integer(func)): return self.transform(**{ self.dep_var: func, self.indep_vars[0]: params[0], self.indep_vars[1]: params[1] | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
indep_var_dummy = sage.symbolic.ring.var(self.indep_var) dep_var_dummies = sage.symbolic.ring.var(','.join(self.dep_vars)) transformation = self.gen_transform(**{ self.indep_var: indep_var_dummy, self.dep_vars[0]: dep_var_dummies[0], self.dep_vars[1]: dep_var_dummies[1] | dep_var_dummy = sage.symbolic.ring.var(self.dep_var) indep_var_dummies = sage.symbolic.ring.var(','.join(self.indep_vars)) transformation = self.transform(**{ self.dep_var: dep_var_dummy, self.indep_vars[0]: indep_var_dummies[0], self.indep_vars[1]: indep_var_dummies[1] | def to_cartesian(self, func, params): """ Returns a 3-tuple of functions, parameterized over ``params``, that represents the cartesian coordinates of the value of ``func``. | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
indep_var_dummy: func(x, y), dep_var_dummies[0]: x, dep_var_dummies[1]: y | dep_var_dummy: func(x, y), indep_var_dummies[0]: x, indep_var_dummies[1]: y | def subs_func(t): return lambda x,y: t.subs({ indep_var_dummy: func(x, y), dep_var_dummies[0]: x, dep_var_dummies[1]: y }) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
_name = 'Unknown coordinate system' | def subs_func(t): return lambda x,y: t.subs({ indep_var_dummy: func(x, y), dep_var_dummies[0]: x, dep_var_dummies[1]: y }) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py | |
return '%s (%s in terms of %s)' % \ (self._name, self.indep_var, ', '.join(self.dep_vars)) class _ArbCoordTrans(_CoordTrans): """ An arbitrary coordinate system transformation. """ def __init__(self, custom_trans, fvar): """ | """ Print out a coordinate system :: sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates as arb sage: x,y,z=var('x,y,z') sage: c=arb((x+z,y*z,z), z, (x,y)) sage: c Arbitrary Coordinates coordinate transform (z in terms of x, y) sage: c.__dict__['_name'] = 'My Special Coordinates' sage: c My Special Coordi... | def __repr__(self): return '%s (%s in terms of %s)' % \ (self._name, self.indep_var, ', '.join(self.dep_vars)) | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``custom_trans`` - A 3-tuple of transformations. This will be returned almost unchanged by ``gen_transform``, except the function variable will be substituted. - ``fvar`` - The function variable. """ super(_ArbCoordTrans, self).__init__('f', ['u', 'v']) self.custom_trans = custom_trans self.fvar = fvar def gen_tran... | - ``custom_trans`` - A 3-tuple of transformation functions. - ``dep_var`` - The dependent (function) variable. - ``indep_vars`` - a list of the two other independent variables. EXAMPLES:: sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates sage: x, y, z = var('x y z') sage: T = _ArbitraryCoordinates((x ... | def __init__(self, custom_trans, fvar): """ INPUT: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans | sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: T = _ArbCoordTrans((x + y, x - y, z), x) The independent and dependent variables don't really matter in the case of an arbitrary transformation (since it is already in terms of its own variables), so default values are provided:: sage: T.indep_var 'f' sage: T.dep_vars ['u', 'v'] Finally, an example of gen_tran... | sage: T = _ArbitraryCoordinates((x + y, x - y, z), x,[y,z]) sage: T.transform(x=z,y=1) (z + 1, z - 1, z) """ return tuple(t.subs(**kwds) for t in self.custom_trans) class Spherical(_Coordinates): | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- the *radial distance* (``r``), - the *elevation angle* (``theta``), - and the *azimuth angle* (``phi``). | - the *radial distance* (``radius``) from the origin - the *azimuth angle* (``azimuth``) from the positive `x`-axis - the *inclination angle* (``inclination``) from the positive `z`-axis | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
Construct a spherical transformation for a function ``r`` in terms of ``theta`` and ``phi``:: sage: T = Spherical('r', ['phi', 'theta']) If we construct some concrete variables, we can get a transformation:: | Construct a spherical transformation for a function for the radius in terms of the azimuth and inclination:: sage: T = Spherical('radius', ['azimuth', 'inclination']) If we construct some concrete variables, we can get a transformation in terms of those variables:: | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: T.gen_transform(r=r, theta=theta, phi=phi) (r*sin(theta)*cos(phi), r*sin(phi)*sin(theta), r*cos(theta)) Use with plot3d on a made-up function:: sage: plot3d(phi * theta, (phi, 0, 1), (theta, 0, 1), transformation=T) To graph a function ``theta`` in terms of ``r`` and ``phi``, you would use:: sage: Spherical('... | sage: T.transform(radius=r, azimuth=theta, inclination=phi) (r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)) We can plot with this transform. Remember that the independent variable is the radius, and the dependent variables are the azimuth and the inclination (in that order):: sage: plot3d(phi * theta, (th... | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
all_vars = ['r', 'theta', 'phi'] _name = 'Spherical coordinate system' def gen_transform(self, r=None, theta=None, phi=None): """ | def transform(self, radius=None, azimuth=None, inclination=None): """ A spherical coordinates transform. | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: T = Spherical('r', ['theta', 'phi']) sage: T.gen_transform(r=var('r'), theta=var('theta'), phi=var('phi')) (r*sin(theta)*cos(phi), r*sin(phi)*sin(theta), r*cos(theta)) """ return (r * sin(theta) * cos(phi), r * sin(theta) * sin(phi), r * cos(theta)) class Cylindrical(_CoordTrans): | sage: T = Spherical('radius', ['azimuth', 'inclination']) sage: T.transform(radius=var('r'), azimuth=var('theta'), inclination=var('phi')) (r*sin(phi)*cos(theta), r*sin(phi)*sin(theta), r*cos(phi)) """ return (radius * sin(inclination) * cos(azimuth), radius * sin(inclination) * sin(azimuth), radius * cos(inclination))... | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- the *radial distance* (``rho``), - the *angular position* or *azimuth* (``phi``), - and the *height* or *altitude* (``z``). | - the *radial distance* (``radius``) from the `z`-axis - the *azimuth angle* (``azimuth``) from the positive `x`-axis - the *height* or *altitude* (``height``) above the `xy`-plane | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
Construct a cylindrical transformation for a function ``rho`` in terms of ``phi`` and ``z``:: sage: T = Cylindrical('rho', ['phi', 'z']) | Construct a cylindrical transformation for a function for ``height`` in terms of ``radius`` and ``azimuth``:: sage: T = Cylindrical('height', ['radius', 'azimuth']) | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: rho, phi, z = var('rho phi z') sage: T.gen_transform(rho=rho, phi=phi, z=z) (rho*cos(phi), rho*sin(phi), z) Use with plot3d on a made-up function:: sage: plot3d(phi * z, (phi, 0, 1), (z, 0, 1), transformation=T) To graph a function ``z`` in terms of ``phi`` and ``rho`` you would use:: sage: Cylindrical('z', [... | sage: r, theta, z = var('r theta z') sage: T.transform(radius=r, azimuth=theta, height=z) (r*cos(theta), r*sin(theta), z) We can plot with this transform. Remember that the independent variable is the height, and the dependent variables are the radius and the azimuth (in that order):: sage: plot3d(9-r^2, (r, 0, 3), ... | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
_name = 'Cylindrical coordinate system' all_vars = ['rho', 'phi', 'z'] def gen_transform(self, rho=None, phi=None, z=None): """ | def transform(self, radius=None, azimuth=None, height=None): """ A cylindrical coordinates transform. | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: T = Cylindrical('z', ['phi', 'rho']) sage: T.gen_transform(rho=var('rho'), phi=var('phi'), z=var('z')) (rho*cos(phi), rho*sin(phi), z) """ return (rho * cos(phi), rho * sin(phi), z) | sage: T = Cylindrical('height', ['azimuth', 'radius']) sage: T.transform(radius=var('r'), azimuth=var('theta'), height=var('z')) (r*cos(theta), r*sin(theta), z) """ return (radius * cos(azimuth), radius * sin(azimuth), height) | def gen_transform(self, rho=None, phi=None, z=None): """ EXAMPLE:: | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``transformation`` - (default: None) a transformation to apply. May be a 4-tuple (x_func, y_func, z_func, fvar) where the first 3 items indicate a transformation to cartesian coordinates (from your coordinate system) in terms of u, v, and the function variable fvar (for which the value of f will be substituted). May ... | - ``transformation`` - (default: None) a transformation to apply. May be a 3 or 4-tuple (x_func, y_func, z_func, independent_vars) where the first 3 items indicate a transformation to cartesian coordinates (from your coordinate system) in terms of u, v, and the function variable fvar (for which the value of f will be s... | def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): """ INPUT: - ``f`` - a symbolic expression or function of 2 variables - ``urange`` - a 2-tuple (u_min, u_max) or a 3-tuple (u, u_min, u_max) - ``vrange`` - a 2-tuple (v_min, v_max) or a 3-tuple (v, v_min, v_max) - ``adaptive`` - (defaul... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: trans=(r*cos(phi),r*sin(phi),z,z) | sage: trans=(r*cos(phi),r*sin(phi),z) | def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): """ INPUT: - ``f`` - a symbolic expression or function of 2 variables - ``urange`` - a 2-tuple (u_min, u_max) or a 3-tuple (u, u_min, u_max) - ``vrange`` - a 2-tuple (v_min, v_max) or a 3-tuple (v, v_min, v_max) - ``adaptive`` - (defaul... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: rectangular=(u,v,w,w) sage: spherical=(w*cos(u)*sin(v),w*sin(u)*sin(v),w*cos(v),w) sage: cylindric_radial=(w*cos(u),w*sin(u),v,w) sage: cylindric_axial=(v*cos(u),v*sin(u),w,w) sage: parabolic_cylindrical=(w*v,(v^2-w^2)/2,u,w) | sage: rectangular=(u,v,w) sage: spherical=(w*cos(u)*sin(v),w*sin(u)*sin(v),w*cos(v)) sage: cylindric_radial=(w*cos(u),w*sin(u),v) sage: cylindric_axial=(v*cos(u),v*sin(u),w) sage: parabolic_cylindrical=(w*v,(v^2-w^2)/2,u) | def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): """ INPUT: - ``f`` - a symbolic expression or function of 2 variables - ``urange`` - a 2-tuple (u_min, u_max) or a 3-tuple (u, u_min, u_max) - ``vrange`` - a 2-tuple (v_min, v_max) or a 3-tuple (v, v_min, v_max) - ``adaptive`` - (defaul... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: def _(which_plot=[A,B,C,D,E]): | ... def _(which_plot=[A,B,C,D,E]): | sage: def _(which_plot=[A,B,C,D,E]): | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: def _(which_plot=[F, G, H, I, J]): | ... def _(which_plot=[F, G, H, I, J]): | sage: def _(which_plot=[F, G, H, I, J]): | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
else: raise ValueError, 'expected 3-tuple for urange and vrange' | sage: def _(which_plot=[F, G, H, I, J]): | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py | |
transformation = _ArbCoordTrans(transformation[0:3], transformation[3]) if isinstance(transformation, _CoordTrans): | if len(transformation)==3: if params is None: raise ValueError, "must specify independent variable names in the ranges when using generic transformation" indep_vars = params elif len(transformation)==4: indep_vars = transformation[3] transformation = transformation[0:3] else: raise ValueError, "unknown transformation t... | sage: def _(which_plot=[F, G, H, I, J]): | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
Takes a function and plots it in spherical coordinates in the domain specified by urange and vrange. This function is equivalent to:: sage: var('r,u,u') sage: T = (r*cos(u)*sin(v), r*sin(u)*sin(v), r*cos(v), r) | Plots a function in spherical coordinates. This function is equivalent to:: sage: r,u,v=var('r,u,v') sage: f=u*v; urange=(u,0,pi); vrange=(v,0,pi) sage: T = (r*cos(u)*sin(v), r*sin(u)*sin(v), r*cos(v), [u,v]) | def spherical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in spherical coordinates in the domain specified by urange and vrange. This function is equivalent to:: sage: var('r,u,u') sage: T = (r*cos(u)*sin(v), r*sin(u)*sin(v), r*cos(v), r) sage: plot3d(f, urange, vrange, transformation=T) INPU... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
return plot3d(f, urange, vrange, transformation=Spherical('r', ['phi', 'theta']), **kwds) | return plot3d(f, urange, vrange, transformation=Spherical('radius', ['azimuth', 'inclination']), **kwds) | def spherical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in spherical coordinates in the domain specified by urange and vrange. This function is equivalent to:: sage: var('r,u,u') sage: T = (r*cos(u)*sin(v), r*sin(u)*sin(v), r*cos(v), r) sage: plot3d(f, urange, vrange, transformation=T) INPU... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) | Plots a function in cylindrical coordinates. This function is equivalent to:: sage: r,u,v=var('r,u,v') sage: f=u*v; urange=(u,0,pi); vrange=(v,0,pi) sage: T = (r*cos(u), r*sin(u), v, [u,v]) | def cylindrical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) sage: plot3d(f, urange, vrange, transformation=T) INPUT: - ``f`` - a sy... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
- ``f`` - a symbolic expression or function of two variables. - ``urange`` - a 3-tuple (u, u_min, u_max), the domain of the azimuth variable. - ``vrange`` - a 3-tuple (v, v_min, v_max), the domain of the elevation (z) variable. | - ``f`` - a symbolic expression or function of two variables, representing the radius from the `z`-axis. - ``urange`` - a 3-tuple (u, u_min, u_max), the domain of the azimuth variable. - ``vrange`` - a 3-tuple (v, v_min, v_max), the domain of the elevation (`z`) variable. | def cylindrical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) sage: plot3d(f, urange, vrange, transformation=T) INPUT: - ``f`` - a sy... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: var('fi,z') sage: cylindrical_plot3d(2,(fi,0,3*pi/2),(z,-2,2)) | sage: theta,z=var('theta,z') sage: cylindrical_plot3d(2,(theta,0,3*pi/2),(z,-2,2)) | def cylindrical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) sage: plot3d(f, urange, vrange, transformation=T) INPUT: - ``f`` - a sy... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: cylindrical_plot3d(cosh(z),(fi,0,2*pi),(z,-2,2)) | sage: cylindrical_plot3d(cosh(z),(theta,0,2*pi),(z,-2,2)) | def cylindrical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) sage: plot3d(f, urange, vrange, transformation=T) INPUT: - ``f`` - a sy... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
sage: cylindrical_plot3d(e^(-z^2)*(cos(4*fi)+2)+1,(fi,0,2*pi),(z,-2,2),plot_points=[80,80]).show(aspect_ratio=(1,1,1)) """ return plot3d(f, urange, vrange, transformation=Cylindrical('rho', ['phi', 'z']), **kwds) | sage: cylindrical_plot3d(e^(-z^2)*(cos(4*theta)+2)+1,(theta,0,2*pi),(z,-2,2),plot_points=[80,80]).show(aspect_ratio=(1,1,1)) """ return plot3d(f, urange, vrange, transformation=Cylindrical('radius', ['azimuth', 'height']), **kwds) | def cylindrical_plot3d(f, urange, vrange, **kwds): """ Takes a function and plots it in cylindrical coordinates in the domain specified by urange and vrange. This command is equivalent to:: sage: var('r,u,v') sage: T = (r*cos(u), r*sin(u), v, r) sage: plot3d(f, urange, vrange, transformation=T) INPUT: - ``f`` - a sy... | 85811d8c24ec26acc8a960fadc0b24274c01a5a8 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/85811d8c24ec26acc8a960fadc0b24274c01a5a8/plot3d.py |
TypeError, "No lookup table provided." | raise TypeError("No lookup table provided.") | def __init__(self, *args, **kwargs): """ Construct a substitution box (S-box) for a given lookup table `S`. | 7db71f52a07b6303429fd5109e3af046f6d5f775 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7db71f52a07b6303429fd5109e3af046f6d5f775/sbox.py |
length = ZZ(len(S)).exact_log(2) if length != int(length): TypeError, "lookup table length is not a power of 2." self.m = int(length) | self.m = ZZ(len(S)).exact_log(2) | def __init__(self, *args, **kwargs): """ Construct a substitution box (S-box) for a given lookup table `S`. | 7db71f52a07b6303429fd5109e3af046f6d5f775 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/7db71f52a07b6303429fd5109e3af046f6d5f775/sbox.py |
variables x,y:: | variables `x`, `y`:: | def contour_plot(f, xrange, yrange, **options): r""" ``contour_plot`` takes a function of two variables, `f(x,y)` and plots contour lines of the function over the specified ``xrange`` and ``yrange`` as demonstrated below. ``contour_plot(f, (xmin, xmax), (ymin, ymax), ...)`` INPUT: - ``f`` -- a function of two variab... | 1be89942e80d3d044db8b1d126931ba7f5a875fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/1be89942e80d3d044db8b1d126931ba7f5a875fb/contour_plot.py |
sage: contour_plot(x^2-y^2,(x,-3,3),(y,-3,3),contours=[0,1,2,3,4],linewidths=[1,5],linestyles=['solid','dashed'],fill=False) sage: contour_plot(x^2-y^2,(x,-3,3),(y,-3,3),contours=[0,1,2,3,4],linewidths=[1,5],linestyles=['solid','dashed']) | :: sage: P=contour_plot(x^2-y^2,(x,-3,3),(y,-3,3),contours=[0,1,2,3,4],\ ... linewidths=[1,5],linestyles=['solid','dashed'],fill=False) sage: P :: sage: P=contour_plot(x^2-y^2,(x,-3,3),(y,-3,3),contours=[0,1,2,3,4],\ ... linewidths=[1,5],linestyles=['solid','dashed']) sage: P | def contour_plot(f, xrange, yrange, **options): r""" ``contour_plot`` takes a function of two variables, `f(x,y)` and plots contour lines of the function over the specified ``xrange`` and ``yrange`` as demonstrated below. ``contour_plot(f, (xmin, xmax), (ymin, ymax), ...)`` INPUT: - ``f`` -- a function of two variab... | 1be89942e80d3d044db8b1d126931ba7f5a875fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/1be89942e80d3d044db8b1d126931ba7f5a875fb/contour_plot.py |
sage: contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi), fill=False, cmap='hsv', labels=True) sage: contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi), fill=False, cmap='hsv', labels=True, label_fmt="%1.0f", label_colors='black') sage: contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi), fill=False, cmap='h... | sage: contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi), fill=False, cmap='hsv', labels=True) :: sage: P=contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi), (y,-pi,pi), fill=False, cmap='hsv',\ ... labels=True, label_fmt="%1.0f", label_colors='black') sage: P :: sage: P=contour_plot(y^2 + 1 - x^3 - x, (x,-pi,pi),... | def contour_plot(f, xrange, yrange, **options): r""" ``contour_plot`` takes a function of two variables, `f(x,y)` and plots contour lines of the function over the specified ``xrange`` and ``yrange`` as demonstrated below. ``contour_plot(f, (xmin, xmax), (ymin, ymax), ...)`` INPUT: - ``f`` -- a function of two variab... | 1be89942e80d3d044db8b1d126931ba7f5a875fb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/1be89942e80d3d044db8b1d126931ba7f5a875fb/contour_plot.py |
- ``m``, ``n`` - two moduli, or None. | - ``m``, ``n`` - (default: ``None``) two moduli, or ``None``. | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
If ``m``, ``n`` are not None, returns a solution `x` to the | If ``m``, ``n`` are not ``None``, returns a solution `x` to the | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
n`, if one exists; which is if and only if `a\equiv b\pmod{\gcd(m,n)}` by the Chinese Remainder Theorem. The solution `x` is only well-defined modulo lcm`(m,n)`. | n`, if one exists. By the Chinese Remainder Theorem, a solution to the simultaneous congruences exists if and only if `a\equiv b\pmod{\gcd(m,n)}`. The solution `x` is only well-defined modulo `\text{lcm}(m,n)`. | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
EXAMPLES:: | .. SEEALSO:: - :func:`CRT_list` EXAMPLES: Using ``crt`` by giving it pairs of residues and moduli:: | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
sage: crt(13,20,100,301) | sage: crt(13, 20, 100, 301) 28013 sage: crt([2, 1], [3, 5]) 11 sage: crt([13, 20], [100, 301]) | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
if isinstance(a,list): return CRT_list(a,b) g, alpha, beta = XGCD(m,n) q,r = (b-a).quo_rem(g) if r!=0: raise ValueError, "No solution to crt problem since gcd(%s,%s) does not divide %s-%s"%(m,n,a,b) return (a+q*alpha*m) % lcm(m,n) | if isinstance(a, list): return CRT_list(a, b) g, alpha, beta = XGCD(m, n) q, r = (b - a).quo_rem(g) if r != 0: raise ValueError("No solution to crt problem since gcd(%s,%s) does not divide %s-%s" % (m, n, a, b)) return (a + q*alpha*m) % lcm(m, n) | def crt(a,b,m=None,n=None): r""" Returns a solution to a Chinese Remainder Theorem problem. INPUT: - ``a``, ``b`` - two residues (elements of some ring for which extended gcd is available), or two lists, one of residues and one of moduli. - ``m``, ``n`` - two moduli, or None. OUTPUT: If ``m``, ``n`` are not None, ... | c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c4c4857b06059d9fdba46cbaf64ffd83c3f8bac4/arith.py |
and only if `p_2` dominates `p_1`. | and only if the conjugate of `p_2` dominates `p_1`. | def gale_ryser_theorem(p1, p2, algorithm="ryser"): r""" Returns the binary matrix given by the Gale-Ryser theorem. The Gale Ryser theorem asserts that if `p_1,p_2` are two partitions of `n` of respective lengths `k_1,k_2`, then there is a binary `k_1\times k_2` matrix `M` such that `p_1` is the vector of row sums and ... | cc09b0fb3f408604caeb1f77a7922892fa54ded4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/cc09b0fb3f408604caeb1f77a7922892fa54ded4/integer_vector.py |
- ``p1`` -- the first partition of `n` (trailing 0's allowed) - ``p2`` -- the second partition of `n` (trailing 0's allowed) | - ``p1, p2``-- list of integers representing the vectors of row/column sums | def gale_ryser_theorem(p1, p2, algorithm="ryser"): r""" Returns the binary matrix given by the Gale-Ryser theorem. The Gale Ryser theorem asserts that if `p_1,p_2` are two partitions of `n` of respective lengths `k_1,k_2`, then there is a binary `k_1\times k_2` matrix `M` such that `p_1` is the vector of row sums and ... | cc09b0fb3f408604caeb1f77a7922892fa54ded4 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/cc09b0fb3f408604caeb1f77a7922892fa54ded4/integer_vector.py |
""" | r""" | def selmer_group(self, S, m, proof=True): """ Compute the Selmer group `K(S,m)`, which is defined to be the subgroup of `K^\times/(K^\times)^m` consisting of elements `a` such that `K(\sqrt[m]{a})/K` is unramified at all primes of `K` lying above a place outside of `S`. | 5d98cd9b58ad8f7017f5282eda58958e195331b7 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/5d98cd9b58ad8f7017f5282eda58958e195331b7/number_field.py |
sage: P1 in G | sage: P1 in G | def _call_(self, x): r""" TEST:: | 0bd99622f910c5a456ea17a7a8b3975be000dabb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0bd99622f910c5a456ea17a7a8b3975be000dabb/additive_abelian_wrapper.py |
return u[0] | return u[0].vector() | def _discrete_log(self,x): # EVEN DUMBER IMPLEMENTATION! u = [y for y in self.list() if y.element() == x] if len(u) == 0: raise TypeError, "Not in group" if len(u) > 1: raise NotImplementedError return u[0] | 0bd99622f910c5a456ea17a7a8b3975be000dabb /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0bd99622f910c5a456ea17a7a8b3975be000dabb/additive_abelian_wrapper.py |
p.add_constraint(v[x] + b[x][y] - v[y], min=0, max=0) | p.add_constraint(v[x] + b[x][y] - v[y], min=0) | def edge_cut(self, s, t, value_only=True, use_edge_labels=False, vertices=False, solver=None, verbose=0): r""" Returns a minimum edge cut between vertices `s` and `t` represented by a list of edges. | e54fd0c7a4489bf943b961b01f9db55f6922f699 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/e54fd0c7a4489bf943b961b01f9db55f6922f699/generic_graph.py |
-95 -1 -2 | -95 -1 -2 | def _sage_(self, R=None): """ Coerces self to Sage. | c65378511e7fe1a936f41572269504b0ee5226b9 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/c65378511e7fe1a936f41572269504b0ee5226b9/singular.py |
(\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of strings like | (\\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (\`$ or \$`), because of strings like | def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of s... | 645ba13928c1b03876b1efd1df87a08b25f28314 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/645ba13928c1b03876b1efd1df87a08b25f28314/sagedoc.py |
Replace \$ with $, and don't do anything when backticks are involved:: | Replace \\$ with $, and don't do anything when backticks are involved:: | def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of s... | 645ba13928c1b03876b1efd1df87a08b25f28314 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/645ba13928c1b03876b1efd1df87a08b25f28314/sagedoc.py |
This is not perfect: | This is not perfect:: | def process_dollars(s): r"""nodetex Replace dollar signs with backticks. More precisely, do a regular expression search. Replace a plain dollar sign ($) by a backtick (`). Replace an escaped dollar sign (\$) by a dollar sign ($). Don't change a dollar sign preceded or followed by a backtick (`$ or $`), because of s... | 645ba13928c1b03876b1efd1df87a08b25f28314 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/645ba13928c1b03876b1efd1df87a08b25f28314/sagedoc.py |
Replace \mathtt{BLAH} with either \verb|BLAH| (in the notebook) or | Replace \\mathtt{BLAH} with either \\verb|BLAH| (in the notebook) or | def process_mathtt(s, embedded=False): r"""nodetex Replace \mathtt{BLAH} with either \verb|BLAH| (in the notebook) or BLAH (from the command line). INPUT: - ``s`` - string, in practice a docstring - ``embedded`` - boolean (optional, default False) This function is called by :func:`format`, and if in the notebook, it... | 645ba13928c1b03876b1efd1df87a08b25f28314 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/645ba13928c1b03876b1efd1df87a08b25f28314/sagedoc.py |
- ``category`` - a category; reserved for future use - ``skip`` - a string or list (or iterable) of strings | - ``category`` - a category; reserved for future use - ``skip`` - a string or list (or iterable) of strings | def run(self, category = None, skip = [], catch = True, raise_on_failure = False, **options): """ Run all the tests from this test suite: | b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f/sage_unittest.py |
- ``catch` - a boolean (default: True) | - ``catch`` - a boolean (default: True) | def run(self, category = None, skip = [], catch = True, raise_on_failure = False, **options): """ Run all the tests from this test suite: | b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f/sage_unittest.py |
sage: ZZ._tester() Testing utilities for Integer Ring | sage: QQ._tester() Testing utilities for Rational Field | def instance_tester(instance, tester = None, **options): """ Returns a gadget attached to ``instance`` providing testing utilities. EXAMPLES:: sage: from sage.misc.sage_unittest import instance_tester sage: tester = instance_tester(ZZ) sage: tester.assert_(1 == 1) sage: tester.assert_(1 == 0) Traceback (most recent ... | b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f/sage_unittest.py |
sage: ZZ._tester() Testing utilities for Integer Ring | sage: QQ._tester() Testing utilities for Rational Field | def __init__(self, instance, elements = None, verbose = False, prefix = "", **options): """ A gadget attached to an instance providing it with testing utilities. | b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/b2b6998afb309d52df6e83bf3b9b672c2c6a0e8f/sage_unittest.py |
sage: m = matrix(3, lambda i,j: i-j) | sage: m = matrix(3, lambda i,j: i-j); m | def matrix(*args, **kwds): """ Create a matrix. INPUT: The matrix command takes the entries of a matrix, optionally preceded by a ring and the dimensions of the matrix, and returns a matrix. The entries of a matrix can be specified as a flat list of elements, a list of lists (i.e., a list of rows), a list of Sage vec... | 8e568895f17b6ba26e53cc5640add7f2b3281139 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/8e568895f17b6ba26e53cc5640add7f2b3281139/constructor.py |
out = copy.deepcopy(_pik.loads(self._check_types)) return out def check_ieee_macros(self, *a, **kw): if self._check_ieee_macros is None: out = check_ieee_macros(*a, **kw) self._check_ieee_macros = _pik.dumps(out) | body.append(" %s;" % func) body.append(" return 0;") body.append("}") body = '\n'.join(body) + "\n" return self.try_link(body, headers, include_dirs, libraries, library_dirs) def check_funcs_once(self, funcs, headers=None, include_dirs=None, libraries=None, library_dirs=None, decl=False, call=False, call_args=None)... | def check_types(self, *a, **kw): if self._check_types is None: out = check_types(*a, **kw) self._check_types = _pik.dumps(out) else: out = copy.deepcopy(_pik.loads(self._check_types)) return out | 37a71c453b67f06646e51013b2c929ce8b65459c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/37a71c453b67f06646e51013b2c929ce8b65459c/config.py |
out = copy.deepcopy(_pik.loads(self._check_ieee_macros)) return out def check_complex(self, *a, **kw): if self._check_complex is None: out = check_complex(*a, **kw) self._check_complex = _pik.dumps(out) else: out = copy.deepcopy(_pik.loads(self._check_complex)) return out PYTHON_HAS_UNICODE_WIDE = True def pythonlib... | for f in funcs: body.append(" %s;" % f) body.append(" return 0;") body.append("}") body = '\n'.join(body) + "\n" return self.try_link(body, headers, include_dirs, libraries, library_dirs) def check_inline(self): """Return the inline keyword recognized by the compiler, empty string otherwise.""" return check_inline(... | def check_ieee_macros(self, *a, **kw): if self._check_ieee_macros is None: out = check_ieee_macros(*a, **kw) self._check_ieee_macros = _pik.dumps(out) else: out = copy.deepcopy(_pik.loads(self._check_ieee_macros)) return out | 37a71c453b67f06646e51013b2c929ce8b65459c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/37a71c453b67f06646e51013b2c929ce8b65459c/config.py |
nosmp = os.environ['NPY_NOSMP'] nosmp = 1 except KeyError: nosmp = 0 return nosmp == 1 def win32_checks(deflist): from numpy.distutils.misc_util import get_build_architecture a = get_build_architecture() print('BUILD_ARCHITECTURE: %r, os.name=%r, sys.platform=%r' % \ (a, os.name, sys.platform)) if a == 'AMD64': defl... | src, obj, exe = self._link(body, headers, include_dirs, libraries, library_dirs, lang) exe = os.path.join('.', exe) exitstatus, output = exec_command(exe, execute_in='.') if hasattr(os, 'WEXITSTATUS'): exitcode = os.WEXITSTATUS(exitstatus) if os.WIFSIGNALED(exitstatus): sig = os.WTERMSIG(exitstatus) log.error('subproce... | def is_npy_no_smp(): """Return True if the NPY_NO_SMP symbol must be defined in public header (when SMP support cannot be reliably enabled).""" # Python 2.3 causes a segfault when # trying to re-acquire the thread-state # which is done in error-handling # ufunc code. NPY_ALLOW_C_API and friends # cause the segfaul... | 37a71c453b67f06646e51013b2c929ce8b65459c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/37a71c453b67f06646e51013b2c929ce8b65459c/config.py |
priv.extend([fname2def(f) for f in flist]) check_prec('') check_prec('f') check_prec('l') return priv, pub def check_ieee_macros(config): priv = [] pub = [] macros = [] def _add_decl(f): priv.append(fname2def("decl_%s" % f)) pub.append('NPY_%s' % fname2def("decl_%s" % f)) _macros = ["isnan", "isinf", "signbit... | exitcode = exitstatus log.info("success!") except (CompileError, LinkError): log.info("failure.") self._clean() return exitcode, output | def check_prec(prec): flist = [f + prec for f in C99_COMPLEX_FUNCS] decl = dict([(f, True) for f in flist]) if not config.check_funcs_once(flist, call=decl, decl=decl, libraries=mathlibs): for f in flist: if config.check_func(f, call=True, decl=True, libraries=mathlibs): priv.append(fname2def(f)) else: priv.extend([fna... | 37a71c453b67f06646e51013b2c929ce8b65459c /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/37a71c453b67f06646e51013b2c929ce8b65459c/config.py |
Check if a sage object belongs to self. This methods is a helper for | Check if a Sage object belongs to self. This methods is a helper for | def _is_a(self, x): """ Check if a sage object belongs to self. This methods is a helper for :meth:`__contains__` and the constructor :meth:`_element_constructor_`. | 62c8437e005a688e712c36d6d3897153c0c6da68 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/62c8437e005a688e712c36d6d3897153c0c6da68/disjoint_union_enumerated_sets.py |
self._error_re = re.compile('(Principal Value|debugmode|Incorrect syntax|Maxima encountered a Lisp error)') | self._error_re = re.compile('(Principal Value|debugmode|incorrect syntax|Maxima encountered a Lisp error)') | def __init__(self, script_subdirectory=None, logfile=None, server=None, init_code = None): """ Create an instance of the Maxima interpreter. | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
sage: maxima.eval('sage0: x == x;') | sage: maxima._eval_line('sage0: x == x;') | def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
TypeError: error evaluating "sage0: x == x;":... | TypeError: Error executing code in Maxima... | def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
pre_out = self._before() self._expect_expr() out = self._before() | out = self._before() | def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
self._error_check(line, pre_out) | def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py | |
i = o.rfind('(%o') return o[:i] | def _eval_line(self, line, allow_use_file=False, wait_for_prompt=True, reformat=True, error_check=True): """ EXAMPLES: | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py | |
def _command_runner(self, command, s, redirect=True): """ Run ``command`` in a new Maxima session and return its output as an ``AsciiArtString``. | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py | ||
for _ in range(3): | for _ in range(5): | def _command_runner(self, command, s, redirect=True): """ Run ``command`` in a new Maxima session and return its output as an ``AsciiArtString``. | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
'5.20.1' | '5.22.1' | def version(self): """ Return the version of Maxima that Sage includes. | 0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0 /local1/tlutelli/issta_data/temp/all_python//python/2010_temp/2010/9417/0b796a5c0ac8e667cd5ef6b96db8e7e2b5b339c0/maxima.py |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.