repo stringlengths 7 54 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 20 28.4k | docstring stringlengths 1 46.3k | docstring_tokens listlengths 1 1.66k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 1
value | summary stringlengths 4 350 | obf_code stringlengths 7.85k 764k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
HIPS/autograd | examples/fluidsim/fluidsim.py | project | def project(vx, vy):
"""Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel."""
p = np.zeros(vx.shape)
h = 1.0/vx.shape[0]
div = -0.5 * h * (np.roll(vx, -1, axis=0) - np.roll(vx, 1, axis=0)
+ np.roll(vy, -1, axis=1) - np.roll(... | python | def project(vx, vy):
"""Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel."""
p = np.zeros(vx.shape)
h = 1.0/vx.shape[0]
div = -0.5 * h * (np.roll(vx, -1, axis=0) - np.roll(vx, 1, axis=0)
+ np.roll(vy, -1, axis=1) - np.roll(... | [
"def",
"project",
"(",
"vx",
",",
"vy",
")",
":",
"p",
"=",
"np",
".",
"zeros",
"(",
"vx",
".",
"shape",
")",
"h",
"=",
"1.0",
"/",
"vx",
".",
"shape",
"[",
"0",
"]",
"div",
"=",
"-",
"0.5",
"*",
"h",
"*",
"(",
"np",
".",
"roll",
"(",
"... | Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel. | [
"Project",
"the",
"velocity",
"field",
"to",
"be",
"approximately",
"mass",
"-",
"conserving",
"using",
"a",
"few",
"iterations",
"of",
"Gauss",
"-",
"Seidel",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/fluidsim/fluidsim.py#L18-L32 | train | Project the velocity field to be approximately mass - conserving and
Mvc using a few iterations of Gauss - Seidel. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/tracer.py | primitive | def primitive(f_raw):
"""
Wraps a function so that its gradient can be specified and its invocation
can be recorded. For examples, see the docs."""
@wraps(f_raw)
def f_wrapped(*args, **kwargs):
boxed_args, trace, node_constructor = find_top_boxed_args(args)
if boxed_args:
... | python | def primitive(f_raw):
"""
Wraps a function so that its gradient can be specified and its invocation
can be recorded. For examples, see the docs."""
@wraps(f_raw)
def f_wrapped(*args, **kwargs):
boxed_args, trace, node_constructor = find_top_boxed_args(args)
if boxed_args:
... | [
"def",
"primitive",
"(",
"f_raw",
")",
":",
"@",
"wraps",
"(",
"f_raw",
")",
"def",
"f_wrapped",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"boxed_args",
",",
"trace",
",",
"node_constructor",
"=",
"find_top_boxed_args",
"(",
"args",
")",
"if... | Wraps a function so that its gradient can be specified and its invocation
can be recorded. For examples, see the docs. | [
"Wraps",
"a",
"function",
"so",
"that",
"its",
"gradient",
"can",
"be",
"specified",
"and",
"its",
"invocation",
"can",
"be",
"recorded",
".",
"For",
"examples",
"see",
"the",
"docs",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/tracer.py#L31-L51 | train | A wrapper for functions that can be used to create a non - primitive version of the object. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/define_gradient.py | logsumexp | def logsumexp(x):
"""Numerically stable log(sum(exp(x))), also defined in scipy.misc"""
max_x = np.max(x)
return max_x + np.log(np.sum(np.exp(x - max_x))) | python | def logsumexp(x):
"""Numerically stable log(sum(exp(x))), also defined in scipy.misc"""
max_x = np.max(x)
return max_x + np.log(np.sum(np.exp(x - max_x))) | [
"def",
"logsumexp",
"(",
"x",
")",
":",
"max_x",
"=",
"np",
".",
"max",
"(",
"x",
")",
"return",
"max_x",
"+",
"np",
".",
"log",
"(",
"np",
".",
"sum",
"(",
"np",
".",
"exp",
"(",
"x",
"-",
"max_x",
")",
")",
")"
] | Numerically stable log(sum(exp(x))), also defined in scipy.misc | [
"Numerically",
"stable",
"log",
"(",
"sum",
"(",
"exp",
"(",
"x",
")))",
"also",
"defined",
"in",
"scipy",
".",
"misc"
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/define_gradient.py#L19-L22 | train | Numerically stable log sum of exp | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/variational_autoencoder.py | init_net_params | def init_net_params(scale, layer_sizes, rs=npr.RandomState(0)):
"""Build a (weights, biases) tuples for all layers."""
return [(scale * rs.randn(m, n), # weight matrix
scale * rs.randn(n)) # bias vector
for m, n in zip(layer_sizes[:-1], layer_sizes[1:])] | python | def init_net_params(scale, layer_sizes, rs=npr.RandomState(0)):
"""Build a (weights, biases) tuples for all layers."""
return [(scale * rs.randn(m, n), # weight matrix
scale * rs.randn(n)) # bias vector
for m, n in zip(layer_sizes[:-1], layer_sizes[1:])] | [
"def",
"init_net_params",
"(",
"scale",
",",
"layer_sizes",
",",
"rs",
"=",
"npr",
".",
"RandomState",
"(",
"0",
")",
")",
":",
"return",
"[",
"(",
"scale",
"*",
"rs",
".",
"randn",
"(",
"m",
",",
"n",
")",
",",
"# weight matrix",
"scale",
"*",
"rs... | Build a (weights, biases) tuples for all layers. | [
"Build",
"a",
"(",
"weights",
"biases",
")",
"tuples",
"for",
"all",
"layers",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/variational_autoencoder.py#L34-L38 | train | Build a list of tuples for all layers. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/hmm_em.py | build_dataset | def build_dataset(filename, max_lines=-1):
"""Loads a text file, and turns each line into an encoded sequence."""
encodings = dict(list(map(reversed, enumerate(string.printable))))
digitize = lambda char: encodings[char] if char in encodings else len(encodings)
encode_line = lambda line: np.array(list(m... | python | def build_dataset(filename, max_lines=-1):
"""Loads a text file, and turns each line into an encoded sequence."""
encodings = dict(list(map(reversed, enumerate(string.printable))))
digitize = lambda char: encodings[char] if char in encodings else len(encodings)
encode_line = lambda line: np.array(list(m... | [
"def",
"build_dataset",
"(",
"filename",
",",
"max_lines",
"=",
"-",
"1",
")",
":",
"encodings",
"=",
"dict",
"(",
"list",
"(",
"map",
"(",
"reversed",
",",
"enumerate",
"(",
"string",
".",
"printable",
")",
")",
")",
")",
"digitize",
"=",
"lambda",
... | Loads a text file, and turns each line into an encoded sequence. | [
"Loads",
"a",
"text",
"file",
"and",
"turns",
"each",
"line",
"into",
"an",
"encoded",
"sequence",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/hmm_em.py#L57-L70 | train | Loads a text file and turns each line into an encoded sequence. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/fluidsim/wing.py | project | def project(vx, vy, occlusion):
"""Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel."""
p = np.zeros(vx.shape)
div = -0.5 * (np.roll(vx, -1, axis=1) - np.roll(vx, 1, axis=1)
+ np.roll(vy, -1, axis=0) - np.roll(vy, 1, axis=0))
d... | python | def project(vx, vy, occlusion):
"""Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel."""
p = np.zeros(vx.shape)
div = -0.5 * (np.roll(vx, -1, axis=1) - np.roll(vx, 1, axis=1)
+ np.roll(vy, -1, axis=0) - np.roll(vy, 1, axis=0))
d... | [
"def",
"project",
"(",
"vx",
",",
"vy",
",",
"occlusion",
")",
":",
"p",
"=",
"np",
".",
"zeros",
"(",
"vx",
".",
"shape",
")",
"div",
"=",
"-",
"0.5",
"*",
"(",
"np",
".",
"roll",
"(",
"vx",
",",
"-",
"1",
",",
"axis",
"=",
"1",
")",
"-"... | Project the velocity field to be approximately mass-conserving,
using a few iterations of Gauss-Seidel. | [
"Project",
"the",
"velocity",
"field",
"to",
"be",
"approximately",
"mass",
"-",
"conserving",
"using",
"a",
"few",
"iterations",
"of",
"Gauss",
"-",
"Seidel",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/fluidsim/wing.py#L21-L39 | train | Project the velocity field to be approximately mass - conserving and
MANAGER using a few iterations of Gauss - Seidel. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/fluidsim/wing.py | advect | def advect(f, vx, vy):
"""Move field f according to x and y velocities (u and v)
using an implicit Euler integrator."""
rows, cols = f.shape
cell_xs, cell_ys = np.meshgrid(np.arange(cols), np.arange(rows))
center_xs = (cell_xs - vx).ravel()
center_ys = (cell_ys - vy).ravel()
# Compute in... | python | def advect(f, vx, vy):
"""Move field f according to x and y velocities (u and v)
using an implicit Euler integrator."""
rows, cols = f.shape
cell_xs, cell_ys = np.meshgrid(np.arange(cols), np.arange(rows))
center_xs = (cell_xs - vx).ravel()
center_ys = (cell_ys - vy).ravel()
# Compute in... | [
"def",
"advect",
"(",
"f",
",",
"vx",
",",
"vy",
")",
":",
"rows",
",",
"cols",
"=",
"f",
".",
"shape",
"cell_xs",
",",
"cell_ys",
"=",
"np",
".",
"meshgrid",
"(",
"np",
".",
"arange",
"(",
"cols",
")",
",",
"np",
".",
"arange",
"(",
"rows",
... | Move field f according to x and y velocities (u and v)
using an implicit Euler integrator. | [
"Move",
"field",
"f",
"according",
"to",
"x",
"and",
"y",
"velocities",
"(",
"u",
"and",
"v",
")",
"using",
"an",
"implicit",
"Euler",
"integrator",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/fluidsim/wing.py#L41-L62 | train | Move field f according to x and y velocities u and v. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/misc/optimizers.py | unflatten_optimizer | def unflatten_optimizer(optimize):
"""Takes an optimizer that operates on flat 1D numpy arrays and returns a
wrapped version that handles trees of nested containers (lists/tuples/dicts)
with arrays/scalars at the leaves."""
@wraps(optimize)
def _optimize(grad, x0, callback=None, *args, **kwargs):
... | python | def unflatten_optimizer(optimize):
"""Takes an optimizer that operates on flat 1D numpy arrays and returns a
wrapped version that handles trees of nested containers (lists/tuples/dicts)
with arrays/scalars at the leaves."""
@wraps(optimize)
def _optimize(grad, x0, callback=None, *args, **kwargs):
... | [
"def",
"unflatten_optimizer",
"(",
"optimize",
")",
":",
"@",
"wraps",
"(",
"optimize",
")",
"def",
"_optimize",
"(",
"grad",
",",
"x0",
",",
"callback",
"=",
"None",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"_x0",
",",
"unflatten",
"=",
... | Takes an optimizer that operates on flat 1D numpy arrays and returns a
wrapped version that handles trees of nested containers (lists/tuples/dicts)
with arrays/scalars at the leaves. | [
"Takes",
"an",
"optimizer",
"that",
"operates",
"on",
"flat",
"1D",
"numpy",
"arrays",
"and",
"returns",
"a",
"wrapped",
"version",
"that",
"handles",
"trees",
"of",
"nested",
"containers",
"(",
"lists",
"/",
"tuples",
"/",
"dicts",
")",
"with",
"arrays",
... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/misc/optimizers.py#L16-L30 | train | Takes an optimizer that operates on flat 1D numpy arrays and returns a
wrapped version that handles trees of nested containers with arrays and scalars at the leaves. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/misc/optimizers.py | sgd | def sgd(grad, x, callback=None, num_iters=200, step_size=0.1, mass=0.9):
"""Stochastic gradient descent with momentum.
grad() must have signature grad(x, i), where i is the iteration number."""
velocity = np.zeros(len(x))
for i in range(num_iters):
g = grad(x, i)
if callback: callback(x,... | python | def sgd(grad, x, callback=None, num_iters=200, step_size=0.1, mass=0.9):
"""Stochastic gradient descent with momentum.
grad() must have signature grad(x, i), where i is the iteration number."""
velocity = np.zeros(len(x))
for i in range(num_iters):
g = grad(x, i)
if callback: callback(x,... | [
"def",
"sgd",
"(",
"grad",
",",
"x",
",",
"callback",
"=",
"None",
",",
"num_iters",
"=",
"200",
",",
"step_size",
"=",
"0.1",
",",
"mass",
"=",
"0.9",
")",
":",
"velocity",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"x",
")",
")",
"for",
"i",
... | Stochastic gradient descent with momentum.
grad() must have signature grad(x, i), where i is the iteration number. | [
"Stochastic",
"gradient",
"descent",
"with",
"momentum",
".",
"grad",
"()",
"must",
"have",
"signature",
"grad",
"(",
"x",
"i",
")",
"where",
"i",
"is",
"the",
"iteration",
"number",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/misc/optimizers.py#L33-L42 | train | Stochastic gradient descent with momentum.
grad must have signature grad x and i is the iteration number. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/misc/optimizers.py | rmsprop | def rmsprop(grad, x, callback=None, num_iters=100,
step_size=0.1, gamma=0.9, eps=10**-8):
"""Root mean squared prop: See Adagrad paper for details."""
avg_sq_grad = np.ones(len(x))
for i in range(num_iters):
g = grad(x, i)
if callback: callback(x, i, g)
avg_sq_grad = avg_... | python | def rmsprop(grad, x, callback=None, num_iters=100,
step_size=0.1, gamma=0.9, eps=10**-8):
"""Root mean squared prop: See Adagrad paper for details."""
avg_sq_grad = np.ones(len(x))
for i in range(num_iters):
g = grad(x, i)
if callback: callback(x, i, g)
avg_sq_grad = avg_... | [
"def",
"rmsprop",
"(",
"grad",
",",
"x",
",",
"callback",
"=",
"None",
",",
"num_iters",
"=",
"100",
",",
"step_size",
"=",
"0.1",
",",
"gamma",
"=",
"0.9",
",",
"eps",
"=",
"10",
"**",
"-",
"8",
")",
":",
"avg_sq_grad",
"=",
"np",
".",
"ones",
... | Root mean squared prop: See Adagrad paper for details. | [
"Root",
"mean",
"squared",
"prop",
":",
"See",
"Adagrad",
"paper",
"for",
"details",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/misc/optimizers.py#L45-L54 | train | Root mean squared prop | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/misc/optimizers.py | adam | def adam(grad, x, callback=None, num_iters=100,
step_size=0.001, b1=0.9, b2=0.999, eps=10**-8):
"""Adam as described in http://arxiv.org/pdf/1412.6980.pdf.
It's basically RMSprop with momentum and some correction terms."""
m = np.zeros(len(x))
v = np.zeros(len(x))
for i in range(num_iters):... | python | def adam(grad, x, callback=None, num_iters=100,
step_size=0.001, b1=0.9, b2=0.999, eps=10**-8):
"""Adam as described in http://arxiv.org/pdf/1412.6980.pdf.
It's basically RMSprop with momentum and some correction terms."""
m = np.zeros(len(x))
v = np.zeros(len(x))
for i in range(num_iters):... | [
"def",
"adam",
"(",
"grad",
",",
"x",
",",
"callback",
"=",
"None",
",",
"num_iters",
"=",
"100",
",",
"step_size",
"=",
"0.001",
",",
"b1",
"=",
"0.9",
",",
"b2",
"=",
"0.999",
",",
"eps",
"=",
"10",
"**",
"-",
"8",
")",
":",
"m",
"=",
"np",... | Adam as described in http://arxiv.org/pdf/1412.6980.pdf.
It's basically RMSprop with momentum and some correction terms. | [
"Adam",
"as",
"described",
"in",
"http",
":",
"//",
"arxiv",
".",
"org",
"/",
"pdf",
"/",
"1412",
".",
"6980",
".",
"pdf",
".",
"It",
"s",
"basically",
"RMSprop",
"with",
"momentum",
"and",
"some",
"correction",
"terms",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/misc/optimizers.py#L57-L71 | train | Adam function for the given gradient function x. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/ica.py | make_ica_funs | def make_ica_funs(observed_dimension, latent_dimension):
"""These functions implement independent component analysis.
The model is:
latents are drawn i.i.d. for each data point from a product of student-ts.
weights are the same across all datapoints.
each data = latents * weghts + noise."""
de... | python | def make_ica_funs(observed_dimension, latent_dimension):
"""These functions implement independent component analysis.
The model is:
latents are drawn i.i.d. for each data point from a product of student-ts.
weights are the same across all datapoints.
each data = latents * weghts + noise."""
de... | [
"def",
"make_ica_funs",
"(",
"observed_dimension",
",",
"latent_dimension",
")",
":",
"def",
"sample",
"(",
"weights",
",",
"n_samples",
",",
"noise_std",
",",
"rs",
")",
":",
"latents",
"=",
"rs",
".",
"randn",
"(",
"latent_dimension",
",",
"n_samples",
")"... | These functions implement independent component analysis.
The model is:
latents are drawn i.i.d. for each data point from a product of student-ts.
weights are the same across all datapoints.
each data = latents * weghts + noise. | [
"These",
"functions",
"implement",
"independent",
"component",
"analysis",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/ica.py#L13-L41 | train | This function returns the functions that implement independent component analysis. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/neural_net.py | neural_net_predict | def neural_net_predict(params, inputs):
"""Implements a deep neural network for classification.
params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix.
returns normalized class log-probabilities."""
for W, b in params:
outputs = np.dot(inputs, W) + b
inputs ... | python | def neural_net_predict(params, inputs):
"""Implements a deep neural network for classification.
params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix.
returns normalized class log-probabilities."""
for W, b in params:
outputs = np.dot(inputs, W) + b
inputs ... | [
"def",
"neural_net_predict",
"(",
"params",
",",
"inputs",
")",
":",
"for",
"W",
",",
"b",
"in",
"params",
":",
"outputs",
"=",
"np",
".",
"dot",
"(",
"inputs",
",",
"W",
")",
"+",
"b",
"inputs",
"=",
"np",
".",
"tanh",
"(",
"outputs",
")",
"retu... | Implements a deep neural network for classification.
params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix.
returns normalized class log-probabilities. | [
"Implements",
"a",
"deep",
"neural",
"network",
"for",
"classification",
".",
"params",
"is",
"a",
"list",
"of",
"(",
"weights",
"bias",
")",
"tuples",
".",
"inputs",
"is",
"an",
"(",
"N",
"x",
"D",
")",
"matrix",
".",
"returns",
"normalized",
"class",
... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/neural_net.py#L20-L28 | train | Implements a deep neural network for classification. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/neural_net.py | l2_norm | def l2_norm(params):
"""Computes l2 norm of params by flattening them into a vector."""
flattened, _ = flatten(params)
return np.dot(flattened, flattened) | python | def l2_norm(params):
"""Computes l2 norm of params by flattening them into a vector."""
flattened, _ = flatten(params)
return np.dot(flattened, flattened) | [
"def",
"l2_norm",
"(",
"params",
")",
":",
"flattened",
",",
"_",
"=",
"flatten",
"(",
"params",
")",
"return",
"np",
".",
"dot",
"(",
"flattened",
",",
"flattened",
")"
] | Computes l2 norm of params by flattening them into a vector. | [
"Computes",
"l2",
"norm",
"of",
"params",
"by",
"flattening",
"them",
"into",
"a",
"vector",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/neural_net.py#L30-L33 | train | Computes the l2 norm of params by flattening them into a vector. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/bayesian_neural_net.py | make_nn_funs | def make_nn_funs(layer_sizes, L2_reg, noise_variance, nonlinearity=np.tanh):
"""These functions implement a standard multi-layer perceptron,
vectorized over both training examples and weight samples."""
shapes = list(zip(layer_sizes[:-1], layer_sizes[1:]))
num_weights = sum((m+1)*n for m, n in shapes)
... | python | def make_nn_funs(layer_sizes, L2_reg, noise_variance, nonlinearity=np.tanh):
"""These functions implement a standard multi-layer perceptron,
vectorized over both training examples and weight samples."""
shapes = list(zip(layer_sizes[:-1], layer_sizes[1:]))
num_weights = sum((m+1)*n for m, n in shapes)
... | [
"def",
"make_nn_funs",
"(",
"layer_sizes",
",",
"L2_reg",
",",
"noise_variance",
",",
"nonlinearity",
"=",
"np",
".",
"tanh",
")",
":",
"shapes",
"=",
"list",
"(",
"zip",
"(",
"layer_sizes",
"[",
":",
"-",
"1",
"]",
",",
"layer_sizes",
"[",
"1",
":",
... | These functions implement a standard multi-layer perceptron,
vectorized over both training examples and weight samples. | [
"These",
"functions",
"implement",
"a",
"standard",
"multi",
"-",
"layer",
"perceptron",
"vectorized",
"over",
"both",
"training",
"examples",
"and",
"weight",
"samples",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/bayesian_neural_net.py#L12-L40 | train | This function returns a list of functions that can be used to compute the network for each training example. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/generative_adversarial_net.py | neural_net_predict | def neural_net_predict(params, inputs):
"""Params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix."""
inpW, inpb = params[0]
inputs = relu(np.dot(inputs, inpW) + inpb)
for W, b in params[1:-1]:
outputs = batch_normalize(np.dot(inputs, W) + b)
inputs = relu(outputs... | python | def neural_net_predict(params, inputs):
"""Params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix."""
inpW, inpb = params[0]
inputs = relu(np.dot(inputs, inpW) + inpb)
for W, b in params[1:-1]:
outputs = batch_normalize(np.dot(inputs, W) + b)
inputs = relu(outputs... | [
"def",
"neural_net_predict",
"(",
"params",
",",
"inputs",
")",
":",
"inpW",
",",
"inpb",
"=",
"params",
"[",
"0",
"]",
"inputs",
"=",
"relu",
"(",
"np",
".",
"dot",
"(",
"inputs",
",",
"inpW",
")",
"+",
"inpb",
")",
"for",
"W",
",",
"b",
"in",
... | Params is a list of (weights, bias) tuples.
inputs is an (N x D) matrix. | [
"Params",
"is",
"a",
"list",
"of",
"(",
"weights",
"bias",
")",
"tuples",
".",
"inputs",
"is",
"an",
"(",
"N",
"x",
"D",
")",
"matrix",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/generative_adversarial_net.py#L33-L43 | train | Params is a list of weights and bias tuples. inputs is an N x D matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/generative_adversarial_net.py | adam_minimax | def adam_minimax(grad_both, init_params_max, init_params_min, callback=None, num_iters=100,
step_size_max=0.001, step_size_min=0.001, b1=0.9, b2=0.999, eps=10**-8):
"""Adam modified to do minimiax optimization, for instance to help with
training generative adversarial networks."""
x_max, unflatten... | python | def adam_minimax(grad_both, init_params_max, init_params_min, callback=None, num_iters=100,
step_size_max=0.001, step_size_min=0.001, b1=0.9, b2=0.999, eps=10**-8):
"""Adam modified to do minimiax optimization, for instance to help with
training generative adversarial networks."""
x_max, unflatten... | [
"def",
"adam_minimax",
"(",
"grad_both",
",",
"init_params_max",
",",
"init_params_min",
",",
"callback",
"=",
"None",
",",
"num_iters",
"=",
"100",
",",
"step_size_max",
"=",
"0.001",
",",
"step_size_min",
"=",
"0.001",
",",
"b1",
"=",
"0.9",
",",
"b2",
"... | Adam modified to do minimiax optimization, for instance to help with
training generative adversarial networks. | [
"Adam",
"modified",
"to",
"do",
"minimiax",
"optimization",
"for",
"instance",
"to",
"help",
"with",
"training",
"generative",
"adversarial",
"networks",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/generative_adversarial_net.py#L59-L91 | train | Adam modified to do minimiax optimization for instance to help with adversarial network training generative adversarial networks. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | elementwise_grad | def elementwise_grad(fun, x):
"""
Returns a function that computes the sum of each column of the Jacobian of
`fun`, in one pass. If the Jacobian is diagonal, then this is the diagonal
of the Jacobian.
"""
vjp, ans = _make_vjp(fun, x)
if vspace(ans).iscomplex:
raise TypeError("Element... | python | def elementwise_grad(fun, x):
"""
Returns a function that computes the sum of each column of the Jacobian of
`fun`, in one pass. If the Jacobian is diagonal, then this is the diagonal
of the Jacobian.
"""
vjp, ans = _make_vjp(fun, x)
if vspace(ans).iscomplex:
raise TypeError("Element... | [
"def",
"elementwise_grad",
"(",
"fun",
",",
"x",
")",
":",
"vjp",
",",
"ans",
"=",
"_make_vjp",
"(",
"fun",
",",
"x",
")",
"if",
"vspace",
"(",
"ans",
")",
".",
"iscomplex",
":",
"raise",
"TypeError",
"(",
"\"Elementwise_grad only applies to real-output func... | Returns a function that computes the sum of each column of the Jacobian of
`fun`, in one pass. If the Jacobian is diagonal, then this is the diagonal
of the Jacobian. | [
"Returns",
"a",
"function",
"that",
"computes",
"the",
"sum",
"of",
"each",
"column",
"of",
"the",
"Jacobian",
"of",
"fun",
"in",
"one",
"pass",
".",
"If",
"the",
"Jacobian",
"is",
"diagonal",
"then",
"this",
"is",
"the",
"diagonal",
"of",
"the",
"Jacobi... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L32-L41 | train | Returns a function that computes the sum of each column of the Jacobian of fun at x. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | jacobian | def jacobian(fun, x):
"""
Returns a function which computes the Jacobian of `fun` with respect to
positional argument number `argnum`, which must be a scalar or array. Unlike
`grad` it is not restricted to scalar-output functions, but also it cannot
take derivatives with respect to some argument typ... | python | def jacobian(fun, x):
"""
Returns a function which computes the Jacobian of `fun` with respect to
positional argument number `argnum`, which must be a scalar or array. Unlike
`grad` it is not restricted to scalar-output functions, but also it cannot
take derivatives with respect to some argument typ... | [
"def",
"jacobian",
"(",
"fun",
",",
"x",
")",
":",
"vjp",
",",
"ans",
"=",
"_make_vjp",
"(",
"fun",
",",
"x",
")",
"ans_vspace",
"=",
"vspace",
"(",
"ans",
")",
"jacobian_shape",
"=",
"ans_vspace",
".",
"shape",
"+",
"vspace",
"(",
"x",
")",
".",
... | Returns a function which computes the Jacobian of `fun` with respect to
positional argument number `argnum`, which must be a scalar or array. Unlike
`grad` it is not restricted to scalar-output functions, but also it cannot
take derivatives with respect to some argument types (like lists or dicts).
If t... | [
"Returns",
"a",
"function",
"which",
"computes",
"the",
"Jacobian",
"of",
"fun",
"with",
"respect",
"to",
"positional",
"argument",
"number",
"argnum",
"which",
"must",
"be",
"a",
"scalar",
"or",
"array",
".",
"Unlike",
"grad",
"it",
"is",
"not",
"restricted... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L48-L61 | train | Returns a function which computes the Jacobian of fun with respect to the given positional argument number argnum. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | grad_named | def grad_named(fun, argname):
'''Takes gradients with respect to a named argument.
Doesn't work on *args or **kwargs.'''
arg_index = getargspec(fun).args.index(argname)
return grad(fun, arg_index) | python | def grad_named(fun, argname):
'''Takes gradients with respect to a named argument.
Doesn't work on *args or **kwargs.'''
arg_index = getargspec(fun).args.index(argname)
return grad(fun, arg_index) | [
"def",
"grad_named",
"(",
"fun",
",",
"argname",
")",
":",
"arg_index",
"=",
"getargspec",
"(",
"fun",
")",
".",
"args",
".",
"index",
"(",
"argname",
")",
"return",
"grad",
"(",
"fun",
",",
"arg_index",
")"
] | Takes gradients with respect to a named argument.
Doesn't work on *args or **kwargs. | [
"Takes",
"gradients",
"with",
"respect",
"to",
"a",
"named",
"argument",
".",
"Doesn",
"t",
"work",
"on",
"*",
"args",
"or",
"**",
"kwargs",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L69-L73 | train | Takes gradients with respect to a named argument.
Doesn t work on args and kwargs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | hessian_tensor_product | def hessian_tensor_product(fun, argnum=0):
"""Builds a function that returns the exact Hessian-tensor product.
The returned function has arguments (*args, tensor, **kwargs), and for
vectors takes roughly 4x as long to evaluate as the original function."""
fun_grad = grad(fun, argnum)
def vector_dot_... | python | def hessian_tensor_product(fun, argnum=0):
"""Builds a function that returns the exact Hessian-tensor product.
The returned function has arguments (*args, tensor, **kwargs), and for
vectors takes roughly 4x as long to evaluate as the original function."""
fun_grad = grad(fun, argnum)
def vector_dot_... | [
"def",
"hessian_tensor_product",
"(",
"fun",
",",
"argnum",
"=",
"0",
")",
":",
"fun_grad",
"=",
"grad",
"(",
"fun",
",",
"argnum",
")",
"def",
"vector_dot_grad",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
",",
"vector",
"=",
"args"... | Builds a function that returns the exact Hessian-tensor product.
The returned function has arguments (*args, tensor, **kwargs), and for
vectors takes roughly 4x as long to evaluate as the original function. | [
"Builds",
"a",
"function",
"that",
"returns",
"the",
"exact",
"Hessian",
"-",
"tensor",
"product",
".",
"The",
"returned",
"function",
"has",
"arguments",
"(",
"*",
"args",
"tensor",
"**",
"kwargs",
")",
"and",
"for",
"vectors",
"takes",
"roughly",
"4x",
"... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L87-L95 | train | Builds a function that returns the exact Hessian - tensor product. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | tensor_jacobian_product | def tensor_jacobian_product(fun, argnum=0):
"""Builds a function that returns the exact tensor-Jacobian product, that
is the Jacobian matrix left-multiplied by tensor. The returned function
has arguments (*args, tensor, **kwargs)."""
def vector_dot_fun(*args, **kwargs):
args, vector = args[:-1],... | python | def tensor_jacobian_product(fun, argnum=0):
"""Builds a function that returns the exact tensor-Jacobian product, that
is the Jacobian matrix left-multiplied by tensor. The returned function
has arguments (*args, tensor, **kwargs)."""
def vector_dot_fun(*args, **kwargs):
args, vector = args[:-1],... | [
"def",
"tensor_jacobian_product",
"(",
"fun",
",",
"argnum",
"=",
"0",
")",
":",
"def",
"vector_dot_fun",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"args",
",",
"vector",
"=",
"args",
"[",
":",
"-",
"1",
"]",
",",
"args",
"[",
"-",
"1"... | Builds a function that returns the exact tensor-Jacobian product, that
is the Jacobian matrix left-multiplied by tensor. The returned function
has arguments (*args, tensor, **kwargs). | [
"Builds",
"a",
"function",
"that",
"returns",
"the",
"exact",
"tensor",
"-",
"Jacobian",
"product",
"that",
"is",
"the",
"Jacobian",
"matrix",
"left",
"-",
"multiplied",
"by",
"tensor",
".",
"The",
"returned",
"function",
"has",
"arguments",
"(",
"*",
"args"... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L98-L105 | train | Builds a function that returns the exact tensor - Jacobian product that is left - multiplied by tensor. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | make_jvp_reversemode | def make_jvp_reversemode(fun, x):
"""Builds a function for evaluating the Jacobian-vector product at a
point. Roughly 1.5x more FLOPs than forward-mode, plus memory requirements
that scale with the number of primitives applied in the evaluation of f, as
well as other overheads. See j-towns.github.io/201... | python | def make_jvp_reversemode(fun, x):
"""Builds a function for evaluating the Jacobian-vector product at a
point. Roughly 1.5x more FLOPs than forward-mode, plus memory requirements
that scale with the number of primitives applied in the evaluation of f, as
well as other overheads. See j-towns.github.io/201... | [
"def",
"make_jvp_reversemode",
"(",
"fun",
",",
"x",
")",
":",
"vjp",
",",
"y",
"=",
"_make_vjp",
"(",
"fun",
",",
"x",
")",
"vjp_vjp",
",",
"_",
"=",
"_make_vjp",
"(",
"vjp",
",",
"vspace",
"(",
"y",
")",
".",
"zeros",
"(",
")",
")",
"return",
... | Builds a function for evaluating the Jacobian-vector product at a
point. Roughly 1.5x more FLOPs than forward-mode, plus memory requirements
that scale with the number of primitives applied in the evaluation of f, as
well as other overheads. See j-towns.github.io/2017/06/12/A-new-trick.html. | [
"Builds",
"a",
"function",
"for",
"evaluating",
"the",
"Jacobian",
"-",
"vector",
"product",
"at",
"a",
"point",
".",
"Roughly",
"1",
".",
"5x",
"more",
"FLOPs",
"than",
"forward",
"-",
"mode",
"plus",
"memory",
"requirements",
"that",
"scale",
"with",
"th... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L109-L116 | train | Builds a function for evaluating the Jacobian - vector product at a
point. Roughly 1. 5x more FLOPs than forward - mode plus memory requirements
that scale with the number of primitives applied in the evaluation of f. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | make_ggnvp | def make_ggnvp(f, g=lambda x: 1./2*np.sum(x**2, axis=-1), f_argnum=0):
"""Builds a function for evaluating generalized-Gauss-Newton-vector products
at a point. Slightly more expensive than mixed-mode."""
@unary_to_nary
def _make_ggnvp(f, x):
f_vjp, f_x = _make_vjp(f, x)
g_hvp, grad_g_x =... | python | def make_ggnvp(f, g=lambda x: 1./2*np.sum(x**2, axis=-1), f_argnum=0):
"""Builds a function for evaluating generalized-Gauss-Newton-vector products
at a point. Slightly more expensive than mixed-mode."""
@unary_to_nary
def _make_ggnvp(f, x):
f_vjp, f_x = _make_vjp(f, x)
g_hvp, grad_g_x =... | [
"def",
"make_ggnvp",
"(",
"f",
",",
"g",
"=",
"lambda",
"x",
":",
"1.",
"/",
"2",
"*",
"np",
".",
"sum",
"(",
"x",
"**",
"2",
",",
"axis",
"=",
"-",
"1",
")",
",",
"f_argnum",
"=",
"0",
")",
":",
"@",
"unary_to_nary",
"def",
"_make_ggnvp",
"(... | Builds a function for evaluating generalized-Gauss-Newton-vector products
at a point. Slightly more expensive than mixed-mode. | [
"Builds",
"a",
"function",
"for",
"evaluating",
"generalized",
"-",
"Gauss",
"-",
"Newton",
"-",
"vector",
"products",
"at",
"a",
"point",
".",
"Slightly",
"more",
"expensive",
"than",
"mixed",
"-",
"mode",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L119-L129 | train | Builds a function for evaluating generalized - Gauss - Newton - vector products
at a point. Slightly more expensive than mixed - mode. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | value_and_grad | def value_and_grad(fun, x):
"""Returns a function that returns both value and gradient. Suitable for use
in scipy.optimize"""
vjp, ans = _make_vjp(fun, x)
if not vspace(ans).size == 1:
raise TypeError("value_and_grad only applies to real scalar-output "
"functions. Try ja... | python | def value_and_grad(fun, x):
"""Returns a function that returns both value and gradient. Suitable for use
in scipy.optimize"""
vjp, ans = _make_vjp(fun, x)
if not vspace(ans).size == 1:
raise TypeError("value_and_grad only applies to real scalar-output "
"functions. Try ja... | [
"def",
"value_and_grad",
"(",
"fun",
",",
"x",
")",
":",
"vjp",
",",
"ans",
"=",
"_make_vjp",
"(",
"fun",
",",
"x",
")",
"if",
"not",
"vspace",
"(",
"ans",
")",
".",
"size",
"==",
"1",
":",
"raise",
"TypeError",
"(",
"\"value_and_grad only applies to r... | Returns a function that returns both value and gradient. Suitable for use
in scipy.optimize | [
"Returns",
"a",
"function",
"that",
"returns",
"both",
"value",
"and",
"gradient",
".",
"Suitable",
"for",
"use",
"in",
"scipy",
".",
"optimize"
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L132-L140 | train | Returns a function that returns both value and gradient. Suitable for use
in scipy. optimize. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | grad_and_aux | def grad_and_aux(fun, x):
"""Builds a function that returns the gradient of the first output and the
(unmodified) second output of a function that returns two outputs."""
vjp, (ans, aux) = _make_vjp(lambda x: atuple(fun(x)), x)
return vjp((vspace(ans).ones(), vspace(aux).zeros())), aux | python | def grad_and_aux(fun, x):
"""Builds a function that returns the gradient of the first output and the
(unmodified) second output of a function that returns two outputs."""
vjp, (ans, aux) = _make_vjp(lambda x: atuple(fun(x)), x)
return vjp((vspace(ans).ones(), vspace(aux).zeros())), aux | [
"def",
"grad_and_aux",
"(",
"fun",
",",
"x",
")",
":",
"vjp",
",",
"(",
"ans",
",",
"aux",
")",
"=",
"_make_vjp",
"(",
"lambda",
"x",
":",
"atuple",
"(",
"fun",
"(",
"x",
")",
")",
",",
"x",
")",
"return",
"vjp",
"(",
"(",
"vspace",
"(",
"ans... | Builds a function that returns the gradient of the first output and the
(unmodified) second output of a function that returns two outputs. | [
"Builds",
"a",
"function",
"that",
"returns",
"the",
"gradient",
"of",
"the",
"first",
"output",
"and",
"the",
"(",
"unmodified",
")",
"second",
"output",
"of",
"a",
"function",
"that",
"returns",
"two",
"outputs",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L143-L147 | train | Builds a function that returns the gradient of the first output and the
( unmodified ) second output of a function that returns two outputs. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | multigrad_dict | def multigrad_dict(fun):
"Takes gradients wrt all arguments simultaneously,"
"returns a dict mapping 'argname' to 'gradval'"
import funcsigs
sig = funcsigs.signature(fun)
def select(preds, lst):
idx = lambda item: next(
(i for i, pred in enumerate(preds) if pred(item)), len(pre... | python | def multigrad_dict(fun):
"Takes gradients wrt all arguments simultaneously,"
"returns a dict mapping 'argname' to 'gradval'"
import funcsigs
sig = funcsigs.signature(fun)
def select(preds, lst):
idx = lambda item: next(
(i for i, pred in enumerate(preds) if pred(item)), len(pre... | [
"def",
"multigrad_dict",
"(",
"fun",
")",
":",
"\"returns a dict mapping 'argname' to 'gradval'\"",
"import",
"funcsigs",
"sig",
"=",
"funcsigs",
".",
"signature",
"(",
"fun",
")",
"def",
"select",
"(",
"preds",
",",
"lst",
")",
":",
"idx",
"=",
"lambda",
"ite... | Takes gradients wrt all arguments simultaneously, | [
"Takes",
"gradients",
"wrt",
"all",
"arguments",
"simultaneously"
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L149-L190 | train | Takes gradients wrt all arguments simultaneously | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/differential_operators.py | checkpoint | def checkpoint(fun):
"""Returns a checkpointed version of `fun`, where intermediate values
computed during the forward pass of `fun` are discarded and then recomputed
for the backward pass. Useful to save memory, effectively trading off time
and memory. See e.g. arxiv.org/abs/1604.06174.
"""
def... | python | def checkpoint(fun):
"""Returns a checkpointed version of `fun`, where intermediate values
computed during the forward pass of `fun` are discarded and then recomputed
for the backward pass. Useful to save memory, effectively trading off time
and memory. See e.g. arxiv.org/abs/1604.06174.
"""
def... | [
"def",
"checkpoint",
"(",
"fun",
")",
":",
"def",
"wrapped_grad",
"(",
"argnum",
",",
"ans",
",",
"args",
",",
"kwargs",
")",
":",
"return",
"make_vjp",
"(",
"fun",
",",
"argnum",
")",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
"[",
"0",
"]"... | Returns a checkpointed version of `fun`, where intermediate values
computed during the forward pass of `fun` are discarded and then recomputed
for the backward pass. Useful to save memory, effectively trading off time
and memory. See e.g. arxiv.org/abs/1604.06174. | [
"Returns",
"a",
"checkpointed",
"version",
"of",
"fun",
"where",
"intermediate",
"values",
"computed",
"during",
"the",
"forward",
"pass",
"of",
"fun",
"are",
"discarded",
"and",
"then",
"recomputed",
"for",
"the",
"backward",
"pass",
".",
"Useful",
"to",
"sav... | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/differential_operators.py#L192-L202 | train | Returns a checkpointed version of fun that is used to compute intermediate values
for the forward pass of fun. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/rnn.py | string_to_one_hot | def string_to_one_hot(string, maxchar):
"""Converts an ASCII string to a one-of-k encoding."""
ascii = np.array([ord(c) for c in string]).T
return np.array(ascii[:,None] == np.arange(maxchar)[None, :], dtype=int) | python | def string_to_one_hot(string, maxchar):
"""Converts an ASCII string to a one-of-k encoding."""
ascii = np.array([ord(c) for c in string]).T
return np.array(ascii[:,None] == np.arange(maxchar)[None, :], dtype=int) | [
"def",
"string_to_one_hot",
"(",
"string",
",",
"maxchar",
")",
":",
"ascii",
"=",
"np",
".",
"array",
"(",
"[",
"ord",
"(",
"c",
")",
"for",
"c",
"in",
"string",
"]",
")",
".",
"T",
"return",
"np",
".",
"array",
"(",
"ascii",
"[",
":",
",",
"N... | Converts an ASCII string to a one-of-k encoding. | [
"Converts",
"an",
"ASCII",
"string",
"to",
"a",
"one",
"-",
"of",
"-",
"k",
"encoding",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/rnn.py#L62-L65 | train | Converts an ASCII string to a one - hot encoding. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/rnn.py | build_dataset | def build_dataset(filename, sequence_length, alphabet_size, max_lines=-1):
"""Loads a text file, and turns each line into an encoded sequence."""
with open(filename) as f:
content = f.readlines()
content = content[:max_lines]
content = [line for line in content if len(line) > 2] # Remove blank... | python | def build_dataset(filename, sequence_length, alphabet_size, max_lines=-1):
"""Loads a text file, and turns each line into an encoded sequence."""
with open(filename) as f:
content = f.readlines()
content = content[:max_lines]
content = [line for line in content if len(line) > 2] # Remove blank... | [
"def",
"build_dataset",
"(",
"filename",
",",
"sequence_length",
",",
"alphabet_size",
",",
"max_lines",
"=",
"-",
"1",
")",
":",
"with",
"open",
"(",
"filename",
")",
"as",
"f",
":",
"content",
"=",
"f",
".",
"readlines",
"(",
")",
"content",
"=",
"co... | Loads a text file, and turns each line into an encoded sequence. | [
"Loads",
"a",
"text",
"file",
"and",
"turns",
"each",
"line",
"into",
"an",
"encoded",
"sequence",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/rnn.py#L70-L80 | train | Loads a text file and turns each line into an encoded sequence. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/ode_net.py | init_nn_params | def init_nn_params(scale, layer_sizes, rs=npr.RandomState(0)):
"""Build a list of (weights, biases) tuples, one for each layer."""
return [(rs.randn(insize, outsize) * scale, # weight matrix
rs.randn(outsize) * scale) # bias vector
for insize, outsize in zip(layer_sizes[:-1]... | python | def init_nn_params(scale, layer_sizes, rs=npr.RandomState(0)):
"""Build a list of (weights, biases) tuples, one for each layer."""
return [(rs.randn(insize, outsize) * scale, # weight matrix
rs.randn(outsize) * scale) # bias vector
for insize, outsize in zip(layer_sizes[:-1]... | [
"def",
"init_nn_params",
"(",
"scale",
",",
"layer_sizes",
",",
"rs",
"=",
"npr",
".",
"RandomState",
"(",
"0",
")",
")",
":",
"return",
"[",
"(",
"rs",
".",
"randn",
"(",
"insize",
",",
"outsize",
")",
"*",
"scale",
",",
"# weight matrix",
"rs",
"."... | Build a list of (weights, biases) tuples, one for each layer. | [
"Build",
"a",
"list",
"of",
"(",
"weights",
"biases",
")",
"tuples",
"one",
"for",
"each",
"layer",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/ode_net.py#L32-L36 | train | Initialize the nn parameters. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/numpy/fft.py | make_rfft_factors | def make_rfft_factors(axes, resshape, facshape, normshape, norm):
""" make the compression factors and compute the normalization
for irfft and rfft.
"""
N = 1.0
for n in normshape: N = N * n
# inplace modification is fine because we produce a constant
# which doesn't go into autograd.
... | python | def make_rfft_factors(axes, resshape, facshape, normshape, norm):
""" make the compression factors and compute the normalization
for irfft and rfft.
"""
N = 1.0
for n in normshape: N = N * n
# inplace modification is fine because we produce a constant
# which doesn't go into autograd.
... | [
"def",
"make_rfft_factors",
"(",
"axes",
",",
"resshape",
",",
"facshape",
",",
"normshape",
",",
"norm",
")",
":",
"N",
"=",
"1.0",
"for",
"n",
"in",
"normshape",
":",
"N",
"=",
"N",
"*",
"n",
"# inplace modification is fine because we produce a constant",
"#... | make the compression factors and compute the normalization
for irfft and rfft. | [
"make",
"the",
"compression",
"factors",
"and",
"compute",
"the",
"normalization",
"for",
"irfft",
"and",
"rfft",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/numpy/fft.py#L128-L149 | train | make the compression factors and compute the normalization
for irfft and rfft. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/mixture_variational_inference.py | variational_lower_bound | def variational_lower_bound(params, t, logprob, sampler, log_density,
num_samples, rs):
"""Provides a stochastic estimate of the variational lower bound,
for any variational family and model density."""
samples = sampler(params, num_samples, rs)
log_qs = log_density(params... | python | def variational_lower_bound(params, t, logprob, sampler, log_density,
num_samples, rs):
"""Provides a stochastic estimate of the variational lower bound,
for any variational family and model density."""
samples = sampler(params, num_samples, rs)
log_qs = log_density(params... | [
"def",
"variational_lower_bound",
"(",
"params",
",",
"t",
",",
"logprob",
",",
"sampler",
",",
"log_density",
",",
"num_samples",
",",
"rs",
")",
":",
"samples",
"=",
"sampler",
"(",
"params",
",",
"num_samples",
",",
"rs",
")",
"log_qs",
"=",
"log_densit... | Provides a stochastic estimate of the variational lower bound,
for any variational family and model density. | [
"Provides",
"a",
"stochastic",
"estimate",
"of",
"the",
"variational",
"lower",
"bound",
"for",
"any",
"variational",
"family",
"and",
"model",
"density",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/mixture_variational_inference.py#L37-L46 | train | Provides a stochastic estimate of the variational lower bound for any variational family and model density. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/numpy/linalg.py | grad_eigh | def grad_eigh(ans, x, UPLO='L'):
"""Gradient for eigenvalues and vectors of a symmetric matrix."""
N = x.shape[-1]
w, v = ans # Eigenvalues, eigenvectors.
def vjp(g):
wg, vg = g # Gradient w.r.t. eigenvalues, eigenvectors.
w_repeated = anp.repeat(w[..., anp.newaxis]... | python | def grad_eigh(ans, x, UPLO='L'):
"""Gradient for eigenvalues and vectors of a symmetric matrix."""
N = x.shape[-1]
w, v = ans # Eigenvalues, eigenvectors.
def vjp(g):
wg, vg = g # Gradient w.r.t. eigenvalues, eigenvectors.
w_repeated = anp.repeat(w[..., anp.newaxis]... | [
"def",
"grad_eigh",
"(",
"ans",
",",
"x",
",",
"UPLO",
"=",
"'L'",
")",
":",
"N",
"=",
"x",
".",
"shape",
"[",
"-",
"1",
"]",
"w",
",",
"v",
"=",
"ans",
"# Eigenvalues, eigenvectors.",
"def",
"vjp",
"(",
"g",
")",
":",
"wg",
",",
"vg",
"=",
"... | Gradient for eigenvalues and vectors of a symmetric matrix. | [
"Gradient",
"for",
"eigenvalues",
"and",
"vectors",
"of",
"a",
"symmetric",
"matrix",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/numpy/linalg.py#L104-L114 | train | Gradient for eigenvalues and vectors of a symmetric matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | autograd/numpy/numpy_vjps.py | repeat_to_match_shape | def repeat_to_match_shape(g, shape, dtype, axis, keepdims):
"""Returns the array g repeated along axis to fit vector space vs.
Also returns the number of repetitions of the array."""
if shape == ():
return g, 1
axis = list(axis) if isinstance(axis, tuple) else axis
new_shape = onp.array(sha... | python | def repeat_to_match_shape(g, shape, dtype, axis, keepdims):
"""Returns the array g repeated along axis to fit vector space vs.
Also returns the number of repetitions of the array."""
if shape == ():
return g, 1
axis = list(axis) if isinstance(axis, tuple) else axis
new_shape = onp.array(sha... | [
"def",
"repeat_to_match_shape",
"(",
"g",
",",
"shape",
",",
"dtype",
",",
"axis",
",",
"keepdims",
")",
":",
"if",
"shape",
"==",
"(",
")",
":",
"return",
"g",
",",
"1",
"axis",
"=",
"list",
"(",
"axis",
")",
"if",
"isinstance",
"(",
"axis",
",",
... | Returns the array g repeated along axis to fit vector space vs.
Also returns the number of repetitions of the array. | [
"Returns",
"the",
"array",
"g",
"repeated",
"along",
"axis",
"to",
"fit",
"vector",
"space",
"vs",
".",
"Also",
"returns",
"the",
"number",
"of",
"repetitions",
"of",
"the",
"array",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/autograd/numpy/numpy_vjps.py#L274-L285 | train | Returns the array g repeated along axis to fit vector space vs.
Also returns the number of repetitions of the array g. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/data.py | plot_images | def plot_images(images, ax, ims_per_row=5, padding=5, digit_dimensions=(28, 28),
cmap=matplotlib.cm.binary, vmin=None, vmax=None):
"""Images should be a (N_images x pixels) matrix."""
N_images = images.shape[0]
N_rows = (N_images - 1) // ims_per_row + 1
pad_value = np.min(images.ravel())... | python | def plot_images(images, ax, ims_per_row=5, padding=5, digit_dimensions=(28, 28),
cmap=matplotlib.cm.binary, vmin=None, vmax=None):
"""Images should be a (N_images x pixels) matrix."""
N_images = images.shape[0]
N_rows = (N_images - 1) // ims_per_row + 1
pad_value = np.min(images.ravel())... | [
"def",
"plot_images",
"(",
"images",
",",
"ax",
",",
"ims_per_row",
"=",
"5",
",",
"padding",
"=",
"5",
",",
"digit_dimensions",
"=",
"(",
"28",
",",
"28",
")",
",",
"cmap",
"=",
"matplotlib",
".",
"cm",
".",
"binary",
",",
"vmin",
"=",
"None",
","... | Images should be a (N_images x pixels) matrix. | [
"Images",
"should",
"be",
"a",
"(",
"N_images",
"x",
"pixels",
")",
"matrix",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/data.py#L22-L41 | train | Plots the images in a matrix. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
HIPS/autograd | examples/data.py | make_pinwheel | def make_pinwheel(radial_std, tangential_std, num_classes, num_per_class, rate,
rs=npr.RandomState(0)):
"""Based on code by Ryan P. Adams."""
rads = np.linspace(0, 2*np.pi, num_classes, endpoint=False)
features = rs.randn(num_classes*num_per_class, 2) \
* np.array([radial_std, tan... | python | def make_pinwheel(radial_std, tangential_std, num_classes, num_per_class, rate,
rs=npr.RandomState(0)):
"""Based on code by Ryan P. Adams."""
rads = np.linspace(0, 2*np.pi, num_classes, endpoint=False)
features = rs.randn(num_classes*num_per_class, 2) \
* np.array([radial_std, tan... | [
"def",
"make_pinwheel",
"(",
"radial_std",
",",
"tangential_std",
",",
"num_classes",
",",
"num_per_class",
",",
"rate",
",",
"rs",
"=",
"npr",
".",
"RandomState",
"(",
"0",
")",
")",
":",
"rads",
"=",
"np",
".",
"linspace",
"(",
"0",
",",
"2",
"*",
... | Based on code by Ryan P. Adams. | [
"Based",
"on",
"code",
"by",
"Ryan",
"P",
".",
"Adams",
"."
] | e3b525302529d7490769d5c0bcfc7457e24e3b3e | https://github.com/HIPS/autograd/blob/e3b525302529d7490769d5c0bcfc7457e24e3b3e/examples/data.py#L53-L67 | train | Generate a pinwheel from the given radial standard and tangential standard. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
dxa4481/truffleHog | truffleHog/truffleHog.py | shannon_entropy | def shannon_entropy(data, iterator):
"""
Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html
"""
if not data:
return 0
entropy = 0
for x in iterator:
p_x = float(data.count(x))/len(data)
if p_x > 0:
entropy += - p_x*math.log(p_... | python | def shannon_entropy(data, iterator):
"""
Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html
"""
if not data:
return 0
entropy = 0
for x in iterator:
p_x = float(data.count(x))/len(data)
if p_x > 0:
entropy += - p_x*math.log(p_... | [
"def",
"shannon_entropy",
"(",
"data",
",",
"iterator",
")",
":",
"if",
"not",
"data",
":",
"return",
"0",
"entropy",
"=",
"0",
"for",
"x",
"in",
"iterator",
":",
"p_x",
"=",
"float",
"(",
"data",
".",
"count",
"(",
"x",
")",
")",
"/",
"len",
"("... | Borrowed from http://blog.dkbza.org/2007/05/scanning-data-for-entropy-anomalies.html | [
"Borrowed",
"from",
"http",
":",
"//",
"blog",
".",
"dkbza",
".",
"org",
"/",
"2007",
"/",
"05",
"/",
"scanning",
"-",
"data",
"-",
"for",
"-",
"entropy",
"-",
"anomalies",
".",
"html"
] | a4c69fa2f6b256bfe824ac82b96c77eb8c06b2d0 | https://github.com/dxa4481/truffleHog/blob/a4c69fa2f6b256bfe824ac82b96c77eb8c06b2d0/truffleHog/truffleHog.py#L85-L96 | train | Calculates the shannon entropy of the given data. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/formatters.py | srt_formatter | def srt_formatter(subtitles, padding_before=0, padding_after=0):
"""
Serialize a list of subtitles according to the SRT format, with optional time padding.
"""
sub_rip_file = pysrt.SubRipFile()
for i, ((start, end), text) in enumerate(subtitles, start=1):
item = pysrt.SubRipItem()
it... | python | def srt_formatter(subtitles, padding_before=0, padding_after=0):
"""
Serialize a list of subtitles according to the SRT format, with optional time padding.
"""
sub_rip_file = pysrt.SubRipFile()
for i, ((start, end), text) in enumerate(subtitles, start=1):
item = pysrt.SubRipItem()
it... | [
"def",
"srt_formatter",
"(",
"subtitles",
",",
"padding_before",
"=",
"0",
",",
"padding_after",
"=",
"0",
")",
":",
"sub_rip_file",
"=",
"pysrt",
".",
"SubRipFile",
"(",
")",
"for",
"i",
",",
"(",
"(",
"start",
",",
"end",
")",
",",
"text",
")",
"in... | Serialize a list of subtitles according to the SRT format, with optional time padding. | [
"Serialize",
"a",
"list",
"of",
"subtitles",
"according",
"to",
"the",
"SRT",
"format",
"with",
"optional",
"time",
"padding",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/formatters.py#L14-L26 | train | Serialize a list of subtitles according to the SRT format with optional time padding. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/formatters.py | vtt_formatter | def vtt_formatter(subtitles, padding_before=0, padding_after=0):
"""
Serialize a list of subtitles according to the VTT format, with optional time padding.
"""
text = srt_formatter(subtitles, padding_before, padding_after)
text = 'WEBVTT\n\n' + text.replace(',', '.')
return text | python | def vtt_formatter(subtitles, padding_before=0, padding_after=0):
"""
Serialize a list of subtitles according to the VTT format, with optional time padding.
"""
text = srt_formatter(subtitles, padding_before, padding_after)
text = 'WEBVTT\n\n' + text.replace(',', '.')
return text | [
"def",
"vtt_formatter",
"(",
"subtitles",
",",
"padding_before",
"=",
"0",
",",
"padding_after",
"=",
"0",
")",
":",
"text",
"=",
"srt_formatter",
"(",
"subtitles",
",",
"padding_before",
",",
"padding_after",
")",
"text",
"=",
"'WEBVTT\\n\\n'",
"+",
"text",
... | Serialize a list of subtitles according to the VTT format, with optional time padding. | [
"Serialize",
"a",
"list",
"of",
"subtitles",
"according",
"to",
"the",
"VTT",
"format",
"with",
"optional",
"time",
"padding",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/formatters.py#L29-L35 | train | Serialize a list of subtitles according to the VTT format. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/formatters.py | json_formatter | def json_formatter(subtitles):
"""
Serialize a list of subtitles as a JSON blob.
"""
subtitle_dicts = [
{
'start': start,
'end': end,
'content': text,
}
for ((start, end), text)
in subtitles
]
return json.dumps(subtitle_dicts) | python | def json_formatter(subtitles):
"""
Serialize a list of subtitles as a JSON blob.
"""
subtitle_dicts = [
{
'start': start,
'end': end,
'content': text,
}
for ((start, end), text)
in subtitles
]
return json.dumps(subtitle_dicts) | [
"def",
"json_formatter",
"(",
"subtitles",
")",
":",
"subtitle_dicts",
"=",
"[",
"{",
"'start'",
":",
"start",
",",
"'end'",
":",
"end",
",",
"'content'",
":",
"text",
",",
"}",
"for",
"(",
"(",
"start",
",",
"end",
")",
",",
"text",
")",
"in",
"su... | Serialize a list of subtitles as a JSON blob. | [
"Serialize",
"a",
"list",
"of",
"subtitles",
"as",
"a",
"JSON",
"blob",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/formatters.py#L38-L51 | train | Serialize a list of subtitles as a JSON blob. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | percentile | def percentile(arr, percent):
"""
Calculate the given percentile of arr.
"""
arr = sorted(arr)
index = (len(arr) - 1) * percent
floor = math.floor(index)
ceil = math.ceil(index)
if floor == ceil:
return arr[int(index)]
low_value = arr[int(floor)] * (ceil - index)
high_val... | python | def percentile(arr, percent):
"""
Calculate the given percentile of arr.
"""
arr = sorted(arr)
index = (len(arr) - 1) * percent
floor = math.floor(index)
ceil = math.ceil(index)
if floor == ceil:
return arr[int(index)]
low_value = arr[int(floor)] * (ceil - index)
high_val... | [
"def",
"percentile",
"(",
"arr",
",",
"percent",
")",
":",
"arr",
"=",
"sorted",
"(",
"arr",
")",
"index",
"=",
"(",
"len",
"(",
"arr",
")",
"-",
"1",
")",
"*",
"percent",
"floor",
"=",
"math",
".",
"floor",
"(",
"index",
")",
"ceil",
"=",
"mat... | Calculate the given percentile of arr. | [
"Calculate",
"the",
"given",
"percentile",
"of",
"arr",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L39-L51 | train | Calculate the given percentile of arr. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | extract_audio | def extract_audio(filename, channels=1, rate=16000):
"""
Extract audio from an input file to a temporary WAV file.
"""
temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
if not os.path.isfile(filename):
print("The given file does not exist: {}".format(filename))
raise Ex... | python | def extract_audio(filename, channels=1, rate=16000):
"""
Extract audio from an input file to a temporary WAV file.
"""
temp = tempfile.NamedTemporaryFile(suffix='.wav', delete=False)
if not os.path.isfile(filename):
print("The given file does not exist: {}".format(filename))
raise Ex... | [
"def",
"extract_audio",
"(",
"filename",
",",
"channels",
"=",
"1",
",",
"rate",
"=",
"16000",
")",
":",
"temp",
"=",
"tempfile",
".",
"NamedTemporaryFile",
"(",
"suffix",
"=",
"'.wav'",
",",
"delete",
"=",
"False",
")",
"if",
"not",
"os",
".",
"path",... | Extract audio from an input file to a temporary WAV file. | [
"Extract",
"audio",
"from",
"an",
"input",
"file",
"to",
"a",
"temporary",
"WAV",
"file",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L175-L191 | train | Extract audio from an input file to a temporary WAV file. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | find_speech_regions | def find_speech_regions(filename, frame_width=4096, min_region_size=0.5, max_region_size=6): # pylint: disable=too-many-locals
"""
Perform voice activity detection on a given audio file.
"""
reader = wave.open(filename)
sample_width = reader.getsampwidth()
rate = reader.getframerate()
n_chan... | python | def find_speech_regions(filename, frame_width=4096, min_region_size=0.5, max_region_size=6): # pylint: disable=too-many-locals
"""
Perform voice activity detection on a given audio file.
"""
reader = wave.open(filename)
sample_width = reader.getsampwidth()
rate = reader.getframerate()
n_chan... | [
"def",
"find_speech_regions",
"(",
"filename",
",",
"frame_width",
"=",
"4096",
",",
"min_region_size",
"=",
"0.5",
",",
"max_region_size",
"=",
"6",
")",
":",
"# pylint: disable=too-many-locals",
"reader",
"=",
"wave",
".",
"open",
"(",
"filename",
")",
"sample... | Perform voice activity detection on a given audio file. | [
"Perform",
"voice",
"activity",
"detection",
"on",
"a",
"given",
"audio",
"file",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L194-L230 | train | Find the audio file s audio files and return a list of the audio files that are within the specified range. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | generate_subtitles | def generate_subtitles( # pylint: disable=too-many-locals,too-many-arguments
source_path,
output=None,
concurrency=DEFAULT_CONCURRENCY,
src_language=DEFAULT_SRC_LANGUAGE,
dst_language=DEFAULT_DST_LANGUAGE,
subtitle_file_format=DEFAULT_SUBTITLE_FORMAT,
api_key=None... | python | def generate_subtitles( # pylint: disable=too-many-locals,too-many-arguments
source_path,
output=None,
concurrency=DEFAULT_CONCURRENCY,
src_language=DEFAULT_SRC_LANGUAGE,
dst_language=DEFAULT_DST_LANGUAGE,
subtitle_file_format=DEFAULT_SUBTITLE_FORMAT,
api_key=None... | [
"def",
"generate_subtitles",
"(",
"# pylint: disable=too-many-locals,too-many-arguments",
"source_path",
",",
"output",
"=",
"None",
",",
"concurrency",
"=",
"DEFAULT_CONCURRENCY",
",",
"src_language",
"=",
"DEFAULT_SRC_LANGUAGE",
",",
"dst_language",
"=",
"DEFAULT_DST_LANGUA... | Given an input audio/video file, generate subtitles in the specified language and format. | [
"Given",
"an",
"input",
"audio",
"/",
"video",
"file",
"generate",
"subtitles",
"in",
"the",
"specified",
"language",
"and",
"format",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L233-L318 | train | Generate subtitles from audio files. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | validate | def validate(args):
"""
Check that the CLI arguments passed to autosub are valid.
"""
if args.format not in FORMATTERS:
print(
"Subtitle format not supported. "
"Run with --list-formats to see all supported formats."
)
return False
if args.src_languag... | python | def validate(args):
"""
Check that the CLI arguments passed to autosub are valid.
"""
if args.format not in FORMATTERS:
print(
"Subtitle format not supported. "
"Run with --list-formats to see all supported formats."
)
return False
if args.src_languag... | [
"def",
"validate",
"(",
"args",
")",
":",
"if",
"args",
".",
"format",
"not",
"in",
"FORMATTERS",
":",
"print",
"(",
"\"Subtitle format not supported. \"",
"\"Run with --list-formats to see all supported formats.\"",
")",
"return",
"False",
"if",
"args",
".",
"src_lan... | Check that the CLI arguments passed to autosub are valid. | [
"Check",
"that",
"the",
"CLI",
"arguments",
"passed",
"to",
"autosub",
"are",
"valid",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L321-L350 | train | Check that the CLI arguments passed to autosub are valid. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
agermanidis/autosub | autosub/__init__.py | main | def main():
"""
Run autosub as a command-line program.
"""
parser = argparse.ArgumentParser()
parser.add_argument('source_path', help="Path to the video or audio file to subtitle",
nargs='?')
parser.add_argument('-C', '--concurrency', help="Number of concurrent API reques... | python | def main():
"""
Run autosub as a command-line program.
"""
parser = argparse.ArgumentParser()
parser.add_argument('source_path', help="Path to the video or audio file to subtitle",
nargs='?')
parser.add_argument('-C', '--concurrency', help="Number of concurrent API reques... | [
"def",
"main",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"'source_path'",
",",
"help",
"=",
"\"Path to the video or audio file to subtitle\"",
",",
"nargs",
"=",
"'?'",
")",
"parser",
".",
"a... | Run autosub as a command-line program. | [
"Run",
"autosub",
"as",
"a",
"command",
"-",
"line",
"program",
"."
] | d32389cb76e63ec6959111c3f989a72f36f726fe | https://github.com/agermanidis/autosub/blob/d32389cb76e63ec6959111c3f989a72f36f726fe/autosub/__init__.py#L353-L410 | train | Run autosub as a command - line program. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/plugins/pylint_lint.py | PylintLinter.lint | def lint(cls, document, is_saved, flags=''):
"""Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, ... | python | def lint(cls, document, is_saved, flags=''):
"""Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, ... | [
"def",
"lint",
"(",
"cls",
",",
"document",
",",
"is_saved",
",",
"flags",
"=",
"''",
")",
":",
"if",
"not",
"is_saved",
":",
"# Pylint can only be run on files that have been saved to disk.",
"# Rather than return nothing, return the previous list of",
"# diagnostics. If we ... | Plugin interface to pyls linter.
Args:
document: The document to be linted.
is_saved: Whether or not the file has been saved to disk.
flags: Additional flags to pass to pylint. Not exposed to
pyls_lint, but used for testing.
Returns:
A li... | [
"Plugin",
"interface",
"to",
"pyls",
"linter",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/pylint_lint.py#L15-L131 | train | This function will lint a file and return a list of dicts with the keys of the file and the values of the diagnostics that were found. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/plugins/jedi_completion.py | _sort_text | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
# If its 'hidden', put it next last
prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
return prefix.format(definition.name) | python | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
# If its 'hidden', put it next last
prefix = 'z{}' if definition.name.startswith('_') else 'a{}'
return prefix.format(definition.name) | [
"def",
"_sort_text",
"(",
"definition",
")",
":",
"# If its 'hidden', put it next last",
"prefix",
"=",
"'z{}'",
"if",
"definition",
".",
"name",
".",
"startswith",
"(",
"'_'",
")",
"else",
"'a{}'",
"return",
"prefix",
".",
"format",
"(",
"definition",
".",
"n... | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item> | [
"Ensure",
"builtins",
"appear",
"at",
"the",
"bottom",
".",
"Description",
"is",
"of",
"format",
"<type",
">",
":",
"<module",
">",
".",
"<item",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/jedi_completion.py#L95-L102 | train | Sort the text of a node in order to be used in the tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/config/config.py | Config.settings | def settings(self, document_path=None):
"""Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, fou... | python | def settings(self, document_path=None):
"""Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, fou... | [
"def",
"settings",
"(",
"self",
",",
"document_path",
"=",
"None",
")",
":",
"settings",
"=",
"{",
"}",
"sources",
"=",
"self",
".",
"_settings",
".",
"get",
"(",
"'configurationSources'",
",",
"DEFAULT_CONFIG_SOURCES",
")",
"for",
"source_name",
"in",
"reve... | Settings are constructed from a few sources:
1. User settings, found in user's home directory
2. Plugin settings, reported by PyLS plugins
3. LSP settings, given to us from didChangeConfiguration
4. Project settings, found in config files in the current project.
... | [
"Settings",
"are",
"constructed",
"from",
"a",
"few",
"sources",
":"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/config.py#L95-L133 | train | Returns a dictionary containing user and plugin settings and project settings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/config/config.py | Config.update | def update(self, settings):
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins() | python | def update(self, settings):
"""Recursively merge the given settings into the current settings."""
self.settings.cache_clear()
self._settings = settings
log.info("Updated settings to %s", self._settings)
self._update_disabled_plugins() | [
"def",
"update",
"(",
"self",
",",
"settings",
")",
":",
"self",
".",
"settings",
".",
"cache_clear",
"(",
")",
"self",
".",
"_settings",
"=",
"settings",
"log",
".",
"info",
"(",
"\"Updated settings to %s\"",
",",
"self",
".",
"_settings",
")",
"self",
... | Recursively merge the given settings into the current settings. | [
"Recursively",
"merge",
"the",
"given",
"settings",
"into",
"the",
"current",
"settings",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/config.py#L142-L147 | train | Recursively merge the given settings into the current settings. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/workspace.py | Workspace.get_document | def get_document(self, doc_uri):
"""Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177
"""
return self._docs.get(doc_uri) or self._create_document(doc_uri) | python | def get_document(self, doc_uri):
"""Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177
"""
return self._docs.get(doc_uri) or self._create_document(doc_uri) | [
"def",
"get_document",
"(",
"self",
",",
"doc_uri",
")",
":",
"return",
"self",
".",
"_docs",
".",
"get",
"(",
"doc_uri",
")",
"or",
"self",
".",
"_create_document",
"(",
"doc_uri",
")"
] | Return a managed document if-present, else create one pointing at disk.
See https://github.com/Microsoft/language-server-protocol/issues/177 | [
"Return",
"a",
"managed",
"document",
"if",
"-",
"present",
"else",
"create",
"one",
"pointing",
"at",
"disk",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L63-L68 | train | Return a managed document if - present else create one pointing at disk. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/workspace.py | Workspace.source_roots | def source_roots(self, document_path):
"""Return the source roots for the given document."""
files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
return [os.path.dirname(setup_py) for setup_py in files] | python | def source_roots(self, document_path):
"""Return the source roots for the given document."""
files = _utils.find_parents(self._root_path, document_path, ['setup.py']) or []
return [os.path.dirname(setup_py) for setup_py in files] | [
"def",
"source_roots",
"(",
"self",
",",
"document_path",
")",
":",
"files",
"=",
"_utils",
".",
"find_parents",
"(",
"self",
".",
"_root_path",
",",
"document_path",
",",
"[",
"'setup.py'",
"]",
")",
"or",
"[",
"]",
"return",
"[",
"os",
".",
"path",
"... | Return the source roots for the given document. | [
"Return",
"the",
"source",
"roots",
"for",
"the",
"given",
"document",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L89-L92 | train | Return the source roots for the given document. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/workspace.py | Document.apply_change | def apply_change(self, change):
"""Apply a change to the document."""
text = change['text']
change_range = change.get('range')
if not change_range:
# The whole file has changed
self._source = text
return
start_line = change_range['start']['li... | python | def apply_change(self, change):
"""Apply a change to the document."""
text = change['text']
change_range = change.get('range')
if not change_range:
# The whole file has changed
self._source = text
return
start_line = change_range['start']['li... | [
"def",
"apply_change",
"(",
"self",
",",
"change",
")",
":",
"text",
"=",
"change",
"[",
"'text'",
"]",
"change_range",
"=",
"change",
".",
"get",
"(",
"'range'",
")",
"if",
"not",
"change_range",
":",
"# The whole file has changed",
"self",
".",
"_source",
... | Apply a change to the document. | [
"Apply",
"a",
"change",
"to",
"the",
"document",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L134-L175 | train | Apply a change to the document. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/workspace.py | Document.word_at_position | def word_at_position(self, position):
"""Get the word under the cursor returning the start and end positions."""
if position['line'] >= len(self.lines):
return ''
line = self.lines[position['line']]
i = position['character']
# Split word in two
start = line[:... | python | def word_at_position(self, position):
"""Get the word under the cursor returning the start and end positions."""
if position['line'] >= len(self.lines):
return ''
line = self.lines[position['line']]
i = position['character']
# Split word in two
start = line[:... | [
"def",
"word_at_position",
"(",
"self",
",",
"position",
")",
":",
"if",
"position",
"[",
"'line'",
"]",
">=",
"len",
"(",
"self",
".",
"lines",
")",
":",
"return",
"''",
"line",
"=",
"self",
".",
"lines",
"[",
"position",
"[",
"'line'",
"]",
"]",
... | Get the word under the cursor returning the start and end positions. | [
"Get",
"the",
"word",
"under",
"the",
"cursor",
"returning",
"the",
"start",
"and",
"end",
"positions",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/workspace.py#L181-L197 | train | Get the word under the cursor returning the start and end positions. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/_utils.py | debounce | def debounce(interval_s, keyed_by=None):
"""Debounce calls to this function until interval_s seconds have passed."""
def wrapper(func):
timers = {}
lock = threading.Lock()
@functools.wraps(func)
def debounced(*args, **kwargs):
call_args = inspect.getcallargs(func, *a... | python | def debounce(interval_s, keyed_by=None):
"""Debounce calls to this function until interval_s seconds have passed."""
def wrapper(func):
timers = {}
lock = threading.Lock()
@functools.wraps(func)
def debounced(*args, **kwargs):
call_args = inspect.getcallargs(func, *a... | [
"def",
"debounce",
"(",
"interval_s",
",",
"keyed_by",
"=",
"None",
")",
":",
"def",
"wrapper",
"(",
"func",
")",
":",
"timers",
"=",
"{",
"}",
"lock",
"=",
"threading",
".",
"Lock",
"(",
")",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def"... | Debounce calls to this function until interval_s seconds have passed. | [
"Debounce",
"calls",
"to",
"this",
"function",
"until",
"interval_s",
"seconds",
"have",
"passed",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L11-L36 | train | Decorator that can be used to debounce calls to this function until interval_s seconds have passed. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/_utils.py | find_parents | def find_parents(root, path, names):
"""Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
... | python | def find_parents(root, path, names):
"""Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
... | [
"def",
"find_parents",
"(",
"root",
",",
"path",
",",
"names",
")",
":",
"if",
"not",
"root",
":",
"return",
"[",
"]",
"if",
"not",
"os",
".",
"path",
".",
"commonprefix",
"(",
"(",
"root",
",",
"path",
")",
")",
":",
"log",
".",
"warning",
"(",
... | Find files matching the given names relative to the given path.
Args:
path (str): The file path to start searching up from.
names (List[str]): The file/directory names to look for.
root (str): The directory at which to stop recursing upwards.
Note:
The path MUST be within the r... | [
"Find",
"files",
"matching",
"the",
"given",
"names",
"relative",
"to",
"the",
"given",
"path",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L39-L71 | train | Find files matching the given names relative to the given path. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/_utils.py | merge_dicts | def merge_dicts(dict_a, dict_b):
"""Recursively merge dictionary b into dictionary a.
If override_nones is True, then
"""
def _merge_dicts_(a, b):
for key in set(a.keys()).union(b.keys()):
if key in a and key in b:
if isinstance(a[key], dict) and isinstance(b[key], d... | python | def merge_dicts(dict_a, dict_b):
"""Recursively merge dictionary b into dictionary a.
If override_nones is True, then
"""
def _merge_dicts_(a, b):
for key in set(a.keys()).union(b.keys()):
if key in a and key in b:
if isinstance(a[key], dict) and isinstance(b[key], d... | [
"def",
"merge_dicts",
"(",
"dict_a",
",",
"dict_b",
")",
":",
"def",
"_merge_dicts_",
"(",
"a",
",",
"b",
")",
":",
"for",
"key",
"in",
"set",
"(",
"a",
".",
"keys",
"(",
")",
")",
".",
"union",
"(",
"b",
".",
"keys",
"(",
")",
")",
":",
"if"... | Recursively merge dictionary b into dictionary a.
If override_nones is True, then | [
"Recursively",
"merge",
"dictionary",
"b",
"into",
"dictionary",
"a",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L78-L96 | train | Recursively merge dictionary b into dictionary a.
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/_utils.py | format_docstring | def format_docstring(contents):
"""Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation.
"""
contents = contents.replace('\t', u'\u00A0' * 4)
... | python | def format_docstring(contents):
"""Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation.
"""
contents = contents.replace('\t', u'\u00A0' * 4)
... | [
"def",
"format_docstring",
"(",
"contents",
")",
":",
"contents",
"=",
"contents",
".",
"replace",
"(",
"'\\t'",
",",
"u'\\u00A0'",
"*",
"4",
")",
"contents",
"=",
"contents",
".",
"replace",
"(",
"' '",
",",
"u'\\u00A0'",
"*",
"2",
")",
"contents",
"="... | Python doc strings come in a number of formats, but LSP wants markdown.
Until we can find a fast enough way of discovering and parsing each format,
we can do a little better by at least preserving indentation. | [
"Python",
"doc",
"strings",
"come",
"in",
"a",
"number",
"of",
"formats",
"but",
"LSP",
"wants",
"markdown",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/_utils.py#L99-L108 | train | Format a Python docstring into a number of formats. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/uris.py | urlparse | def urlparse(uri):
"""Parse and decode the parts of a URI."""
scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
return (
parse.unquote(scheme),
parse.unquote(netloc),
parse.unquote(path),
parse.unquote(params),
parse.unquote(query),
parse.unq... | python | def urlparse(uri):
"""Parse and decode the parts of a URI."""
scheme, netloc, path, params, query, fragment = parse.urlparse(uri)
return (
parse.unquote(scheme),
parse.unquote(netloc),
parse.unquote(path),
parse.unquote(params),
parse.unquote(query),
parse.unq... | [
"def",
"urlparse",
"(",
"uri",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"parse",
".",
"urlparse",
"(",
"uri",
")",
"return",
"(",
"parse",
".",
"unquote",
"(",
"scheme",
")",
",",
"parse",
"... | Parse and decode the parts of a URI. | [
"Parse",
"and",
"decode",
"the",
"parts",
"of",
"a",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L13-L23 | train | Parse and decode the parts of a URI. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/uris.py | urlunparse | def urlunparse(parts):
"""Unparse and encode parts of a URI."""
scheme, netloc, path, params, query, fragment = parts
# Avoid encoding the windows drive letter colon
if RE_DRIVE_LETTER_PATH.match(path):
quoted_path = path[:3] + parse.quote(path[3:])
else:
quoted_path = parse.quote(p... | python | def urlunparse(parts):
"""Unparse and encode parts of a URI."""
scheme, netloc, path, params, query, fragment = parts
# Avoid encoding the windows drive letter colon
if RE_DRIVE_LETTER_PATH.match(path):
quoted_path = path[:3] + parse.quote(path[3:])
else:
quoted_path = parse.quote(p... | [
"def",
"urlunparse",
"(",
"parts",
")",
":",
"scheme",
",",
"netloc",
",",
"path",
",",
"params",
",",
"query",
",",
"fragment",
"=",
"parts",
"# Avoid encoding the windows drive letter colon",
"if",
"RE_DRIVE_LETTER_PATH",
".",
"match",
"(",
"path",
")",
":",
... | Unparse and encode parts of a URI. | [
"Unparse",
"and",
"encode",
"parts",
"of",
"a",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L26-L43 | train | Unparse and encode parts of a URI. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/uris.py | to_fs_path | def to_fs_path(uri):
"""Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI.
... | python | def to_fs_path(uri):
"""Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI.
... | [
"def",
"to_fs_path",
"(",
"uri",
")",
":",
"# scheme://netloc/path;parameters?query#fragment",
"scheme",
",",
"netloc",
",",
"path",
",",
"_params",
",",
"_query",
",",
"_fragment",
"=",
"urlparse",
"(",
"uri",
")",
"if",
"netloc",
"and",
"path",
"and",
"schem... | Returns the filesystem path of the given URI.
Will handle UNC paths and normalize windows drive letters to lower-case. Also
uses the platform specific path separator. Will *not* validate the path for
invalid characters and semantics. Will *not* look at the scheme of this URI. | [
"Returns",
"the",
"filesystem",
"path",
"of",
"the",
"given",
"URI",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L46-L71 | train | Returns the filesystem path of the given URI. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/uris.py | from_fs_path | def from_fs_path(path):
"""Returns a URI for the given filesystem path."""
scheme = 'file'
params, query, fragment = '', '', ''
path, netloc = _normalize_win_path(path)
return urlunparse((scheme, netloc, path, params, query, fragment)) | python | def from_fs_path(path):
"""Returns a URI for the given filesystem path."""
scheme = 'file'
params, query, fragment = '', '', ''
path, netloc = _normalize_win_path(path)
return urlunparse((scheme, netloc, path, params, query, fragment)) | [
"def",
"from_fs_path",
"(",
"path",
")",
":",
"scheme",
"=",
"'file'",
"params",
",",
"query",
",",
"fragment",
"=",
"''",
",",
"''",
",",
"''",
"path",
",",
"netloc",
"=",
"_normalize_win_path",
"(",
"path",
")",
"return",
"urlunparse",
"(",
"(",
"sch... | Returns a URI for the given filesystem path. | [
"Returns",
"a",
"URI",
"for",
"the",
"given",
"filesystem",
"path",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L74-L79 | train | Returns a URI for the given filesystem path. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/uris.py | uri_with | def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
"""Return a URI with the given part(s) replaced.
Parts are decoded / encoded.
"""
old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
path, _netloc = _normalize_win_path... | python | def uri_with(uri, scheme=None, netloc=None, path=None, params=None, query=None, fragment=None):
"""Return a URI with the given part(s) replaced.
Parts are decoded / encoded.
"""
old_scheme, old_netloc, old_path, old_params, old_query, old_fragment = urlparse(uri)
path, _netloc = _normalize_win_path... | [
"def",
"uri_with",
"(",
"uri",
",",
"scheme",
"=",
"None",
",",
"netloc",
"=",
"None",
",",
"path",
"=",
"None",
",",
"params",
"=",
"None",
",",
"query",
"=",
"None",
",",
"fragment",
"=",
"None",
")",
":",
"old_scheme",
",",
"old_netloc",
",",
"o... | Return a URI with the given part(s) replaced.
Parts are decoded / encoded. | [
"Return",
"a",
"URI",
"with",
"the",
"given",
"part",
"(",
"s",
")",
"replaced",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/uris.py#L82-L96 | train | Return a new URI with the given part(s ) replaced. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/plugins/pyflakes_lint.py | PyflakesDiagnosticReport.flake | def flake(self, message):
""" Get message like <filename>:<lineno>: <msg> """
err_range = {
'start': {'line': message.lineno - 1, 'character': message.col},
'end': {'line': message.lineno - 1, 'character': len(self.lines[message.lineno - 1])},
}
severity = lsp.Di... | python | def flake(self, message):
""" Get message like <filename>:<lineno>: <msg> """
err_range = {
'start': {'line': message.lineno - 1, 'character': message.col},
'end': {'line': message.lineno - 1, 'character': len(self.lines[message.lineno - 1])},
}
severity = lsp.Di... | [
"def",
"flake",
"(",
"self",
",",
"message",
")",
":",
"err_range",
"=",
"{",
"'start'",
":",
"{",
"'line'",
":",
"message",
".",
"lineno",
"-",
"1",
",",
"'character'",
":",
"message",
".",
"col",
"}",
",",
"'end'",
":",
"{",
"'line'",
":",
"messa... | Get message like <filename>:<lineno>: <msg> | [
"Get",
"message",
"like",
"<filename",
">",
":",
"<lineno",
">",
":",
"<msg",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/pyflakes_lint.py#L62-L80 | train | Add a new error to the list of diagnostics. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/python_ls.py | PythonLanguageServer._hook | def _hook(self, hook_name, doc_uri=None, **kwargs):
"""Calls hook_name and returns a list of results from all registered handlers"""
doc = self.workspace.get_document(doc_uri) if doc_uri else None
hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugi... | python | def _hook(self, hook_name, doc_uri=None, **kwargs):
"""Calls hook_name and returns a list of results from all registered handlers"""
doc = self.workspace.get_document(doc_uri) if doc_uri else None
hook_handlers = self.config.plugin_manager.subset_hook_caller(hook_name, self.config.disabled_plugi... | [
"def",
"_hook",
"(",
"self",
",",
"hook_name",
",",
"doc_uri",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"doc",
"=",
"self",
".",
"workspace",
".",
"get_document",
"(",
"doc_uri",
")",
"if",
"doc_uri",
"else",
"None",
"hook_handlers",
"=",
"self"... | Calls hook_name and returns a list of results from all registered handlers | [
"Calls",
"hook_name",
"and",
"returns",
"a",
"list",
"of",
"results",
"from",
"all",
"registered",
"handlers"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/python_ls.py#L118-L122 | train | Calls hook_name and returns a list of results from all registered handlers | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/plugins/rope_completion.py | _sort_text | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
if definition.name.startswith("_"):
# It's a 'hidden' func, put it next last
return 'z' + definition.name
elif definition.scope == 'builtin':
return 'y' ... | python | def _sort_text(definition):
""" Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item>
"""
if definition.name.startswith("_"):
# It's a 'hidden' func, put it next last
return 'z' + definition.name
elif definition.scope == 'builtin':
return 'y' ... | [
"def",
"_sort_text",
"(",
"definition",
")",
":",
"if",
"definition",
".",
"name",
".",
"startswith",
"(",
"\"_\"",
")",
":",
"# It's a 'hidden' func, put it next last",
"return",
"'z'",
"+",
"definition",
".",
"name",
"elif",
"definition",
".",
"scope",
"==",
... | Ensure builtins appear at the bottom.
Description is of format <type>: <module>.<item> | [
"Ensure",
"builtins",
"appear",
"at",
"the",
"bottom",
".",
"Description",
"is",
"of",
"format",
"<type",
">",
":",
"<module",
">",
".",
"<item",
">"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/rope_completion.py#L58-L69 | train | Sort the text of a resource in order to be used in the tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/plugins/rope_completion.py | _kind | def _kind(d):
""" Return the VSCode type """
MAP = {
'none': lsp.CompletionItemKind.Value,
'type': lsp.CompletionItemKind.Class,
'tuple': lsp.CompletionItemKind.Class,
'dict': lsp.CompletionItemKind.Class,
'dictionary': lsp.CompletionItemKind.Class,
'function': ls... | python | def _kind(d):
""" Return the VSCode type """
MAP = {
'none': lsp.CompletionItemKind.Value,
'type': lsp.CompletionItemKind.Class,
'tuple': lsp.CompletionItemKind.Class,
'dict': lsp.CompletionItemKind.Class,
'dictionary': lsp.CompletionItemKind.Class,
'function': ls... | [
"def",
"_kind",
"(",
"d",
")",
":",
"MAP",
"=",
"{",
"'none'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Value",
",",
"'type'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Class",
",",
"'tuple'",
":",
"lsp",
".",
"CompletionItemKind",
".",
"Class",
... | Return the VSCode type | [
"Return",
"the",
"VSCode",
"type"
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/plugins/rope_completion.py#L72-L107 | train | Return the VSCode type of the given object | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/config/source.py | _get_opt | def _get_opt(config, key, option, opt_type):
"""Get an option from a configparser with the given type."""
for opt_key in [option, option.replace('-', '_')]:
if not config.has_option(key, opt_key):
continue
if opt_type == bool:
return config.getbool(key, opt_key)
... | python | def _get_opt(config, key, option, opt_type):
"""Get an option from a configparser with the given type."""
for opt_key in [option, option.replace('-', '_')]:
if not config.has_option(key, opt_key):
continue
if opt_type == bool:
return config.getbool(key, opt_key)
... | [
"def",
"_get_opt",
"(",
"config",
",",
"key",
",",
"option",
",",
"opt_type",
")",
":",
"for",
"opt_key",
"in",
"[",
"option",
",",
"option",
".",
"replace",
"(",
"'-'",
",",
"'_'",
")",
"]",
":",
"if",
"not",
"config",
".",
"has_option",
"(",
"key... | Get an option from a configparser with the given type. | [
"Get",
"an",
"option",
"from",
"a",
"configparser",
"with",
"the",
"given",
"type",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L48-L66 | train | Get an option from a configparser with the given type. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/config/source.py | _set_opt | def _set_opt(config_dict, path, value):
"""Set the value in the dictionary at the given path if the value is not None."""
if value is None:
return
if '.' not in path:
config_dict[path] = value
return
key, rest = path.split(".", 1)
if key not in config_dict:
config_d... | python | def _set_opt(config_dict, path, value):
"""Set the value in the dictionary at the given path if the value is not None."""
if value is None:
return
if '.' not in path:
config_dict[path] = value
return
key, rest = path.split(".", 1)
if key not in config_dict:
config_d... | [
"def",
"_set_opt",
"(",
"config_dict",
",",
"path",
",",
"value",
")",
":",
"if",
"value",
"is",
"None",
":",
"return",
"if",
"'.'",
"not",
"in",
"path",
":",
"config_dict",
"[",
"path",
"]",
"=",
"value",
"return",
"key",
",",
"rest",
"=",
"path",
... | Set the value in the dictionary at the given path if the value is not None. | [
"Set",
"the",
"value",
"in",
"the",
"dictionary",
"at",
"the",
"given",
"path",
"if",
"the",
"value",
"is",
"not",
"None",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L73-L86 | train | Set the value in the dictionary at the given path. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/config/source.py | ConfigSource.parse_config | def parse_config(config, key, options):
"""Parse the config with the given options."""
conf = {}
for source, destination, opt_type in options:
opt_value = _get_opt(config, key, source, opt_type)
if opt_value is not None:
_set_opt(conf, destination, opt_val... | python | def parse_config(config, key, options):
"""Parse the config with the given options."""
conf = {}
for source, destination, opt_type in options:
opt_value = _get_opt(config, key, source, opt_type)
if opt_value is not None:
_set_opt(conf, destination, opt_val... | [
"def",
"parse_config",
"(",
"config",
",",
"key",
",",
"options",
")",
":",
"conf",
"=",
"{",
"}",
"for",
"source",
",",
"destination",
",",
"opt_type",
"in",
"options",
":",
"opt_value",
"=",
"_get_opt",
"(",
"config",
",",
"key",
",",
"source",
",",
... | Parse the config with the given options. | [
"Parse",
"the",
"config",
"with",
"the",
"given",
"options",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/config/source.py#L38-L45 | train | Parse the config with the given options. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
palantir/python-language-server | pyls/__main__.py | _binary_stdio | def _binary_stdio():
"""Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
"""
PY3K = sys.version_info >= (3, 0)
if PY3K:
# pylint: disable=no-... | python | def _binary_stdio():
"""Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin
"""
PY3K = sys.version_info >= (3, 0)
if PY3K:
# pylint: disable=no-... | [
"def",
"_binary_stdio",
"(",
")",
":",
"PY3K",
"=",
"sys",
".",
"version_info",
">=",
"(",
"3",
",",
"0",
")",
"if",
"PY3K",
":",
"# pylint: disable=no-member",
"stdin",
",",
"stdout",
"=",
"sys",
".",
"stdin",
".",
"buffer",
",",
"sys",
".",
"stdout",... | Construct binary stdio streams (not text mode).
This seems to be different for Window/Unix Python2/3, so going by:
https://stackoverflow.com/questions/2850893/reading-binary-data-from-stdin | [
"Construct",
"binary",
"stdio",
"streams",
"(",
"not",
"text",
"mode",
")",
"."
] | 96e08d85635382d17024c352306c4759f124195d | https://github.com/palantir/python-language-server/blob/96e08d85635382d17024c352306c4759f124195d/pyls/__main__.py#L64-L87 | train | Construct binary stdio streams. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/examples/interactive.py | Interactive.run | def run(self):
"""
Run the interactive window until the user quits
"""
# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet
# and also involves inverting your code to run inside the pyglet framework
# avoid... | python | def run(self):
"""
Run the interactive window until the user quits
"""
# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet
# and also involves inverting your code to run inside the pyglet framework
# avoid... | [
"def",
"run",
"(",
"self",
")",
":",
"# pyglet.app.run() has issues like https://bitbucket.org/pyglet/pyglet/issues/199/attempting-to-resize-or-close-pyglet",
"# and also involves inverting your code to run inside the pyglet framework",
"# avoid both by using a while loop",
"prev_frame_time",
"=... | Run the interactive window until the user quits | [
"Run",
"the",
"interactive",
"window",
"until",
"the",
"user",
"quits"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/interactive.py#L179-L194 | train | Run the interactive window until the user quits
AttributeNames | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/data/__init__.py | get_file_path | def get_file_path(game, file, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's directory
"""
base = path()
for t in inttype.paths:
possible_path = os.path.join(base, t, game, file)
if os.path.exists(possible_path):
return possible_path
return None | python | def get_file_path(game, file, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's directory
"""
base = path()
for t in inttype.paths:
possible_path = os.path.join(base, t, game, file)
if os.path.exists(possible_path):
return possible_path
return None | [
"def",
"get_file_path",
"(",
"game",
",",
"file",
",",
"inttype",
"=",
"Integrations",
".",
"DEFAULT",
")",
":",
"base",
"=",
"path",
"(",
")",
"for",
"t",
"in",
"inttype",
".",
"paths",
":",
"possible_path",
"=",
"os",
".",
"path",
".",
"join",
"(",... | Return the path to a given game's directory | [
"Return",
"the",
"path",
"to",
"a",
"given",
"game",
"s",
"directory"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/data/__init__.py#L266-L276 | train | Return the path to a given game s directory | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/data/__init__.py | get_romfile_path | def get_romfile_path(game, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's romfile
"""
for extension in EMU_EXTENSIONS.keys():
possible_path = get_file_path(game, "rom" + extension, inttype)
if possible_path:
return possible_path
raise FileNotFoundEr... | python | def get_romfile_path(game, inttype=Integrations.DEFAULT):
"""
Return the path to a given game's romfile
"""
for extension in EMU_EXTENSIONS.keys():
possible_path = get_file_path(game, "rom" + extension, inttype)
if possible_path:
return possible_path
raise FileNotFoundEr... | [
"def",
"get_romfile_path",
"(",
"game",
",",
"inttype",
"=",
"Integrations",
".",
"DEFAULT",
")",
":",
"for",
"extension",
"in",
"EMU_EXTENSIONS",
".",
"keys",
"(",
")",
":",
"possible_path",
"=",
"get_file_path",
"(",
"game",
",",
"\"rom\"",
"+",
"extension... | Return the path to a given game's romfile | [
"Return",
"the",
"path",
"to",
"a",
"given",
"game",
"s",
"romfile"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/data/__init__.py#L279-L288 | train | Return the path to a given game s romfile | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/__init__.py | make | def make(game, state=State.DEFAULT, inttype=retro.data.Integrations.DEFAULT, **kwargs):
"""
Create a Gym environment for the specified game
"""
try:
retro.data.get_romfile_path(game, inttype)
except FileNotFoundError:
if not retro.data.get_file_path(game, "rom.sha", inttype):
... | python | def make(game, state=State.DEFAULT, inttype=retro.data.Integrations.DEFAULT, **kwargs):
"""
Create a Gym environment for the specified game
"""
try:
retro.data.get_romfile_path(game, inttype)
except FileNotFoundError:
if not retro.data.get_file_path(game, "rom.sha", inttype):
... | [
"def",
"make",
"(",
"game",
",",
"state",
"=",
"State",
".",
"DEFAULT",
",",
"inttype",
"=",
"retro",
".",
"data",
".",
"Integrations",
".",
"DEFAULT",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"retro",
".",
"data",
".",
"get_romfile_path",
"(",... | Create a Gym environment for the specified game | [
"Create",
"a",
"Gym",
"environment",
"for",
"the",
"specified",
"game"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/__init__.py#L44-L55 | train | Create a Gym environment for the specified game | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/examples/brute.py | select_actions | def select_actions(root, action_space, max_episode_steps):
"""
Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
curr... | python | def select_actions(root, action_space, max_episode_steps):
"""
Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
curr... | [
"def",
"select_actions",
"(",
"root",
",",
"action_space",
",",
"max_episode_steps",
")",
":",
"node",
"=",
"root",
"acts",
"=",
"[",
"]",
"steps",
"=",
"0",
"while",
"steps",
"<",
"max_episode_steps",
":",
"if",
"node",
"is",
"None",
":",
"# we've fallen ... | Select actions from the tree
Normally we select the greedy action that has the highest reward
associated with that subtree. We have a small chance to select a
random action based on the exploration param and visit count of the
current node at each step.
We select actions for the longest possible ... | [
"Select",
"actions",
"from",
"the",
"tree"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L76-L124 | train | Select actions from the tree. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/examples/brute.py | rollout | def rollout(env, acts):
"""
Perform a rollout using a preset collection of actions
"""
total_rew = 0
env.reset()
steps = 0
for act in acts:
_obs, rew, done, _info = env.step(act)
steps += 1
total_rew += rew
if done:
break
return steps, total_r... | python | def rollout(env, acts):
"""
Perform a rollout using a preset collection of actions
"""
total_rew = 0
env.reset()
steps = 0
for act in acts:
_obs, rew, done, _info = env.step(act)
steps += 1
total_rew += rew
if done:
break
return steps, total_r... | [
"def",
"rollout",
"(",
"env",
",",
"acts",
")",
":",
"total_rew",
"=",
"0",
"env",
".",
"reset",
"(",
")",
"steps",
"=",
"0",
"for",
"act",
"in",
"acts",
":",
"_obs",
",",
"rew",
",",
"done",
",",
"_info",
"=",
"env",
".",
"step",
"(",
"act",
... | Perform a rollout using a preset collection of actions | [
"Perform",
"a",
"rollout",
"using",
"a",
"preset",
"collection",
"of",
"actions"
] | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L127-L141 | train | Perform a rollout using a preset collection of actions
| Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
openai/retro | retro/examples/brute.py | update_tree | def update_tree(root, executed_acts, total_rew):
"""
Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward.
"""
root.value = max(total_rew, root.value)
root.visit... | python | def update_tree(root, executed_acts, total_rew):
"""
Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward.
"""
root.value = max(total_rew, root.value)
root.visit... | [
"def",
"update_tree",
"(",
"root",
",",
"executed_acts",
",",
"total_rew",
")",
":",
"root",
".",
"value",
"=",
"max",
"(",
"total_rew",
",",
"root",
".",
"value",
")",
"root",
".",
"visits",
"+=",
"1",
"new_nodes",
"=",
"0",
"node",
"=",
"root",
"fo... | Given the tree, a list of actions that were executed before the game ended, and a reward, update the tree
so that the path formed by the executed actions are all updated to the new reward. | [
"Given",
"the",
"tree",
"a",
"list",
"of",
"actions",
"that",
"were",
"executed",
"before",
"the",
"game",
"ended",
"and",
"a",
"reward",
"update",
"the",
"tree",
"so",
"that",
"the",
"path",
"formed",
"by",
"the",
"executed",
"actions",
"are",
"all",
"u... | 29dc84fef6d7076fd11a3847d2877fe59e705d36 | https://github.com/openai/retro/blob/29dc84fef6d7076fd11a3847d2877fe59e705d36/retro/examples/brute.py#L144-L162 | train | Given the tree root and a list of actions that were executed before the game ended and a reward update the tree with the new value. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_authorization_url | def get_authorization_url(self,
signin_with_twitter=False,
access_type=None):
"""Get the authorization URL to redirect the user"""
try:
if signin_with_twitter:
url = self._get_oauth_url('authenticate')
... | python | def get_authorization_url(self,
signin_with_twitter=False,
access_type=None):
"""Get the authorization URL to redirect the user"""
try:
if signin_with_twitter:
url = self._get_oauth_url('authenticate')
... | [
"def",
"get_authorization_url",
"(",
"self",
",",
"signin_with_twitter",
"=",
"False",
",",
"access_type",
"=",
"None",
")",
":",
"try",
":",
"if",
"signin_with_twitter",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'authenticate'",
")",
"if",
"access... | Get the authorization URL to redirect the user | [
"Get",
"the",
"authorization",
"URL",
"to",
"redirect",
"the",
"user"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L75-L89 | train | Get the authorization URL to redirect the user to | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_access_token | def get_access_token(self, verifier=None):
"""
After user has authorized the request token, get access token
with user supplied verifier.
"""
try:
url = self._get_oauth_url('access_token')
self.oauth = OAuth1Session(self.consumer_key,
... | python | def get_access_token(self, verifier=None):
"""
After user has authorized the request token, get access token
with user supplied verifier.
"""
try:
url = self._get_oauth_url('access_token')
self.oauth = OAuth1Session(self.consumer_key,
... | [
"def",
"get_access_token",
"(",
"self",
",",
"verifier",
"=",
"None",
")",
":",
"try",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'access_token'",
")",
"self",
".",
"oauth",
"=",
"OAuth1Session",
"(",
"self",
".",
"consumer_key",
",",
"client_se... | After user has authorized the request token, get access token
with user supplied verifier. | [
"After",
"user",
"has",
"authorized",
"the",
"request",
"token",
"get",
"access",
"token",
"with",
"user",
"supplied",
"verifier",
"."
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L91-L108 | train | Get the access token and secret for the current user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/auth.py | OAuthHandler.get_xauth_access_token | def get_xauth_access_token(self, username, password):
"""
Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth fo... | python | def get_xauth_access_token(self, username, password):
"""
Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth fo... | [
"def",
"get_xauth_access_token",
"(",
"self",
",",
"username",
",",
"password",
")",
":",
"try",
":",
"url",
"=",
"self",
".",
"_get_oauth_url",
"(",
"'access_token'",
")",
"oauth",
"=",
"OAuth1",
"(",
"self",
".",
"consumer_key",
",",
"client_secret",
"=",
... | Get an access token from an username and password combination.
In order to get this working you need to create an app at
http://twitter.com/apps, after that send a mail to api@twitter.com
and request activation of xAuth for it. | [
"Get",
"an",
"access",
"token",
"from",
"an",
"username",
"and",
"password",
"combination",
".",
"In",
"order",
"to",
"get",
"this",
"working",
"you",
"need",
"to",
"create",
"an",
"app",
"at",
"http",
":",
"//",
"twitter",
".",
"com",
"/",
"apps",
"af... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/auth.py#L110-L130 | train | Get an access token from an username and password combination. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | MemCacheCache.store | def store(self, key, value):
"""Add new record to cache
key: entry key
value: data of entry
"""
self.client.set(key, value, time=self.timeout) | python | def store(self, key, value):
"""Add new record to cache
key: entry key
value: data of entry
"""
self.client.set(key, value, time=self.timeout) | [
"def",
"store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"self",
".",
"client",
".",
"set",
"(",
"key",
",",
"value",
",",
"time",
"=",
"self",
".",
"timeout",
")"
] | Add new record to cache
key: entry key
value: data of entry | [
"Add",
"new",
"record",
"to",
"cache",
"key",
":",
"entry",
"key",
"value",
":",
"data",
"of",
"entry"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L282-L287 | train | Store a new record in the cache. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | RedisCache.store | def store(self, key, value):
"""Store the key, value pair in our redis server"""
# Prepend tweepy to our key,
# this makes it easier to identify tweepy keys in our redis server
key = self.pre_identifier + key
# Get a pipe (to execute several redis commands in one step)
pi... | python | def store(self, key, value):
"""Store the key, value pair in our redis server"""
# Prepend tweepy to our key,
# this makes it easier to identify tweepy keys in our redis server
key = self.pre_identifier + key
# Get a pipe (to execute several redis commands in one step)
pi... | [
"def",
"store",
"(",
"self",
",",
"key",
",",
"value",
")",
":",
"# Prepend tweepy to our key,",
"# this makes it easier to identify tweepy keys in our redis server",
"key",
"=",
"self",
".",
"pre_identifier",
"+",
"key",
"# Get a pipe (to execute several redis commands in one ... | Store the key, value pair in our redis server | [
"Store",
"the",
"key",
"value",
"pair",
"in",
"our",
"redis",
"server"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L326-L340 | train | Store the key value pair in our redis server | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | RedisCache.get | def get(self, key, timeout=None):
"""Given a key, returns an element from the redis table"""
key = self.pre_identifier + key
# Check to see if we have this key
unpickled_entry = self.client.get(key)
if not unpickled_entry:
# No hit, return nothing
return N... | python | def get(self, key, timeout=None):
"""Given a key, returns an element from the redis table"""
key = self.pre_identifier + key
# Check to see if we have this key
unpickled_entry = self.client.get(key)
if not unpickled_entry:
# No hit, return nothing
return N... | [
"def",
"get",
"(",
"self",
",",
"key",
",",
"timeout",
"=",
"None",
")",
":",
"key",
"=",
"self",
".",
"pre_identifier",
"+",
"key",
"# Check to see if we have this key",
"unpickled_entry",
"=",
"self",
".",
"client",
".",
"get",
"(",
"key",
")",
"if",
"... | Given a key, returns an element from the redis table | [
"Given",
"a",
"key",
"returns",
"an",
"element",
"from",
"the",
"redis",
"table"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L342-L363 | train | Given a key returns an element from the redis table | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | RedisCache.delete_entry | def delete_entry(self, key):
"""Delete an object from the redis table"""
pipe = self.client.pipeline()
pipe.srem(self.keys_container, key)
pipe.delete(key)
pipe.execute() | python | def delete_entry(self, key):
"""Delete an object from the redis table"""
pipe = self.client.pipeline()
pipe.srem(self.keys_container, key)
pipe.delete(key)
pipe.execute() | [
"def",
"delete_entry",
"(",
"self",
",",
"key",
")",
":",
"pipe",
"=",
"self",
".",
"client",
".",
"pipeline",
"(",
")",
"pipe",
".",
"srem",
"(",
"self",
".",
"keys_container",
",",
"key",
")",
"pipe",
".",
"delete",
"(",
"key",
")",
"pipe",
".",
... | Delete an object from the redis table | [
"Delete",
"an",
"object",
"from",
"the",
"redis",
"table"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L371-L376 | train | Delete an object from the redis table | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | RedisCache.cleanup | def cleanup(self):
"""Cleanup all the expired keys"""
keys = self.client.smembers(self.keys_container)
for key in keys:
entry = self.client.get(key)
if entry:
entry = pickle.loads(entry)
if self._is_expired(entry, self.timeout):
... | python | def cleanup(self):
"""Cleanup all the expired keys"""
keys = self.client.smembers(self.keys_container)
for key in keys:
entry = self.client.get(key)
if entry:
entry = pickle.loads(entry)
if self._is_expired(entry, self.timeout):
... | [
"def",
"cleanup",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"client",
".",
"smembers",
"(",
"self",
".",
"keys_container",
")",
"for",
"key",
"in",
"keys",
":",
"entry",
"=",
"self",
".",
"client",
".",
"get",
"(",
"key",
")",
"if",
"entry",... | Cleanup all the expired keys | [
"Cleanup",
"all",
"the",
"expired",
"keys"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L378-L386 | train | Cleanup all the expired keys | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/cache.py | RedisCache.flush | def flush(self):
"""Delete all entries from the cache"""
keys = self.client.smembers(self.keys_container)
for key in keys:
self.delete_entry(key) | python | def flush(self):
"""Delete all entries from the cache"""
keys = self.client.smembers(self.keys_container)
for key in keys:
self.delete_entry(key) | [
"def",
"flush",
"(",
"self",
")",
":",
"keys",
"=",
"self",
".",
"client",
".",
"smembers",
"(",
"self",
".",
"keys_container",
")",
"for",
"key",
"in",
"keys",
":",
"self",
".",
"delete_entry",
"(",
"key",
")"
] | Delete all entries from the cache | [
"Delete",
"all",
"entries",
"from",
"the",
"cache"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/cache.py#L388-L392 | train | Delete all entries from the cache | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.related_results | def related_results(self):
""" :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/related_results/show/{id}.json',
payload_type='relation', payload_list=Tr... | python | def related_results(self):
""" :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/related_results/show/{id}.json',
payload_type='relation', payload_list=Tr... | [
"def",
"related_results",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/related_results/show/{id}.json'",
",",
"payload_type",
"=",
"'relation'",
",",
"payload_list",
"=",
"True",
",",
"allowed_param",
"=",
"[",
"'i... | :reference: https://dev.twitter.com/docs/api/1.1/get/related_results/show/%3id.format
:allowed_param:'id' | [
":",
"reference",
":",
"https",
":",
"//",
"dev",
".",
"twitter",
".",
"com",
"/",
"docs",
"/",
"api",
"/",
"1",
".",
"1",
"/",
"get",
"/",
"related_results",
"/",
"show",
"/",
"%3id",
".",
"format",
":",
"allowed_param",
":",
"id"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L142-L152 | train | bind to twitter api | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.media_upload | def media_upload(self, filename, *args, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param:
"""
f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 4883, form_field='media'... | python | def media_upload(self, filename, *args, **kwargs):
""" :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param:
"""
f = kwargs.pop('file', None)
headers, post_data = API._pack_image(filename, 4883, form_field='media'... | [
"def",
"media_upload",
"(",
"self",
",",
"filename",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"f",
"=",
"kwargs",
".",
"pop",
"(",
"'file'",
",",
"None",
")",
"headers",
",",
"post_data",
"=",
"API",
".",
"_pack_image",
"(",
"filename",
... | :reference: https://developer.twitter.com/en/docs/media/upload-media/api-reference/post-media-upload
:allowed_param: | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"media",
"/",
"upload",
"-",
"media",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"media",
"-",
"upload",
":",
"allowed_param",
":"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L197-L213 | train | Upload a media file to the user s twitter account. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.destroy_status | def destroy_status(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/statuses/destroy/{id}.json',
method='POST',
... | python | def destroy_status(self):
""" :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id'
"""
return bind_api(
api=self,
path='/statuses/destroy/{id}.json',
method='POST',
... | [
"def",
"destroy_status",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/statuses/destroy/{id}.json'",
",",
"method",
"=",
"'POST'",
",",
"payload_type",
"=",
"'status'",
",",
"allowed_param",
"=",
"[",
"'id'",
"]",... | :reference: https://developer.twitter.com/en/docs/tweets/post-and-engage/api-reference/post-statuses-destroy-id
:allowed_param:'id' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"tweets",
"/",
"post",
"-",
"and",
"-",
"engage",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"statuses",
"-",
"destroy",
"-",
"id"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L236-L247 | train | destroy a status from a specific post | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.lookup_users | def lookup_users(self, user_ids=None, screen_names=None, include_entities=None, tweet_mode=None):
""" Perform bulk look up of users from user ID or screen_name """
post_data = {}
if include_entities is not None:
include_entities = 'true' if include_entities else 'false'
p... | python | def lookup_users(self, user_ids=None, screen_names=None, include_entities=None, tweet_mode=None):
""" Perform bulk look up of users from user ID or screen_name """
post_data = {}
if include_entities is not None:
include_entities = 'true' if include_entities else 'false'
p... | [
"def",
"lookup_users",
"(",
"self",
",",
"user_ids",
"=",
"None",
",",
"screen_names",
"=",
"None",
",",
"include_entities",
"=",
"None",
",",
"tweet_mode",
"=",
"None",
")",
":",
"post_data",
"=",
"{",
"}",
"if",
"include_entities",
"is",
"not",
"None",
... | Perform bulk look up of users from user ID or screen_name | [
"Perform",
"bulk",
"look",
"up",
"of",
"users",
"from",
"user",
"ID",
"or",
"screen_name"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L326-L339 | train | Perform bulk lookup of users from user ID or screen name | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API._lookup_users | def _lookup_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode'
"""
return bind_api(
api=self,
pat... | python | def _lookup_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode'
"""
return bind_api(
api=self,
pat... | [
"def",
"_lookup_users",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/users/lookup.json'",
",",
"payload_type",
"=",
"'user'",
",",
"payload_list",
"=",
"True",
",",
"method",
"=",
"'POST'",
",",
"allowed_param",
... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-lookup
allowed_param='user_id', 'screen_name', 'include_entities', 'tweet_mode' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"follow",
"-",
"search",
"-",
"get",
"-",
"users",
"/",
"api",
"-",
"reference",
"/",
"get",... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L342-L352 | train | Lookup users by their ID. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.search_users | def search_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page'
"""
return bind_api(
api=self,
path='/users/search.json',
pa... | python | def search_users(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page'
"""
return bind_api(
api=self,
path='/users/search.json',
pa... | [
"def",
"search_users",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/users/search.json'",
",",
"payload_type",
"=",
"'user'",
",",
"payload_list",
"=",
"True",
",",
"require_auth",
"=",
"True",
",",
"allowed_param... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/follow-search-get-users/api-reference/get-users-search
:allowed_param:'q', 'count', 'page' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"follow",
"-",
"search",
"-",
"get",
"-",
"users",
"/",
"api",
"-",
"reference",
"/",
"get",... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L359-L369 | train | Search for users in the user list. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.get_direct_message | def get_direct_message(self):
""" :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text'
"""
return bind_api(
api=self,
path='/direct_messages/show/{id}.json',
... | python | def get_direct_message(self):
""" :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text'
"""
return bind_api(
api=self,
path='/direct_messages/show/{id}.json',
... | [
"def",
"get_direct_message",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/direct_messages/show/{id}.json'",
",",
"payload_type",
"=",
"'direct_message'",
",",
"allowed_param",
"=",
"[",
"'id'",
",",
"'full_text'",
"]... | :reference: https://developer.twitter.com/en/docs/direct-messages/sending-and-receiving/api-reference/get-message
:allowed_param:'id', 'full_text' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"direct",
"-",
"messages",
"/",
"sending",
"-",
"and",
"-",
"receiving",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"message",
":",
... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L424-L434 | train | Get a direct message from the user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.lookup_friendships | def lookup_friendships(self, user_ids=None, screen_names=None):
""" Perform bulk look up of friendships from user ID or screenname """
return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names)) | python | def lookup_friendships(self, user_ids=None, screen_names=None):
""" Perform bulk look up of friendships from user ID or screenname """
return self._lookup_friendships(list_to_csv(user_ids), list_to_csv(screen_names)) | [
"def",
"lookup_friendships",
"(",
"self",
",",
"user_ids",
"=",
"None",
",",
"screen_names",
"=",
"None",
")",
":",
"return",
"self",
".",
"_lookup_friendships",
"(",
"list_to_csv",
"(",
"user_ids",
")",
",",
"list_to_csv",
"(",
"screen_names",
")",
")"
] | Perform bulk look up of friendships from user ID or screenname | [
"Perform",
"bulk",
"look",
"up",
"of",
"friendships",
"from",
"user",
"ID",
"or",
"screenname"
] | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L518-L520 | train | Perform bulk lookup of friendships from user ID or screenname | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.set_settings | def set_settings(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_... | python | def set_settings(self):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_... | [
"def",
"set_settings",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/account/settings.json'",
",",
"method",
"=",
"'POST'",
",",
"payload_type",
"=",
"'json'",
",",
"allowed_param",
"=",
"[",
"'sleep_time_enabled'",... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-settings
:allowed_param:'sleep_time_enabled', 'start_sleep_time',
'end_sleep_time', 'time_zone', 'trend_location_woeid',
'allow_contributor_request', 'lang' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L619-L635 | train | Set settings for the current user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.verify_credentials | def verify_credentials(self, **kargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email'
"""
try:
return bind_api(... | python | def verify_credentials(self, **kargs):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email'
"""
try:
return bind_api(... | [
"def",
"verify_credentials",
"(",
"self",
",",
"*",
"*",
"kargs",
")",
":",
"try",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/account/verify_credentials.json'",
",",
"payload_type",
"=",
"'user'",
",",
"require_auth",
"=",
"True... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/get-account-verify_credentials
:allowed_param:'include_entities', 'skip_status', 'include_email' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"a... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L637-L652 | train | Verify credentials for a user. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.rate_limit_status | def rate_limit_status(self):
""" :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources'
"""
return bind_api(
api=self,
path='/application/rate_limit_sta... | python | def rate_limit_status(self):
""" :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources'
"""
return bind_api(
api=self,
path='/application/rate_limit_sta... | [
"def",
"rate_limit_status",
"(",
"self",
")",
":",
"return",
"bind_api",
"(",
"api",
"=",
"self",
",",
"path",
"=",
"'/application/rate_limit_status.json'",
",",
"payload_type",
"=",
"'json'",
",",
"allowed_param",
"=",
"[",
"'resources'",
"]",
",",
"use_cache",... | :reference: https://developer.twitter.com/en/docs/developer-utilities/rate-limit-status/api-reference/get-application-rate_limit_status
:allowed_param:'resources' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"developer",
"-",
"utilities",
"/",
"rate",
"-",
"limit",
"-",
"status",
"/",
"api",
"-",
"reference",
"/",
"get",
"-",
"application",
"-... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L655-L665 | train | Get the status of the application rate limit. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
tweepy/tweepy | tweepy/api.py | API.update_profile_image | def update_profile_image(self, filename, file_=None):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status'
"""
headers, post_data = API._pack_i... | python | def update_profile_image(self, filename, file_=None):
""" :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status'
"""
headers, post_data = API._pack_i... | [
"def",
"update_profile_image",
"(",
"self",
",",
"filename",
",",
"file_",
"=",
"None",
")",
":",
"headers",
",",
"post_data",
"=",
"API",
".",
"_pack_image",
"(",
"filename",
",",
"700",
",",
"f",
"=",
"file_",
")",
"return",
"bind_api",
"(",
"api",
"... | :reference: https://developer.twitter.com/en/docs/accounts-and-users/manage-account-settings/api-reference/post-account-update_profile_image
:allowed_param:'include_entities', 'skip_status' | [
":",
"reference",
":",
"https",
":",
"//",
"developer",
".",
"twitter",
".",
"com",
"/",
"en",
"/",
"docs",
"/",
"accounts",
"-",
"and",
"-",
"users",
"/",
"manage",
"-",
"account",
"-",
"settings",
"/",
"api",
"-",
"reference",
"/",
"post",
"-",
"... | cc3894073905811c4d9fd816202f93454ed932da | https://github.com/tweepy/tweepy/blob/cc3894073905811c4d9fd816202f93454ed932da/tweepy/api.py#L681-L693 | train | Update profile image. | Pu7Z6IJCgH3a,vcEHXBQXuDuh,sHOWSIAKtU58,ZVWAAMjVVHHl,qRin5pdYOdbB,IySsVMyKT3tF,FwEHNICjJCy0,yISIa0MMKKfB,GAtvbI59wr0o,OmNM6rT0Sgul,gu1MSKhYvigU,S2TTo9DhhiSh,aaLV7ZjAfkcR,ker4pIJmdvxf,WaQEaQCVMQ03,xV97BFGi0hY9,YnM1HtHE4j7G,X5FyJb4ToTo6,jLmadlzMdunT,GGFwFLsDF9Fv,prtR0Uw1GMh5,oNamnshN4dFG,QZzQeAYvsoum,VHAt7CcYKC2T,cKsTbNGL... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.