hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
9f9eb02690fb25a662827a1dcf0c88f4e087f4c7 | Software-Engineering-Group-4-Maamy/chat-bot | python/chatbot.py | [
"MIT"
] | Python | generate_token | <not_specific> | def generate_token(msg):
"""Tokenize response and remove all stop words to simplify the statement"""
text_tokens = wordpunct_tokenize(msg)
tokens_without_sw = [word for word in text_tokens if not word in stopwords]
print("Generated tokens: ", " ".join(tokens_without_sw))
return " ".join(tokens_witho... | Tokenize response and remove all stop words to simplify the statement | Tokenize response and remove all stop words to simplify the statement | [
"Tokenize",
"response",
"and",
"remove",
"all",
"stop",
"words",
"to",
"simplify",
"the",
"statement"
] | def generate_token(msg):
text_tokens = wordpunct_tokenize(msg)
tokens_without_sw = [word for word in text_tokens if not word in stopwords]
print("Generated tokens: ", " ".join(tokens_without_sw))
return " ".join(tokens_without_sw) | [
"def",
"generate_token",
"(",
"msg",
")",
":",
"text_tokens",
"=",
"wordpunct_tokenize",
"(",
"msg",
")",
"tokens_without_sw",
"=",
"[",
"word",
"for",
"word",
"in",
"text_tokens",
"if",
"not",
"word",
"in",
"stopwords",
"]",
"print",
"(",
"\"Generated tokens:... | Tokenize response and remove all stop words to simplify the statement | [
"Tokenize",
"response",
"and",
"remove",
"all",
"stop",
"words",
"to",
"simplify",
"the",
"statement"
] | [
"\"\"\"Tokenize response and remove all stop words to simplify the statement\"\"\""
] | [
{
"param": "msg",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "msg",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
42eadbf3a070822581cc89ba4573ddf5c4abf749 | FarnazAdib/Crash_course_on_RL | lq/pltlib.py | [
"MIT"
] | Python | relative_inf_cost | null | def relative_inf_cost(self, j, tot_samples, alg, xlab, uplim=6, zoomplt = True):
'''
Relative Infinite average cost error for for N_fix iterations for different trajectory length over MC stable samples
:param j: Infinite average cost
:param tot_samples:
:param alg: Algorithm name... |
Relative Infinite average cost error for for N_fix iterations for different trajectory length over MC stable samples
:param j: Infinite average cost
:param tot_samples:
:param alg: Algorithm names
:return:
| Relative Infinite average cost error for for N_fix iterations for different trajectory length over MC stable samples | [
"Relative",
"Infinite",
"average",
"cost",
"error",
"for",
"for",
"N_fix",
"iterations",
"for",
"different",
"trajectory",
"length",
"over",
"MC",
"stable",
"samples"
] | def relative_inf_cost(self, j, tot_samples, alg, xlab, uplim=6, zoomplt = True):
fig, ax = plt.subplots()
for alg_i in range(len(alg)):
ax.plot(tot_samples, np.median((j[alg_i]-self._j_inf_opt)/self._j_inf_opt, axis=0),
linestyle=self._linestyle[alg_i+1],
... | [
"def",
"relative_inf_cost",
"(",
"self",
",",
"j",
",",
"tot_samples",
",",
"alg",
",",
"xlab",
",",
"uplim",
"=",
"6",
",",
"zoomplt",
"=",
"True",
")",
":",
"fig",
",",
"ax",
"=",
"plt",
".",
"subplots",
"(",
")",
"for",
"alg_i",
"in",
"range",
... | Relative Infinite average cost error for for N_fix iterations for different trajectory length over MC stable samples | [
"Relative",
"Infinite",
"average",
"cost",
"error",
"for",
"for",
"N_fix",
"iterations",
"for",
"different",
"trajectory",
"length",
"over",
"MC",
"stable",
"samples"
] | [
"'''\n Relative Infinite average cost error for for N_fix iterations for different trajectory length over MC stable samples\n :param j: Infinite average cost\n :param tot_samples:\n :param alg: Algorithm names\n :return:\n '''",
"# plt.legend(fontsize=self._legend_fontsiz... | [
{
"param": "self",
"type": null
},
{
"param": "j",
"type": null
},
{
"param": "tot_samples",
"type": null
},
{
"param": "alg",
"type": null
},
{
"param": "xlab",
"type": null
},
{
"param": "uplim",
"type": null
},
{
"param": "zoomplt",
... | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
c5cfd0eb33723ce89f62a7d7767ecd1bcb452634 | FarnazAdib/Crash_course_on_RL | lq/pgrl.py | [
"MIT"
] | Python | random_search_linpolicy | <not_specific> | def random_search_linpolicy(self, K0, N, batch_size, T, explore_mag=0.04, step_size=0.05, safeguard=10):
'''
Random search.
Gian initialization is not important
:param N: Number of rollouts
:param T: Time horizon
:param explore_mag: Magnitude of the noise to explore
... |
Random search.
Gian initialization is not important
:param N: Number of rollouts
:param T: Time horizon
:param explore_mag: Magnitude of the noise to explore
:param step_size: the step size for learning
:param batch_size: Number of directions per minibatches
... | Random search.
Gian initialization is not important | [
"Random",
"search",
".",
"Gian",
"initialization",
"is",
"not",
"important"
] | def random_search_linpolicy(self, K0, N, batch_size, T, explore_mag=0.04, step_size=0.05, safeguard=10):
Lin_gain = LinK(copy.copy(K0))
for k in range(N):
reward_store = []
batch = np.zeros((self.m, self.n))
for j in range(batch_size):
gain_randomness ... | [
"def",
"random_search_linpolicy",
"(",
"self",
",",
"K0",
",",
"N",
",",
"batch_size",
",",
"T",
",",
"explore_mag",
"=",
"0.04",
",",
"step_size",
"=",
"0.05",
",",
"safeguard",
"=",
"10",
")",
":",
"Lin_gain",
"=",
"LinK",
"(",
"copy",
".",
"copy",
... | Random search. | [
"Random",
"search",
"."
] | [
"'''\n Random search.\n Gian initialization is not important\n :param N: Number of rollouts\n :param T: Time horizon\n :param explore_mag: Magnitude of the noise to explore\n :param step_size: the step size for learning\n :param batch_size: Number of directions per m... | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "explore_mag",
"type": null
},
{
"param": "step_size",
... | {
"returns": [
{
"docstring": "Controller K by random search on LQ problem",
"docstring_tokens": [
"Controller",
"K",
"by",
"random",
"search",
"on",
"LQ",
"problem"
],
"type": null
}
],
"raises": [],
"params": [
... |
c5cfd0eb33723ce89f62a7d7767ecd1bcb452634 | FarnazAdib/Crash_course_on_RL | lq/pgrl.py | [
"MIT"
] | Python | uniform_random_search_linpolicy | <not_specific> | def uniform_random_search_linpolicy(self, K0, N, T, linf_norm=3):
'''
Uniform random search
Initialization is not important
:param N: Number of rollouts
:param T: Time horizon
:param linf_norm: Maximum controller value
:return: Controller by uniform random linear ... |
Uniform random search
Initialization is not important
:param N: Number of rollouts
:param T: Time horizon
:param linf_norm: Maximum controller value
:return: Controller by uniform random linear policy
| Uniform random search
Initialization is not important | [
"Uniform",
"random",
"search",
"Initialization",
"is",
"not",
"important"
] | def uniform_random_search_linpolicy(self, K0, N, T, linf_norm=3):
Lin_gain = LinK(copy.copy(K0))
best_K = Lin_gain.K
best_reward = -float("inf")
for k in range(N):
Lin_gain.K = Lin_gain.uniform_sample_gain(linf_norm)
_, _, costs, _ = self.dyn.one_rollout(Lin_gain.... | [
"def",
"uniform_random_search_linpolicy",
"(",
"self",
",",
"K0",
",",
"N",
",",
"T",
",",
"linf_norm",
"=",
"3",
")",
":",
"Lin_gain",
"=",
"LinK",
"(",
"copy",
".",
"copy",
"(",
"K0",
")",
")",
"best_K",
"=",
"Lin_gain",
".",
"K",
"best_reward",
"=... | Uniform random search
Initialization is not important | [
"Uniform",
"random",
"search",
"Initialization",
"is",
"not",
"important"
] | [
"'''\n Uniform random search\n Initialization is not important\n :param N: Number of rollouts\n :param T: Time horizon\n :param linf_norm: Maximum controller value\n :return: Controller by uniform random linear policy\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "linf_norm",
"type": null
}
] | {
"returns": [
{
"docstring": "Controller by uniform random linear policy",
"docstring_tokens": [
"Controller",
"by",
"uniform",
"random",
"linear",
"policy"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "... |
c5cfd0eb33723ce89f62a7d7767ecd1bcb452634 | FarnazAdib/Crash_course_on_RL | lq/pgrl.py | [
"MIT"
] | Python | pg_linpolicy | <not_specific> | def pg_linpolicy(self, K0, N, batch_size, T, explore_mag=0.1,
step_size=0.1, beta1=0.9, beta2=0.999, epsilon=1.0e-8, safeguard=10):
'''
The policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.
:param K0: The initial controller gain... |
The policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.
:param K0: The initial controller gain
:param N: Number of iterations
:param batch_size: number of batches per each step of optimization
:param T: Trajectory length
:para... | The policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization. | [
"The",
"policy",
"gradient",
"algorithm",
"where",
"the",
"policy",
"is",
"considered",
"to",
"be",
"linear",
".",
"We",
"use",
"ADAM",
"optimization",
"."
] | def pg_linpolicy(self, K0, N, batch_size, T, explore_mag=0.1,
step_size=0.1, beta1=0.9, beta2=0.999, epsilon=1.0e-8, safeguard=10):
Lin_gain = LinK(copy.copy(K0))
Lin_gain.make_sampling_on(explore_mag)
baseline = 0.0
adam = ADAM(self.m, self.n, step_size=step_size, b... | [
"def",
"pg_linpolicy",
"(",
"self",
",",
"K0",
",",
"N",
",",
"batch_size",
",",
"T",
",",
"explore_mag",
"=",
"0.1",
",",
"step_size",
"=",
"0.1",
",",
"beta1",
"=",
"0.9",
",",
"beta2",
"=",
"0.999",
",",
"epsilon",
"=",
"1.0e-8",
",",
"safeguard",... | The policy gradient algorithm where the policy is considered to be linear. | [
"The",
"policy",
"gradient",
"algorithm",
"where",
"the",
"policy",
"is",
"considered",
"to",
"be",
"linear",
"."
] | [
"'''\n The policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.\n :param K0: The initial controller gain\n :param N: Number of iterations\n :param batch_size: number of batches per each step of optimization\n :param T: Trajectory length\... | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "explore_mag",
"type": null
},
{
"param": "step_size",
... | {
"returns": [
{
"docstring": "The controller gain K",
"docstring_tokens": [
"The",
"controller",
"gain",
"K"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docst... |
c5cfd0eb33723ce89f62a7d7767ecd1bcb452634 | FarnazAdib/Crash_course_on_RL | lq/pgrl.py | [
"MIT"
] | Python | pg_vanilla_linpolicy | <not_specific> | def pg_vanilla_linpolicy(self, K0, N, batch_size, T, explore_mag=0.1,
step_size=0.1, beta1=0.9, beta2=0.999, epsilon=1.0e-8, safeguard=10):
'''
The vanilla policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.
Different from... |
The vanilla policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.
Different from the policy gradient, in each step rewards to go for that step is used.
:param N: Number of rollouts
:param batch_size: Number of stochastic gradient per minibatch
... | The vanilla policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.
Different from the policy gradient, in each step rewards to go for that step is used. | [
"The",
"vanilla",
"policy",
"gradient",
"algorithm",
"where",
"the",
"policy",
"is",
"considered",
"to",
"be",
"linear",
".",
"We",
"use",
"ADAM",
"optimization",
".",
"Different",
"from",
"the",
"policy",
"gradient",
"in",
"each",
"step",
"rewards",
"to",
"... | def pg_vanilla_linpolicy(self, K0, N, batch_size, T, explore_mag=0.1,
step_size=0.1, beta1=0.9, beta2=0.999, epsilon=1.0e-8, safeguard=10):
Lin_gain = LinK(copy.copy(K0))
Lin_gain.make_sampling_on(explore_mag)
baseline = 0.0
adam = ADAM(self.m, self.n, step_s... | [
"def",
"pg_vanilla_linpolicy",
"(",
"self",
",",
"K0",
",",
"N",
",",
"batch_size",
",",
"T",
",",
"explore_mag",
"=",
"0.1",
",",
"step_size",
"=",
"0.1",
",",
"beta1",
"=",
"0.9",
",",
"beta2",
"=",
"0.999",
",",
"epsilon",
"=",
"1.0e-8",
",",
"saf... | The vanilla policy gradient algorithm where the policy is considered to be linear. | [
"The",
"vanilla",
"policy",
"gradient",
"algorithm",
"where",
"the",
"policy",
"is",
"considered",
"to",
"be",
"linear",
"."
] | [
"'''\n The vanilla policy gradient algorithm where the policy is considered to be linear. We use ADAM optimization.\n Different from the policy gradient, in each step rewards to go for that step is used.\n :param N: Number of rollouts\n :param batch_size: Number of stochastic gradient pe... | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "explore_mag",
"type": null
},
{
"param": "step_size",
... | {
"returns": [
{
"docstring": "Controller gain by vanilla PG using ADAM",
"docstring_tokens": [
"Controller",
"gain",
"by",
"vanilla",
"PG",
"using",
"ADAM"
],
"type": null
}
],
"raises": [],
"params": [
{
"identif... |
8fa9abfb2afd8bae479e589aa7690e057eeeac2a | FarnazAdib/Crash_course_on_RL | lq/policy_iteration.py | [
"MIT"
] | Python | ql | <not_specific> | def ql(self, K0, N, T, explore_mag=1.0):
'''
Q learning loop to iterate over policy iteration and policy improvement
:param K0: The initial policy gain
:param N: Number of iterations
:param T: Trajectory length
:param explore_mag: The amount of randomness in Q learning
... |
Q learning loop to iterate over policy iteration and policy improvement
:param K0: The initial policy gain
:param N: Number of iterations
:param T: Trajectory length
:param explore_mag: The amount of randomness in Q learning
:return: The kernel of the value function P an... | Q learning loop to iterate over policy iteration and policy improvement | [
"Q",
"learning",
"loop",
"to",
"iterate",
"over",
"policy",
"iteration",
"and",
"policy",
"improvement"
] | def ql(self, K0, N, T, explore_mag=1.0):
self.K = K0
for k in range(N):
if self.dyn.is_stable(self.K):
G = self.q_evaluation(T, explore_mag)
self.K = self.q_improvement(G)
P = GtoP(G, self.K)
else:
P, self.K = self.u... | [
"def",
"ql",
"(",
"self",
",",
"K0",
",",
"N",
",",
"T",
",",
"explore_mag",
"=",
"1.0",
")",
":",
"self",
".",
"K",
"=",
"K0",
"for",
"k",
"in",
"range",
"(",
"N",
")",
":",
"if",
"self",
".",
"dyn",
".",
"is_stable",
"(",
"self",
".",
"K"... | Q learning loop to iterate over policy iteration and policy improvement | [
"Q",
"learning",
"loop",
"to",
"iterate",
"over",
"policy",
"iteration",
"and",
"policy",
"improvement"
] | [
"'''\n Q learning loop to iterate over policy iteration and policy improvement\n :param K0: The initial policy gain\n :param N: Number of iterations\n :param T: Trajectory length\n :param explore_mag: The amount of randomness in Q learning\n :return: The kernel of the value... | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "explore_mag",
"type": null
}
] | {
"returns": [
{
"docstring": "The kernel of the value function P and the controller gain K",
"docstring_tokens": [
"The",
"kernel",
"of",
"the",
"value",
"function",
"P",
"and",
"the",
"controller",
"gain",
... |
281520816de6e0963eb58a86265fa3a6e2b30af5 | FarnazAdib/Crash_course_on_RL | lq/funlib.py | [
"MIT"
] | Python | opt_onestep | <not_specific> | def opt_onestep(self, g):
'''
This function calculate one iteration of adam optimization. It takes the gradient of cost functin with repect to
parameter thetha and return dtheta. Note that you should use +dtheta when you are maximizing and -dtheta when
minimizing.
return the cha... |
This function calculate one iteration of adam optimization. It takes the gradient of cost functin with repect to
parameter thetha and return dtheta. Note that you should use +dtheta when you are maximizing and -dtheta when
minimizing.
return the changes for the learning parameter
... | This function calculate one iteration of adam optimization. It takes the gradient of cost functin with repect to
parameter thetha and return dtheta. Note that you should use +dtheta when you are maximizing and -dtheta when
minimizing.
return the changes for the learning parameter | [
"This",
"function",
"calculate",
"one",
"iteration",
"of",
"adam",
"optimization",
".",
"It",
"takes",
"the",
"gradient",
"of",
"cost",
"functin",
"with",
"repect",
"to",
"parameter",
"thetha",
"and",
"return",
"dtheta",
".",
"Note",
"that",
"you",
"should",
... | def opt_onestep(self, g):
self.adam_M = self.beta1 * self.adam_M + (1 - self.beta1) * g
self.adam_V = self.beta2 * self.adam_V + (1 - self.beta2) * (g * g)
mhat = copy.copy(self.adam_M) / (1 - self.beta1 ** (self.it_index + 1))
vhat = copy.copy(self.adam_V) / (1 - self.beta2 ** (self.it_... | [
"def",
"opt_onestep",
"(",
"self",
",",
"g",
")",
":",
"self",
".",
"adam_M",
"=",
"self",
".",
"beta1",
"*",
"self",
".",
"adam_M",
"+",
"(",
"1",
"-",
"self",
".",
"beta1",
")",
"*",
"g",
"self",
".",
"adam_V",
"=",
"self",
".",
"beta2",
"*",... | This function calculate one iteration of adam optimization. | [
"This",
"function",
"calculate",
"one",
"iteration",
"of",
"adam",
"optimization",
"."
] | [
"'''\n This function calculate one iteration of adam optimization. It takes the gradient of cost functin with repect to\n parameter thetha and return dtheta. Note that you should use +dtheta when you are maximizing and -dtheta when\n minimizing.\n return the changes for the learning par... | [
{
"param": "self",
"type": null
},
{
"param": "g",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
a565c07058e6615101d9e440bcdae65e869bb459 | FarnazAdib/Crash_course_on_RL | lq/dynamics.py | [
"MIT"
] | Python | cost_inf_K | <not_specific> | def cost_inf_K(self, K):
'''
Arguments:
Control Gain K
process noise covariance Qn
observation noise covariance Rn
Outputs:
cost: Infinite time horizon LQR cost of static gain K
u=Kx
'''
if self.is_stable(K):
... |
Arguments:
Control Gain K
process noise covariance Qn
observation noise covariance Rn
Outputs:
cost: Infinite time horizon LQR cost of static gain K
u=Kx
| Control Gain K
process noise covariance Qn
observation noise covariance Rn
Outputs:
cost: Infinite time horizon LQR cost of static gain K
u=Kx | [
"Control",
"Gain",
"K",
"process",
"noise",
"covariance",
"Qn",
"observation",
"noise",
"covariance",
"Rn",
"Outputs",
":",
"cost",
":",
"Infinite",
"time",
"horizon",
"LQR",
"cost",
"of",
"static",
"gain",
"K",
"u",
"=",
"Kx"
] | def cost_inf_K(self, K):
if self.is_stable(K):
P,_ = self.P_and_Pe_associated_to_K(K)
cost = np.trace(P @ self.Qn)
else:
cost = float("inf")
return cost | [
"def",
"cost_inf_K",
"(",
"self",
",",
"K",
")",
":",
"if",
"self",
".",
"is_stable",
"(",
"K",
")",
":",
"P",
",",
"_",
"=",
"self",
".",
"P_and_Pe_associated_to_K",
"(",
"K",
")",
"cost",
"=",
"np",
".",
"trace",
"(",
"P",
"@",
"self",
".",
"... | Arguments:
Control Gain K
process noise covariance Qn
observation noise covariance Rn
Outputs:
cost: Infinite time horizon LQR cost of static gain K
u=Kx | [
"Arguments",
":",
"Control",
"Gain",
"K",
"process",
"noise",
"covariance",
"Qn",
"observation",
"noise",
"covariance",
"Rn",
"Outputs",
":",
"cost",
":",
"Infinite",
"time",
"horizon",
"LQR",
"cost",
"of",
"static",
"gain",
"K",
"u",
"=",
"Kx"
] | [
"'''\n Arguments:\n Control Gain K\n process noise covariance Qn\n observation noise covariance Rn\n Outputs:\n cost: Infinite time horizon LQR cost of static gain K\n u=Kx\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "K",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "K",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
d0234477e63793d0564db5f08a9d2e9099a90c92 | FarnazAdib/Crash_course_on_RL | lq/model_estimation.py | [
"MIT"
] | Python | nominal_PK | <not_specific> | def nominal_PK(self, K0, N, T, explore_mag=10, res_time=100):
'''
An iterative approach to find the optimal controller based on learning the dynamics.
In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
are estimated and then the optimal co... |
An iterative approach to find the optimal controller based on learning the dynamics.
In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation
... | An iterative approach to find the optimal controller based on learning the dynamics.
In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom
are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati Equation | [
"An",
"iterative",
"approach",
"to",
"find",
"the",
"optimal",
"controller",
"based",
"on",
"learning",
"the",
"dynamics",
".",
"In",
"each",
"iteration",
"the",
"system",
"is",
"rolled",
"out",
"with",
"the",
"current",
"controller",
"gain",
".",
"Then",
"A... | def nominal_PK(self, K0, N, T, explore_mag=10, res_time=100):
K = K0
for n in range(N):
if self.dyn.is_stable(K):
A_nom, B_nom = self.nominal_AB(K, 1, T, explore_mag=explore_mag, res_time=res_time)
try:
P = LA.solve_discrete_are(A_nom, B_no... | [
"def",
"nominal_PK",
"(",
"self",
",",
"K0",
",",
"N",
",",
"T",
",",
"explore_mag",
"=",
"10",
",",
"res_time",
"=",
"100",
")",
":",
"K",
"=",
"K0",
"for",
"n",
"in",
"range",
"(",
"N",
")",
":",
"if",
"self",
".",
"dyn",
".",
"is_stable",
... | An iterative approach to find the optimal controller based on learning the dynamics. | [
"An",
"iterative",
"approach",
"to",
"find",
"the",
"optimal",
"controller",
"based",
"on",
"learning",
"the",
"dynamics",
"."
] | [
"'''\n An iterative approach to find the optimal controller based on learning the dynamics.\n In each iteration, the system is rolled out with the current controller gain. Then, A_nom and B_nom\n are estimated and then the optimal controller gain K is computed by solving the Algebraic Riccati E... | [
{
"param": "self",
"type": null
},
{
"param": "K0",
"type": null
},
{
"param": "N",
"type": null
},
{
"param": "T",
"type": null
},
{
"param": "explore_mag",
"type": null
},
{
"param": "res_time",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "K0",
"type": null,
"docstring": "Initial controller gain",
"d... |
035df06bfde5fc41c6aaeb4feb5d33b4bee442b6 | FarnazAdib/Crash_course_on_RL | lq/policies.py | [
"MIT"
] | Python | lin_policy | <not_specific> | def lin_policy(self, x):
'''
A linear policy u=K x
:param x: Input of shape T, n
:return: the policy of shape T, m
'''
return x @ self.K.T |
A linear policy u=K x
:param x: Input of shape T, n
:return: the policy of shape T, m
| A linear policy u=K x | [
"A",
"linear",
"policy",
"u",
"=",
"K",
"x"
] | def lin_policy(self, x):
return x @ self.K.T | [
"def",
"lin_policy",
"(",
"self",
",",
"x",
")",
":",
"return",
"x",
"@",
"self",
".",
"K",
".",
"T"
] | A linear policy u=K x | [
"A",
"linear",
"policy",
"u",
"=",
"K",
"x"
] | [
"'''\n A linear policy u=K x\n :param x: Input of shape T, n\n :return: the policy of shape T, m\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "x",
"type": null
}
] | {
"returns": [
{
"docstring": "the policy of shape T, m",
"docstring_tokens": [
"the",
"policy",
"of",
"shape",
"T",
"m"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"doc... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | clear | None | def clear(self) -> None:
"""
Clear all contents of the HashMap without changing capacity.
:return: None
"""
for i in range(self.capacity):
self.buckets[i] = LinkedList()
self.size = 0 |
Clear all contents of the HashMap without changing capacity.
:return: None
| Clear all contents of the HashMap without changing capacity. | [
"Clear",
"all",
"contents",
"of",
"the",
"HashMap",
"without",
"changing",
"capacity",
"."
] | def clear(self) -> None:
for i in range(self.capacity):
self.buckets[i] = LinkedList()
self.size = 0 | [
"def",
"clear",
"(",
"self",
")",
"->",
"None",
":",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"capacity",
")",
":",
"self",
".",
"buckets",
"[",
"i",
"]",
"=",
"LinkedList",
"(",
")",
"self",
".",
"size",
"=",
"0"
] | Clear all contents of the HashMap without changing capacity. | [
"Clear",
"all",
"contents",
"of",
"the",
"HashMap",
"without",
"changing",
"capacity",
"."
] | [
"\"\"\"\n Clear all contents of the HashMap without changing capacity.\n :return: None\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | remove | None | def remove(self, key: str) -> None:
"""
Remove a key/value pair from the map.
If `key` is not in the map, method does nothing.
:param key: a string
:return: None
"""
hashed_key = self.hash_function(key)
index = hashed_key % self.capacity
is_removed... |
Remove a key/value pair from the map.
If `key` is not in the map, method does nothing.
:param key: a string
:return: None
| Remove a key/value pair from the map.
If `key` is not in the map, method does nothing. | [
"Remove",
"a",
"key",
"/",
"value",
"pair",
"from",
"the",
"map",
".",
"If",
"`",
"key",
"`",
"is",
"not",
"in",
"the",
"map",
"method",
"does",
"nothing",
"."
] | def remove(self, key: str) -> None:
hashed_key = self.hash_function(key)
index = hashed_key % self.capacity
is_removed = self.buckets[index].remove(key)
if is_removed:
self.size -= 1 | [
"def",
"remove",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"None",
":",
"hashed_key",
"=",
"self",
".",
"hash_function",
"(",
"key",
")",
"index",
"=",
"hashed_key",
"%",
"self",
".",
"capacity",
"is_removed",
"=",
"self",
".",
"buckets",
"[",
... | Remove a key/value pair from the map. | [
"Remove",
"a",
"key",
"/",
"value",
"pair",
"from",
"the",
"map",
"."
] | [
"\"\"\"\n Remove a key/value pair from the map.\n If `key` is not in the map, method does nothing.\n :param key: a string\n :return: None\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key",
"type": "str"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | contains_key | bool | def contains_key(self, key: str) -> bool:
"""
Return True if the map contains 'key'. False otherwise.
:param key: a string to search the map for.
:return: a boolean
"""
if self.size == 0:
return False
hashed_key = self.hash_function(key)
index ... |
Return True if the map contains 'key'. False otherwise.
:param key: a string to search the map for.
:return: a boolean
| Return True if the map contains 'key'. False otherwise. | [
"Return",
"True",
"if",
"the",
"map",
"contains",
"'",
"key",
"'",
".",
"False",
"otherwise",
"."
] | def contains_key(self, key: str) -> bool:
if self.size == 0:
return False
hashed_key = self.hash_function(key)
index = hashed_key % self.capacity
return self.buckets[index].contains(key) is not None | [
"def",
"contains_key",
"(",
"self",
",",
"key",
":",
"str",
")",
"->",
"bool",
":",
"if",
"self",
".",
"size",
"==",
"0",
":",
"return",
"False",
"hashed_key",
"=",
"self",
".",
"hash_function",
"(",
"key",
")",
"index",
"=",
"hashed_key",
"%",
"self... | Return True if the map contains 'key'. | [
"Return",
"True",
"if",
"the",
"map",
"contains",
"'",
"key",
"'",
"."
] | [
"\"\"\"\n Return True if the map contains 'key'. False otherwise.\n :param key: a string to search the map for.\n :return: a boolean\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "key",
"type": "str"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | empty_buckets | int | def empty_buckets(self) -> int:
"""
Return the number of empty buckets in the HashMap.
:return: an integer
"""
count = 0
for i in range(self.capacity):
if self.buckets[i].length() == 0:
count += 1
return count |
Return the number of empty buckets in the HashMap.
:return: an integer
| Return the number of empty buckets in the HashMap. | [
"Return",
"the",
"number",
"of",
"empty",
"buckets",
"in",
"the",
"HashMap",
"."
] | def empty_buckets(self) -> int:
count = 0
for i in range(self.capacity):
if self.buckets[i].length() == 0:
count += 1
return count | [
"def",
"empty_buckets",
"(",
"self",
")",
"->",
"int",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"self",
".",
"capacity",
")",
":",
"if",
"self",
".",
"buckets",
"[",
"i",
"]",
".",
"length",
"(",
")",
"==",
"0",
":",
"count",
"+=... | Return the number of empty buckets in the HashMap. | [
"Return",
"the",
"number",
"of",
"empty",
"buckets",
"in",
"the",
"HashMap",
"."
] | [
"\"\"\"\n Return the number of empty buckets in the HashMap.\n :return: an integer\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | table_load | float | def table_load(self) -> float:
"""
Return the current HashMap load factor.
:return: a float
"""
return self.size / self.capacity |
Return the current HashMap load factor.
:return: a float
| Return the current HashMap load factor. | [
"Return",
"the",
"current",
"HashMap",
"load",
"factor",
"."
] | def table_load(self) -> float:
return self.size / self.capacity | [
"def",
"table_load",
"(",
"self",
")",
"->",
"float",
":",
"return",
"self",
".",
"size",
"/",
"self",
".",
"capacity"
] | Return the current HashMap load factor. | [
"Return",
"the",
"current",
"HashMap",
"load",
"factor",
"."
] | [
"\"\"\"\n Return the current HashMap load factor.\n :return: a float\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
aab596ed2dde958658aa613ebd29f65a177dbf6a | EJLada/HashMap | hash_map.py | [
"MIT"
] | Python | resize_table | None | def resize_table(self, new_capacity: int) -> None:
"""
Change the capacity of the internal hash table and re-hash
all key/value pairs.
If `new_capacity` < 1 the method does nothing.
:param new_capacity: an int
:return: None
"""
if new_capacity > 0:
... |
Change the capacity of the internal hash table and re-hash
all key/value pairs.
If `new_capacity` < 1 the method does nothing.
:param new_capacity: an int
:return: None
| Change the capacity of the internal hash table and re-hash
all key/value pairs.
If `new_capacity` < 1 the method does nothing. | [
"Change",
"the",
"capacity",
"of",
"the",
"internal",
"hash",
"table",
"and",
"re",
"-",
"hash",
"all",
"key",
"/",
"value",
"pairs",
".",
"If",
"`",
"new_capacity",
"`",
"<",
"1",
"the",
"method",
"does",
"nothing",
"."
] | def resize_table(self, new_capacity: int) -> None:
if new_capacity > 0:
temp = HashMap(new_capacity, self.hash_function)
for i in range(new_capacity):
temp.buckets.append(LinkedList())
for j in range(self.capacity):
if self.buckets[j].length() ... | [
"def",
"resize_table",
"(",
"self",
",",
"new_capacity",
":",
"int",
")",
"->",
"None",
":",
"if",
"new_capacity",
">",
"0",
":",
"temp",
"=",
"HashMap",
"(",
"new_capacity",
",",
"self",
".",
"hash_function",
")",
"for",
"i",
"in",
"range",
"(",
"new_... | Change the capacity of the internal hash table and re-hash
all key/value pairs. | [
"Change",
"the",
"capacity",
"of",
"the",
"internal",
"hash",
"table",
"and",
"re",
"-",
"hash",
"all",
"key",
"/",
"value",
"pairs",
"."
] | [
"\"\"\"\n Change the capacity of the internal hash table and re-hash\n all key/value pairs.\n If `new_capacity` < 1 the method does nothing.\n :param new_capacity: an int\n :return: None\n \"\"\"",
"# Create new HashMap and buckets",
"# Re-hash contents of original map ... | [
{
"param": "self",
"type": null
},
{
"param": "new_capacity",
"type": "int"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
4ed1484f2ccae70be8534ac1594a8fd5f498ae70 | zauberwild/paamestia | code/drinks_lib.py | [
"MIT"
] | Python | update_recipes_and_drinks | null | def update_recipes_and_drinks():
""" updates the recipe and drinks list"""
global drinks, recipes
drinks.clear()
recipes.clear()
# look for drinks
file1 = open(gl.gen_path + "/src/drinks", 'r') # open file
drinks = file1.readlines() # save lines as a list
file1.close()
file1 = open(gl.gen_path + "/sr... | updates the recipe and drinks list | updates the recipe and drinks list | [
"updates",
"the",
"recipe",
"and",
"drinks",
"list"
] | def update_recipes_and_drinks():
global drinks, recipes
drinks.clear()
recipes.clear()
file1 = open(gl.gen_path + "/src/drinks", 'r')
drinks = file1.readlines()
file1.close()
file1 = open(gl.gen_path + "/src/drinks_custom", 'r')
drinks += file1.readlines()
file1.close()
for idx, i in enu... | [
"def",
"update_recipes_and_drinks",
"(",
")",
":",
"global",
"drinks",
",",
"recipes",
"drinks",
".",
"clear",
"(",
")",
"recipes",
".",
"clear",
"(",
")",
"file1",
"=",
"open",
"(",
"gl",
".",
"gen_path",
"+",
"\"/src/drinks\"",
",",
"'r'",
")",
"drinks... | updates the recipe and drinks list | [
"updates",
"the",
"recipe",
"and",
"drinks",
"list"
] | [
"\"\"\" updates the recipe and drinks list\"\"\"",
"# look for drinks",
"# open file",
"# save lines as a list",
"# open file",
"# save lines as a list",
"# remove trailing newline characters",
"# look for recipes",
"# sort out the free mixed recipe, as it should not appear in the recipe list",
"#... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4ed1484f2ccae70be8534ac1594a8fd5f498ae70 | zauberwild/paamestia | code/drinks_lib.py | [
"MIT"
] | Python | add_drinks | <not_specific> | def add_drinks(new_drinks):
""" add new drinks to the drink file
drinks: a list of the new drinks
returns True if successfull, False if an error occurred
"""
global drinks
print("[DR AD] adding new drinks")
file = open(gl.gen_path + "/src/drinks_custom", "a")
for i in new_drinks:
file.write(i+"\n")
file.c... | add new drinks to the drink file
drinks: a list of the new drinks
returns True if successfull, False if an error occurred
| add new drinks to the drink file
drinks: a list of the new drinks
returns True if successfull, False if an error occurred | [
"add",
"new",
"drinks",
"to",
"the",
"drink",
"file",
"drinks",
":",
"a",
"list",
"of",
"the",
"new",
"drinks",
"returns",
"True",
"if",
"successfull",
"False",
"if",
"an",
"error",
"occurred"
] | def add_drinks(new_drinks):
global drinks
print("[DR AD] adding new drinks")
file = open(gl.gen_path + "/src/drinks_custom", "a")
for i in new_drinks:
file.write(i+"\n")
file.close()
drinks.sort()
print("[DR AD] finished adding new drinks")
return True | [
"def",
"add_drinks",
"(",
"new_drinks",
")",
":",
"global",
"drinks",
"print",
"(",
"\"[DR AD] adding new drinks\"",
")",
"file",
"=",
"open",
"(",
"gl",
".",
"gen_path",
"+",
"\"/src/drinks_custom\"",
",",
"\"a\"",
")",
"for",
"i",
"in",
"new_drinks",
":",
... | add new drinks to the drink file
drinks: a list of the new drinks
returns True if successfull, False if an error occurred | [
"add",
"new",
"drinks",
"to",
"the",
"drink",
"file",
"drinks",
":",
"a",
"list",
"of",
"the",
"new",
"drinks",
"returns",
"True",
"if",
"successfull",
"False",
"if",
"an",
"error",
"occurred"
] | [
"\"\"\" add new drinks to the drink file\n\tdrinks: a list of the new drinks\n\treturns True if successfull, False if an error occurred\n\t\"\"\""
] | [
{
"param": "new_drinks",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "new_drinks",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4ed1484f2ccae70be8534ac1594a8fd5f498ae70 | zauberwild/paamestia | code/drinks_lib.py | [
"MIT"
] | Python | import_recipe | <not_specific> | def import_recipe():
""" opens a file prompt to import a new recipe
returns True if successfull, False if an error occurred
"""
file_path = prompt_file() # select a file
print("[DR IR] 1/6 file path:", file_path)
file = open(file_path, 'r') # read the file and do a compatability check
lines = file.readl... | opens a file prompt to import a new recipe
returns True if successfull, False if an error occurred
| opens a file prompt to import a new recipe
returns True if successfull, False if an error occurred | [
"opens",
"a",
"file",
"prompt",
"to",
"import",
"a",
"new",
"recipe",
"returns",
"True",
"if",
"successfull",
"False",
"if",
"an",
"error",
"occurred"
] | def import_recipe():
file_path = prompt_file()
print("[DR IR] 1/6 file path:", file_path)
file = open(file_path, 'r')
lines = file.readlines()
file.close()
for idx, i in enumerate(lines):
if lines[idx].endswith('\n'):
lines[idx] = lines[idx][:-1]
print("[DR IR] 2/6 could read file and remove... | [
"def",
"import_recipe",
"(",
")",
":",
"file_path",
"=",
"prompt_file",
"(",
")",
"print",
"(",
"\"[DR IR] 1/6 file path:\"",
",",
"file_path",
")",
"file",
"=",
"open",
"(",
"file_path",
",",
"'r'",
")",
"lines",
"=",
"file",
".",
"readlines",
"(",
")",
... | opens a file prompt to import a new recipe
returns True if successfull, False if an error occurred | [
"opens",
"a",
"file",
"prompt",
"to",
"import",
"a",
"new",
"recipe",
"returns",
"True",
"if",
"successfull",
"False",
"if",
"an",
"error",
"occurred"
] | [
"\"\"\" opens a file prompt to import a new recipe\n\treturns True if successfull, False if an error occurred\n\t\"\"\"",
"# select a file",
"# read the file and do a compatability check",
"# remove trailing newline characters",
"# trying to convert the second param of the instructions to int",
"# if nece... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
4ed1484f2ccae70be8534ac1594a8fd5f498ae70 | zauberwild/paamestia | code/drinks_lib.py | [
"MIT"
] | Python | delete_recipe | <not_specific> | def delete_recipe(recipe):
""" deletes recipe
- recipe: either in index of recipe_list, or String for recipe name
"""
print("[DR DelR]", "1/ starting deleting procedure")
if type(recipe) != int and type(recipe) != str: # break when input type not correct
return
print("[DR DelR]", "2/ correct input type")
i... | deletes recipe
- recipe: either in index of recipe_list, or String for recipe name
| deletes recipe
recipe: either in index of recipe_list, or String for recipe name | [
"deletes",
"recipe",
"recipe",
":",
"either",
"in",
"index",
"of",
"recipe_list",
"or",
"String",
"for",
"recipe",
"name"
] | def delete_recipe(recipe):
print("[DR DelR]", "1/ starting deleting procedure")
if type(recipe) != int and type(recipe) != str:
return
print("[DR DelR]", "2/ correct input type")
if type(recipe) == int:
recipe = recipes[recipe]
print("[DR DelR]", "3/ got recipe name from index (if needed)")
if recip... | [
"def",
"delete_recipe",
"(",
"recipe",
")",
":",
"print",
"(",
"\"[DR DelR]\"",
",",
"\"1/ starting deleting procedure\"",
")",
"if",
"type",
"(",
"recipe",
")",
"!=",
"int",
"and",
"type",
"(",
"recipe",
")",
"!=",
"str",
":",
"return",
"print",
"(",
"\"[... | deletes recipe
recipe: either in index of recipe_list, or String for recipe name | [
"deletes",
"recipe",
"recipe",
":",
"either",
"in",
"index",
"of",
"recipe_list",
"or",
"String",
"for",
"recipe",
"name"
] | [
"\"\"\" deletes recipe \n\t- recipe: either in index of recipe_list, or String for recipe name\n\t\"\"\"",
"# break when input type not correct",
"# get recipe name when index given",
"# check if recipe is immutable / can't be deleted",
"# delete recipe",
"# update recipe and drinks list"
] | [
{
"param": "recipe",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "recipe",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
4ed1484f2ccae70be8534ac1594a8fd5f498ae70 | zauberwild/paamestia | code/drinks_lib.py | [
"MIT"
] | Python | start_mixing | <not_specific> | def start_mixing(recipe):
""" compiles the recipe and starts the mixing process.
recipe: EITHER as string with recipe name OR as int with index in recipes list
"""
global is_mixing, recipe_step, commands, recipes
if is_mixing: # break, when there's already a recipe mixing
return
print("[DR SM]", "1/... | compiles the recipe and starts the mixing process.
recipe: EITHER as string with recipe name OR as int with index in recipes list
| compiles the recipe and starts the mixing process.
recipe: EITHER as string with recipe name OR as int with index in recipes list | [
"compiles",
"the",
"recipe",
"and",
"starts",
"the",
"mixing",
"process",
".",
"recipe",
":",
"EITHER",
"as",
"string",
"with",
"recipe",
"name",
"OR",
"as",
"int",
"with",
"index",
"in",
"recipes",
"list"
] | def start_mixing(recipe):
global is_mixing, recipe_step, commands, recipes
if is_mixing:
return
print("[DR SM]", "1/4 no other recipe mixing")
if type(recipe) != int and type(recipe) != str:
return
print("[DR SM]", "2/4 correct input type")
if type(recipe) == int:
recipe = recipes[recipe... | [
"def",
"start_mixing",
"(",
"recipe",
")",
":",
"global",
"is_mixing",
",",
"recipe_step",
",",
"commands",
",",
"recipes",
"if",
"is_mixing",
":",
"return",
"print",
"(",
"\"[DR SM]\"",
",",
"\"1/4 no other recipe mixing\"",
")",
"if",
"type",
"(",
"recipe",
... | compiles the recipe and starts the mixing process. | [
"compiles",
"the",
"recipe",
"and",
"starts",
"the",
"mixing",
"process",
"."
] | [
"\"\"\" compiles the recipe and starts the mixing process.\n\trecipe: EITHER as string with recipe name OR as int with index in recipes list\n\t\"\"\"",
"# break, when there's already a recipe mixing",
"# break when input type not correct",
"# get recipe name when index given",
"# break when recipe not avai... | [
{
"param": "recipe",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "recipe",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
acb447ed5719d7e1e4fffcc91d00327bebe4d671 | zauberwild/paamestia | code/ext_ui_methods_lib.py | [
"MIT"
] | Python | loop | null | def loop():
""" actions that need to be executed every loop (independently from prog_pos) are here.
this function will be called before any other actions in the main loop
"""
io.keyboard_input() # keyboard input
io.update_input() # button input
# debug information about input and output
if gl.show_debug:
i... | actions that need to be executed every loop (independently from prog_pos) are here.
this function will be called before any other actions in the main loop
| actions that need to be executed every loop (independently from prog_pos) are here.
this function will be called before any other actions in the main loop | [
"actions",
"that",
"need",
"to",
"be",
"executed",
"every",
"loop",
"(",
"independently",
"from",
"prog_pos",
")",
"are",
"here",
".",
"this",
"function",
"will",
"be",
"called",
"before",
"any",
"other",
"actions",
"in",
"the",
"main",
"loop"
] | def loop():
io.keyboard_input()
io.update_input()
if gl.show_debug:
if not gl.prog_pos == 'i':
i_s = "O: "
for i in io.valves_state:
i_s += str(int(i)) + "; "
i_s += str(int(io.pump_state))
gl.debug_text.append(i_s)
i_s = "I: up: " + str(int(io.read_input(io.UP))) + "; down: " + str(int(io.r... | [
"def",
"loop",
"(",
")",
":",
"io",
".",
"keyboard_input",
"(",
")",
"io",
".",
"update_input",
"(",
")",
"if",
"gl",
".",
"show_debug",
":",
"if",
"not",
"gl",
".",
"prog_pos",
"==",
"'i'",
":",
"i_s",
"=",
"\"O: \"",
"for",
"i",
"in",
"io",
"."... | actions that need to be executed every loop (independently from prog_pos) are here. | [
"actions",
"that",
"need",
"to",
"be",
"executed",
"every",
"loop",
"(",
"independently",
"from",
"prog_pos",
")",
"are",
"here",
"."
] | [
"\"\"\" actions that need to be executed every loop (independently from prog_pos) are here.\n\t\tthis function will be called before any other actions in the main loop\n\t\"\"\"",
"# keyboard input",
"# button input",
"# debug information about input and output"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
acb447ed5719d7e1e4fffcc91d00327bebe4d671 | zauberwild/paamestia | code/ext_ui_methods_lib.py | [
"MIT"
] | Python | end_loop | null | def end_loop():
""" actions that need to be executed every loop AT THE END are here. """
# draw and update notifications
for i in gl.notifications:
i.update() | actions that need to be executed every loop AT THE END are here. | actions that need to be executed every loop AT THE END are here. | [
"actions",
"that",
"need",
"to",
"be",
"executed",
"every",
"loop",
"AT",
"THE",
"END",
"are",
"here",
"."
] | def end_loop():
for i in gl.notifications:
i.update() | [
"def",
"end_loop",
"(",
")",
":",
"for",
"i",
"in",
"gl",
".",
"notifications",
":",
"i",
".",
"update",
"(",
")"
] | actions that need to be executed every loop AT THE END are here. | [
"actions",
"that",
"need",
"to",
"be",
"executed",
"every",
"loop",
"AT",
"THE",
"END",
"are",
"here",
"."
] | [
"\"\"\" actions that need to be executed every loop AT THE END are here. \"\"\"",
"# draw and update notifications"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | load | null | def load(self):
""" loads the frames as pygame.Surface. please use sparingly to keep RAM clear
"""
if not self.loaded:
for i in self.img_path:
self.img.append(pygame.transform.scale(pygame.image.load(i), (self.w, self.h)))
self.n_frames = len(self.img)
self.loaded = True | loads the frames as pygame.Surface. please use sparingly to keep RAM clear
| loads the frames as pygame.Surface. please use sparingly to keep RAM clear | [
"loads",
"the",
"frames",
"as",
"pygame",
".",
"Surface",
".",
"please",
"use",
"sparingly",
"to",
"keep",
"RAM",
"clear"
] | def load(self):
if not self.loaded:
for i in self.img_path:
self.img.append(pygame.transform.scale(pygame.image.load(i), (self.w, self.h)))
self.n_frames = len(self.img)
self.loaded = True | [
"def",
"load",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"loaded",
":",
"for",
"i",
"in",
"self",
".",
"img_path",
":",
"self",
".",
"img",
".",
"append",
"(",
"pygame",
".",
"transform",
".",
"scale",
"(",
"pygame",
".",
"image",
".",
"lo... | loads the frames as pygame.Surface. | [
"loads",
"the",
"frames",
"as",
"pygame",
".",
"Surface",
"."
] | [
"\"\"\" loads the frames as pygame.Surface. please use sparingly to keep RAM clear\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | start | <not_specific> | def start(self, forwards=True, repeat=False):
""" start video from the beginning
- forwards=True: set False, if you want play it backwards
- repeat=False: set True, to endlessly repeat the video
(can be stopped with stop())
"""
if self.loaded == False: # interrupt when images are not loaded
return
s... | start video from the beginning
- forwards=True: set False, if you want play it backwards
- repeat=False: set True, to endlessly repeat the video
(can be stopped with stop())
| start video from the beginning
forwards=True: set False, if you want play it backwards
repeat=False: set True, to endlessly repeat the video
(can be stopped with stop()) | [
"start",
"video",
"from",
"the",
"beginning",
"forwards",
"=",
"True",
":",
"set",
"False",
"if",
"you",
"want",
"play",
"it",
"backwards",
"repeat",
"=",
"False",
":",
"set",
"True",
"to",
"endlessly",
"repeat",
"the",
"video",
"(",
"can",
"be",
"stoppe... | def start(self, forwards=True, repeat=False):
if self.loaded == False:
return
self.play = True
self. interrupt = False
self.forwards = forwards
self.repeat = repeat
if forwards:
self.frame = 0
else:
self.frame = self.n_frames - 1 | [
"def",
"start",
"(",
"self",
",",
"forwards",
"=",
"True",
",",
"repeat",
"=",
"False",
")",
":",
"if",
"self",
".",
"loaded",
"==",
"False",
":",
"return",
"self",
".",
"play",
"=",
"True",
"self",
".",
"interrupt",
"=",
"False",
"self",
".",
"for... | start video from the beginning
forwards=True: set False, if you want play it backwards
repeat=False: set True, to endlessly repeat the video
(can be stopped with stop()) | [
"start",
"video",
"from",
"the",
"beginning",
"forwards",
"=",
"True",
":",
"set",
"False",
"if",
"you",
"want",
"play",
"it",
"backwards",
"repeat",
"=",
"False",
":",
"set",
"True",
"to",
"endlessly",
"repeat",
"the",
"video",
"(",
"can",
"be",
"stoppe... | [
"\"\"\"\tstart video from the beginning\n\t\t- forwards=True: set False, if you want play it backwards\n\t\t- repeat=False: set True, to endlessly repeat the video\n\t\t\t(can be stopped with stop())\n\t\t\"\"\"",
"# interrupt when images are not loaded",
"# start video",
"# un-pause video, just in case",
"... | [
{
"param": "self",
"type": null
},
{
"param": "forwards",
"type": null
},
{
"param": "repeat",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "forwards",
"type": null,
"docstring": null,
"docstring_tokens... |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | start | null | def start(self, repeat=False, frame_counter=0):
""" starts the video
- repeat=False: set True, to play repeatedly
"""
self.play = True
self.repeat = repeat
self.cap = cv2.VideoCapture(self.file)
if frame_counter != 0:
self.cap.set(1, frame_counter-1)
self.frames = self.cap.get(cv2.CAP_PROP_FRAME_COUN... | starts the video
- repeat=False: set True, to play repeatedly
| starts the video
repeat=False: set True, to play repeatedly | [
"starts",
"the",
"video",
"repeat",
"=",
"False",
":",
"set",
"True",
"to",
"play",
"repeatedly"
] | def start(self, repeat=False, frame_counter=0):
self.play = True
self.repeat = repeat
self.cap = cv2.VideoCapture(self.file)
if frame_counter != 0:
self.cap.set(1, frame_counter-1)
self.frames = self.cap.get(cv2.CAP_PROP_FRAME_COUNT)
self.frame_counter = frame_counter | [
"def",
"start",
"(",
"self",
",",
"repeat",
"=",
"False",
",",
"frame_counter",
"=",
"0",
")",
":",
"self",
".",
"play",
"=",
"True",
"self",
".",
"repeat",
"=",
"repeat",
"self",
".",
"cap",
"=",
"cv2",
".",
"VideoCapture",
"(",
"self",
".",
"file... | starts the video
repeat=False: set True, to play repeatedly | [
"starts",
"the",
"video",
"repeat",
"=",
"False",
":",
"set",
"True",
"to",
"play",
"repeatedly"
] | [
"\"\"\" starts the video\n\t\t- repeat=False: set True, to play repeatedly\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "repeat",
"type": null
},
{
"param": "frame_counter",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "repeat",
"type": null,
"docstring": null,
"docstring_tokens":... |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | draw | null | def draw(self):
""" draw the video
- screen: the pygame screen object
"""
if self.play:
ret, frame = self.cap.read()
self.frame_counter += 1
if(self.test_for_last_frame()):
if self.repeat:
self.frame_counter = 0
self.cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
else:
self.play = False
... | draw the video
- screen: the pygame screen object
| draw the video
screen: the pygame screen object | [
"draw",
"the",
"video",
"screen",
":",
"the",
"pygame",
"screen",
"object"
] | def draw(self):
if self.play:
ret, frame = self.cap.read()
self.frame_counter += 1
if(self.test_for_last_frame()):
if self.repeat:
self.frame_counter = 0
self.cap.set(cv2.CAP_PROP_POS_FRAMES, 0)
else:
self.play = False
frame = cv2.cvtColor(frame, cv2.COLOR_RGB2BGR)
frame = frame.... | [
"def",
"draw",
"(",
"self",
")",
":",
"if",
"self",
".",
"play",
":",
"ret",
",",
"frame",
"=",
"self",
".",
"cap",
".",
"read",
"(",
")",
"self",
".",
"frame_counter",
"+=",
"1",
"if",
"(",
"self",
".",
"test_for_last_frame",
"(",
")",
")",
":",... | draw the video
screen: the pygame screen object | [
"draw",
"the",
"video",
"screen",
":",
"the",
"pygame",
"screen",
"object"
] | [
"\"\"\" draw the video\n\t\t- screen: the pygame screen object\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | wrapline | <not_specific> | def wrapline(text, font, maxwidth):
""" this functions splits a string into a list, making lines that fit into a given width.
It can also deal with newlines by first splitting the text into paragraphs (sort of), then applieing the the
text-break to each paragraph and putting this into a final list.
"""
all_lin... | this functions splits a string into a list, making lines that fit into a given width.
It can also deal with newlines by first splitting the text into paragraphs (sort of), then applieing the the
text-break to each paragraph and putting this into a final list.
| this functions splits a string into a list, making lines that fit into a given width.
It can also deal with newlines by first splitting the text into paragraphs (sort of), then applieing the the
text-break to each paragraph and putting this into a final list. | [
"this",
"functions",
"splits",
"a",
"string",
"into",
"a",
"list",
"making",
"lines",
"that",
"fit",
"into",
"a",
"given",
"width",
".",
"It",
"can",
"also",
"deal",
"with",
"newlines",
"by",
"first",
"splitting",
"the",
"text",
"into",
"paragraphs",
"(",
... | def wrapline(text, font, maxwidth):
all_lines = []
ntext = text.split('\n')
for line in ntext:
done=0
wrapped=[]
while not done:
nl, done, stext=truncline(line, font, maxwidth)
wrapped.append(stext.strip())
line=line[nl:]
for wrapped_line in wrapped:
all_... | [
"def",
"wrapline",
"(",
"text",
",",
"font",
",",
"maxwidth",
")",
":",
"all_lines",
"=",
"[",
"]",
"ntext",
"=",
"text",
".",
"split",
"(",
"'\\n'",
")",
"for",
"line",
"in",
"ntext",
":",
"done",
"=",
"0",
"wrapped",
"=",
"[",
"]",
"while",
"no... | this functions splits a string into a list, making lines that fit into a given width. | [
"this",
"functions",
"splits",
"a",
"string",
"into",
"a",
"list",
"making",
"lines",
"that",
"fit",
"into",
"a",
"given",
"width",
"."
] | [
"\"\"\" this functions splits a string into a list, making lines that fit into a given width.\n\tIt can also deal with newlines by first splitting the text into paragraphs (sort of), then applieing the the \n\ttext-break to each paragraph and putting this into a final list.\n\t\"\"\"",
"# includes all lines, with... | [
{
"param": "text",
"type": null
},
{
"param": "font",
"type": null
},
{
"param": "maxwidth",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "text",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "font",
"type": null,
"docstring": null,
"docstring_tokens": [... |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | add_background | null | def add_background(self, path):
""" add a background image
- path: complete path to image file
"""
# the background is added as a Button object with only one image shown
self.background = Image(path, self.x, self.y, self.width, self.height)
self.show_background = True | add a background image
- path: complete path to image file
| add a background image
path: complete path to image file | [
"add",
"a",
"background",
"image",
"path",
":",
"complete",
"path",
"to",
"image",
"file"
] | def add_background(self, path):
self.background = Image(path, self.x, self.y, self.width, self.height)
self.show_background = True | [
"def",
"add_background",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"background",
"=",
"Image",
"(",
"path",
",",
"self",
".",
"x",
",",
"self",
".",
"y",
",",
"self",
".",
"width",
",",
"self",
".",
"height",
")",
"self",
".",
"show_backgrou... | add a background image
path: complete path to image file | [
"add",
"a",
"background",
"image",
"path",
":",
"complete",
"path",
"to",
"image",
"file"
] | [
"\"\"\" add a background image\n\t\t- path:\tcomplete path to image file\n\t\t\"\"\"",
"# the background is added as a Button object with only one image shown"
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [... |
5a46a76e1cfb348626f01fa53f3ccf1314a7e900 | zauberwild/paamestia | code/media_lib.py | [
"MIT"
] | Python | prompt_file | <not_specific> | def prompt_file():
"""Create a Tk file dialog and cleanup when finished"""
top = tkinter.Tk()
top.withdraw() # hide window
file_name = tkinter.filedialog.askopenfilename(parent=top)
top.destroy()
return file_name | Create a Tk file dialog and cleanup when finished | Create a Tk file dialog and cleanup when finished | [
"Create",
"a",
"Tk",
"file",
"dialog",
"and",
"cleanup",
"when",
"finished"
] | def prompt_file():
top = tkinter.Tk()
top.withdraw()
file_name = tkinter.filedialog.askopenfilename(parent=top)
top.destroy()
return file_name | [
"def",
"prompt_file",
"(",
")",
":",
"top",
"=",
"tkinter",
".",
"Tk",
"(",
")",
"top",
".",
"withdraw",
"(",
")",
"file_name",
"=",
"tkinter",
".",
"filedialog",
".",
"askopenfilename",
"(",
"parent",
"=",
"top",
")",
"top",
".",
"destroy",
"(",
")"... | Create a Tk file dialog and cleanup when finished | [
"Create",
"a",
"Tk",
"file",
"dialog",
"and",
"cleanup",
"when",
"finished"
] | [
"\"\"\"Create a Tk file dialog and cleanup when finished\"\"\"",
"# hide window"
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
5c1cd57311720b56342489b1a97817fe67e2789b | zauberwild/paamestia | code/io_lib.py | [
"MIT"
] | Python | update_input | null | def update_input():
""" update all / reads the input and stores it to be returned by read_input() """
global UP, DOWN, LEFT, RIGHT, NEXT, BACK, pygame_events
global up_state, down_state, left_state, right_state, next_state, back_state
global up_state_prev, down_state_prev, left_state_prev, right_state_prev, next_s... | update all / reads the input and stores it to be returned by read_input() | update all / reads the input and stores it to be returned by read_input() | [
"update",
"all",
"/",
"reads",
"the",
"input",
"and",
"stores",
"it",
"to",
"be",
"returned",
"by",
"read_input",
"()"
] | def update_input():
global UP, DOWN, LEFT, RIGHT, NEXT, BACK, pygame_events
global up_state, down_state, left_state, right_state, next_state, back_state
global up_state_prev, down_state_prev, left_state_prev, right_state_prev, next_state_prev, back_state_prev
if gl.os_is_linux:
global UP_BT, DOWN_BT, LEFT_BT, RIG... | [
"def",
"update_input",
"(",
")",
":",
"global",
"UP",
",",
"DOWN",
",",
"LEFT",
",",
"RIGHT",
",",
"NEXT",
",",
"BACK",
",",
"pygame_events",
"global",
"up_state",
",",
"down_state",
",",
"left_state",
",",
"right_state",
",",
"next_state",
",",
"back_stat... | update all / reads the input and stores it to be returned by read_input() | [
"update",
"all",
"/",
"reads",
"the",
"input",
"and",
"stores",
"it",
"to",
"be",
"returned",
"by",
"read_input",
"()"
] | [
"\"\"\" update all / reads the input and stores it to be returned by read_input() \"\"\"",
"# refresh previous states",
"# read current state",
"# for the raspberry pi / buttons on gpio",
"# read every input",
"# for keyboard",
"# if pressed down",
"# if released",
"# check for credits (activate by... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f170e0f49817cf4b82011d9006f17157dc99e050 | jgbrasier/am_205_project | DeepMod/train.py | [
"MIT"
] | Python | train | None | def train(model: DeepMoD,
data: torch.Tensor,
target: torch.Tensor,
optimizer,
sparsity_scheduler,
split: float = 0.8,
exp_ID: str = None,
log_dir: str = None,
max_iterations: int = 10000,
write_iterations: int = 25,
**c... | Trains the DeepMoD model. This function automatically splits the data set in a train and test set.
Args:
model (DeepMoD): A DeepMoD object.
data (torch.Tensor): Tensor of shape (n_samples x (n_spatial + 1)) containing the coordinates, first column should be the time coordinate.
target (to... | Trains the DeepMoD model. This function automatically splits the data set in a train and test set. | [
"Trains",
"the",
"DeepMoD",
"model",
".",
"This",
"function",
"automatically",
"splits",
"the",
"data",
"set",
"in",
"a",
"train",
"and",
"test",
"set",
"."
] | def train(model: DeepMoD,
data: torch.Tensor,
target: torch.Tensor,
optimizer,
sparsity_scheduler,
split: float = 0.8,
exp_ID: str = None,
log_dir: str = None,
max_iterations: int = 10000,
write_iterations: int = 25,
**c... | [
"def",
"train",
"(",
"model",
":",
"DeepMoD",
",",
"data",
":",
"torch",
".",
"Tensor",
",",
"target",
":",
"torch",
".",
"Tensor",
",",
"optimizer",
",",
"sparsity_scheduler",
",",
"split",
":",
"float",
"=",
"0.8",
",",
"exp_ID",
":",
"str",
"=",
"... | Trains the DeepMoD model. | [
"Trains",
"the",
"DeepMoD",
"model",
"."
] | [
"\"\"\"Trains the DeepMoD model. This function automatically splits the data set in a train and test set. \n Args:\n model (DeepMoD): A DeepMoD object.\n data (torch.Tensor): Tensor of shape (n_samples x (n_spatial + 1)) containing the coordinates, first column should be the time coordinate.\n ... | [
{
"param": "model",
"type": "DeepMoD"
},
{
"param": "data",
"type": "torch.Tensor"
},
{
"param": "target",
"type": "torch.Tensor"
},
{
"param": "optimizer",
"type": null
},
{
"param": "sparsity_scheduler",
"type": null
},
{
"param": "split",
"type"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "model",
"type": "DeepMoD",
"docstring": "A DeepMoD object.",
"docstring_tokens": [
"A",
"DeepMoD",
"object",
"."
],
"default": null,
"is_optional": false
},
{
"id... |
4b2d2a9876cfe7bdc5f2b6a48c147dde8469f110 | jgbrasier/am_205_project | DeepMod/lotka_volterra.py | [
"MIT"
] | Python | lotkavolterra | <not_specific> | def lotkavolterra(t, U):
""" Return the growth rate of predator and prey populations.
U: [x, y] population vector
"""
return np.array([ a*U[0] - b*U[0]*U[1] ,
-c*U[1] + d*b*U[0]*U[1] ]) | Return the growth rate of predator and prey populations.
U: [x, y] population vector
| Return the growth rate of predator and prey populations.
U: [x, y] population vector | [
"Return",
"the",
"growth",
"rate",
"of",
"predator",
"and",
"prey",
"populations",
".",
"U",
":",
"[",
"x",
"y",
"]",
"population",
"vector"
] | def lotkavolterra(t, U):
return np.array([ a*U[0] - b*U[0]*U[1] ,
-c*U[1] + d*b*U[0]*U[1] ]) | [
"def",
"lotkavolterra",
"(",
"t",
",",
"U",
")",
":",
"return",
"np",
".",
"array",
"(",
"[",
"a",
"*",
"U",
"[",
"0",
"]",
"-",
"b",
"*",
"U",
"[",
"0",
"]",
"*",
"U",
"[",
"1",
"]",
",",
"-",
"c",
"*",
"U",
"[",
"1",
"]",
"+",
"d",
... | Return the growth rate of predator and prey populations. | [
"Return",
"the",
"growth",
"rate",
"of",
"predator",
"and",
"prey",
"populations",
"."
] | [
"\"\"\" Return the growth rate of predator and prey populations. \n U: [x, y] population vector\n \"\"\""
] | [
{
"param": "t",
"type": null
},
{
"param": "U",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "t",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "U",
"type": null,
"docstring": null,
"docstring_tokens": [],
... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | atrous_identity_block_share | <not_specific> | def atrous_identity_block_share(input_tensor_list, kernel_size, filters, stage,
block, atrous_rate=(2, 2), use_bias=True):
'''The identity_block is the block that has no conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path... | The identity_block is the block that has no conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names... | The identity_block is the block that has no conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current bl... | [
"The",
"identity_block",
"is",
"the",
"block",
"that",
"has",
"no",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
... | def atrous_identity_block_share(input_tensor_list, kernel_size, filters, stage,
block, atrous_rate=(2, 2), use_bias=True):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
c... | [
"def",
"atrous_identity_block_share",
"(",
"input_tensor_list",
",",
"kernel_size",
",",
"filters",
",",
"stage",
",",
"block",
",",
"atrous_rate",
"=",
"(",
"2",
",",
"2",
")",
",",
"use_bias",
"=",
"True",
")",
":",
"nb_filter1",
",",
"nb_filter2",
",",
... | The identity_block is the block that has no conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current b... | [
"The",
"identity_block",
"is",
"the",
"block",
"that",
"has",
"no",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
... | [
"'''The identity_block is the block that has no conv layer at shortcut\n # Arguments\n kernel_size: defualt 3, the kernel size of middle conv layer at main path\n filters: list of integers, the nb_filters of 3 conv layer at main path\n stage: integer, current stage label, used for generating... | [
{
"param": "input_tensor_list",
"type": null
},
{
"param": "kernel_size",
"type": null
},
{
"param": "filters",
"type": null
},
{
"param": "stage",
"type": null
},
{
"param": "block",
"type": null
},
{
"param": "atrous_rate",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_tensor_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_size",
"type": null,
"docstring": null,
"... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | atrous_conv_block_share | <not_specific> | def atrous_conv_block_share(input_tensor_list, kernel_size, filters, stage,
block, strides=(1, 1), atrous_rate=(2, 2), use_bias=True):
'''conv_block is the block that has a conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
... | conv_block is the block that has a conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
... | conv_block is the block that has a conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current block label... | [
"conv_block",
"is",
"the",
"block",
"that",
"has",
"a",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
"of",
"integ... | def atrous_conv_block_share(input_tensor_list, kernel_size, filters, stage,
block, strides=(1, 1), atrous_rate=(2, 2), use_bias=True):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branc... | [
"def",
"atrous_conv_block_share",
"(",
"input_tensor_list",
",",
"kernel_size",
",",
"filters",
",",
"stage",
",",
"block",
",",
"strides",
"=",
"(",
"1",
",",
"1",
")",
",",
"atrous_rate",
"=",
"(",
"2",
",",
"2",
")",
",",
"use_bias",
"=",
"True",
")... | conv_block is the block that has a conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current block labe... | [
"conv_block",
"is",
"the",
"block",
"that",
"has",
"a",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
"of",
"integ... | [
"'''conv_block is the block that has a conv layer at shortcut\n # Arguments\n kernel_size: defualt 3, the kernel size of middle conv layer at main path\n filters: list of integers, the nb_filters of 3 conv layer at main path\n stage: integer, current stage label, used for generating layer na... | [
{
"param": "input_tensor_list",
"type": null
},
{
"param": "kernel_size",
"type": null
},
{
"param": "filters",
"type": null
},
{
"param": "stage",
"type": null
},
{
"param": "block",
"type": null
},
{
"param": "strides",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_tensor_list",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_size",
"type": null,
"docstring": null,
"... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | deeplab_resnet_share | <not_specific> | def deeplab_resnet_share(img_inputs, architecture):
"""
Build the architecture of resnet-101.
img_inputs: a list of input image
"""
# Stage 1
conv1 = KL.Conv2D(64, (7, 7), strides=(2, 2),
name='conv1', use_bias=False)
bn_conv1 = BatchNorm(axis=-1, name='bn_conv1')
c1 = []
f... |
Build the architecture of resnet-101.
img_inputs: a list of input image
| Build the architecture of resnet-101.
img_inputs: a list of input image | [
"Build",
"the",
"architecture",
"of",
"resnet",
"-",
"101",
".",
"img_inputs",
":",
"a",
"list",
"of",
"input",
"image"
] | def deeplab_resnet_share(img_inputs, architecture):
conv1 = KL.Conv2D(64, (7, 7), strides=(2, 2),
name='conv1', use_bias=False)
bn_conv1 = BatchNorm(axis=-1, name='bn_conv1')
c1 = []
for img_input in img_inputs:
x = KL.ZeroPadding2D((3, 3))(img_input)
x = conv1(x)
x = bn... | [
"def",
"deeplab_resnet_share",
"(",
"img_inputs",
",",
"architecture",
")",
":",
"conv1",
"=",
"KL",
".",
"Conv2D",
"(",
"64",
",",
"(",
"7",
",",
"7",
")",
",",
"strides",
"=",
"(",
"2",
",",
"2",
")",
",",
"name",
"=",
"'conv1'",
",",
"use_bias",... | Build the architecture of resnet-101. | [
"Build",
"the",
"architecture",
"of",
"resnet",
"-",
"101",
"."
] | [
"\"\"\"\n Build the architecture of resnet-101.\n img_inputs: a list of input image\n \"\"\"",
"# Stage 1",
"# Stage 2",
"# Stage 3",
"# Stage 4",
"# Stage 5"
] | [
{
"param": "img_inputs",
"type": null
},
{
"param": "architecture",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "img_inputs",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "architecture",
"type": null,
"docstring": null,
"docstr... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | load_image_gt | <not_specific> | def load_image_gt(dataset, config, image_id, augment=False,
use_mini_mask=False):
"""Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If F... | Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If False, returns full-size masks that are the same height
and width as the original image. These can b... | Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If False, returns full-size masks that are the same height
and width as the original image. These can be big, for example
1024x1... | [
"Load",
"and",
"return",
"ground",
"truth",
"data",
"for",
"an",
"image",
"(",
"image",
"mask",
"bounding",
"boxes",
")",
".",
"augment",
":",
"If",
"true",
"apply",
"random",
"image",
"augmentation",
".",
"Currently",
"only",
"horizontal",
"flipping",
"is",... | def load_image_gt(dataset, config, image_id, augment=False,
use_mini_mask=False):
image = dataset.load_image(image_id)
keys, identity_ind = dataset.load_keys(image_id, config.KEY_RANGE_L, 3)
mask, class_ids = dataset.load_mask(image_id)
part = dataset.load_part(image_id)
part_rev ... | [
"def",
"load_image_gt",
"(",
"dataset",
",",
"config",
",",
"image_id",
",",
"augment",
"=",
"False",
",",
"use_mini_mask",
"=",
"False",
")",
":",
"image",
"=",
"dataset",
".",
"load_image",
"(",
"image_id",
")",
"keys",
",",
"identity_ind",
"=",
"dataset... | Load and return ground truth data for an image (image, mask, bounding boxes). | [
"Load",
"and",
"return",
"ground",
"truth",
"data",
"for",
"an",
"image",
"(",
"image",
"mask",
"bounding",
"boxes",
")",
"."
] | [
"\"\"\"Load and return ground truth data for an image (image, mask, bounding boxes).\n\n augment: If true, apply random image augmentation. Currently, only\n horizontal flipping is offered.\n use_mini_mask: If False, returns full-size masks that are the same height\n and width as the original im... | [
{
"param": "dataset",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "image_id",
"type": null
},
{
"param": "augment",
"type": null
},
{
"param": "use_mini_mask",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | find_last | <not_specific> | def find_last(self):
"""Finds the last checkpoint file of the last trained model in the
model directory.
Returns:
log_dir: The directory where events and weights are saved
checkpoint_path: the path to the last checkpoint file
"""
# Get directory names. Eac... | Finds the last checkpoint file of the last trained model in the
model directory.
Returns:
log_dir: The directory where events and weights are saved
checkpoint_path: the path to the last checkpoint file
| Finds the last checkpoint file of the last trained model in the
model directory. | [
"Finds",
"the",
"last",
"checkpoint",
"file",
"of",
"the",
"last",
"trained",
"model",
"in",
"the",
"model",
"directory",
"."
] | def find_last(self):
dir_names = next(os.walk(self.model_dir))[1]
key = self.config.NAME.lower()
dir_names = filter(lambda f: f.startswith(key), dir_names)
dir_names = sorted(dir_names)
if not dir_names:
return None, None
dir_name = os.path.join(self.model_dir... | [
"def",
"find_last",
"(",
"self",
")",
":",
"dir_names",
"=",
"next",
"(",
"os",
".",
"walk",
"(",
"self",
".",
"model_dir",
")",
")",
"[",
"1",
"]",
"key",
"=",
"self",
".",
"config",
".",
"NAME",
".",
"lower",
"(",
")",
"dir_names",
"=",
"filter... | Finds the last checkpoint file of the last trained model in the
model directory. | [
"Finds",
"the",
"last",
"checkpoint",
"file",
"of",
"the",
"last",
"trained",
"model",
"in",
"the",
"model",
"directory",
"."
] | [
"\"\"\"Finds the last checkpoint file of the last trained model in the\n model directory.\n Returns:\n log_dir: The directory where events and weights are saved\n checkpoint_path: the path to the last checkpoint file\n \"\"\"",
"# Get directory names. Each directory corr... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "The directory where events and weights are saved\ncheckpoint_path: the path to the last checkpoint file",
"docstring_tokens": [
"The",
"directory",
"where",
"events",
"and",
"weights",
"are",
"saved",
... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | load_weights | null | def load_weights(self, filepath, by_name=False, exclude=None):
"""Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce
"""
import h5py
... | Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce
| Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce | [
"Modified",
"version",
"of",
"the",
"correspoding",
"Keras",
"function",
"with",
"the",
"addition",
"of",
"multi",
"-",
"GPU",
"support",
"and",
"the",
"ability",
"to",
"exclude",
"some",
"layers",
"from",
"loading",
".",
"exlude",
":",
"list",
"of",
"layer"... | def load_weights(self, filepath, by_name=False, exclude=None):
import h5py
from keras.engine import topology
if exclude:
by_name = True
if h5py is None:
raise ImportError('`load_weights` requires h5py.')
f = h5py.File(filepath, mode='r')
if 'layer_... | [
"def",
"load_weights",
"(",
"self",
",",
"filepath",
",",
"by_name",
"=",
"False",
",",
"exclude",
"=",
"None",
")",
":",
"import",
"h5py",
"from",
"keras",
".",
"engine",
"import",
"topology",
"if",
"exclude",
":",
"by_name",
"=",
"True",
"if",
"h5py",
... | Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading. | [
"Modified",
"version",
"of",
"the",
"correspoding",
"Keras",
"function",
"with",
"the",
"addition",
"of",
"multi",
"-",
"GPU",
"support",
"and",
"the",
"ability",
"to",
"exclude",
"some",
"layers",
"from",
"loading",
"."
] | [
"\"\"\"Modified version of the correspoding Keras function with\n the addition of multi-GPU support and the ability to exclude\n some layers from loading.\n exlude: list of layer names to excluce\n \"\"\"",
"# In multi-GPU training, we wrap the model. Get layers",
"# of the inner mod... | [
{
"param": "self",
"type": null
},
{
"param": "filepath",
"type": null
},
{
"param": "by_name",
"type": null
},
{
"param": "exclude",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | compile | null | def compile(self, learning_rate, momentum):
"""Gets the model ready for training. Adds losses, regularization, and
metrics. Then calls the Keras compile() function.
"""
# Optimizer object
optimizer = keras.optimizers.SGD(lr=learning_rate, momentum=momentum,
... | Gets the model ready for training. Adds losses, regularization, and
metrics. Then calls the Keras compile() function.
| Gets the model ready for training. Adds losses, regularization, and
metrics. Then calls the Keras compile() function. | [
"Gets",
"the",
"model",
"ready",
"for",
"training",
".",
"Adds",
"losses",
"regularization",
"and",
"metrics",
".",
"Then",
"calls",
"the",
"Keras",
"compile",
"()",
"function",
"."
] | def compile(self, learning_rate, momentum):
optimizer = keras.optimizers.SGD(lr=learning_rate, momentum=momentum,
clipnorm=5.0)
self.keras_model._losses = []
self.keras_model._per_input_losses = {}
loss_names = ["rpn_class_loss", "rpn_bbox_loss",
... | [
"def",
"compile",
"(",
"self",
",",
"learning_rate",
",",
"momentum",
")",
":",
"optimizer",
"=",
"keras",
".",
"optimizers",
".",
"SGD",
"(",
"lr",
"=",
"learning_rate",
",",
"momentum",
"=",
"momentum",
",",
"clipnorm",
"=",
"5.0",
")",
"self",
".",
... | Gets the model ready for training. | [
"Gets",
"the",
"model",
"ready",
"for",
"training",
"."
] | [
"\"\"\"Gets the model ready for training. Adds losses, regularization, and\n metrics. Then calls the Keras compile() function.\n \"\"\"",
"# Optimizer object",
"# Add Losses",
"# First, clear previously set losses to avoid duplication",
"# Add L2 Regularization",
"# Compile",
"# Add metric... | [
{
"param": "self",
"type": null
},
{
"param": "learning_rate",
"type": null
},
{
"param": "momentum",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "learning_rate",
"type": null,
"docstring": null,
"docstring_t... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | train | null | def train(self, train_dataset, val_dataset, learning_rate, epochs, layers, period):
"""Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epoch... | Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epochs
are considered to be done alreay, so this actually determines
... | Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epochs
are considered to be done alreay, so this actually determines
the epochs to train in total rather than in this partic... | [
"Train",
"the",
"model",
".",
"train_dataset",
"val_dataset",
":",
"Training",
"and",
"validation",
"Dataset",
"objects",
".",
"learning_rate",
":",
"The",
"learning",
"rate",
"to",
"train",
"with",
"epochs",
":",
"Number",
"of",
"training",
"epochs",
".",
"No... | def train(self, train_dataset, val_dataset, learning_rate, epochs, layers, period):
assert self.mode == "training", "Create model in training mode."
layer_regex = {
"mask_heads": r"(mrcnn\_bbox\_.*)|(rpn\_.*)|(mrcnn\_class\_.*)|(mrcnn\_mask\_.*)|(mrcnn\_share\_.*)",
"heads": r"(m... | [
"def",
"train",
"(",
"self",
",",
"train_dataset",
",",
"val_dataset",
",",
"learning_rate",
",",
"epochs",
",",
"layers",
",",
"period",
")",
":",
"assert",
"self",
".",
"mode",
"==",
"\"training\"",
",",
"\"Create model in training mode.\"",
"layer_regex",
"="... | Train the model. | [
"Train",
"the",
"model",
"."
] | [
"\"\"\"Train the model.\n train_dataset, val_dataset: Training and validation Dataset objects.\n learning_rate: The learning rate to train with\n epochs: Number of training epochs. Note that previous training epochs\n are considered to be done alreay, so this actually determines\... | [
{
"param": "self",
"type": null
},
{
"param": "train_dataset",
"type": null
},
{
"param": "val_dataset",
"type": null
},
{
"param": "learning_rate",
"type": null
},
{
"param": "epochs",
"type": null
},
{
"param": "layers",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "train_dataset",
"type": null,
"docstring": null,
"docstring_t... |
948187880ec0337c07d27f0fca8ac6067b36c46f | HCPLab-SYSU/ATEN | aten_model.py | [
"MIT"
] | Python | detect | <not_specific> | def detect(self, images, key1s, key2s, key3s, identity_ind):
"""Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. The dict contains:
rois: [N, (y1, x1, y2, x2)] detection bounding boxes
class_ids: [... | Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. The dict contains:
rois: [N, (y1, x1, y2, x2)] detection bounding boxes
class_ids: [N] int class IDs
scores: [N] float probability scores for the cl... | Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. | [
"Runs",
"the",
"detection",
"pipeline",
".",
"images",
":",
"List",
"of",
"images",
"potentially",
"of",
"different",
"sizes",
".",
"Returns",
"a",
"list",
"of",
"dicts",
"one",
"dict",
"per",
"image",
"."
] | def detect(self, images, key1s, key2s, key3s, identity_ind):
assert len(images) == len(identity_ind
) == self.config.BATCH_SIZE, "len(images) must be equal to BATCH_SIZE"
molded_images, image_metas, windows = self.mold_inputs(images)
molded_key1s, _, _ = self.mold_inputs(key1s)
... | [
"def",
"detect",
"(",
"self",
",",
"images",
",",
"key1s",
",",
"key2s",
",",
"key3s",
",",
"identity_ind",
")",
":",
"assert",
"len",
"(",
"images",
")",
"==",
"len",
"(",
"identity_ind",
")",
"==",
"self",
".",
"config",
".",
"BATCH_SIZE",
",",
"\"... | Runs the detection pipeline. | [
"Runs",
"the",
"detection",
"pipeline",
"."
] | [
"\"\"\"Runs the detection pipeline.\n\n images: List of images, potentially of different sizes.\n\n Returns a list of dicts, one dict per image. The dict contains:\n rois: [N, (y1, x1, y2, x2)] detection bounding boxes\n class_ids: [N] int class IDs\n scores: [N] float probability... | [
{
"param": "self",
"type": null
},
{
"param": "images",
"type": null
},
{
"param": "key1s",
"type": null
},
{
"param": "key2s",
"type": null
},
{
"param": "key3s",
"type": null
},
{
"param": "identity_ind",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "images",
"type": null,
"docstring": null,
"docstring_tokens":... |
33ac880c22831ff28faee4abd8ed3ca94eb41f5f | HCPLab-SYSU/ATEN | visualize.py | [
"MIT"
] | Python | apply_parsing | <not_specific> | def apply_parsing(image, part, color_map, alpha=0.7):
"""Apply the given parsing to the image.
"""
assert image.shape[0] == part.shape[0] and image.shape[1] == part.shape[1]
coordinates = np.where(part > 0)
for i in range(len(coordinates[0])):
image[coordinates[0][i], coordinates[1][i], :] =... | Apply the given parsing to the image.
| Apply the given parsing to the image. | [
"Apply",
"the",
"given",
"parsing",
"to",
"the",
"image",
"."
] | def apply_parsing(image, part, color_map, alpha=0.7):
assert image.shape[0] == part.shape[0] and image.shape[1] == part.shape[1]
coordinates = np.where(part > 0)
for i in range(len(coordinates[0])):
image[coordinates[0][i], coordinates[1][i], :] = color_map[part[coordinates[0][i], coordinates[1][i]]... | [
"def",
"apply_parsing",
"(",
"image",
",",
"part",
",",
"color_map",
",",
"alpha",
"=",
"0.7",
")",
":",
"assert",
"image",
".",
"shape",
"[",
"0",
"]",
"==",
"part",
".",
"shape",
"[",
"0",
"]",
"and",
"image",
".",
"shape",
"[",
"1",
"]",
"==",... | Apply the given parsing to the image. | [
"Apply",
"the",
"given",
"parsing",
"to",
"the",
"image",
"."
] | [
"\"\"\"Apply the given parsing to the image.\n \"\"\""
] | [
{
"param": "image",
"type": null
},
{
"param": "part",
"type": null
},
{
"param": "color_map",
"type": null
},
{
"param": "alpha",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "image",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "part",
"type": null,
"docstring": null,
"docstring_tokens": ... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | atrous_identity_block | <not_specific> | def atrous_identity_block(input_tensor, kernel_size, filters, stage,
block, atrous_rate=(2, 2), use_bias=True, roi_res=False):
'''The identity_block is the block that has no conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main ... | The identity_block is the block that has no conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names... | The identity_block is the block that has no conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current bl... | [
"The",
"identity_block",
"is",
"the",
"block",
"that",
"has",
"no",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
... | def atrous_identity_block(input_tensor, kernel_size, filters, stage,
block, atrous_rate=(2, 2), use_bias=True, roi_res=False):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_branch'
... | [
"def",
"atrous_identity_block",
"(",
"input_tensor",
",",
"kernel_size",
",",
"filters",
",",
"stage",
",",
"block",
",",
"atrous_rate",
"=",
"(",
"2",
",",
"2",
")",
",",
"use_bias",
"=",
"True",
",",
"roi_res",
"=",
"False",
")",
":",
"nb_filter1",
","... | The identity_block is the block that has no conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current b... | [
"The",
"identity_block",
"is",
"the",
"block",
"that",
"has",
"no",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
... | [
"'''The identity_block is the block that has no conv layer at shortcut\n # Arguments\n kernel_size: defualt 3, the kernel size of middle conv layer at main path\n filters: list of integers, the nb_filters of 3 conv layer at main path\n stage: integer, current stage label, used for generating... | [
{
"param": "input_tensor",
"type": null
},
{
"param": "kernel_size",
"type": null
},
{
"param": "filters",
"type": null
},
{
"param": "stage",
"type": null
},
{
"param": "block",
"type": null
},
{
"param": "atrous_rate",
"type": null
},
{
"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_tensor",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_size",
"type": null,
"docstring": null,
"docst... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | atrous_conv_block | <not_specific> | def atrous_conv_block(input_tensor, kernel_size, filters, stage,
block, strides=(1, 1), atrous_rate=(2, 2), use_bias=True, roi_res=False):
'''conv_block is the block that has a conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main p... | conv_block is the block that has a conv layer at shortcut
# Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
... | conv_block is the block that has a conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current block label... | [
"conv_block",
"is",
"the",
"block",
"that",
"has",
"a",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
"of",
"integ... | def atrous_conv_block(input_tensor, kernel_size, filters, stage,
block, strides=(1, 1), atrous_rate=(2, 2), use_bias=True, roi_res=False):
nb_filter1, nb_filter2, nb_filter3 = filters
conv_name_base = 'res' + str(stage) + block + '_branch'
bn_name_base = 'bn' + str(stage) + block + '_b... | [
"def",
"atrous_conv_block",
"(",
"input_tensor",
",",
"kernel_size",
",",
"filters",
",",
"stage",
",",
"block",
",",
"strides",
"=",
"(",
"1",
",",
"1",
")",
",",
"atrous_rate",
"=",
"(",
"2",
",",
"2",
")",
",",
"use_bias",
"=",
"True",
",",
"roi_r... | conv_block is the block that has a conv layer at shortcut
Arguments
kernel_size: defualt 3, the kernel size of middle conv layer at main path
filters: list of integers, the nb_filters of 3 conv layer at main path
stage: integer, current stage label, used for generating layer names
block: 'a','b'..., current block labe... | [
"conv_block",
"is",
"the",
"block",
"that",
"has",
"a",
"conv",
"layer",
"at",
"shortcut",
"Arguments",
"kernel_size",
":",
"defualt",
"3",
"the",
"kernel",
"size",
"of",
"middle",
"conv",
"layer",
"at",
"main",
"path",
"filters",
":",
"list",
"of",
"integ... | [
"'''conv_block is the block that has a conv layer at shortcut\n # Arguments\n kernel_size: defualt 3, the kernel size of middle conv layer at main path\n filters: list of integers, the nb_filters of 3 conv layer at main path\n stage: integer, current stage label, used for generating layer na... | [
{
"param": "input_tensor",
"type": null
},
{
"param": "kernel_size",
"type": null
},
{
"param": "filters",
"type": null
},
{
"param": "stage",
"type": null
},
{
"param": "block",
"type": null
},
{
"param": "strides",
"type": null
},
{
"para... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_tensor",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "kernel_size",
"type": null,
"docstring": null,
"docst... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | roi_crop_and_resize | <not_specific> | def roi_crop_and_resize(image, boxes, box_ind, crop_shape):
"""
Better-aligned version of tf.image.crop_and_resize, following our definition of floating point boxes.
Args:
image: BHWC
boxes: nx4, y1x1y2x2 normalized coor
box_ind: (n,)
crop_size (int,int):
Returns:
... |
Better-aligned version of tf.image.crop_and_resize, following our definition of floating point boxes.
Args:
image: BHWC
boxes: nx4, y1x1y2x2 normalized coor
box_ind: (n,)
crop_size (int,int):
Returns:
n,C,size,size
| Better-aligned version of tf.image.crop_and_resize, following our definition of floating point boxes. | [
"Better",
"-",
"aligned",
"version",
"of",
"tf",
".",
"image",
".",
"crop_and_resize",
"following",
"our",
"definition",
"of",
"floating",
"point",
"boxes",
"."
] | def roi_crop_and_resize(image, boxes, box_ind, crop_shape):
def transform_fpcoor_for_tf(boxes, image_shape, crop_shape):
y0, x0, y1, x1 = tf.split(boxes, 4, axis=1)
spacing_w = (x1 - x0) / tf.to_float(crop_shape[1])
spacing_h = (y1 - y0) / tf.to_float(crop_shape[0])
nx0 = (x0 + spaci... | [
"def",
"roi_crop_and_resize",
"(",
"image",
",",
"boxes",
",",
"box_ind",
",",
"crop_shape",
")",
":",
"def",
"transform_fpcoor_for_tf",
"(",
"boxes",
",",
"image_shape",
",",
"crop_shape",
")",
":",
"\"\"\"\n The way tf.image.crop_and_resize works (with normalized... | Better-aligned version of tf.image.crop_and_resize, following our definition of floating point boxes. | [
"Better",
"-",
"aligned",
"version",
"of",
"tf",
".",
"image",
".",
"crop_and_resize",
"following",
"our",
"definition",
"of",
"floating",
"point",
"boxes",
"."
] | [
"\"\"\"\n Better-aligned version of tf.image.crop_and_resize, following our definition of floating point boxes.\n\n Args:\n image: BHWC\n boxes: nx4, y1x1y2x2 normalized coor\n box_ind: (n,)\n crop_size (int,int):\n Returns:\n n,C,size,size\n \"\"\"",
"\"\"\"\n ... | [
{
"param": "image",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "box_ind",
"type": null
},
{
"param": "crop_shape",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "image",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | load_image_gt | <not_specific> | def load_image_gt(dataset, config, image_id, augment=False,
use_mini_mask=False):
"""Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If F... | Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If False, returns full-size masks that are the same height
and width as the original image. These can b... | Load and return ground truth data for an image (image, mask, bounding boxes).
augment: If true, apply random image augmentation. Currently, only
horizontal flipping is offered.
use_mini_mask: If False, returns full-size masks that are the same height
and width as the original image. These can be big, for example
1024x1... | [
"Load",
"and",
"return",
"ground",
"truth",
"data",
"for",
"an",
"image",
"(",
"image",
"mask",
"bounding",
"boxes",
")",
".",
"augment",
":",
"If",
"true",
"apply",
"random",
"image",
"augmentation",
".",
"Currently",
"only",
"horizontal",
"flipping",
"is",... | def load_image_gt(dataset, config, image_id, augment=False,
use_mini_mask=False):
image = dataset.load_image(image_id)
mask, class_ids = dataset.load_mask(image_id)
part = dataset.load_part(image_id)
part_rev = dataset.load_reverse_part(image_id)
shape = image.shape
image, wind... | [
"def",
"load_image_gt",
"(",
"dataset",
",",
"config",
",",
"image_id",
",",
"augment",
"=",
"False",
",",
"use_mini_mask",
"=",
"False",
")",
":",
"image",
"=",
"dataset",
".",
"load_image",
"(",
"image_id",
")",
"mask",
",",
"class_ids",
"=",
"dataset",
... | Load and return ground truth data for an image (image, mask, bounding boxes). | [
"Load",
"and",
"return",
"ground",
"truth",
"data",
"for",
"an",
"image",
"(",
"image",
"mask",
"bounding",
"boxes",
")",
"."
] | [
"\"\"\"Load and return ground truth data for an image (image, mask, bounding boxes).\n\n augment: If true, apply random image augmentation. Currently, only\n horizontal flipping is offered.\n use_mini_mask: If False, returns full-size masks that are the same height\n and width as the original im... | [
{
"param": "dataset",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "image_id",
"type": null
},
{
"param": "augment",
"type": null
},
{
"param": "use_mini_mask",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | build_rpn_targets | <not_specific> | def build_rpn_targets(image_shape, anchors, gt_class_ids, gt_boxes, config):
"""Given the anchors and GT boxes, compute overlaps and identify positive
anchors and deltas to refine them to match their corresponding GT boxes.
anchors: [num_anchors, (y1, x1, y2, x2)]
gt_class_ids: [num_gt_boxes] Integer c... | Given the anchors and GT boxes, compute overlaps and identify positive
anchors and deltas to refine them to match their corresponding GT boxes.
anchors: [num_anchors, (y1, x1, y2, x2)]
gt_class_ids: [num_gt_boxes] Integer class IDs.
gt_boxes: [num_gt_boxes, (y1, x1, y2, x2)]
Returns:
rpn_match... | Given the anchors and GT boxes, compute overlaps and identify positive
anchors and deltas to refine them to match their corresponding GT boxes.
| [
"Given",
"the",
"anchors",
"and",
"GT",
"boxes",
"compute",
"overlaps",
"and",
"identify",
"positive",
"anchors",
"and",
"deltas",
"to",
"refine",
"them",
"to",
"match",
"their",
"corresponding",
"GT",
"boxes",
"."
] | def build_rpn_targets(image_shape, anchors, gt_class_ids, gt_boxes, config):
rpn_match = np.zeros([anchors.shape[0]], dtype=np.int32)
rpn_bbox = np.zeros((config.RPN_TRAIN_ANCHORS_PER_IMAGE, 4))
overlaps = utils.compute_overlaps(anchors, gt_boxes)
1. Set negative anchors first. They get overwritten bel... | [
"def",
"build_rpn_targets",
"(",
"image_shape",
",",
"anchors",
",",
"gt_class_ids",
",",
"gt_boxes",
",",
"config",
")",
":",
"rpn_match",
"=",
"np",
".",
"zeros",
"(",
"[",
"anchors",
".",
"shape",
"[",
"0",
"]",
"]",
",",
"dtype",
"=",
"np",
".",
... | Given the anchors and GT boxes, compute overlaps and identify positive
anchors and deltas to refine them to match their corresponding GT boxes. | [
"Given",
"the",
"anchors",
"and",
"GT",
"boxes",
"compute",
"overlaps",
"and",
"identify",
"positive",
"anchors",
"and",
"deltas",
"to",
"refine",
"them",
"to",
"match",
"their",
"corresponding",
"GT",
"boxes",
"."
] | [
"\"\"\"Given the anchors and GT boxes, compute overlaps and identify positive\n anchors and deltas to refine them to match their corresponding GT boxes.\n\n anchors: [num_anchors, (y1, x1, y2, x2)]\n gt_class_ids: [num_gt_boxes] Integer class IDs.\n gt_boxes: [num_gt_boxes, (y1, x1, y2, x2)]\n\n Retu... | [
{
"param": "image_shape",
"type": null
},
{
"param": "anchors",
"type": null
},
{
"param": "gt_class_ids",
"type": null
},
{
"param": "gt_boxes",
"type": null
},
{
"param": "config",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "image_shape",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": ... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | data_generator | null | def data_generator(dataset, config, shuffle=True, augment=True, random_rois=0,
batch_size=1, detection_targets=False):
"""A generator that returns images and corresponding target class ids,
bounding box deltas, and masks.
dataset: The Dataset object to pick data from
config: The mode... | A generator that returns images and corresponding target class ids,
bounding box deltas, and masks.
dataset: The Dataset object to pick data from
config: The model config object
shuffle: If True, shuffles the samples before every epoch
augment: If True, applies image augmentation to images (current... | A generator that returns images and corresponding target class ids,
bounding box deltas, and masks.
The Dataset object to pick data from
config: The model config object
shuffle: If True, shuffles the samples before every epoch
augment: If True, applies image augmentation to images (currently only
horizontal flips are ... | [
"A",
"generator",
"that",
"returns",
"images",
"and",
"corresponding",
"target",
"class",
"ids",
"bounding",
"box",
"deltas",
"and",
"masks",
".",
"The",
"Dataset",
"object",
"to",
"pick",
"data",
"from",
"config",
":",
"The",
"model",
"config",
"object",
"s... | def data_generator(dataset, config, shuffle=True, augment=True, random_rois=0,
batch_size=1, detection_targets=False):
b = 0
image_index = -1
image_ids = np.copy(dataset.image_ids)
error_count = 0
anchors = utils.generate_anchors(config.RPN_ANCHOR_SCALES,
... | [
"def",
"data_generator",
"(",
"dataset",
",",
"config",
",",
"shuffle",
"=",
"True",
",",
"augment",
"=",
"True",
",",
"random_rois",
"=",
"0",
",",
"batch_size",
"=",
"1",
",",
"detection_targets",
"=",
"False",
")",
":",
"b",
"=",
"0",
"image_index",
... | A generator that returns images and corresponding target class ids,
bounding box deltas, and masks. | [
"A",
"generator",
"that",
"returns",
"images",
"and",
"corresponding",
"target",
"class",
"ids",
"bounding",
"box",
"deltas",
"and",
"masks",
"."
] | [
"\"\"\"A generator that returns images and corresponding target class ids,\n bounding box deltas, and masks.\n\n dataset: The Dataset object to pick data from\n config: The model config object\n shuffle: If True, shuffles the samples before every epoch\n augment: If True, applies image augmentation t... | [
{
"param": "dataset",
"type": null
},
{
"param": "config",
"type": null
},
{
"param": "shuffle",
"type": null
},
{
"param": "augment",
"type": null
},
{
"param": "random_rois",
"type": null
},
{
"param": "batch_size",
"type": null
},
{
"par... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "config",
"type": null,
"docstring": null,
"docstring_token... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | find_last | <not_specific> | def find_last(self):
"""Finds the last checkpoint file of the last trained model in the
model directory.
Returns:
log_dir: The directory where events and weights are saved
checkpoint_path: the path to the last checkpoint file
"""
# Get directory names. Eac... | Finds the last checkpoint file of the last trained model in the
model directory.
Returns:
log_dir: The directory where events and weights are saved
checkpoint_path: the path to the last checkpoint file
| Finds the last checkpoint file of the last trained model in the
model directory. | [
"Finds",
"the",
"last",
"checkpoint",
"file",
"of",
"the",
"last",
"trained",
"model",
"in",
"the",
"model",
"directory",
"."
] | def find_last(self):
dir_names = next(os.walk(self.model_dir))[1]
key = self.config.NAME.lower()
dir_names = filter(lambda f: f.startswith(key), dir_names)
dir_names = sorted(dir_names)
if not dir_names:
return None, None
dir_name = os.path.join(self.model_dir... | [
"def",
"find_last",
"(",
"self",
")",
":",
"dir_names",
"=",
"next",
"(",
"os",
".",
"walk",
"(",
"self",
".",
"model_dir",
")",
")",
"[",
"1",
"]",
"key",
"=",
"self",
".",
"config",
".",
"NAME",
".",
"lower",
"(",
")",
"dir_names",
"=",
"filter... | Finds the last checkpoint file of the last trained model in the
model directory. | [
"Finds",
"the",
"last",
"checkpoint",
"file",
"of",
"the",
"last",
"trained",
"model",
"in",
"the",
"model",
"directory",
"."
] | [
"\"\"\"Finds the last checkpoint file of the last trained model in the\n model directory.\n Returns:\n log_dir: The directory where events and weights are saved\n checkpoint_path: the path to the last checkpoint file\n \"\"\"",
"# Get directory names. Each directory corr... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "The directory where events and weights are saved\ncheckpoint_path: the path to the last checkpoint file",
"docstring_tokens": [
"The",
"directory",
"where",
"events",
"and",
"weights",
"are",
"saved",
... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | load_weights | null | def load_weights(self, filepath, by_name=False, exclude_pattern=None):
"""Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce
"""
import h5py... | Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce
| Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading.
exlude: list of layer names to excluce | [
"Modified",
"version",
"of",
"the",
"correspoding",
"Keras",
"function",
"with",
"the",
"addition",
"of",
"multi",
"-",
"GPU",
"support",
"and",
"the",
"ability",
"to",
"exclude",
"some",
"layers",
"from",
"loading",
".",
"exlude",
":",
"list",
"of",
"layer"... | def load_weights(self, filepath, by_name=False, exclude_pattern=None):
import h5py
from keras.engine import topology
if exclude_pattern:
by_name = True
if h5py is None:
raise ImportError('`load_weights` requires h5py.')
f = h5py.File(filepath, mode='r')
... | [
"def",
"load_weights",
"(",
"self",
",",
"filepath",
",",
"by_name",
"=",
"False",
",",
"exclude_pattern",
"=",
"None",
")",
":",
"import",
"h5py",
"from",
"keras",
".",
"engine",
"import",
"topology",
"if",
"exclude_pattern",
":",
"by_name",
"=",
"True",
... | Modified version of the correspoding Keras function with
the addition of multi-GPU support and the ability to exclude
some layers from loading. | [
"Modified",
"version",
"of",
"the",
"correspoding",
"Keras",
"function",
"with",
"the",
"addition",
"of",
"multi",
"-",
"GPU",
"support",
"and",
"the",
"ability",
"to",
"exclude",
"some",
"layers",
"from",
"loading",
"."
] | [
"\"\"\"Modified version of the correspoding Keras function with\n the addition of multi-GPU support and the ability to exclude\n some layers from loading.\n exlude: list of layer names to excluce\n \"\"\"",
"# In multi-GPU training, we wrap the model. Get layers",
"# of the inner mod... | [
{
"param": "self",
"type": null
},
{
"param": "filepath",
"type": null
},
{
"param": "by_name",
"type": null
},
{
"param": "exclude_pattern",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "filepath",
"type": null,
"docstring": null,
"docstring_tokens... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | train | null | def train(self, train_dataset, val_dataset, learning_rate, epochs, layers, period):
"""Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epoch... | Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epochs
are considered to be done alreay, so this actually determines
... | Train the model.
train_dataset, val_dataset: Training and validation Dataset objects.
learning_rate: The learning rate to train with
epochs: Number of training epochs. Note that previous training epochs
are considered to be done alreay, so this actually determines
the epochs to train in total rather than in this partic... | [
"Train",
"the",
"model",
".",
"train_dataset",
"val_dataset",
":",
"Training",
"and",
"validation",
"Dataset",
"objects",
".",
"learning_rate",
":",
"The",
"learning",
"rate",
"to",
"train",
"with",
"epochs",
":",
"Number",
"of",
"training",
"epochs",
".",
"No... | def train(self, train_dataset, val_dataset, learning_rate, epochs, layers, period):
assert self.mode == "training", "Create model in training mode."
layer_regex = {
"rpn": r"(rpn\_.*)",
"roi_process_head": r"(mrcnn\_bbox\_.*)|(mrcnn\_class\_.*)|(mrcnn\_mask\_.*)|(mrcnn\_share\_.*... | [
"def",
"train",
"(",
"self",
",",
"train_dataset",
",",
"val_dataset",
",",
"learning_rate",
",",
"epochs",
",",
"layers",
",",
"period",
")",
":",
"assert",
"self",
".",
"mode",
"==",
"\"training\"",
",",
"\"Create model in training mode.\"",
"layer_regex",
"="... | Train the model. | [
"Train",
"the",
"model",
"."
] | [
"\"\"\"Train the model.\n train_dataset, val_dataset: Training and validation Dataset objects.\n learning_rate: The learning rate to train with\n epochs: Number of training epochs. Note that previous training epochs\n are considered to be done alreay, so this actually determines\... | [
{
"param": "self",
"type": null
},
{
"param": "train_dataset",
"type": null
},
{
"param": "val_dataset",
"type": null
},
{
"param": "learning_rate",
"type": null
},
{
"param": "epochs",
"type": null
},
{
"param": "layers",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "train_dataset",
"type": null,
"docstring": null,
"docstring_t... |
3d91e4f7faaa586cfc96f93247d5ba5696e962c6 | HCPLab-SYSU/ATEN | parsing_rcnn_model.py | [
"MIT"
] | Python | detect | <not_specific> | def detect(self, images, verbose=0):
"""Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. The dict contains:
rois: [N, (y1, x1, y2, x2)] detection bounding boxes
class_ids: [N] int class IDs
... | Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. The dict contains:
rois: [N, (y1, x1, y2, x2)] detection bounding boxes
class_ids: [N] int class IDs
scores: [N] float probability scores for the cl... | Runs the detection pipeline.
images: List of images, potentially of different sizes.
Returns a list of dicts, one dict per image. | [
"Runs",
"the",
"detection",
"pipeline",
".",
"images",
":",
"List",
"of",
"images",
"potentially",
"of",
"different",
"sizes",
".",
"Returns",
"a",
"list",
"of",
"dicts",
"one",
"dict",
"per",
"image",
"."
] | def detect(self, images, verbose=0):
assert self.mode == "inference", "Create model in inference mode."
assert len(
images) == self.config.BATCH_SIZE, "len(images) must be equal to BATCH_SIZE"
if verbose:
log("Processing {} images".format(len(images)))
for ima... | [
"def",
"detect",
"(",
"self",
",",
"images",
",",
"verbose",
"=",
"0",
")",
":",
"assert",
"self",
".",
"mode",
"==",
"\"inference\"",
",",
"\"Create model in inference mode.\"",
"assert",
"len",
"(",
"images",
")",
"==",
"self",
".",
"config",
".",
"BATCH... | Runs the detection pipeline. | [
"Runs",
"the",
"detection",
"pipeline",
"."
] | [
"\"\"\"Runs the detection pipeline.\n\n images: List of images, potentially of different sizes.\n\n Returns a list of dicts, one dict per image. The dict contains:\n rois: [N, (y1, x1, y2, x2)] detection bounding boxes\n class_ids: [N] int class IDs\n scores: [N] float probability... | [
{
"param": "self",
"type": null
},
{
"param": "images",
"type": null
},
{
"param": "verbose",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "images",
"type": null,
"docstring": null,
"docstring_tokens":... |
fd85d7704130388661df680abcccc34651de0c4e | HCPLab-SYSU/ATEN | vip.py | [
"MIT"
] | Python | load_mask | <not_specific> | def load_mask(self, image_id):
"""Load instance masks for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a bitmap [height, width, instances].
Returns:
masks: A bool arr... | Load instance masks for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a bitmap [height, width, instances].
Returns:
masks: A bool array of shape [height, width, instance count... | Load instance masks for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a bitmap [height, width, instances]. | [
"Load",
"instance",
"masks",
"for",
"the",
"given",
"image",
".",
"Different",
"datasets",
"use",
"different",
"ways",
"to",
"store",
"masks",
".",
"This",
"function",
"converts",
"the",
"different",
"mask",
"format",
"to",
"one",
"format",
"in",
"the",
"for... | def load_mask(self, image_id):
image_info = self.image_info[image_id]
if image_info["source"] != "VIP":
return super(VIPDataset, self).load_mask(image_id)
class_ids = []
instance_masks = []
gt_inst_data = cv2.imread(image_info["inst_anno"], cv2.IMREAD_GRAYSCALE)
... | [
"def",
"load_mask",
"(",
"self",
",",
"image_id",
")",
":",
"image_info",
"=",
"self",
".",
"image_info",
"[",
"image_id",
"]",
"if",
"image_info",
"[",
"\"source\"",
"]",
"!=",
"\"VIP\"",
":",
"return",
"super",
"(",
"VIPDataset",
",",
"self",
")",
".",... | Load instance masks for the given image. | [
"Load",
"instance",
"masks",
"for",
"the",
"given",
"image",
"."
] | [
"\"\"\"Load instance masks for the given image.\n\n Different datasets use different ways to store masks. This\n function converts the different mask format to one format\n in the form of a bitmap [height, width, instances].\n\n Returns:\n masks: A bool array of shape [height, wid... | [
{
"param": "self",
"type": null
},
{
"param": "image_id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
fd85d7704130388661df680abcccc34651de0c4e | HCPLab-SYSU/ATEN | vip.py | [
"MIT"
] | Python | load_part | <not_specific> | def load_part(self, image_id):
"""Load part category map for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a category_id map [height, width].
Returns:
parts: A uint8 a... | Load part category map for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a category_id map [height, width].
Returns:
parts: A uint8 array of shape [height, width].
| Load part category map for the given image.
Different datasets use different ways to store masks. This
function converts the different mask format to one format
in the form of a category_id map [height, width]. | [
"Load",
"part",
"category",
"map",
"for",
"the",
"given",
"image",
".",
"Different",
"datasets",
"use",
"different",
"ways",
"to",
"store",
"masks",
".",
"This",
"function",
"converts",
"the",
"different",
"mask",
"format",
"to",
"one",
"format",
"in",
"the"... | def load_part(self, image_id):
image_info = self.image_info[image_id]
gt_part_data = cv2.imread(image_info["part_anno"], cv2.IMREAD_GRAYSCALE)
return gt_part_data.astype(np.uint8) | [
"def",
"load_part",
"(",
"self",
",",
"image_id",
")",
":",
"image_info",
"=",
"self",
".",
"image_info",
"[",
"image_id",
"]",
"gt_part_data",
"=",
"cv2",
".",
"imread",
"(",
"image_info",
"[",
"\"part_anno\"",
"]",
",",
"cv2",
".",
"IMREAD_GRAYSCALE",
")... | Load part category map for the given image. | [
"Load",
"part",
"category",
"map",
"for",
"the",
"given",
"image",
"."
] | [
"\"\"\"Load part category map for the given image.\n\n Different datasets use different ways to store masks. This\n function converts the different mask format to one format\n in the form of a category_id map [height, width].\n\n Returns:\n parts: A uint8 array of shape [height, w... | [
{
"param": "self",
"type": null
},
{
"param": "image_id",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6a0f17edff691575a2fe513bb0d698d625f4b02f | HCPLab-SYSU/ATEN | evaluate/test_ap.py | [
"MIT"
] | Python | compute_bbox_iou | <not_specific> | def compute_bbox_iou(box, boxes, box_area, boxes_area):
"""Calculates IoU of the given box with the array of the given boxes.
box: 1D vector [y1, x1, y2, x2]
boxes: [boxes_count, (y1, x1, y2, x2)]
box_area: float. the area of 'box' ground_truth box
boxes_area: array of length boxes_count.
Not... | Calculates IoU of the given box with the array of the given boxes.
box: 1D vector [y1, x1, y2, x2]
boxes: [boxes_count, (y1, x1, y2, x2)]
box_area: float. the area of 'box' ground_truth box
boxes_area: array of length boxes_count.
Note: the areas are passed in rather than calculated here for
... | Calculates IoU of the given box with the array of the given boxes.
the areas are passed in rather than calculated here for
efficency. Calculate once in the caller to avoid duplicate work. | [
"Calculates",
"IoU",
"of",
"the",
"given",
"box",
"with",
"the",
"array",
"of",
"the",
"given",
"boxes",
".",
"the",
"areas",
"are",
"passed",
"in",
"rather",
"than",
"calculated",
"here",
"for",
"efficency",
".",
"Calculate",
"once",
"in",
"the",
"caller"... | def compute_bbox_iou(box, boxes, box_area, boxes_area):
y1 = np.maximum(box[0], boxes[:, 0])
y2 = np.minimum(box[2], boxes[:, 2])
x1 = np.maximum(box[1], boxes[:, 1])
x2 = np.minimum(box[3], boxes[:, 3])
intersection = np.maximum(x2 - x1, 0) * np.maximum(y2 - y1, 0)
union = box_area + boxes_area... | [
"def",
"compute_bbox_iou",
"(",
"box",
",",
"boxes",
",",
"box_area",
",",
"boxes_area",
")",
":",
"y1",
"=",
"np",
".",
"maximum",
"(",
"box",
"[",
"0",
"]",
",",
"boxes",
"[",
":",
",",
"0",
"]",
")",
"y2",
"=",
"np",
".",
"minimum",
"(",
"bo... | Calculates IoU of the given box with the array of the given boxes. | [
"Calculates",
"IoU",
"of",
"the",
"given",
"box",
"with",
"the",
"array",
"of",
"the",
"given",
"boxes",
"."
] | [
"\"\"\"Calculates IoU of the given box with the array of the given boxes.\n box: 1D vector [y1, x1, y2, x2]\n boxes: [boxes_count, (y1, x1, y2, x2)]\n box_area: float. the area of 'box' ground_truth box\n boxes_area: array of length boxes_count.\n\n Note: the areas are passed in rather than calcula... | [
{
"param": "box",
"type": null
},
{
"param": "boxes",
"type": null
},
{
"param": "box_area",
"type": null
},
{
"param": "boxes_area",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "box",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "boxes",
"type": null,
"docstring": null,
"docstring_tokens": [... |
6a0f17edff691575a2fe513bb0d698d625f4b02f | HCPLab-SYSU/ATEN | evaluate/test_ap.py | [
"MIT"
] | Python | compute_bbox_overlaps | <not_specific> | def compute_bbox_overlaps(boxes1, boxes2):
"""Computes IoU overlaps between two sets of boxes.
boxes1, boxes2: [N, (y1, x1, y2, x2)].
For better performance, pass the largest set first and the smaller second.
"""
# Areas of anchors and GT boxes
area1 = (boxes1[:, 2] - boxes1[:, 0]) * (boxes1[:,... | Computes IoU overlaps between two sets of boxes.
boxes1, boxes2: [N, (y1, x1, y2, x2)].
For better performance, pass the largest set first and the smaller second.
| Computes IoU overlaps between two sets of boxes.
For better performance, pass the largest set first and the smaller second. | [
"Computes",
"IoU",
"overlaps",
"between",
"two",
"sets",
"of",
"boxes",
".",
"For",
"better",
"performance",
"pass",
"the",
"largest",
"set",
"first",
"and",
"the",
"smaller",
"second",
"."
] | def compute_bbox_overlaps(boxes1, boxes2):
area1 = (boxes1[:, 2] - boxes1[:, 0]) * (boxes1[:, 3] - boxes1[:, 1])
area2 = (boxes2[:, 2] - boxes2[:, 0]) * (boxes2[:, 3] - boxes2[:, 1])
overlaps = np.zeros((boxes1.shape[0], boxes2.shape[0]))
for i in range(overlaps.shape[1]):
box2 = boxes2[i]
... | [
"def",
"compute_bbox_overlaps",
"(",
"boxes1",
",",
"boxes2",
")",
":",
"area1",
"=",
"(",
"boxes1",
"[",
":",
",",
"2",
"]",
"-",
"boxes1",
"[",
":",
",",
"0",
"]",
")",
"*",
"(",
"boxes1",
"[",
":",
",",
"3",
"]",
"-",
"boxes1",
"[",
":",
"... | Computes IoU overlaps between two sets of boxes. | [
"Computes",
"IoU",
"overlaps",
"between",
"two",
"sets",
"of",
"boxes",
"."
] | [
"\"\"\"Computes IoU overlaps between two sets of boxes.\n boxes1, boxes2: [N, (y1, x1, y2, x2)].\n\n For better performance, pass the largest set first and the smaller second.\n \"\"\"",
"# Areas of anchors and GT boxes",
"# Compute overlaps to generate matrix [boxes1 count, boxes2 count]",
"# Each c... | [
{
"param": "boxes1",
"type": null
},
{
"param": "boxes2",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "boxes1",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "boxes2",
"type": null,
"docstring": null,
"docstring_tokens... |
dab8aaf07867dd9d46cc127061a560d1acde5b45 | raunakvasistha/Covid-Portal | src/pages/utils/fetch_url.py | [
"MIT"
] | Python | fetch_url | <not_specific> | def fetch_url(date, country=None):
"""
Function fetches the url of the most recent report.
:param date: datetime object
:param country: str
:return: str
"""
DATA_URL = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/"
"csse_covid_19_dail... |
Function fetches the url of the most recent report.
:param date: datetime object
:param country: str
:return: str
| Function fetches the url of the most recent report. | [
"Function",
"fetches",
"the",
"url",
"of",
"the",
"most",
"recent",
"report",
"."
] | def fetch_url(date, country=None):
DATA_URL = ("https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/"
"csse_covid_19_daily_reports/{}.csv".format(date.date().strftime("%m-%d-%Y")))
if country == "US":
DATA_URL = ("https://raw.githubusercontent.com/CSSEGISa... | [
"def",
"fetch_url",
"(",
"date",
",",
"country",
"=",
"None",
")",
":",
"DATA_URL",
"=",
"(",
"\"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/\"",
"\"csse_covid_19_daily_reports/{}.csv\"",
".",
"format",
"(",
"date",
".",
"date",
"(",
... | Function fetches the url of the most recent report. | [
"Function",
"fetches",
"the",
"url",
"of",
"the",
"most",
"recent",
"report",
"."
] | [
"\"\"\"\n Function fetches the url of the most recent report.\n\n :param date: datetime object\n :param country: str\n :return: str\n \"\"\""
] | [
{
"param": "date",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "date",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | plot_snapshot_numbers | <not_specific> | def plot_snapshot_numbers(df, colors, date, country=None):
"""
Function plots snapshots for worldwide and countries.
:param df: DataFrame
:param colors: list
:param date: datetime object
:param country: str
:return: plotly.figure
"""
with st.spinner("Rendering chart..."):
co... |
Function plots snapshots for worldwide and countries.
:param df: DataFrame
:param colors: list
:param date: datetime object
:param country: str
:return: plotly.figure
| Function plots snapshots for worldwide and countries. | [
"Function",
"plots",
"snapshots",
"for",
"worldwide",
"and",
"countries",
"."
] | def plot_snapshot_numbers(df, colors, date, country=None):
with st.spinner("Rendering chart..."):
colors = px.colors.qualitative.D3
if country:
df = df[df["Country_Region"] == country]
fig = go.Figure()
fig.add_trace(go.Bar(y=df[["Confirmed", "Deaths", "Recovered", "Activ... | [
"def",
"plot_snapshot_numbers",
"(",
"df",
",",
"colors",
",",
"date",
",",
"country",
"=",
"None",
")",
":",
"with",
"st",
".",
"spinner",
"(",
"\"Rendering chart...\"",
")",
":",
"colors",
"=",
"px",
".",
"colors",
".",
"qualitative",
".",
"D3",
"if",
... | Function plots snapshots for worldwide and countries. | [
"Function",
"plots",
"snapshots",
"for",
"worldwide",
"and",
"countries",
"."
] | [
"\"\"\"\n Function plots snapshots for worldwide and countries.\n\n :param df: DataFrame\n :param colors: list\n :param date: datetime object\n :param country: str\n :return: plotly.figure\n \"\"\""
] | [
{
"param": "df",
"type": null
},
{
"param": "colors",
"type": null
},
{
"param": "date",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | plot_top_countries | <not_specific> | def plot_top_countries(df, colors, date):
"""
Function plots top countries by confirmed, deaths, recovered, active cases.
:param df: DataFrame
:param colors: list
:param date: datetime object
:return: plotly.figure
"""
with st.spinner("Rendering chart..."):
temp = df.groupby("Co... |
Function plots top countries by confirmed, deaths, recovered, active cases.
:param df: DataFrame
:param colors: list
:param date: datetime object
:return: plotly.figure
| Function plots top countries by confirmed, deaths, recovered, active cases. | [
"Function",
"plots",
"top",
"countries",
"by",
"confirmed",
"deaths",
"recovered",
"active",
"cases",
"."
] | def plot_top_countries(df, colors, date):
with st.spinner("Rendering chart..."):
temp = df.groupby("Country_Region").agg({"Confirmed": "sum",
"Deaths": "sum",
"Recovered": "sum",
... | [
"def",
"plot_top_countries",
"(",
"df",
",",
"colors",
",",
"date",
")",
":",
"with",
"st",
".",
"spinner",
"(",
"\"Rendering chart...\"",
")",
":",
"temp",
"=",
"df",
".",
"groupby",
"(",
"\"Country_Region\"",
")",
".",
"agg",
"(",
"{",
"\"Confirmed\"",
... | Function plots top countries by confirmed, deaths, recovered, active cases. | [
"Function",
"plots",
"top",
"countries",
"by",
"confirmed",
"deaths",
"recovered",
"active",
"cases",
"."
] | [
"\"\"\"\n Function plots top countries by confirmed, deaths, recovered, active cases.\n\n :param df: DataFrame\n :param colors: list\n :param date: datetime object\n :return: plotly.figure\n \"\"\""
] | [
{
"param": "df",
"type": null
},
{
"param": "colors",
"type": null
},
{
"param": "date",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | plot_timeline | <not_specific> | def plot_timeline(df, feature, country=None):
"""
Function plots time series charts for worldwide as well as countries
:param df: DataFrame
:param feature: str
:param country: str
:return: plotly.figure, DataFrame
"""
color = px.colors.qualitative.Prism
if country:
df = df[d... |
Function plots time series charts for worldwide as well as countries
:param df: DataFrame
:param feature: str
:param country: str
:return: plotly.figure, DataFrame
| Function plots time series charts for worldwide as well as countries | [
"Function",
"plots",
"time",
"series",
"charts",
"for",
"worldwide",
"as",
"well",
"as",
"countries"
] | def plot_timeline(df, feature, country=None):
color = px.colors.qualitative.Prism
if country:
df = df[df["Country/Region"] == country]
temp = df.groupby(["Date"]).agg({feature: "sum"}).reset_index()
temp["Delta_{}".format(feature)] = temp[feature].diff()
temp["Delta_{}".format(feature)].clip... | [
"def",
"plot_timeline",
"(",
"df",
",",
"feature",
",",
"country",
"=",
"None",
")",
":",
"color",
"=",
"px",
".",
"colors",
".",
"qualitative",
".",
"Prism",
"if",
"country",
":",
"df",
"=",
"df",
"[",
"df",
"[",
"\"Country/Region\"",
"]",
"==",
"co... | Function plots time series charts for worldwide as well as countries | [
"Function",
"plots",
"time",
"series",
"charts",
"for",
"worldwide",
"as",
"well",
"as",
"countries"
] | [
"\"\"\"\n Function plots time series charts for worldwide as well as countries\n :param df: DataFrame\n :param feature: str\n :param country: str\n :return: plotly.figure, DataFrame\n \"\"\""
] | [
{
"param": "df",
"type": null
},
{
"param": "feature",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | plot_province_drilled | <not_specific> | def plot_province_drilled(df, country):
"""
Function computes top provinces by confirmed, deaths, recovered and active cases.
:param df: DataFrame
:param country: str
:return: plotly.figure
"""
fig = make_subplots(2, 2, subplot_titles=["Top 10 States by cases",
... |
Function computes top provinces by confirmed, deaths, recovered and active cases.
:param df: DataFrame
:param country: str
:return: plotly.figure
| Function computes top provinces by confirmed, deaths, recovered and active cases. | [
"Function",
"computes",
"top",
"provinces",
"by",
"confirmed",
"deaths",
"recovered",
"and",
"active",
"cases",
"."
] | def plot_province_drilled(df, country):
fig = make_subplots(2, 2, subplot_titles=["Top 10 States by cases",
"Top 10 States by deaths",
"Top 10 States by recoveries",
"Top 10 Stat... | [
"def",
"plot_province_drilled",
"(",
"df",
",",
"country",
")",
":",
"fig",
"=",
"make_subplots",
"(",
"2",
",",
"2",
",",
"subplot_titles",
"=",
"[",
"\"Top 10 States by cases\"",
",",
"\"Top 10 States by deaths\"",
",",
"\"Top 10 States by recoveries\"",
",",
"\"T... | Function computes top provinces by confirmed, deaths, recovered and active cases. | [
"Function",
"computes",
"top",
"provinces",
"by",
"confirmed",
"deaths",
"recovered",
"and",
"active",
"cases",
"."
] | [
"\"\"\"\n Function computes top provinces by confirmed, deaths, recovered and active cases.\n\n :param df: DataFrame\n :param country: str\n :return: plotly.figure\n \"\"\""
] | [
{
"param": "df",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | load_day_change | null | def load_day_change(time_series_dict, keys, granularity, country=None):
"""
Function computes the delta change in confirmed, deaths, recovered and active cases over a single day
:param time_series_dict: dict
:param keys: list
:param granularity: str
:param country: str
:return: plotly.figur... |
Function computes the delta change in confirmed, deaths, recovered and active cases over a single day
:param time_series_dict: dict
:param keys: list
:param granularity: str
:param country: str
:return: plotly.figure
| Function computes the delta change in confirmed, deaths, recovered and active cases over a single day | [
"Function",
"computes",
"the",
"delta",
"change",
"in",
"confirmed",
"deaths",
"recovered",
"and",
"active",
"cases",
"over",
"a",
"single",
"day"
] | def load_day_change(time_series_dict, keys, granularity, country=None):
response_dict = {}
PATH = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../'))
local_css(PATH + "/style.css")
curr = 0
prev = 0
for key in keys:
if granularity == "Country":
_, temp = plot_t... | [
"def",
"load_day_change",
"(",
"time_series_dict",
",",
"keys",
",",
"granularity",
",",
"country",
"=",
"None",
")",
":",
"response_dict",
"=",
"{",
"}",
"PATH",
"=",
"os",
".",
"path",
".",
"abspath",
"(",
"os",
".",
"path",
".",
"join",
"(",
"os",
... | Function computes the delta change in confirmed, deaths, recovered and active cases over a single day | [
"Function",
"computes",
"the",
"delta",
"change",
"in",
"confirmed",
"deaths",
"recovered",
"and",
"active",
"cases",
"over",
"a",
"single",
"day"
] | [
"\"\"\"\n Function computes the delta change in confirmed, deaths, recovered and active cases over a single day\n\n :param time_series_dict: dict\n :param keys: list\n :param granularity: str\n :param country: str\n :return: plotly.figure\n \"\"\""
] | [
{
"param": "time_series_dict",
"type": null
},
{
"param": "keys",
"type": null
},
{
"param": "granularity",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "time_series_dict",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": ... |
3f23daff0a5cb8bab4d9606186d16d92fa91b8fd | raunakvasistha/Covid-Portal | src/pages/dashboard.py | [
"MIT"
] | Python | plot_province | <not_specific> | def plot_province(df, country):
"""
Function plots the map of a country with the state/county level information as a hover.
:param df: DataFrame
:param country: str
:return: plotly.figure
"""
fig = None
df = df[df["Country_Region"] == country]
if df["Province_State"].isnull().all():... |
Function plots the map of a country with the state/county level information as a hover.
:param df: DataFrame
:param country: str
:return: plotly.figure
| Function plots the map of a country with the state/county level information as a hover. | [
"Function",
"plots",
"the",
"map",
"of",
"a",
"country",
"with",
"the",
"state",
"/",
"county",
"level",
"information",
"as",
"a",
"hover",
"."
] | def plot_province(df, country):
fig = None
df = df[df["Country_Region"] == country]
if df["Province_State"].isnull().all():
st.info("Sorry we do not have province/state level information for {}".format(country))
else:
df.rename(columns={"Lat": "lat",
"Long_": "... | [
"def",
"plot_province",
"(",
"df",
",",
"country",
")",
":",
"fig",
"=",
"None",
"df",
"=",
"df",
"[",
"df",
"[",
"\"Country_Region\"",
"]",
"==",
"country",
"]",
"if",
"df",
"[",
"\"Province_State\"",
"]",
".",
"isnull",
"(",
")",
".",
"all",
"(",
... | Function plots the map of a country with the state/county level information as a hover. | [
"Function",
"plots",
"the",
"map",
"of",
"a",
"country",
"with",
"the",
"state",
"/",
"county",
"level",
"information",
"as",
"a",
"hover",
"."
] | [
"\"\"\"\n Function plots the map of a country with the state/county level information as a hover.\n\n :param df: DataFrame\n :param country: str\n :return: plotly.figure\n \"\"\""
] | [
{
"param": "df",
"type": null
},
{
"param": "country",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"i... |
70e95f2f62b845e0f5407ef95de3600f65c2277e | raunakvasistha/Covid-Portal | src/pages/utils/load_time_series.py | [
"MIT"
] | Python | load_time_series | <not_specific> | def load_time_series():
"""
Function aggregates and returns a dictionary of time series data.
:return: dict
"""
confirmed_data = pd.read_csv(
"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.c... |
Function aggregates and returns a dictionary of time series data.
:return: dict
| Function aggregates and returns a dictionary of time series data. | [
"Function",
"aggregates",
"and",
"returns",
"a",
"dictionary",
"of",
"time",
"series",
"data",
"."
] | def load_time_series():
confirmed_data = pd.read_csv(
"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv")
death_data = pd.read_csv(
"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/mas... | [
"def",
"load_time_series",
"(",
")",
":",
"confirmed_data",
"=",
"pd",
".",
"read_csv",
"(",
"\"https://raw.githubusercontent.com/CSSEGISandData/COVID-19/master/csse_covid_19_data/csse_covid_19_time_series/time_series_covid19_confirmed_global.csv\"",
")",
"death_data",
"=",
"pd",
"."... | Function aggregates and returns a dictionary of time series data. | [
"Function",
"aggregates",
"and",
"returns",
"a",
"dictionary",
"of",
"time",
"series",
"data",
"."
] | [
"\"\"\"\n Function aggregates and returns a dictionary of time series data.\n\n :return: dict\n \"\"\""
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
a31bec9aef20a09edbe797833cdfde13eb307e71 | raunakvasistha/Covid-Portal | src/pages/utils/load_data.py | [
"MIT"
] | Python | load_data | <not_specific> | def load_data(DATA_URL, nrows=None):
"""
Function reads data from the url and returns a dataframe
:param DATA_URL: str
:param nrows: int
:return: DataFrame
"""
df = pd.read_csv(DATA_URL, nrows=nrows)
return df |
Function reads data from the url and returns a dataframe
:param DATA_URL: str
:param nrows: int
:return: DataFrame
| Function reads data from the url and returns a dataframe | [
"Function",
"reads",
"data",
"from",
"the",
"url",
"and",
"returns",
"a",
"dataframe"
] | def load_data(DATA_URL, nrows=None):
df = pd.read_csv(DATA_URL, nrows=nrows)
return df | [
"def",
"load_data",
"(",
"DATA_URL",
",",
"nrows",
"=",
"None",
")",
":",
"df",
"=",
"pd",
".",
"read_csv",
"(",
"DATA_URL",
",",
"nrows",
"=",
"nrows",
")",
"return",
"df"
] | Function reads data from the url and returns a dataframe | [
"Function",
"reads",
"data",
"from",
"the",
"url",
"and",
"returns",
"a",
"dataframe"
] | [
"\"\"\"\n Function reads data from the url and returns a dataframe\n\n :param DATA_URL: str\n :param nrows: int\n :return: DataFrame\n \"\"\""
] | [
{
"param": "DATA_URL",
"type": null
},
{
"param": "nrows",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "DATA_URL",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
7509c5c20a22c18f8bea23c7f9c8e10b15f1ec8a | blaxii/Python | maths/abs.py | [
"MIT"
] | Python | abs_val | <not_specific> | def abs_val(num):
"""
Find the absolute value of a number.
>>abs_val(-5)
5
>>abs_val(0)
0
"""
return -num if num < 0 else num |
Find the absolute value of a number.
>>abs_val(-5)
5
>>abs_val(0)
0
| Find the absolute value of a number. | [
"Find",
"the",
"absolute",
"value",
"of",
"a",
"number",
"."
] | def abs_val(num):
return -num if num < 0 else num | [
"def",
"abs_val",
"(",
"num",
")",
":",
"return",
"-",
"num",
"if",
"num",
"<",
"0",
"else",
"num"
] | Find the absolute value of a number. | [
"Find",
"the",
"absolute",
"value",
"of",
"a",
"number",
"."
] | [
"\"\"\"\n Find the absolute value of a number.\n\n >>abs_val(-5)\n 5\n >>abs_val(0)\n 0\n \"\"\""
] | [
{
"param": "num",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "num",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | _to_affine_matrix | <not_specific> | def _to_affine_matrix(self,coords):
"""
returns an affine matrix for the specified coordinates
"""
return np.hstack((coords, np.ones((coords.shape[0],1)))).T |
returns an affine matrix for the specified coordinates
| returns an affine matrix for the specified coordinates | [
"returns",
"an",
"affine",
"matrix",
"for",
"the",
"specified",
"coordinates"
] | def _to_affine_matrix(self,coords):
return np.hstack((coords, np.ones((coords.shape[0],1)))).T | [
"def",
"_to_affine_matrix",
"(",
"self",
",",
"coords",
")",
":",
"return",
"np",
".",
"hstack",
"(",
"(",
"coords",
",",
"np",
".",
"ones",
"(",
"(",
"coords",
".",
"shape",
"[",
"0",
"]",
",",
"1",
")",
")",
")",
")",
".",
"T"
] | returns an affine matrix for the specified coordinates | [
"returns",
"an",
"affine",
"matrix",
"for",
"the",
"specified",
"coordinates"
] | [
"\"\"\"\n returns an affine matrix for the specified coordinates\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "coords",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "coords",
"type": null,
"docstring": null,
"docstring_tokens":... |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | img2imgcoord | <not_specific> | def img2imgcoord(self, ref_img, ref_name=None, method='linear', input_reorient2std=False, ref_reorient2std=False, wf_base_dir=None, wf_name='register',
linear_reg_file=None, warp_field_file = None, return_as_array=False):
"""
registers the coordinates to another volume.
... |
registers the coordinates to another volume.
Parameters:
-----------
ref_img:
path to reference image
ref_name: str
reference subject name
method: str, {'linear', 'nonlinear'}
... | registers the coordinates to another volume.
Parameters.
path to reference image
str
reference subject name
boolean
reorient moving volume (img_file) to standard space using fslreorient2std
boolean
reorient the reference image to standard orientation using fslreorient2std
str
the base directory where the results... | [
"registers",
"the",
"coordinates",
"to",
"another",
"volume",
".",
"Parameters",
".",
"path",
"to",
"reference",
"image",
"str",
"reference",
"subject",
"name",
"boolean",
"reorient",
"moving",
"volume",
"(",
"img_file",
")",
"to",
"standard",
"space",
"using",
... | def img2imgcoord(self, ref_img, ref_name=None, method='linear', input_reorient2std=False, ref_reorient2std=False, wf_base_dir=None, wf_name='register',
linear_reg_file=None, warp_field_file = None, return_as_array=False):
if wf_base_dir is None and self.working_dir is not None:
... | [
"def",
"img2imgcoord",
"(",
"self",
",",
"ref_img",
",",
"ref_name",
"=",
"None",
",",
"method",
"=",
"'linear'",
",",
"input_reorient2std",
"=",
"False",
",",
"ref_reorient2std",
"=",
"False",
",",
"wf_base_dir",
"=",
"None",
",",
"wf_name",
"=",
"'register... | registers the coordinates to another volume. | [
"registers",
"the",
"coordinates",
"to",
"another",
"volume",
"."
] | [
"\"\"\"\n registers the coordinates to another volume. \n \n Parameters:\n -----------\n \n ref_img: \n path to reference image\n \n ref_name: str\n reference subject name\n \n method: str, {'linear', 'no... | [
{
"param": "self",
"type": null
},
{
"param": "ref_img",
"type": null
},
{
"param": "ref_name",
"type": null
},
{
"param": "method",
"type": null
},
{
"param": "input_reorient2std",
"type": null
},
{
"param": "ref_reorient2std",
"type": null
},
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ref_img",
"type": null,
"docstring": null,
"docstring_tokens"... |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | subset | <not_specific> | def subset(self,by,vals):
"""
subsets the coordinates
Parameters:
-----------
by: str
which trait to use for subseting the coordinates; for instance you can use "name" to subset the coordinates
vals: list
what ... |
subsets the coordinates
Parameters:
-----------
by: str
which trait to use for subseting the coordinates; for instance you can use "name" to subset the coordinates
vals: list
what values to use; for instance you can provide a ... | subsets the coordinates
Parameters.
str
which trait to use for subseting the coordinates; for instance you can use "name" to subset the coordinates
list
what values to use; for instance you can provide a list of the names
An object of class Coords with all the traits from the original coords instance
| [
"subsets",
"the",
"coordinates",
"Parameters",
".",
"str",
"which",
"trait",
"to",
"use",
"for",
"subseting",
"the",
"coordinates",
";",
"for",
"instance",
"you",
"can",
"use",
"\"",
"name",
"\"",
"to",
"subset",
"the",
"coordinates",
"list",
"what",
"values... | def subset(self,by,vals):
idx = []
for val in vals:
x = np.where(self.__getattribute__(by)==val)[0].tolist()
idx.extend(x)
idx = np.array(idx)
coords = self.coordinates['ras_coord'][idx,:]
traits={}
for trait in self.traits_list:
trait... | [
"def",
"subset",
"(",
"self",
",",
"by",
",",
"vals",
")",
":",
"idx",
"=",
"[",
"]",
"for",
"val",
"in",
"vals",
":",
"x",
"=",
"np",
".",
"where",
"(",
"self",
".",
"__getattribute__",
"(",
"by",
")",
"==",
"val",
")",
"[",
"0",
"]",
".",
... | subsets the coordinates
Parameters: | [
"subsets",
"the",
"coordinates",
"Parameters",
":"
] | [
"\"\"\"\n subsets the coordinates\n \n Parameters:\n -----------\n \n by: str\n which trait to use for subseting the coordinates; for instance you can use \"name\" to subset the coordinates\n \n vals: list\n what values to use; for inst... | [
{
"param": "self",
"type": null
},
{
"param": "by",
"type": null
},
{
"param": "vals",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "by",
"type": null,
"docstring": null,
"docstring_tokens": [],... |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | _guess_hemi | null | def _guess_hemi(self):
"""
uses Freesurfer voxel coordinate to guess hemisphere.
"""
self.hemi = []
self.hemi_not_determined = []
for s in np.arange(self.npoints):
if self.coordinates['fsvoxel_coord'][s,0]> 128:
self.hemi.app... |
uses Freesurfer voxel coordinate to guess hemisphere.
| uses Freesurfer voxel coordinate to guess hemisphere. | [
"uses",
"Freesurfer",
"voxel",
"coordinate",
"to",
"guess",
"hemisphere",
"."
] | def _guess_hemi(self):
self.hemi = []
self.hemi_not_determined = []
for s in np.arange(self.npoints):
if self.coordinates['fsvoxel_coord'][s,0]> 128:
self.hemi.append('lh')
elif self.coordinates['fsvoxel_coord'][s,0] < 128:
self.hemi.ap... | [
"def",
"_guess_hemi",
"(",
"self",
")",
":",
"self",
".",
"hemi",
"=",
"[",
"]",
"self",
".",
"hemi_not_determined",
"=",
"[",
"]",
"for",
"s",
"in",
"np",
".",
"arange",
"(",
"self",
".",
"npoints",
")",
":",
"if",
"self",
".",
"coordinates",
"[",... | uses Freesurfer voxel coordinate to guess hemisphere. | [
"uses",
"Freesurfer",
"voxel",
"coordinate",
"to",
"guess",
"hemisphere",
"."
] | [
"\"\"\"\n uses Freesurfer voxel coordinate to guess hemisphere.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | _read_talaraich_transformation | <not_specific> | def _read_talaraich_transformation(self):
""" read talairach transformation from freesurfer talairach.xfm output"""
fname = '{freesurfer_dir}/{subject}/mri/transforms/talairach.xfm'.format(freesurfer_dir=self.freesurfer_dir,
... | read talairach transformation from freesurfer talairach.xfm output | read talairach transformation from freesurfer talairach.xfm output | [
"read",
"talairach",
"transformation",
"from",
"freesurfer",
"talairach",
".",
"xfm",
"output"
] | def _read_talaraich_transformation(self):
fname = '{freesurfer_dir}/{subject}/mri/transforms/talairach.xfm'.format(freesurfer_dir=self.freesurfer_dir,
subject=self.subject)
f = open(fname,'r').read().split('\n')
def c... | [
"def",
"_read_talaraich_transformation",
"(",
"self",
")",
":",
"fname",
"=",
"'{freesurfer_dir}/{subject}/mri/transforms/talairach.xfm'",
".",
"format",
"(",
"freesurfer_dir",
"=",
"self",
".",
"freesurfer_dir",
",",
"subject",
"=",
"self",
".",
"subject",
")",
"f",
... | read talairach transformation from freesurfer talairach.xfm output | [
"read",
"talairach",
"transformation",
"from",
"freesurfer",
"talairach",
".",
"xfm",
"output"
] | [
"\"\"\" read talairach transformation from freesurfer talairach.xfm output\"\"\"",
"### cleaning rows of file"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | _get_talairach_coords | <not_specific> | def _get_talairach_coords(self):
""" transforms the coordinates by talairach transform matrix from freesurfer talairach.xfm"""
talairach_tr = self._read_talaraich_transformation()
return np.dot(talairach_tr,self._to_affine_matrix(self.coordinates['ras_coord'])).T[:,:3] | transforms the coordinates by talairach transform matrix from freesurfer talairach.xfm | transforms the coordinates by talairach transform matrix from freesurfer talairach.xfm | [
"transforms",
"the",
"coordinates",
"by",
"talairach",
"transform",
"matrix",
"from",
"freesurfer",
"talairach",
".",
"xfm"
] | def _get_talairach_coords(self):
talairach_tr = self._read_talaraich_transformation()
return np.dot(talairach_tr,self._to_affine_matrix(self.coordinates['ras_coord'])).T[:,:3] | [
"def",
"_get_talairach_coords",
"(",
"self",
")",
":",
"talairach_tr",
"=",
"self",
".",
"_read_talaraich_transformation",
"(",
")",
"return",
"np",
".",
"dot",
"(",
"talairach_tr",
",",
"self",
".",
"_to_affine_matrix",
"(",
"self",
".",
"coordinates",
"[",
"... | transforms the coordinates by talairach transform matrix from freesurfer talairach.xfm | [
"transforms",
"the",
"coordinates",
"by",
"talairach",
"transform",
"matrix",
"from",
"freesurfer",
"talairach",
".",
"xfm"
] | [
"\"\"\" transforms the coordinates by talairach transform matrix from freesurfer talairach.xfm\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | map_to_annot | <not_specific> | def map_to_annot(self, annot, map_surface='white', inplace=True):
""" map each point to specified annotation
Parameters:
-----------
annot: str
which annotation to use
map_surface: str, {'pial','white'}
the surface that points ... | map each point to specified annotation
Parameters:
-----------
annot: str
which annotation to use
map_surface: str, {'pial','white'}
the surface that points are projected into to get the vertices
Returns:
---------... | map each point to specified annotation
Parameters.
str
which annotation to use
str, {'pial','white'}
the surface that points are projected into to get the vertices
numpy array
a numpy array of structures ( annotations)
numpy array
a numpy array (npoints x 3) that specifies the color based on the annotation provid... | [
"map",
"each",
"point",
"to",
"specified",
"annotation",
"Parameters",
".",
"str",
"which",
"annotation",
"to",
"use",
"str",
"{",
"'",
"pial",
"'",
"'",
"white",
"'",
"}",
"the",
"surface",
"that",
"points",
"are",
"projected",
"into",
"to",
"get",
"the... | def map_to_annot(self, annot, map_surface='white', inplace=True):
if len(self.hemi_not_determined)>0:
raise ValueError('Use set_hemi_manually to assign hemiphere to these points: %s'%(','.join(self.hemi_not_determined)))
lh_annot = Annot('lh', annot, self.subject, self.freesurfer_dir)
... | [
"def",
"map_to_annot",
"(",
"self",
",",
"annot",
",",
"map_surface",
"=",
"'white'",
",",
"inplace",
"=",
"True",
")",
":",
"if",
"len",
"(",
"self",
".",
"hemi_not_determined",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'Use set_hemi_manually to assi... | map each point to specified annotation
Parameters: | [
"map",
"each",
"point",
"to",
"specified",
"annotation",
"Parameters",
":"
] | [
"\"\"\" map each point to specified annotation \n \n Parameters:\n -----------\n annot: str\n which annotation to use \n \n map_surface: str, {'pial','white'}\n the surface that points are projected into to get the vertices\n \n Retur... | [
{
"param": "self",
"type": null
},
{
"param": "annot",
"type": null
},
{
"param": "map_surface",
"type": null
},
{
"param": "inplace",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "annot",
"type": null,
"docstring": null,
"docstring_tokens": ... |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | map_to_surface | <not_specific> | def map_to_surface(self, surface='white'):
"""
maps the points to a surface ( either pial or white) or an instance of Surf class.
"""
if len(self.hemi_not_determined)>0:
raise ValueError('Use set_hemi_manually to assign hemiphere to these points: %s'%(','.j... |
maps the points to a surface ( either pial or white) or an instance of Surf class.
| maps the points to a surface ( either pial or white) or an instance of Surf class. | [
"maps",
"the",
"points",
"to",
"a",
"surface",
"(",
"either",
"pial",
"or",
"white",
")",
"or",
"an",
"instance",
"of",
"Surf",
"class",
"."
] | def map_to_surface(self, surface='white'):
if len(self.hemi_not_determined)>0:
raise ValueError('Use set_hemi_manually to assign hemiphere to these points: %s'%(','.join(self.hemi_not_determined)))
lh_coords_ras_tkr = self.coordinates['ras_tkr_coord'][self.hemi=='lh',:]
rh_coords_ras... | [
"def",
"map_to_surface",
"(",
"self",
",",
"surface",
"=",
"'white'",
")",
":",
"if",
"len",
"(",
"self",
".",
"hemi_not_determined",
")",
">",
"0",
":",
"raise",
"ValueError",
"(",
"'Use set_hemi_manually to assign hemiphere to these points: %s'",
"%",
"(",
"','"... | maps the points to a surface ( either pial or white) or an instance of Surf class. | [
"maps",
"the",
"points",
"to",
"a",
"surface",
"(",
"either",
"pial",
"or",
"white",
")",
"or",
"an",
"instance",
"of",
"Surf",
"class",
"."
] | [
"\"\"\"\n maps the points to a surface ( either pial or white) or an instance of Surf class. \n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "surface",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "surface",
"type": null,
"docstring": null,
"docstring_tokens"... |
cbe3c90697a8da3be7194240451dcd5c6f1ceea3 | EhsanTadayon/pynetstim | pynetstim/coordinates.py | [
"MIT"
] | Python | create_surf_roi | <not_specific> | def create_surf_roi(self, extents, surface='white', map_surface='white', map_to_annot=None, wf_base_dir=None,
wf_name='surf_roi', add_vertex_to_name=True):
""" creates surface ROIs for each coordinate point
Parameters
----------
extents: float or numpy array
... | creates surface ROIs for each coordinate point
Parameters
----------
extents: float or numpy array
specifies the raidus of the growing ROI. Either one single number for all the points or a numpy array containing
radius for each point
surfac... | creates surface ROIs for each coordinate point
Parameters
float or numpy array
specifies the raidus of the growing ROI. Either one single number for all the points or a numpy array containing
radius for each point
str
specifies which surface to use for growing the ROIs ( white or pial)
str
specifies which annotation... | [
"creates",
"surface",
"ROIs",
"for",
"each",
"coordinate",
"point",
"Parameters",
"float",
"or",
"numpy",
"array",
"specifies",
"the",
"raidus",
"of",
"the",
"growing",
"ROI",
".",
"Either",
"one",
"single",
"number",
"for",
"all",
"the",
"points",
"or",
"a"... | def create_surf_roi(self, extents, surface='white', map_surface='white', map_to_annot=None, wf_base_dir=None,
wf_name='surf_roi', add_vertex_to_name=True):
if wf_base_dir is None and self.working_dir is not None:
wf_base_dir = self.working_dir
elif wf_base_dir is None and self.working_... | [
"def",
"create_surf_roi",
"(",
"self",
",",
"extents",
",",
"surface",
"=",
"'white'",
",",
"map_surface",
"=",
"'white'",
",",
"map_to_annot",
"=",
"None",
",",
"wf_base_dir",
"=",
"None",
",",
"wf_name",
"=",
"'surf_roi'",
",",
"add_vertex_to_name",
"=",
"... | creates surface ROIs for each coordinate point
Parameters | [
"creates",
"surface",
"ROIs",
"for",
"each",
"coordinate",
"point",
"Parameters"
] | [
"\"\"\" creates surface ROIs for each coordinate point\n \n Parameters\n ----------\n extents: float or numpy array\n specifies the raidus of the growing ROI. Either one single number for all the points or a numpy array containing \n radius for each point\n ... | [
{
"param": "self",
"type": null
},
{
"param": "extents",
"type": null
},
{
"param": "surface",
"type": null
},
{
"param": "map_surface",
"type": null
},
{
"param": "map_to_annot",
"type": null
},
{
"param": "wf_base_dir",
"type": null
},
{
... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "extents",
"type": null,
"docstring": null,
"docstring_tokens"... |
006566de3fd19937b2929653de2ad567f5145fd4 | manzar96/distr_sys_ntua | src/node.py | [
"MIT"
] | Python | verify_transaction_signature | <not_specific> | def verify_transaction_signature(self, sender_address, signature, transaction):
"""
Check that the provided signature corresponds to transaction
signed by the public key (sender_address)
"""
public_key = RSA.importKey(binascii.unhexlify(sender_address))
verifier = PKCS1_v... |
Check that the provided signature corresponds to transaction
signed by the public key (sender_address)
| Check that the provided signature corresponds to transaction
signed by the public key (sender_address) | [
"Check",
"that",
"the",
"provided",
"signature",
"corresponds",
"to",
"transaction",
"signed",
"by",
"the",
"public",
"key",
"(",
"sender_address",
")"
] | def verify_transaction_signature(self, sender_address, signature, transaction):
public_key = RSA.importKey(binascii.unhexlify(sender_address))
verifier = PKCS1_v1_5.new(public_key)
temp = transaction.to_dict2()
h = SHA.new(str(temp).encode('utf8'))
print("verify_transaction_signa... | [
"def",
"verify_transaction_signature",
"(",
"self",
",",
"sender_address",
",",
"signature",
",",
"transaction",
")",
":",
"public_key",
"=",
"RSA",
".",
"importKey",
"(",
"binascii",
".",
"unhexlify",
"(",
"sender_address",
")",
")",
"verifier",
"=",
"PKCS1_v1_... | Check that the provided signature corresponds to transaction
signed by the public key (sender_address) | [
"Check",
"that",
"the",
"provided",
"signature",
"corresponds",
"to",
"transaction",
"signed",
"by",
"the",
"public",
"key",
"(",
"sender_address",
")"
] | [
"\"\"\"\n Check that the provided signature corresponds to transaction\n signed by the public key (sender_address)\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "sender_address",
"type": null
},
{
"param": "signature",
"type": null
},
{
"param": "transaction",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sender_address",
"type": null,
"docstring": null,
"docstring_... |
3fe3e42c97f42b85f0262b802f0f1eb4a97e757a | tcramm0nd/strava_map | strava_map/stravauth/stravauth.py | [
"MIT"
] | Python | authorize | null | def authorize(self, response_type='code',
scope='read,profile:read_all,activity:read_all',
approval_prompt='auto'
):
"""Authorizes the Strava Client if there are no exisiting credentials.
Args:
response_type (str, optional): The response... | Authorizes the Strava Client if there are no exisiting credentials.
Args:
response_type (str, optional): The response of the authorization
request. Defaults to 'code'.
scope (str, optional): The scope of what the app is allowed to
access. Defaults to 'rea... | Authorizes the Strava Client if there are no exisiting credentials. | [
"Authorizes",
"the",
"Strava",
"Client",
"if",
"there",
"are",
"no",
"exisiting",
"credentials",
"."
] | def authorize(self, response_type='code',
scope='read,profile:read_all,activity:read_all',
approval_prompt='auto'
):
if not (self.client_id or self.client_secret):
self.client_id = int(input('Enter Client ID: '))
self.client_secret = ... | [
"def",
"authorize",
"(",
"self",
",",
"response_type",
"=",
"'code'",
",",
"scope",
"=",
"'read,profile:read_all,activity:read_all'",
",",
"approval_prompt",
"=",
"'auto'",
")",
":",
"if",
"not",
"(",
"self",
".",
"client_id",
"or",
"self",
".",
"client_secret",... | Authorizes the Strava Client if there are no exisiting credentials. | [
"Authorizes",
"the",
"Strava",
"Client",
"if",
"there",
"are",
"no",
"exisiting",
"credentials",
"."
] | [
"\"\"\"Authorizes the Strava Client if there are no exisiting credentials.\n\n Args:\n response_type (str, optional): The response of the authorization\n request. Defaults to 'code'.\n scope (str, optional): The scope of what the app is allowed to\n access.... | [
{
"param": "self",
"type": null
},
{
"param": "response_type",
"type": null
},
{
"param": "scope",
"type": null
},
{
"param": "approval_prompt",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response_type",
"type": null,
"docstring": "The response of the aut... |
3fe3e42c97f42b85f0262b802f0f1eb4a97e757a | tcramm0nd/strava_map | strava_map/stravauth/stravauth.py | [
"MIT"
] | Python | refresh | null | def refresh(self):
"""Refreshes the Bearer Token if the token has expired."""
if self.access_token:
del self.access_token
self.refresh_params = {"client_id": self.client_id,
"client_secret": self.client_secret,
"grant_type": "r... | Refreshes the Bearer Token if the token has expired. | Refreshes the Bearer Token if the token has expired. | [
"Refreshes",
"the",
"Bearer",
"Token",
"if",
"the",
"token",
"has",
"expired",
"."
] | def refresh(self):
if self.access_token:
del self.access_token
self.refresh_params = {"client_id": self.client_id,
"client_secret": self.client_secret,
"grant_type": "refresh_token",
'refresh_token': self.refresh_token
... | [
"def",
"refresh",
"(",
"self",
")",
":",
"if",
"self",
".",
"access_token",
":",
"del",
"self",
".",
"access_token",
"self",
".",
"refresh_params",
"=",
"{",
"\"client_id\"",
":",
"self",
".",
"client_id",
",",
"\"client_secret\"",
":",
"self",
".",
"clien... | Refreshes the Bearer Token if the token has expired. | [
"Refreshes",
"the",
"Bearer",
"Token",
"if",
"the",
"token",
"has",
"expired",
"."
] | [
"\"\"\"Refreshes the Bearer Token if the token has expired.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3fe3e42c97f42b85f0262b802f0f1eb4a97e757a | tcramm0nd/strava_map | strava_map/stravauth/stravauth.py | [
"MIT"
] | Python | write_creds | null | def write_creds(self):
"""Writes Strava authorization info to a credentials JSON"""
self.credentials = self.r.json()
self.access_token = self.credentials['access_token']
self.credentials['client_id'] = self.client_id
self.credentials['client_secret'] = self.client_secre... | Writes Strava authorization info to a credentials JSON | Writes Strava authorization info to a credentials JSON | [
"Writes",
"Strava",
"authorization",
"info",
"to",
"a",
"credentials",
"JSON"
] | def write_creds(self):
self.credentials = self.r.json()
self.access_token = self.credentials['access_token']
self.credentials['client_id'] = self.client_id
self.credentials['client_secret'] = self.client_secret
with open('.credentials.json', 'w+') as f:
json.dump(self... | [
"def",
"write_creds",
"(",
"self",
")",
":",
"self",
".",
"credentials",
"=",
"self",
".",
"r",
".",
"json",
"(",
")",
"self",
".",
"access_token",
"=",
"self",
".",
"credentials",
"[",
"'access_token'",
"]",
"self",
".",
"credentials",
"[",
"'client_id'... | Writes Strava authorization info to a credentials JSON | [
"Writes",
"Strava",
"authorization",
"info",
"to",
"a",
"credentials",
"JSON"
] | [
"\"\"\"Writes Strava authorization info to a credentials JSON\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3fe3e42c97f42b85f0262b802f0f1eb4a97e757a | tcramm0nd/strava_map | strava_map/stravauth/stravauth.py | [
"MIT"
] | Python | read_creds | null | def read_creds(self, path=None):
"""Reads Strava Credentials from an existing credentials file.
Args:
path (str, optional): Path to an existing credentials file. Defaults to None.
"""
# make filename local
if path:
self.path = path
else:
... | Reads Strava Credentials from an existing credentials file.
Args:
path (str, optional): Path to an existing credentials file. Defaults to None.
| Reads Strava Credentials from an existing credentials file. | [
"Reads",
"Strava",
"Credentials",
"from",
"an",
"existing",
"credentials",
"file",
"."
] | def read_creds(self, path=None):
if path:
self.path = path
else:
self.path = '.credentials.json'
with open(self.path) as f:
self.credentials = json.load(f)
self.client_id = int(self.credentials['client_id'])
self.client_secret = str(sel... | [
"def",
"read_creds",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
":",
"self",
".",
"path",
"=",
"path",
"else",
":",
"self",
".",
"path",
"=",
"'.credentials.json'",
"with",
"open",
"(",
"self",
".",
"path",
")",
"as",
"f",
":",
... | Reads Strava Credentials from an existing credentials file. | [
"Reads",
"Strava",
"Credentials",
"from",
"an",
"existing",
"credentials",
"file",
"."
] | [
"\"\"\"Reads Strava Credentials from an existing credentials file.\n\n Args:\n path (str, optional): Path to an existing credentials file. Defaults to None.\n \"\"\"",
"# make filename local"
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": "Path to an existing credentials ... |
a8f30c11d26510360bac26c7d4babe89f671867c | tcramm0nd/strava_map | strava_map/map.py | [
"MIT"
] | Python | create_heatmap | null | def create_heatmap(self):
"""Creates a heatmap of Strava activity data
Args:
activities (str or list, optional): A string or list of activities
to include in the heatmap. Defaults to 'All'.
"""
heatmap_coordinates = self._coordinates_b... | Creates a heatmap of Strava activity data
Args:
activities (str or list, optional): A string or list of activities
to include in the heatmap. Defaults to 'All'.
| Creates a heatmap of Strava activity data | [
"Creates",
"a",
"heatmap",
"of",
"Strava",
"activity",
"data"
] | def create_heatmap(self):
heatmap_coordinates = self._coordinates_by_type()
gradients = self._generate_gradients()
for a_type, coords in heatmap_coordinates.items():
feature_group = folium.FeatureGroup(name=a_type, show=True)
gradient = gradients[a_type]
featu... | [
"def",
"create_heatmap",
"(",
"self",
")",
":",
"heatmap_coordinates",
"=",
"self",
".",
"_coordinates_by_type",
"(",
")",
"gradients",
"=",
"self",
".",
"_generate_gradients",
"(",
")",
"for",
"a_type",
",",
"coords",
"in",
"heatmap_coordinates",
".",
"items",
... | Creates a heatmap of Strava activity data | [
"Creates",
"a",
"heatmap",
"of",
"Strava",
"activity",
"data"
] | [
"\"\"\"Creates a heatmap of Strava activity data\n Args:\n activities (str or list, optional): A string or list of activities\n to include in the heatmap. Defaults to 'All'.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [
{
"identifier": "activities",
"type": null,
"docstring": "... |
a8f30c11d26510360bac26c7d4babe89f671867c | tcramm0nd/strava_map | strava_map/map.py | [
"MIT"
] | Python | _coordinates_by_type | <not_specific> | def _coordinates_by_type(self):
"""Processes the coordinates for use.
"""
if self._split:
coords = {}
for t in self.activity_types:
a = self.data[self.data['type'] == t]
c = a['coordinates'].apply(pd.Series).stack().reset_index(drop=Tr... | Processes the coordinates for use.
| Processes the coordinates for use. | [
"Processes",
"the",
"coordinates",
"for",
"use",
"."
] | def _coordinates_by_type(self):
if self._split:
coords = {}
for t in self.activity_types:
a = self.data[self.data['type'] == t]
c = a['coordinates'].apply(pd.Series).stack().reset_index(drop=True)
if len(c) > 0:
coords[t... | [
"def",
"_coordinates_by_type",
"(",
"self",
")",
":",
"if",
"self",
".",
"_split",
":",
"coords",
"=",
"{",
"}",
"for",
"t",
"in",
"self",
".",
"activity_types",
":",
"a",
"=",
"self",
".",
"data",
"[",
"self",
".",
"data",
"[",
"'type'",
"]",
"=="... | Processes the coordinates for use. | [
"Processes",
"the",
"coordinates",
"for",
"use",
"."
] | [
"\"\"\"Processes the coordinates for use.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a8f30c11d26510360bac26c7d4babe89f671867c | tcramm0nd/strava_map | strava_map/map.py | [
"MIT"
] | Python | _center_point | <not_specific> | def _center_point(self):
"""Finds the center point of all activities
"""
all_coords = self.data['coordinates'].apply(pd.Series).stack().reset_index(drop=True)
lat, lon = zip(*all_coords)
center = [median(lat), median(lon)]
return center | Finds the center point of all activities
| Finds the center point of all activities | [
"Finds",
"the",
"center",
"point",
"of",
"all",
"activities"
] | def _center_point(self):
all_coords = self.data['coordinates'].apply(pd.Series).stack().reset_index(drop=True)
lat, lon = zip(*all_coords)
center = [median(lat), median(lon)]
return center | [
"def",
"_center_point",
"(",
"self",
")",
":",
"all_coords",
"=",
"self",
".",
"data",
"[",
"'coordinates'",
"]",
".",
"apply",
"(",
"pd",
".",
"Series",
")",
".",
"stack",
"(",
")",
".",
"reset_index",
"(",
"drop",
"=",
"True",
")",
"lat",
",",
"l... | Finds the center point of all activities | [
"Finds",
"the",
"center",
"point",
"of",
"all",
"activities"
] | [
"\"\"\"Finds the center point of all activities\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
7530df11f29c4c36897ff4f2f41da56eefe55c3d | tcramm0nd/strava_map | strava_map/activities.py | [
"MIT"
] | Python | save | null | def save(self, path=None, filename=None):
"""Saves downloaded activity data as a JSON file
Args:
filename (str, optional): Path to a directory to save activity data. Defaults to None.
"""
if not filename:
filename = str(dt.date.today()) + '_strava_activities.json'... | Saves downloaded activity data as a JSON file
Args:
filename (str, optional): Path to a directory to save activity data. Defaults to None.
| Saves downloaded activity data as a JSON file | [
"Saves",
"downloaded",
"activity",
"data",
"as",
"a",
"JSON",
"file"
] | def save(self, path=None, filename=None):
if not filename:
filename = str(dt.date.today()) + '_strava_activities.json'
if path:
filename = path + filename
self.data.to_json(filename) | [
"def",
"save",
"(",
"self",
",",
"path",
"=",
"None",
",",
"filename",
"=",
"None",
")",
":",
"if",
"not",
"filename",
":",
"filename",
"=",
"str",
"(",
"dt",
".",
"date",
".",
"today",
"(",
")",
")",
"+",
"'_strava_activities.json'",
"if",
"path",
... | Saves downloaded activity data as a JSON file | [
"Saves",
"downloaded",
"activity",
"data",
"as",
"a",
"JSON",
"file"
] | [
"\"\"\"Saves downloaded activity data as a JSON file\n Args:\n filename (str, optional): Path to a directory to save activity data. Defaults to None.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "path",
"type": null,
"docstring": null,
"docstring_tokens": [... |
cdd9f61a0a7fc1a6903808850ffbc2095bbb103d | Dakskihedron/kitakami | src/cogs/misc.py | [
"MIT"
] | Python | user_info | null | async def user_info(self, ctx, user: discord.Member = None):
"""Return information about a user.
user: mention or userid
The user to show information about. Leave blank for youself.
"""
user = user or ctx.author
name = str(user)
if user.nick:
name = ... | Return information about a user.
user: mention or userid
The user to show information about. Leave blank for youself.
| Return information about a user.
user: mention or userid
The user to show information about. Leave blank for youself. | [
"Return",
"information",
"about",
"a",
"user",
".",
"user",
":",
"mention",
"or",
"userid",
"The",
"user",
"to",
"show",
"information",
"about",
".",
"Leave",
"blank",
"for",
"youself",
"."
] | async def user_info(self, ctx, user: discord.Member = None):
user = user or ctx.author
name = str(user)
if user.nick:
name = f'{user.nick} ({user.name})'
else:
name = user.name
roles = ', '.join(role.mention for role in user.roles[1:])
embed = disc... | [
"async",
"def",
"user_info",
"(",
"self",
",",
"ctx",
",",
"user",
":",
"discord",
".",
"Member",
"=",
"None",
")",
":",
"user",
"=",
"user",
"or",
"ctx",
".",
"author",
"name",
"=",
"str",
"(",
"user",
")",
"if",
"user",
".",
"nick",
":",
"name"... | Return information about a user. | [
"Return",
"information",
"about",
"a",
"user",
"."
] | [
"\"\"\"Return information about a user.\n\n user: mention or userid\n The user to show information about. Leave blank for youself.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "user",
"type": "discord.Member"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
cdd9f61a0a7fc1a6903808850ffbc2095bbb103d | Dakskihedron/kitakami | src/cogs/misc.py | [
"MIT"
] | Python | avatar | null | async def avatar(self, ctx, user: discord.Member = None):
"""Return a user's avatar.
user: mention or userid
The user to return the avatar of. Leave blank for yourself.
"""
user = user or ctx.author
await ctx.send(user.avatar_url) | Return a user's avatar.
user: mention or userid
The user to return the avatar of. Leave blank for yourself.
| Return a user's avatar.
user: mention or userid
The user to return the avatar of. Leave blank for yourself. | [
"Return",
"a",
"user",
"'",
"s",
"avatar",
".",
"user",
":",
"mention",
"or",
"userid",
"The",
"user",
"to",
"return",
"the",
"avatar",
"of",
".",
"Leave",
"blank",
"for",
"yourself",
"."
] | async def avatar(self, ctx, user: discord.Member = None):
user = user or ctx.author
await ctx.send(user.avatar_url) | [
"async",
"def",
"avatar",
"(",
"self",
",",
"ctx",
",",
"user",
":",
"discord",
".",
"Member",
"=",
"None",
")",
":",
"user",
"=",
"user",
"or",
"ctx",
".",
"author",
"await",
"ctx",
".",
"send",
"(",
"user",
".",
"avatar_url",
")"
] | Return a user's avatar. | [
"Return",
"a",
"user",
"'",
"s",
"avatar",
"."
] | [
"\"\"\"Return a user's avatar.\n\n user: mention or userid\n The user to return the avatar of. Leave blank for yourself.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "user",
"type": "discord.Member"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8b0cff248e9449cc6e9b7541d11533fe96145ddf | Dakskihedron/kitakami | src/cogs/fun.py | [
"MIT"
] | Python | choose | null | async def choose(self, ctx, *, choices: str):
"""Randomly pick one of multiple choices.
choices: list
List of choices to pick from. Separate choices using commas.
"""
choices = choices.split(',')
await ctx.reply(random.choice(choices)) | Randomly pick one of multiple choices.
choices: list
List of choices to pick from. Separate choices using commas.
| Randomly pick one of multiple choices.
choices: list
List of choices to pick from. Separate choices using commas. | [
"Randomly",
"pick",
"one",
"of",
"multiple",
"choices",
".",
"choices",
":",
"list",
"List",
"of",
"choices",
"to",
"pick",
"from",
".",
"Separate",
"choices",
"using",
"commas",
"."
] | async def choose(self, ctx, *, choices: str):
choices = choices.split(',')
await ctx.reply(random.choice(choices)) | [
"async",
"def",
"choose",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"choices",
":",
"str",
")",
":",
"choices",
"=",
"choices",
".",
"split",
"(",
"','",
")",
"await",
"ctx",
".",
"reply",
"(",
"random",
".",
"choice",
"(",
"choices",
")",
")"
] | Randomly pick one of multiple choices. | [
"Randomly",
"pick",
"one",
"of",
"multiple",
"choices",
"."
] | [
"\"\"\"Randomly pick one of multiple choices.\n\n choices: list\n List of choices to pick from. Separate choices using commas.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "choices",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8b0cff248e9449cc6e9b7541d11533fe96145ddf | Dakskihedron/kitakami | src/cogs/fun.py | [
"MIT"
] | Python | dice | <not_specific> | async def dice(self, ctx, number: float):
"""Random number between one and the specified number.
number: int
End number. Must be a whole number.
"""
if (number).is_integer():
return await ctx.reply(random.randint(1, number))
await ctx.reply("Number must be wh... | Random number between one and the specified number.
number: int
End number. Must be a whole number.
| Random number between one and the specified number.
number: int
End number. Must be a whole number. | [
"Random",
"number",
"between",
"one",
"and",
"the",
"specified",
"number",
".",
"number",
":",
"int",
"End",
"number",
".",
"Must",
"be",
"a",
"whole",
"number",
"."
] | async def dice(self, ctx, number: float):
if (number).is_integer():
return await ctx.reply(random.randint(1, number))
await ctx.reply("Number must be whole number.") | [
"async",
"def",
"dice",
"(",
"self",
",",
"ctx",
",",
"number",
":",
"float",
")",
":",
"if",
"(",
"number",
")",
".",
"is_integer",
"(",
")",
":",
"return",
"await",
"ctx",
".",
"reply",
"(",
"random",
".",
"randint",
"(",
"1",
",",
"number",
")... | Random number between one and the specified number. | [
"Random",
"number",
"between",
"one",
"and",
"the",
"specified",
"number",
"."
] | [
"\"\"\"Random number between one and the specified number.\n\n number: int\n End number. Must be a whole number.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "number",
"type": "float"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8b0cff248e9449cc6e9b7541d11533fe96145ddf | Dakskihedron/kitakami | src/cogs/fun.py | [
"MIT"
] | Python | eight_ball | null | async def eight_ball(self, ctx):
"""Seek advice or fortune-telling."""
responses = [
'It is certain',
'It is decidedly so',
'Without a doubt',
'Yes - definitely',
'You may rely on it',
'As I see it, yes',
'Most likely',
... | Seek advice or fortune-telling. | Seek advice or fortune-telling. | [
"Seek",
"advice",
"or",
"fortune",
"-",
"telling",
"."
] | async def eight_ball(self, ctx):
responses = [
'It is certain',
'It is decidedly so',
'Without a doubt',
'Yes - definitely',
'You may rely on it',
'As I see it, yes',
'Most likely',
'Outlook good',
'Yes',... | [
"async",
"def",
"eight_ball",
"(",
"self",
",",
"ctx",
")",
":",
"responses",
"=",
"[",
"'It is certain'",
",",
"'It is decidedly so'",
",",
"'Without a doubt'",
",",
"'Yes - definitely'",
",",
"'You may rely on it'",
",",
"'As I see it, yes'",
",",
"'Most likely'",
... | Seek advice or fortune-telling. | [
"Seek",
"advice",
"or",
"fortune",
"-",
"telling",
"."
] | [
"\"\"\"Seek advice or fortune-telling.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8b0cff248e9449cc6e9b7541d11533fe96145ddf | Dakskihedron/kitakami | src/cogs/fun.py | [
"MIT"
] | Python | hangman | <not_specific> | async def hangman(self, ctx):
"""Start a game of hangman."""
if ctx.author.id not in self.playing_hangman:
self.playing_hangman.add(ctx.author.id)
else:
return await ctx.reply("Game already running.")
url = 'https://random-word-api.herokuapp.com/word?number=1'
... | Start a game of hangman. | Start a game of hangman. | [
"Start",
"a",
"game",
"of",
"hangman",
"."
] | async def hangman(self, ctx):
if ctx.author.id not in self.playing_hangman:
self.playing_hangman.add(ctx.author.id)
else:
return await ctx.reply("Game already running.")
url = 'https://random-word-api.herokuapp.com/word?number=1'
timeout = aiohttp.ClientTimeout(to... | [
"async",
"def",
"hangman",
"(",
"self",
",",
"ctx",
")",
":",
"if",
"ctx",
".",
"author",
".",
"id",
"not",
"in",
"self",
".",
"playing_hangman",
":",
"self",
".",
"playing_hangman",
".",
"add",
"(",
"ctx",
".",
"author",
".",
"id",
")",
"else",
":... | Start a game of hangman. | [
"Start",
"a",
"game",
"of",
"hangman",
"."
] | [
"\"\"\"Start a game of hangman.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
b3d549934f9dc70483705a10d787595c556898f9 | Dakskihedron/kitakami | src/cogs/roles.py | [
"MIT"
] | Python | rname | null | async def rname(self, ctx, *, name: str):
"""Change the name of your highest role.
name: str
The name to change to. Cannot exceed 100 characters.
"""
old_name = ctx.author.top_role.name
await ctx.author.top_role.edit(name=name)
embed = discord.Embed(
... | Change the name of your highest role.
name: str
The name to change to. Cannot exceed 100 characters.
| Change the name of your highest role.
name: str
The name to change to. Cannot exceed 100 characters. | [
"Change",
"the",
"name",
"of",
"your",
"highest",
"role",
".",
"name",
":",
"str",
"The",
"name",
"to",
"change",
"to",
".",
"Cannot",
"exceed",
"100",
"characters",
"."
] | async def rname(self, ctx, *, name: str):
old_name = ctx.author.top_role.name
await ctx.author.top_role.edit(name=name)
embed = discord.Embed(
colour=discord.Colour.blurple(),
description="```diff\nRole name changed:\n"
f"- {old_name}\n+ {name}\n```"
)... | [
"async",
"def",
"rname",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"name",
":",
"str",
")",
":",
"old_name",
"=",
"ctx",
".",
"author",
".",
"top_role",
".",
"name",
"await",
"ctx",
".",
"author",
".",
"top_role",
".",
"edit",
"(",
"name",
"=",
"na... | Change the name of your highest role. | [
"Change",
"the",
"name",
"of",
"your",
"highest",
"role",
"."
] | [
"\"\"\"Change the name of your highest role.\n\n name: str\n The name to change to. Cannot exceed 100 characters.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "name",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
b3d549934f9dc70483705a10d787595c556898f9 | Dakskihedron/kitakami | src/cogs/roles.py | [
"MIT"
] | Python | rcolour | null | async def rcolour(self, ctx, colour):
"""Change the colour of your highest role.
colour: hex
The hexadecimal code of the colour to change to.
"""
old_colour = ctx.author.top_role.colour
colour = colour.replace('#', '')
await ctx.author.top_role.edit(colour=discor... | Change the colour of your highest role.
colour: hex
The hexadecimal code of the colour to change to.
| Change the colour of your highest role.
colour: hex
The hexadecimal code of the colour to change to. | [
"Change",
"the",
"colour",
"of",
"your",
"highest",
"role",
".",
"colour",
":",
"hex",
"The",
"hexadecimal",
"code",
"of",
"the",
"colour",
"to",
"change",
"to",
"."
] | async def rcolour(self, ctx, colour):
old_colour = ctx.author.top_role.colour
colour = colour.replace('#', '')
await ctx.author.top_role.edit(colour=discord.Colour(int(colour, 16)))
embed = discord.Embed(
colour=discord.Colour.blurple(),
description="```diff\nRole... | [
"async",
"def",
"rcolour",
"(",
"self",
",",
"ctx",
",",
"colour",
")",
":",
"old_colour",
"=",
"ctx",
".",
"author",
".",
"top_role",
".",
"colour",
"colour",
"=",
"colour",
".",
"replace",
"(",
"'#'",
",",
"''",
")",
"await",
"ctx",
".",
"author",
... | Change the colour of your highest role. | [
"Change",
"the",
"colour",
"of",
"your",
"highest",
"role",
"."
] | [
"\"\"\"Change the colour of your highest role.\n\n colour: hex\n The hexadecimal code of the colour to change to.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "colour",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
43a986766b0e690729eecf344f70123725edeefd | Dakskihedron/kitakami | src/cogs/apis.py | [
"MIT"
] | Python | apod | <not_specific> | async def apod(self, ctx, date=None):
"""Show the Astronomical Picture of the Day.
date: yyyy-mm-dd
Optional date for a specific picture.
"""
url = f'https://api.nasa.gov/planetary/apod?api_key={nasa_api_key}'
if date is not None:
url += f'&date={date}'
... | Show the Astronomical Picture of the Day.
date: yyyy-mm-dd
Optional date for a specific picture.
| Show the Astronomical Picture of the Day.
date: yyyy-mm-dd
Optional date for a specific picture. | [
"Show",
"the",
"Astronomical",
"Picture",
"of",
"the",
"Day",
".",
"date",
":",
"yyyy",
"-",
"mm",
"-",
"dd",
"Optional",
"date",
"for",
"a",
"specific",
"picture",
"."
] | async def apod(self, ctx, date=None):
url = f'https://api.nasa.gov/planetary/apod?api_key={nasa_api_key}'
if date is not None:
url += f'&date={date}'
data, status = await self.get_data(url)
if data and status:
return await ctx.reply(f"{status}: {data['msg']}")
... | [
"async",
"def",
"apod",
"(",
"self",
",",
"ctx",
",",
"date",
"=",
"None",
")",
":",
"url",
"=",
"f'https://api.nasa.gov/planetary/apod?api_key={nasa_api_key}'",
"if",
"date",
"is",
"not",
"None",
":",
"url",
"+=",
"f'&date={date}'",
"data",
",",
"status",
"="... | Show the Astronomical Picture of the Day. | [
"Show",
"the",
"Astronomical",
"Picture",
"of",
"the",
"Day",
"."
] | [
"\"\"\"Show the Astronomical Picture of the Day.\n\n date: yyyy-mm-dd\n Optional date for a specific picture.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "date",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
43a986766b0e690729eecf344f70123725edeefd | Dakskihedron/kitakami | src/cogs/apis.py | [
"MIT"
] | Python | danbooru | <not_specific> | async def danbooru(self, ctx, *, tags=''):
"""Show a random image from Danbooru.
tag: str
Optional tag(s) for narrowing image search.
"""
for tag in self.config['blacklist']:
if tag in tags.lower():
return await ctx.reply("The specified tag(s) are bl... | Show a random image from Danbooru.
tag: str
Optional tag(s) for narrowing image search.
| Show a random image from Danbooru.
tag: str
Optional tag(s) for narrowing image search. | [
"Show",
"a",
"random",
"image",
"from",
"Danbooru",
".",
"tag",
":",
"str",
"Optional",
"tag",
"(",
"s",
")",
"for",
"narrowing",
"image",
"search",
"."
] | async def danbooru(self, ctx, *, tags=''):
for tag in self.config['blacklist']:
if tag in tags.lower():
return await ctx.reply("The specified tag(s) are blacklisted.")
url = (
f'https://danbooru.donmai.us/'
f'posts.json?limit=200&tags={tags}')
... | [
"async",
"def",
"danbooru",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"tags",
"=",
"''",
")",
":",
"for",
"tag",
"in",
"self",
".",
"config",
"[",
"'blacklist'",
"]",
":",
"if",
"tag",
"in",
"tags",
".",
"lower",
"(",
")",
":",
"return",
"await",
... | Show a random image from Danbooru. | [
"Show",
"a",
"random",
"image",
"from",
"Danbooru",
"."
] | [
"\"\"\"Show a random image from Danbooru.\n\n tag: str\n Optional tag(s) for narrowing image search.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "tags",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
43a986766b0e690729eecf344f70123725edeefd | Dakskihedron/kitakami | src/cogs/apis.py | [
"MIT"
] | Python | undo | <not_specific> | async def undo(self, ctx):
"""Remove your recently requested image."""
try:
request = self.image_cache[ctx.author.id]
except KeyError:
return await ctx.reply("No image to remove.")
msg = await ctx.channel.fetch_message(request)
await msg.delete()
... | Remove your recently requested image. | Remove your recently requested image. | [
"Remove",
"your",
"recently",
"requested",
"image",
"."
] | async def undo(self, ctx):
try:
request = self.image_cache[ctx.author.id]
except KeyError:
return await ctx.reply("No image to remove.")
msg = await ctx.channel.fetch_message(request)
await msg.delete()
self.image_cache.pop(ctx.author.id) | [
"async",
"def",
"undo",
"(",
"self",
",",
"ctx",
")",
":",
"try",
":",
"request",
"=",
"self",
".",
"image_cache",
"[",
"ctx",
".",
"author",
".",
"id",
"]",
"except",
"KeyError",
":",
"return",
"await",
"ctx",
".",
"reply",
"(",
"\"No image to remove.... | Remove your recently requested image. | [
"Remove",
"your",
"recently",
"requested",
"image",
"."
] | [
"\"\"\"Remove your recently requested image.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
43a986766b0e690729eecf344f70123725edeefd | Dakskihedron/kitakami | src/cogs/apis.py | [
"MIT"
] | Python | weather | <not_specific> | async def weather(self, ctx, *, location):
"""Retrieve weather data for a location from OpenWeatherMap.
location: str
The location to retrieve weather data for.
"""
url = (
f'https://api.openweathermap.org/'
f'data/2.5/weather?q={location}'
f'... | Retrieve weather data for a location from OpenWeatherMap.
location: str
The location to retrieve weather data for.
| Retrieve weather data for a location from OpenWeatherMap.
location: str
The location to retrieve weather data for. | [
"Retrieve",
"weather",
"data",
"for",
"a",
"location",
"from",
"OpenWeatherMap",
".",
"location",
":",
"str",
"The",
"location",
"to",
"retrieve",
"weather",
"data",
"for",
"."
] | async def weather(self, ctx, *, location):
url = (
f'https://api.openweathermap.org/'
f'data/2.5/weather?q={location}'
f'&appid={owm_api_key}&units=metric'
)
data, status = await self.get_data(url)
if data and status:
return await ctx.r... | [
"async",
"def",
"weather",
"(",
"self",
",",
"ctx",
",",
"*",
",",
"location",
")",
":",
"url",
"=",
"(",
"f'https://api.openweathermap.org/'",
"f'data/2.5/weather?q={location}'",
"f'&appid={owm_api_key}&units=metric'",
")",
"data",
",",
"status",
"=",
"await",
"sel... | Retrieve weather data for a location from OpenWeatherMap. | [
"Retrieve",
"weather",
"data",
"for",
"a",
"location",
"from",
"OpenWeatherMap",
"."
] | [
"\"\"\"Retrieve weather data for a location from OpenWeatherMap.\n\n location: str\n The location to retrieve weather data for.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
},
{
"param": "location",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8f2797b0fdfbd6228ed96a5b4b34660c734ba017 | Dakskihedron/kitakami | src/cogs/info.py | [
"MIT"
] | Python | ping | null | async def ping(self, ctx):
"""Return response time and latency."""
m = await ctx.send('Pinging...')
time = m.created_at - ctx.message.created_at
embed = discord.Embed(
colour=discord.Colour.blurple(),
description="```\n"
f"Response: {time.total_seconds... | Return response time and latency. | Return response time and latency. | [
"Return",
"response",
"time",
"and",
"latency",
"."
] | async def ping(self, ctx):
m = await ctx.send('Pinging...')
time = m.created_at - ctx.message.created_at
embed = discord.Embed(
colour=discord.Colour.blurple(),
description="```\n"
f"Response: {time.total_seconds() * 1000} ms\n"
f"Latency: {self.bo... | [
"async",
"def",
"ping",
"(",
"self",
",",
"ctx",
")",
":",
"m",
"=",
"await",
"ctx",
".",
"send",
"(",
"'Pinging...'",
")",
"time",
"=",
"m",
".",
"created_at",
"-",
"ctx",
".",
"message",
".",
"created_at",
"embed",
"=",
"discord",
".",
"Embed",
"... | Return response time and latency. | [
"Return",
"response",
"time",
"and",
"latency",
"."
] | [
"\"\"\"Return response time and latency.\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "ctx",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "ctx",
"type": null,
"docstring": null,
"docstring_tokens": []... |
8d0fa5ad90539f82d63117a3adc66f1cf4aa30f7 | nehal96/full-stack-nd | P4-Catalog-Web-App/vagrant/catalog/helper.py | [
"MIT"
] | Python | chunkify | <not_specific> | def chunkify(l, chunk_size):
"""Return list of evenly sized lists"""
book_chunks = []
for i in xrange(0, len(l), chunk_size):
book_chunks.append(l[i:i + chunk_size])
return book_chunks | Return list of evenly sized lists | Return list of evenly sized lists | [
"Return",
"list",
"of",
"evenly",
"sized",
"lists"
] | def chunkify(l, chunk_size):
book_chunks = []
for i in xrange(0, len(l), chunk_size):
book_chunks.append(l[i:i + chunk_size])
return book_chunks | [
"def",
"chunkify",
"(",
"l",
",",
"chunk_size",
")",
":",
"book_chunks",
"=",
"[",
"]",
"for",
"i",
"in",
"xrange",
"(",
"0",
",",
"len",
"(",
"l",
")",
",",
"chunk_size",
")",
":",
"book_chunks",
".",
"append",
"(",
"l",
"[",
"i",
":",
"i",
"+... | Return list of evenly sized lists | [
"Return",
"list",
"of",
"evenly",
"sized",
"lists"
] | [
"\"\"\"Return list of evenly sized lists\"\"\""
] | [
{
"param": "l",
"type": null
},
{
"param": "chunk_size",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "l",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "chunk_size",
"type": null,
"docstring": null,
"docstring_tokens"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.