title stringclasses 1
value | text stringlengths 46 1.11M | id stringlengths 27 30 |
|---|---|---|
sympy/utilities/lambdify.py/_EvaluatorPrinter/_preprocess
class _EvaluatorPrinter: def _preprocess(self, args, expr):
"""Preprocess args, expr to replace arguments that do not map
to valid Python identifiers.
Returns string form of args, and updated expr.
"""
from sympy impor... | apositive_train_query0_00000 | |
examples/all.py/__import__
def __import__(name, globals=None, locals=None, fromlist=None):
"""An alternative to the import function so that we can import
modules defined as strings.
This code was taken from: http://docs.python.org/lib/examples-imp.html
"""
# Fast path: see if the module has already... | negative_train_query0_00000 | |
examples/all.py/load_example_module
def load_example_module(example):
"""Loads modules based upon the given package name"""
mod = __import__(example)
return mod | negative_train_query0_00001 | |
examples/all.py/run_examples
def run_examples(windowed=False, quiet=False, summary=True):
"""Run all examples in the list of modules.
Returns a boolean value indicating whether all the examples were
successful.
"""
successes = []
failures = []
examples = TERMINAL_EXAMPLES
if windowed:
... | negative_train_query0_00002 | |
examples/all.py/run_example
def run_example(example, reporter=None):
"""Run a specific example.
Returns a boolean value indicating whether the example was successful.
"""
if reporter:
reporter.write(example)
else:
print("=" * 79)
print("Running: ", example)
try:
... | negative_train_query0_00003 | |
examples/all.py/suppress_output
def suppress_output(fn):
"""Suppresses the output of fn on sys.stdout."""
save_stdout = sys.stdout
try:
sys.stdout = DummyFile()
fn()
finally:
sys.stdout = save_stdout | negative_train_query0_00004 | |
examples/all.py/show_summary
def show_summary(successes, failures, reporter=None):
"""Shows a summary detailing which examples were successful and which failed."""
if reporter:
reporter.write("-" * reporter.terminal_width)
if failures:
reporter.write("FAILED:\n", "Red")
f... | negative_train_query0_00005 | |
examples/all.py/main
def main(*args, **kws):
"""Main script runner"""
parser = optparse.OptionParser()
parser.add_option('-w', '--windowed', action="store_true", dest="windowed",
help="also run examples requiring windowed environment")
parser.add_option('-q', '--quiet', action="store_true", dest... | negative_train_query0_00006 | |
examples/all.py/DummyFile/write
class DummyFile: def write(self, x):
pass | negative_train_query0_00007 | |
examples/intermediate/vandermonde.py/symbol_gen
def symbol_gen(sym_str):
"""Symbol generator
Generates sym_str_n where n is the number of times the generator
has been called.
"""
n = 0
while True:
yield Symbol("%s_%d" % (sym_str, n))
n += 1 | negative_train_query0_00008 | |
examples/intermediate/vandermonde.py/comb_w_rep
def comb_w_rep(n, k):
"""Combinations with repetition
Returns the list of k combinations with repetition from n objects.
"""
if k == 0:
return [[]]
combs = [[i] for i in range(n)]
for i in range(k - 1):
curr = []
for p in c... | negative_train_query0_00009 | |
examples/intermediate/vandermonde.py/vandermonde
def vandermonde(order, dim=1, syms='a b c d'):
"""Computes a Vandermonde matrix of given order and dimension.
Define syms to give beginning strings for temporary variables.
Returns the Matrix, the temporary variables, and the terms for the
polynomials.
... | negative_train_query0_00010 | |
examples/intermediate/vandermonde.py/gen_poly
def gen_poly(points, order, syms):
"""Generates a polynomial using a Vandermonde system"""
num_pts = len(points)
if num_pts == 0:
raise ValueError("Must provide points")
dim = len(points[0]) - 1
if dim > len(syms):
raise ValueError("Must ... | negative_train_query0_00011 | |
examples/intermediate/vandermonde.py/main
def main():
order = 2
V, tmp_syms, _ = vandermonde(order)
print("Vandermonde matrix of order 2 in 1 dimension")
pprint(V)
print('-'*79)
print("Computing the determinant and comparing to \sum_{0<i<j<=3}(a_j - a_i)")
det_sum = 1
for j in range(or... | negative_train_query0_00012 | |
examples/intermediate/infinite_1d_box.py/X_n
def X_n(n, a, x):
"""
Returns the wavefunction X_{n} for an infinite 1D box
``n``
the "principal" quantum number. Corresponds to the number of nodes in
the wavefunction. n >= 0
``a``
width of the well. a > 0
``x``
x coord... | negative_train_query0_00013 | |
examples/intermediate/infinite_1d_box.py/E_n
def E_n(n, a, mass):
"""
Returns the Energy psi_{n} for a 1d potential hole with infinity borders
``n``
the "principal" quantum number. Corresponds to the number of nodes in
the wavefunction. n >= 0
``a``
width of the well. a > 0
... | negative_train_query0_00014 | |
examples/intermediate/infinite_1d_box.py/energy_corrections
def energy_corrections(perturbation, n, a=10, mass=0.5):
"""
Calculating first two order corrections due to perturbation theory and
returns tuple where zero element is unperturbated energy, and two second
is corrections
``n``
the "... | negative_train_query0_00015 | |
examples/intermediate/infinite_1d_box.py/main
def main():
print()
print("Applying perturbation theory to calculate the ground state energy")
print("of the infinite 1D box of width ``a`` with a perturbation")
print("which is linear in ``x``, up to second order in perturbation.")
print()
x, _a = ... | negative_train_query0_00016 | |
examples/intermediate/trees.py/T
def T(x):
return x + x**2 + 2*x**3 + 4*x**4 + 9*x**5 + 20*x**6 + 48 * x**7 + \
115*x**8 + 286*x**9 + 719*x**10 | negative_train_query0_00017 | |
examples/intermediate/trees.py/A
def A(x):
return 1 + T(x) - T(x)**2/2 + T(x**2)/2 | negative_train_query0_00018 | |
examples/intermediate/trees.py/main
def main():
x = Symbol("x")
s = Poly(A(x), x)
num = list(reversed(s.coeffs()))[:11]
print(s.as_expr())
print(num) | negative_train_query0_00019 | |
examples/intermediate/differential_equations.py/main
def main():
x = Symbol("x")
f = Function("f")
eq = Eq(f(x).diff(x), f(x))
print("Solution for ", eq, " : ", dsolve(eq, f(x)))
eq = Eq(f(x).diff(x, 2), -f(x))
print("Solution for ", eq, " : ", dsolve(eq, f(x)))
eq = Eq(x**2*f(x).diff(x),... | negative_train_query0_00020 | |
examples/intermediate/print_gtk.py/main
def main():
x = Symbol('x')
example_limit = Limit(sin(x)/x, x, 0)
print_gtk(example_limit)
example_integral = Integral(x, (x, 0, 1))
print_gtk(example_integral) | negative_train_query0_00021 | |
examples/intermediate/coupled_cluster.py/get_CC_operators
def get_CC_operators():
"""
Returns a tuple (T1,T2) of unique operators.
"""
i = symbols('i', below_fermi=True, cls=Dummy)
a = symbols('a', above_fermi=True, cls=Dummy)
t_ai = AntiSymmetricTensor('t', (a,), (i,))
ai = NO(Fd(a)*F(i))
... | negative_train_query0_00022 | |
examples/intermediate/coupled_cluster.py/main
def main():
print()
print("Calculates the Coupled-Cluster energy- and amplitude equations")
print("See 'An Introduction to Coupled Cluster Theory' by")
print("T. Daniel Crawford and Henry F. Schaefer III")
print("Reference to a Lecture Series: http://ver... | negative_train_query0_00023 | |
examples/intermediate/partial_differential_eqs.py/main
def main():
r, phi, theta = symbols("r,phi,theta")
Xi = Function('Xi')
R, Phi, Theta, u = map(Function, ['R', 'Phi', 'Theta', 'u'])
C1, C2 = symbols('C1,C2')
pprint("Separation of variables in Laplace equation in spherical coordinates")
ppr... | negative_train_query0_00024 | |
examples/intermediate/sample.py/sample2d
def sample2d(f, x_args):
"""
Samples a 2d function f over specified intervals and returns two
arrays (X, Y) suitable for plotting with matlab (matplotlib)
syntax. See examples\mplot2d.py.
f is a function of one variable, such as x**2.
x_args is an interv... | negative_train_query0_00025 | |
examples/intermediate/sample.py/sample3d
def sample3d(f, x_args, y_args):
"""
Samples a 3d function f over specified intervals and returns three
2d arrays (X, Y, Z) suitable for plotting with matlab (matplotlib)
syntax. See examples\mplot3d.py.
f is a function of two variables, such as x**2 + y**2.... | negative_train_query0_00026 | |
examples/intermediate/sample.py/sample
def sample(f, *var_args):
"""
Samples a 2d or 3d function over specified intervals and returns
a dataset suitable for plotting with matlab (matplotlib) syntax.
Wrapper for sample2d and sample3d.
f is a function of one or two variables, such as x**2.
var_ar... | negative_train_query0_00027 | |
examples/intermediate/sample.py/meshgrid
def meshgrid(x, y):
"""
Taken from matplotlib.mlab.meshgrid.
"""
x = np.array(x)
y = np.array(y)
numRows, numCols = len(y), len(x)
x.shape = 1, numCols
X = np.repeat(x, numRows, 0)
y.shape = numRows, 1
... | negative_train_query0_00028 | |
examples/intermediate/mplot3d.py/mplot3d
def mplot3d(f, var1, var2, show=True):
"""
Plot a 3d function using matplotlib/Tk.
"""
import warnings
warnings.filterwarnings("ignore", "Could not match \S")
p = import_module('pylab')
# Try newer version first
p3 = import_module('mpl_toolkits.... | negative_train_query0_00029 | |
examples/intermediate/mplot3d.py/main
def main():
x = Symbol('x')
y = Symbol('y')
mplot3d(x**2 - y**2, (x, -10.0, 10.0, 20), (y, -10.0, 10.0, 20)) | negative_train_query0_00030 | |
examples/intermediate/mplot2d.py/mplot2d
def mplot2d(f, var, show=True):
"""
Plot a 2d function using matplotlib/Tk.
"""
import warnings
warnings.filterwarnings("ignore", "Could not match \S")
p = import_module('pylab')
if not p:
sys.exit("Matplotlib is required to use mplot2d.")
... | negative_train_query0_00031 | |
examples/intermediate/mplot2d.py/main
def main():
x = Symbol('x')
# mplot2d(log(x), (x, 0, 2, 100))
# mplot2d([sin(x), -sin(x)], (x, float(-2*pi), float(2*pi), 50))
mplot2d([sqrt(x), -sqrt(x), sqrt(-x), -sqrt(-x)], (x, -40.0, 40.0, 80)) | negative_train_query0_00032 | |
examples/beginner/limits_examples.py/sqrt3
def sqrt3(x):
return x**Rational(1, 3) | negative_train_query0_00033 | |
examples/beginner/limits_examples.py/show
def show(computed, correct):
print("computed:", computed, "correct:", correct) | negative_train_query0_00034 | |
examples/beginner/limits_examples.py/main
def main():
x = Symbol("x")
show( limit(sqrt(x**2 - 5*x + 6) - x, x, oo), -Rational(5)/2 )
show( limit(x*(sqrt(x**2 + 1) - x), x, oo), Rational(1)/2 )
show( limit(x - sqrt(x**3 - 1), x, oo), Rational(0) )
show( limit(log(1 + exp(x))/x, x, -oo), Rational(... | negative_train_query0_00035 | |
examples/beginner/series.py/main
def main():
x = Symbol('x')
e = 1/cos(x)
print('')
print("Series for sec(x):")
print('')
pprint(e.series(x, 0, 10))
print("\n")
e = 1/sin(x)
print("Series for csc(x):")
print('')
pprint(e.series(x, 0, 4))
print('') | negative_train_query0_00036 | |
examples/beginner/precision.py/main
def main():
x = Pow(2, 50, evaluate=False)
y = Pow(10, -50, evaluate=False)
# A large, unevaluated expression
m = Mul(x, y, evaluate=False)
# Evaluating the expression
e = S(2)**50/S(10)**50
print("%s == %s" % (m, e)) | negative_train_query0_00037 | |
examples/beginner/plotting_nice_plot.py/main
def main():
fun1 = cos(x)*sin(y)
fun2 = sin(x)*sin(y)
fun3 = cos(y) + log(tan(y/2)) + 0.2*x
PygletPlot(fun1, fun2, fun3, [x, -0.00, 12.4, 40], [y, 0.1, 2, 40]) | negative_train_query0_00038 | |
examples/beginner/print_pretty.py/main
def main():
x = Symbol("x")
y = Symbol("y")
pprint( x**x )
print('\n') # separate with two blank likes
pprint(x**2 + y + x)
print('\n')
pprint(sin(x)**x)
print('\n')
pprint( sin(x)**cos(x) )
print('\n')
pprint( sin(x)/(cos(x)**2 * ... | negative_train_query0_00039 | |
examples/beginner/expansion.py/main
def main():
a = Symbol('a')
b = Symbol('b')
e = (a + b)**5
print("\nExpression:")
pprint(e)
print('\nExpansion of the above expression:')
pprint(e.expand())
print() | negative_train_query0_00040 | |
examples/beginner/differentiation.py/main
def main():
a = Symbol('a')
b = Symbol('b')
e = (a + 2*b)**5
print("\nExpression : ")
print()
pprint(e)
print("\n\nDifferentiating w.r.t. a:")
print()
pprint(e.diff(a))
print("\n\nDifferentiating w.r.t. b:")
print()
pprint(e.diff... | negative_train_query0_00041 | |
examples/beginner/functions.py/main
def main():
a = Symbol('a')
b = Symbol('b')
e = log((a + b)**5)
print()
pprint(e)
print('\n')
e = exp(e)
pprint(e)
print('\n')
e = log(exp((a + b)**5))
pprint(e)
print | negative_train_query0_00042 | |
examples/beginner/substitution.py/main
def main():
x = sympy.Symbol('x')
y = sympy.Symbol('y')
e = 1/sympy.cos(x)
print()
pprint(e)
print('\n')
pprint(e.subs(sympy.cos(x), y))
print('\n')
pprint(e.subs(sympy.cos(x), y).subs(y, x**2))
e = 1/sympy.log(x)
e = e.subs(x, sympy.F... | negative_train_query0_00043 | |
examples/beginner/basic.py/main
def main():
a = Symbol('a')
b = Symbol('b')
c = Symbol('c')
e = ( a*b*b + 2*b*a*b )**c
print('')
pprint(e)
print('') | negative_train_query0_00044 | |
examples/advanced/grover_example.py/demo_vgate_app
def demo_vgate_app(v):
for i in range(2**v.nqubits):
print('qapply(v*IntQubit(%i, %r))' % (i, v.nqubits))
pprint(qapply(v*IntQubit(i, v.nqubits)))
qapply(v*IntQubit(i, v.nqubits)) | negative_train_query0_00045 | |
examples/advanced/grover_example.py/black_box
def black_box(qubits):
return True if qubits == IntQubit(1, qubits.nqubits) else False | negative_train_query0_00046 | |
examples/advanced/grover_example.py/main
def main():
print()
print('Demonstration of Grover\'s Algorithm')
print('The OracleGate or V Gate carries the unknown function f(x)')
print('> V|x> = ((-1)^f(x))|x> where f(x) = 1 when x = a (True in our case)')
print('> and 0 (False in our case) otherwise')
... | negative_train_query0_00047 | |
examples/advanced/autowrap_integrators.py/main
def main():
print(__doc__)
# arrays are represented with IndexedBase, indices with Idx
m = Symbol('m', integer=True)
i = Idx('i', m)
A = IndexedBase('A')
B = IndexedBase('B')
x = Symbol('x')
print("Compiling ufuncs for radial harmonic osc... | negative_train_query0_00048 | |
examples/advanced/fem.py/bernstein_space
def bernstein_space(order, nsd):
if nsd > 3:
raise RuntimeError("Bernstein only implemented in 1D, 2D, and 3D")
sum = 0
basis = []
coeff = []
if nsd == 1:
b1, b2 = x, 1 - x
for o1 in range(0, order + 1):
for o2 in range(0,... | negative_train_query0_00049 | |
examples/advanced/fem.py/create_point_set
def create_point_set(order, nsd):
h = Rational(1, order)
set = []
if nsd == 1:
for i in range(0, order + 1):
x = i*h
if x <= 1:
set.append((x, y))
if nsd == 2:
for i in range(0, order + 1):
x ... | negative_train_query0_00050 | |
examples/advanced/fem.py/create_matrix
def create_matrix(equations, coeffs):
A = zeros(len(equations))
i = 0
j = 0
for j in range(0, len(coeffs)):
c = coeffs[j]
for i in range(0, len(equations)):
e = equations[i]
d, _ = reduced(e, [c])
A[i, j] = d[0]
... | negative_train_query0_00051 | |
examples/advanced/fem.py/main
def main():
t = ReferenceSimplex(2)
fe = Lagrange(2, 2)
u = 0
# compute u = sum_i u_i N_i
us = []
for i in range(0, fe.nbf()):
ui = Symbol("u_%d" % i)
us.append(ui)
u += ui*fe.N[i]
J = zeros(fe.nbf())
for i in range(0, fe.nbf()):
... | negative_train_query0_00052 | |
examples/advanced/fem.py/ReferenceSimplex/__init__
class ReferenceSimplex: def __init__(self, nsd):
self.nsd = nsd
if nsd <= 3:
coords = symbols('x,y,z')[:nsd]
else:
coords = [Symbol("x_%d" % d) for d in range(nsd)]
self.coords = coords | negative_train_query0_00053 | |
examples/advanced/fem.py/ReferenceSimplex/integrate
class ReferenceSimplex: def integrate(self, f):
coords = self.coords
nsd = self.nsd
limit = 1
for p in coords:
limit -= p
intf = f
for d in range(0, nsd):
p = coords[d]
limit += p... | negative_train_query0_00054 | |
examples/advanced/fem.py/Lagrange/__init__
class Lagrange: def __init__(self, nsd, order):
self.nsd = nsd
self.order = order
self.compute_basis() | negative_train_query0_00055 | |
examples/advanced/fem.py/Lagrange/nbf
class Lagrange: def nbf(self):
return len(self.N) | negative_train_query0_00056 | |
examples/advanced/fem.py/Lagrange/compute_basis
class Lagrange: def compute_basis(self):
order = self.order
nsd = self.nsd
N = []
pol, coeffs, basis = bernstein_space(order, nsd)
points = create_point_set(order, nsd)
equations = []
for p in points:
... | negative_train_query0_00057 | |
examples/advanced/autowrap_ufuncify.py/main
def main():
print(__doc__)
x = symbols('x')
# a numpy array we can apply the ufuncs to
grid = np.linspace(-1, 1, 1000)
# set mpmath precision to 20 significant numbers for verification
mpmath.mp.dps = 20
print("Compiling legendre ufuncs and ch... | negative_train_query0_00058 | |
examples/advanced/dense_coding_example.py/main
def main():
psi = superposition_basis(2)
psi
# Dense coding demo:
# Assume Alice has the left QBit in psi
print("An even superposition of 2 qubits. Assume Alice has the left QBit.")
pprint(psi)
# The corresponding gates applied to Alice's QB... | negative_train_query0_00059 | |
examples/advanced/qft.py/u
def u(p, r):
""" p = (p1, p2, p3); r = 0,1 """
if r not in [1, 2]:
raise ValueError("Value of r should lie between 1 and 2")
p1, p2, p3 = p
if r == 1:
ksi = Matrix([[1], [0]])
else:
ksi = Matrix([[0], [1]])
a = (sigma1*p1 + sigma2*p2 + sigma3*p3... | negative_train_query0_00060 | |
examples/advanced/qft.py/v
def v(p, r):
""" p = (p1, p2, p3); r = 0,1 """
if r not in [1, 2]:
raise ValueError("Value of r should lie between 1 and 2")
p1, p2, p3 = p
if r == 1:
ksi = Matrix([[1], [0]])
else:
ksi = -Matrix([[0], [1]])
a = (sigma1*p1 + sigma2*p2 + sigma3*p... | negative_train_query0_00061 | |
examples/advanced/qft.py/pslash
def pslash(p):
p1, p2, p3 = p
p0 = sqrt(m**2 + p1**2 + p2**2 + p3**2)
return gamma0*p0 - gamma1*p1 - gamma2*p2 - gamma3*p3 | negative_train_query0_00062 | |
examples/advanced/qft.py/Tr
def Tr(M):
return M.trace() | negative_train_query0_00063 | |
examples/advanced/qft.py/xprint
def xprint(lhs, rhs):
pprint(Eq(sympify(lhs), rhs)) | negative_train_query0_00064 | |
examples/advanced/qft.py/main
def main():
a = Symbol("a", real=True)
b = Symbol("b", real=True)
c = Symbol("c", real=True)
p = (a, b, c)
assert u(p, 1).D*u(p, 2) == Matrix(1, 1, [0])
assert u(p, 2).D*u(p, 1) == Matrix(1, 1, [0])
p1, p2, p3 = [Symbol(x, real=True) for x in ["p1", "p2", "p3... | negative_train_query0_00065 | |
examples/advanced/pidigits.py/display_fraction
def display_fraction(digits, skip=0, colwidth=10, columns=5):
"""Pretty printer for first n digits of a fraction"""
perline = colwidth * columns
printed = 0
for linecount in range((len(digits) - skip) // (colwidth * columns)):
line = digits[skip + l... | negative_train_query0_00066 | |
examples/advanced/pidigits.py/calculateit
def calculateit(func, base, n, tofile):
"""Writes first n base-digits of a mpmath function to file"""
prec = 100
intpart = libmp.numeral(3, base)
if intpart == 0:
skip = 0
else:
skip = len(intpart)
print("Step 1 of 2: calculating binary v... | negative_train_query0_00067 | |
examples/advanced/pidigits.py/interactive
def interactive():
"""Simple function to interact with user"""
print("Compute digits of pi with SymPy\n")
base = input("Which base? (2-36, 10 for decimal) \n> ")
digits = input("How many digits? (enter a big number, say, 10000)\n> ")
tofile = raw_input("Outp... | negative_train_query0_00068 | |
examples/advanced/pidigits.py/main
def main():
"""A non-interactive runner"""
base = 16
digits = 500
tofile = None
calculateit(pi, base, digits, tofile) | negative_train_query0_00069 | |
examples/advanced/pyglet_plotting.py/main
def main():
x, y, z = symbols('x,y,z')
# toggle axes visibility with F5, colors with F6
axes_options = 'visible=false; colored=true; label_ticks=true; label_axes=true; overlay=true; stride=0.5'
# axes_options = 'colored=false; overlay=false; stride=(1.0, 0.5, 0... | negative_train_query0_00070 | |
examples/advanced/pyglet_plotting.py/example_wrapper
def example_wrapper(f):
examples.append(f)
return f | negative_train_query0_00071 | |
examples/advanced/pyglet_plotting.py/mirrored_saddles
def mirrored_saddles():
p[5] = x**2 - y**2, [20], [20]
p[6] = y**2 - x**2, [20], [20] | negative_train_query0_00072 | |
examples/advanced/pyglet_plotting.py/mirrored_saddles_saveimage
def mirrored_saddles_saveimage():
p[5] = x**2 - y**2, [20], [20]
p[6] = y**2 - x**2, [20], [20]
p.wait_for_calculations()
# although the calculation is complete,
# we still need to wait for it to be
# ren... | negative_train_query0_00073 | |
examples/advanced/pyglet_plotting.py/mirrored_ellipsoids
def mirrored_ellipsoids():
p[2] = x**2 + y**2, [40], [40], 'color=zfade'
p[3] = -x**2 - y**2, [40], [40], 'color=zfade' | negative_train_query0_00074 | |
examples/advanced/pyglet_plotting.py/saddle_colored_by_derivative
def saddle_colored_by_derivative():
f = x**2 - y**2
p[1] = f, 'style=solid'
p[1].color = abs(f.diff(x)), abs(f.diff(x) + f.diff(y)), abs(f.diff(y)) | negative_train_query0_00075 | |
examples/advanced/pyglet_plotting.py/ding_dong_surface
def ding_dong_surface():
f = sqrt(1.0 - y)*y
p[1] = f, [x, 0, 2*pi,
40], [y, -
1, 4, 100], 'mode=cylindrical; style=solid; color=zfade4' | negative_train_query0_00076 | |
examples/advanced/pyglet_plotting.py/polar_circle
def polar_circle():
p[7] = 1, 'mode=polar' | negative_train_query0_00077 | |
examples/advanced/pyglet_plotting.py/polar_flower
def polar_flower():
p[8] = 1.5*sin(4*x), [160], 'mode=polar'
p[8].color = z, x, y, (0.5, 0.5, 0.5), (
0.8, 0.8, 0.8), (x, y, None, z) # z is used for t | negative_train_query0_00078 | |
examples/advanced/pyglet_plotting.py/simple_cylinder
def simple_cylinder():
p[9] = 1, 'mode=cylindrical' | negative_train_query0_00079 | |
examples/advanced/pyglet_plotting.py/cylindrical_hyperbola
def cylindrical_hyperbola():
# (note that polar is an alias for cylindrical)
p[10] = 1/y, 'mode=polar', [x], [y, -2, 2, 20] | negative_train_query0_00080 | |
examples/advanced/pyglet_plotting.py/extruded_hyperbolas
def extruded_hyperbolas():
p[11] = 1/x, [x, -10, 10, 100], [1], 'style=solid'
p[12] = -1/x, [x, -10, 10, 100], [1], 'style=solid' | negative_train_query0_00081 | |
examples/advanced/pyglet_plotting.py/torus
def torus():
a, b = 1, 0.5 # radius, thickness
p[13] = (a + b*cos(x))*cos(y), (a + b*cos(x)) *\
sin(y), b*sin(x), [x, 0, pi*2, 40], [y, 0, pi*2, 40] | negative_train_query0_00082 | |
examples/advanced/pyglet_plotting.py/warped_torus
def warped_torus():
a, b = 2, 1 # radius, thickness
p[13] = (a + b*cos(x))*cos(y), (a + b*cos(x))*sin(y), b *\
sin(x) + 0.5*sin(4*y), [x, 0, pi*2, 40], [y, 0, pi*2, 40] | negative_train_query0_00083 | |
examples/advanced/pyglet_plotting.py/parametric_spiral
def parametric_spiral():
p[14] = cos(y), sin(y), y / 10.0, [y, -4*pi, 4*pi, 100]
p[14].color = x, (0.1, 0.9), y, (0.1, 0.9), z, (0.1, 0.9) | negative_train_query0_00084 | |
examples/advanced/pyglet_plotting.py/multistep_gradient
def multistep_gradient():
p[1] = 1, 'mode=spherical', 'style=both'
# p[1] = exp(-x**2-y**2+(x*y)/4), [-1.7,1.7,100], [-1.7,1.7,100], 'style=solid'
# p[1] = 5*x*y*exp(-x**2-y**2), [-2,2,100], [-2,2,100]
gradient = [0.0, (0.3, 0.3... | negative_train_query0_00085 | |
examples/advanced/pyglet_plotting.py/lambda_vs_sympy_evaluation
def lambda_vs_sympy_evaluation():
start = clock()
p[4] = x**2 + y**2, [100], [100], 'style=solid'
p.wait_for_calculations()
print("lambda-based calculation took %s seconds." % (clock() - start))
start = clock()
... | negative_train_query0_00086 | |
examples/advanced/pyglet_plotting.py/gradient_vectors
def gradient_vectors():
def gradient_vectors_inner(f, i):
from sympy import lambdify
from sympy.plotting.plot_interval import PlotInterval
from pyglet.gl import glBegin, glColor3f
from pyglet.gl import glVe... | negative_train_query0_00087 | |
examples/advanced/pyglet_plotting.py/help_str
def help_str():
s = ("\nPlot p has been created. Useful commands: \n"
" help(p), p[1] = x**2, print p, p.clear() \n\n"
"Available examples (see source in plotting.py):\n\n")
for i in range(len(examples)):
s += "(%... | negative_train_query0_00088 | |
examples/advanced/pyglet_plotting.py/example
def example(i):
if callable(i):
p.clear()
i()
elif i >= 0 and i < len(examples):
p.clear()
examples[i]()
else:
print("Not a valid example.\n")
print(p) | negative_train_query0_00089 | |
examples/advanced/pyglet_plotting.py/gradient_vectors_inner
def gradient_vectors_inner(f, i):
from sympy import lambdify
from sympy.plotting.plot_interval import PlotInterval
from pyglet.gl import glBegin, glColor3f
from pyglet.gl import glVertex3f, glEnd, GL_LINE... | negative_train_query0_00090 | |
examples/advanced/pyglet_plotting.py/draw_gradient_vectors
def draw_gradient_vectors(f, iu, iv):
"""
Create a function which draws vectors
representing the gradient of f.
"""
dx, dy, dz = f.diff(x), f.diff(y), 0
... | negative_train_query0_00091 | |
examples/advanced/pyglet_plotting.py/draw_arrow
def draw_arrow(p1, p2):
"""
Draw a single vector.
"""
glColor3f(0.4, 0.4, 0.9)
glVertex3f(*p1)
glColor3f(0.9, 0.4, 0.4)
... | negative_train_query0_00092 | |
examples/advanced/pyglet_plotting.py/draw
def draw():
"""
Iterate through the calculated
vectors and draw them.
"""
glBegin(GL_LINES)
for u in Gvl:
for v in u:
... | negative_train_query0_00093 | |
examples/advanced/relativity.py/grad
def grad(f, X):
a = []
for x in X:
a.append(f.diff(x))
return a | negative_train_query0_00094 | |
examples/advanced/relativity.py/d
def d(m, x):
return grad(m[0, 0], x) | negative_train_query0_00095 | |
examples/advanced/relativity.py/curvature
def curvature(Rmn):
return Rmn.ud(0, 0) + Rmn.ud(1, 1) + Rmn.ud(2, 2) + Rmn.ud(3, 3) | negative_train_query0_00096 | |
examples/advanced/relativity.py/pprint_Gamma_udd
def pprint_Gamma_udd(i, k, l):
pprint(Eq(Symbol('Gamma^%i_%i%i' % (i, k, l)), Gamma.udd(i, k, l))) | negative_train_query0_00097 | |
examples/advanced/relativity.py/pprint_Rmn_dd
def pprint_Rmn_dd(i, j):
pprint(Eq(Symbol('R_%i%i' % (i, j)), Rmn.dd(i, j))) | negative_train_query0_00098 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.