rem stringlengths 0 322k | add stringlengths 0 2.05M | context stringlengths 8 228k |
|---|---|---|
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:: sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans sage: x, y, z = var('x y z') sage: T = _ArbCoordTrans((x + y, x - y, z), x) |
- 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 | def gen_transform(self, f=None, u=None, v=None): """ EXAMPLE:: sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans sage: x, y, z = var('x y z') sage: T = _ArbCoordTrans((x + y, x - y, z), x) |
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:: sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans sage: x, y, z = var('x y z') sage: T = _ArbCoordTrans((x + y, x - y, z), x) |
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:: sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans sage: x, y, z = var('x y z') sage: T = _ArbCoordTrans((x + y, x - y, z), x) |
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:: sage: from sage.plot.plot3d.plot3d import _ArbCoordTrans sage: x, y, z = var('x y z') sage: T = _ArbCoordTrans((x + y, x - y, z), x) |
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:: 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(th... |
- the *radial distance* (``rho``), | - the *radial distance* (``radius``) from the `z`-axis - the *azimuth angle* (``azimuth``) from the positive `x`-axis | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: 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(th... |
- the *angular position* or *azimuth* (``phi``), - and the *height* or *altitude* (``z``). | - the *height* or *altitude* (``height``) above the `xy`-plane | def gen_transform(self, r=None, theta=None, phi=None): """ EXAMPLE:: 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(th... |
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:: 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(th... |
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:: 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(th... |
_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:: 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(th... |
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:: |
- ``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`` - (defau... |
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`` - (defau... |
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`` - (defau... |
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]): |
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]): |
else: raise ValueError, 'expected 3-tuple for urange and vrange' | sage: def _(which_plot=[F, G, H, I, J]): | |
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]): |
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... |
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... |
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... |
- ``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... |
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... |
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... |
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... |
""" Theta_Precision = bound | sage: Q = QuadraticForm(ZZ, 4, [1,1,1,1, 1,0,0, 1,0, 1]) sage: map(len, Q.vectors_by_length(2)) [1, 12, 12] """ eps = RDF(1e-6) bound = ZZ(floor(bound)) Theta_Precision = bound + eps | def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all v... |
empty_vec_list = [[] for i in range(Theta_Precision + 1)] theta_vec = [[] for i in range(Theta_Precision + 1)] | theta_vec = [[] for i in range(bound + 1)] | def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all v... |
Z = sqrt(T[i] / Q[i][i]) L[i] = ZZ(floor(Z - U[i])) x[i] = ZZ(ceil(-Z - U[i]) - 0) | Z = (T[i] / Q[i][i]).sqrt(extend=False) L[i] = ( Z - U[i]).floor() x[i] = (-Z - U[i]).ceil() | def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all v... |
Q_val = ZZ(floor(round(Q_val_double))) | Q_val = Q_val_double.round() | def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all v... |
if (Q_val <= Theta_Precision): | if (Q_val <= bound): | def vectors_by_length(self, bound): """ Returns a list of short vectors together with their values. This is a naive algorithm which uses the Cholesky decomposition, but does not use the LLL-reduction algorithm. INPUT: bound -- an integer >= 0 OUTPUT: A list L of length (bound + 1) whose entry L[i] is a list of all v... |
n = x.parent()(1) | n = parent(x)(1) | def squarefree_part(x): """ Returns the square free part of `x`, i.e., a divisor `z` such that `x = z y^2`, for a perfect square `y^2`. EXAMPLES:: sage: squarefree_part(100) 1 sage: squarefree_part(12) 3 sage: squarefree_part(10) 10 :: sage: x = QQ['x'].0 sage: S = squarefree_part(-9*x*(x-6)^7*(x-3)^2); S -9*x^2 + ... |
bug reported in trac | Bug reported in trac | sage: def my_carmichael(n): |
import sage.rings.integer n = sage.rings.integer.Integer(n) | n = Integer(n) | sage: def my_carmichael(n): |
return map(lambda x: int(x), list(n.binary()[-k:])) | return map(int, list(n.binary()[-k:])) | def least_significant_bits(n, k): r""" Return the ``k`` least significant bits of ``n``. INPUT: - ``n`` -- an integer. - ``k`` -- a positive integer. OUTPUT: - The ``k`` least significant bits of the integer ``n``. If ``k=1``, then return the parity bit of the integer ``n``. Let `b` be the binary representation of... |
def CharacteristicSturmianWord(self, cf, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word of the given slope ``cf``. The `n`-th term of the characteristic Sturmian word of an irrational slope `\alpha` is `\lfloor\alpha(n+1)\rfloor - \lfloor\alpha n\rfloor + \lfloor\alpha\rfloor`. [1] | def CharacteristicSturmianWord(self, slope, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word (also called standard Sturmian word) of given slope. Over a binary alphabet `\{a,b\}`, the characteristic Sturmian word `c_\alpha` of slope `\alpha` is the infinite word satisfying `s_{\alpha,0} = ac_... | def CharacteristicSturmianWord(self, cf, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word of the given slope ``cf``. |
- ``cf`` - the slope of the word. It can be one of the following : | - ``slope`` - the slope of the word. It can be one of the following : | def CharacteristicSturmianWord(self, cf, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word of the given slope ``cf``. |
- ``bits`` - integer (optional and considered only if ``cf`` is a real number) the number of bits to consider when computing the | - ``bits`` - integer (optional and considered only if ``slope`` is a real number) the number of bits to consider when computing the | def CharacteristicSturmianWord(self, cf, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word of the given slope ``cf``. |
slope `\alpha` is the limit of the sequence: `s_0 = 1`, `s_1 = 0` | slope `\alpha` is the limit of the sequence: `s_0 = b`, `s_1 = a` | def CharacteristicSturmianWord(self, cf, alphabet=(0, 1), bits=None): r""" Returns the characteristic Sturmian word of the given slope ``cf``. |
The characteristic sturmian word of slope `(\sqrt(3)-1)/2`:: | The characteristic sturmian word of slope `(\sqrt{3}-1)/2`:: | sage: def cf(): |
`(\sqrt(3)-1)/2`:: | `(\sqrt{3}-1)/2`:: | sage: def cf(): |
sturmian word of slope `(\sqrt(3)-1)/2`:: | sturmian word of slope `(\sqrt{3}-1)/2`:: | sage: def cf(): |
NotImplementedError: The argument cf (=5/4) must be in ]0,1[. | ValueError: The argument slope (=5/4) must be in ]0,1[. | sage: def cf(): |
if cf in RR: if not 0 < cf < 1: msg = "The argument cf (=%s) must be in ]0,1[."%cf raise NotImplementedError, msg | if slope in RR: if not 0 < slope < 1: msg = "The argument slope (=%s) must be in ]0,1[."%slope raise ValueError, msg | sage: def cf(): |
cf = iter(CFF(cf, bits=bits)) | cf = iter(CFF(slope, bits=bits)) | sage: def cf(): |
elif hasattr(cf, '__iter__'): cf = iter(cf) | elif hasattr(slope, '__iter__'): cf = iter(slope) | sage: def cf(): |
raise TypeError("cf (=%s) must be a real number"%cf + | raise TypeError("slope (=%s) must be a real number"%slope + | sage: def cf(): |
Returns the lower mechanical word. The word `s_{\alpha,\rho}` is the *lower mechanical word* with slope `\alpha` and intercept `\rho` defined by | Returns the lower mechanical word with slope `\alpha` and intercept `\rho` The lower mechanical word `s_{\alpha,\rho}` with slope `\alpha` and intercept `\rho` is defined by | def LowerMechanicalWord(self, alpha, rho=0, alphabet=None): r""" Returns the lower mechanical word. |
\lfloor\alpha n + \rho\rfloor`. [1] | \lfloor\alpha n + \rho\rfloor` [1]. | def LowerMechanicalWord(self, alpha, rho=0, alphabet=None): r""" Returns the lower mechanical word. |
raise NotImplementedError, msg | raise ValueError, msg | def LowerMechanicalWord(self, alpha, rho=0, alphabet=None): r""" Returns the lower mechanical word. |
Returns the upper mechanical word. The word `s'_{\alpha,\rho}` is the *upper mechanical word* with slope `\alpha` and intercept `\rho` defined by | Returns the upper mechanical word with slope `\alpha` and intercept `\rho` The upper mechanical word `s'_{\alpha,\rho}` with slope `\alpha` and intercept `\rho` is defined by | def UpperMechanicalWord(self, alpha, rho=0, alphabet=None): r""" Returns the upper mechanical word. |
raise NotImplementedError, msg | raise ValueError, msg | def UpperMechanicalWord(self, alpha, rho=0, alphabet=None): r""" Returns the upper mechanical word. |
""" | r""" | def strip_answer(self, s): """ Returns the string s with Matlab's answer prompt removed. EXAMPLES:: sage: s = '\nans =\n\n 2\n' sage: matlab.strip_answer(s) ' 2' """ i = s.find('=') return s[i+1:].strip('\n') |
The error occurs only when printed:: | The error only occurs upon printing:: | ... def __repr__(self): |
.. rubric:: Common Usage: | Most of the time, ``__repr__`` methods are only called during user interaction, and therefore need not be fast; and indeed there are objects ``x`` in Sage such ``x.__repr__()`` is time consuming. | ... def __repr__(self): |
A priori, since they are mostly called during user interaction, there is no particular need to write fast ``__repr__`` methods, and indeed there are some objects ``x`` whose call ``x.__repr__()`` is quite time expensive. However, there are several use case where it is actually called and when the results is simply disc... | There are however some uses cases where many format strings are constructed but not actually printed. This includes error handling messages in :mod:`unittest` or :class:`TestSuite` executions:: | ... def __repr__(self): |
I the previous case ``QQ.__repr__()`` has been called. To show this we replace QQ in the format string argument with out broken object:: | In the above ``QQ.__repr__()`` has been called, and the result immediately discarded. To demonstrate this we replace ``QQ`` in the format string argument with our broken object:: | ... def __repr__(self): |
There is no need to call ``IDontLikeBeingPrinted().__repr__()``, but itx can't be avoided with usual strings. Note that with the usual assert, the call is not performed:: | This behavior can induce major performance penalties when testing. Note that this issue does not impact the usual assert: | ... def __repr__(self): |
We now check that :class:`LazyFormat` indeed solve the assertion problem:: | We now check that :class:`LazyFormat` indeed solves the assertion problem:: | ... def __repr__(self): |
Binds the lazy format with its parameters | Binds the lazy format string with its parameters | def __mod__(self, args): """ Binds the lazy format with its parameters |
raise ValueError, "%s is not a valid perfect matching: all elements of the list must be pairs"%p | raise ValueError, ("%s is not a valid perfect matching:\n" "all elements of the list must be pairs"%p) | def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct o... |
raise ValueError, "%s is not a valid perfect matching: there are some repetitions"%p | raise ValueError, ("%s is not a valid perfect matching:\n" "there are some repetitions"%p) | def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct o... |
or isinstance(p,sage.combinat.permutation.Permutation_class)): | or isinstance(p,Permutation_class)): | def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct o... |
s="The permutation p (= %s) is not a fixpoint-free involution"%p raise ValueError,s | raise ValueError, ("The permutation p (= %s) is not a " "fixed point free involution"%p) | def __classcall_private__(cls,p): r""" This function tries to recognize the input (it can be either a list or a tuple of pairs, or a fix-point free involution given as a list or as a permutation), constructs the parent (enumerated set of PerfectMatchings of the ground set) and calls the __init__ function to construct o... |
We can plot with this transform. Remember that the independent variable is the radius, and the dependent variables are the | We can plot with this transform. Remember that the dependent variable is the radius, and the independent variables are the | def transform(self, **kwds): """ EXAMPLE:: sage: from sage.plot.plot3d.plot3d import _ArbitraryCoordinates sage: x, y, z = var('x y z') sage: T = _ArbitraryCoordinates((x + y, x - y, z), x,[y,z]) |
We can plot with this transform. Remember that the independent variable is the height, and the dependent variables are the | We can plot with this transform. Remember that the dependent variable is the height, and the independent variables are the | def transform(self, radius=None, azimuth=None, inclination=None): """ A spherical coordinates transform. |
... __metaclass__ = sage.structure.unique_representation.ClasscallMetaclass | ... __metaclass__ = ClasscallMetaclass | def __call__(cls, *args, **options): """ This method implements ``cls(<some arguments>)``. |
... print "calling call_cls" | ... print "calling classcall" | ... def __classcall__(cls): |
calling call_cls | calling classcall | ... def __init__(self): |
try: | if '__classcall_private__' in cls.__dict__: return cls.__classcall_private__(cls, *args, **options) elif hasattr(cls, "__classcall__"): | ... def __init__(self): |
except AttributeError: | else: | ... def __init__(self): |
Return a new Weierstrass model of self under the standard transformation `(u,r,s,,t)` | Return a new Weierstrass model of self under the standard transformation `(u,r,s,t)` | def change_weierstrass_model(self, *urst): r""" Return a new Weierstrass model of self under the standard transformation `(u,r,s,,t)` .. math:: (x,y) \mapsto (x',y') = (u^2xr , u^3y + su^2x' + t). EXAMPLES:: sage: E = EllipticCurve('15a') sage: F1 = E.change_weierstrass_model([1/2,0,0,0]); F1 Elliptic Curve define... |
(x,y) \mapsto (x',y') = (u^2xr , u^3y + su^2x' + t). | (x,y) \mapsto (x',y') = (u^2x + r , u^3y + su^2x + t). | def change_weierstrass_model(self, *urst): r""" Return a new Weierstrass model of self under the standard transformation `(u,r,s,,t)` .. math:: (x,y) \mapsto (x',y') = (u^2xr , u^3y + su^2x' + t). EXAMPLES:: sage: E = EllipticCurve('15a') sage: F1 = E.change_weierstrass_model([1/2,0,0,0]); F1 Elliptic Curve define... |
if options['labels']: | if options.get('labels', False): | def _render_on_subplot(self, subplot): """ TESTS: |
if options['colorbar']: | if options.get('colorbar', False): | def _render_on_subplot(self, subplot): """ TESTS: |
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),... |
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),... |
sage: def is_4regular(G): ... D = G.degree_sequence() ... return all(d == 4 for d in D) sage: is_4regular(G) | sage: G.is_regular(4) | sage: def is_4regular(G): |
self.n = ZZ(max(S)+1).exact_log(2) | self.n = ZZ(max(S)).nbits() | def __init__(self, *args, **kwargs): """ Construct a substitution box (S-box) for a given lookup table `S`. |
and the fourth has no control points: path = [[p1, c1, c2, p2], [c3, c4, p3], [c5, p4], [p5], ...] | and the fourth has no control points:: path = [[p1, c1, c2, p2], [c3, c4, p3], [c5, p4], [p5], ...] | def bezier3d(path, **options): """ Draws a 3-dimensional bezier path. Input is similar to bezier_path, but each point in the path and each control point is required to have 3 coordinates. INPUT: - ``path`` - a list of curves, which each is a list of points. See further detail below. - ``thickness`` - (default: 2)... |
EXAMPLES: | EXAMPLES:: | def bezier3d(path, **options): """ Draws a 3-dimensional bezier path. Input is similar to bezier_path, but each point in the path and each control point is required to have 3 coordinates. INPUT: - ``path`` - a list of curves, which each is a list of points. See further detail below. - ``thickness`` - (default: 2)... |
To construct a simple curve, create a list containing a single list: | To construct a simple curve, create a list containing a single list:: | def bezier3d(path, **options): """ Draws a 3-dimensional bezier path. Input is similar to bezier_path, but each point in the path and each control point is required to have 3 coordinates. INPUT: - ``path`` - a list of curves, which each is a list of points. See further detail below. - ``thickness`` - (default: 2)... |
Draw a frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing. | Draw a frame in 3-D. Primarily used as a helper function for creating frames for 3-D graphics viewing. | def frame3d(lower_left, upper_right, **kwds): """ Draw a frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, ... |
list, tuple, or vector | list, tuple, or vector. | def frame3d(lower_left, upper_right, **kwds): """ Draw a frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, ... |
Draw correct labels for a given frame in 3D. Primarily used as a helper function for creating frames for 3D graphics | Draw correct labels for a given frame in 3-D. Primarily used as a helper function for creating frames for 3-D graphics | def frame_labels(lower_left, upper_right, label_lower_left, label_upper_right, eps = 1, **kwds): """ Draw correct labels for a given frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing - do not use directly unless you know what you are doing! INPUT: - ``lower_left`` - the low... |
list, tuple, or vector | list, tuple, or vector. | def frame_labels(lower_left, upper_right, label_lower_left, label_upper_right, eps = 1, **kwds): """ Draw correct labels for a given frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing - do not use directly unless you know what you are doing! INPUT: - ``lower_left`` - the low... |
raise ValueError, "Ensure the upper right labels are above and to the right of the lower left labels." | raise ValueError("Ensure the upper right labels are above and to the right of the lower left labels.") | def frame_labels(lower_left, upper_right, label_lower_left, label_upper_right, eps = 1, **kwds): """ Draw correct labels for a given frame in 3D. Primarily used as a helper function for creating frames for 3D graphics viewing - do not use directly unless you know what you are doing! INPUT: - ``lower_left`` - the low... |
Draw a ruler in 3D, with major and minor ticks. | Draw a ruler in 3-D, with major and minor ticks. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
tuple, or vector | tuple, or vector. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
or vector | or vector. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
shown on the ruler | shown on the ruler. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
subdivisions between each major tick - ``absolute`` - (default: False) if True, makes a huge ruler in the direction of an axis - ``snap`` - (default: False) if True, snaps to an implied grid | subdivisions between each major tick. - ``absolute`` - (default: ``False``) if ``True``, makes a huge ruler in the direction of an axis. - ``snap`` - (default: ``False``) if ``True``, snaps to an implied grid. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
options for lines which are also available. | options for lines, which are also available. | def ruler(start, end, ticks=4, sub_ticks=4, absolute=False, snap=False, **kwds): """ Draw a ruler in 3D, with major and minor ticks. INPUT: - ``start`` - the beginning of the ruler, as a list, tuple, or vector - ``end`` - the end of the ruler, as a list, tuple, or vector - ``ticks`` - (default: 4) the number of maj... |
Draw a frame made of 3D rulers, with major and minor ticks. | Draw a frame made of 3-D rulers, with major and minor ticks. | def ruler_frame(lower_left, upper_right, ticks=4, sub_ticks=4, **kwds): """ Draw a frame made of 3D rulers, with major and minor ticks. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, or vector - ``t... |
list, tuple, or vector | list, tuple, or vector. | def ruler_frame(lower_left, upper_right, ticks=4, sub_ticks=4, **kwds): """ Draw a frame made of 3D rulers, with major and minor ticks. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, or vector - ``t... |
shown on each ruler | shown on each ruler. | def ruler_frame(lower_left, upper_right, ticks=4, sub_ticks=4, **kwds): """ Draw a frame made of 3D rulers, with major and minor ticks. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, or vector - ``t... |
subdivisions between each major tick | subdivisions between each major tick. | def ruler_frame(lower_left, upper_right, ticks=4, sub_ticks=4, **kwds): """ Draw a frame made of 3D rulers, with major and minor ticks. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, or vector - ``t... |
options for lines which are also available. | options for lines, which are also available. | def ruler_frame(lower_left, upper_right, ticks=4, sub_ticks=4, **kwds): """ Draw a frame made of 3D rulers, with major and minor ticks. INPUT: - ``lower_left`` - the lower left corner of the frame, as a list, tuple, or vector - ``upper_right`` - the upper right corner of the frame, as a list, tuple, or vector - ``t... |
We normally access this via the point3d function. Note that extra | We normally access this via the ``point3d`` function. Note that extra | def text3d(txt, (x,y,z), **kwds): r""" Display 3d text. INPUT: - ``txt`` - some text - ``(x,y,z)`` - position - ``**kwds`` - standard 3d graphics options .. note:: There is no way to change the font size or opacity yet. EXAMPLES: We write the word Sage in red at position (1,2,3):: sage: text3d("Sage", (1,2... |
Create the graphics primitive :class:`Point` in 3D. See the | Create the graphics primitive :class:`Point` in 3-D. See the | def __init__(self, center, size=1, **kwds): """ Create the graphics primitive :class:`Point` in 3D. See the docstring of this class for full documentation. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.