repo stringlengths 7 55 | path stringlengths 4 223 | func_name stringlengths 1 134 | original_string stringlengths 75 104k | language stringclasses 1
value | code stringlengths 75 104k | code_tokens listlengths 19 28.4k | docstring stringlengths 1 46.9k | docstring_tokens listlengths 1 1.97k | sha stringlengths 40 40 | url stringlengths 87 315 | partition stringclasses 3
values | summary stringlengths 4 350 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
thiagopbueno/tf-rddlsim | tfrddlsim/viz/navigation_visualizer.py | NavigationVisualizer.render | def render(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array],
batch: Optional[int] = None) -> None:
'''Render the simulated state-action `trajectories` for Navigation domain.
Args:
stats: Performance statistics.
trajectories: NonF... | python | def render(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array],
batch: Optional[int] = None) -> None:
'''Render the simulated state-action `trajectories` for Navigation domain.
Args:
stats: Performance statistics.
trajectories: NonF... | [
"def",
"render",
"(",
"self",
",",
"trajectories",
":",
"Tuple",
"[",
"NonFluents",
",",
"Fluents",
",",
"Fluents",
",",
"Fluents",
",",
"np",
".",
"array",
"]",
",",
"batch",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"None",
":",
"... | Render the simulated state-action `trajectories` for Navigation domain.
Args:
stats: Performance statistics.
trajectories: NonFluents, states, actions, interms and rewards.
batch: Number of batches to render. | [
"Render",
"the",
"simulated",
"state",
"-",
"action",
"trajectories",
"for",
"Navigation",
"domain",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/navigation_visualizer.py#L44-L82 | train | Render the simulated state - action trajectories for Navigation domain. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | persistent_timer | def persistent_timer(func):
"""
Times the execution of a function. If the process is stopped and restarted then timing is continued using saved
files.
Parameters
----------
func
Some function to be timed
Returns
-------
timed_function
The same function with a timer ... | python | def persistent_timer(func):
"""
Times the execution of a function. If the process is stopped and restarted then timing is continued using saved
files.
Parameters
----------
func
Some function to be timed
Returns
-------
timed_function
The same function with a timer ... | [
"def",
"persistent_timer",
"(",
"func",
")",
":",
"@",
"functools",
".",
"wraps",
"(",
"func",
")",
"def",
"timed_function",
"(",
"optimizer_instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"start_time_path",
"=",
"\"{}/.start_time\"",
".",
... | Times the execution of a function. If the process is stopped and restarted then timing is continued using saved
files.
Parameters
----------
func
Some function to be timed
Returns
-------
timed_function
The same function with a timer attached. | [
"Times",
"the",
"execution",
"of",
"a",
"function",
".",
"If",
"the",
"process",
"is",
"stopped",
"and",
"restarted",
"then",
"timing",
"is",
"continued",
"using",
"saved",
"files",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L110-L149 | train | A function that runs a function in persistent mode. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | Result.variable_absolute | def variable_absolute(self, a: float) -> mm.ModelMapper:
"""
Parameters
----------
a
The absolute width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined absolute width.
... | python | def variable_absolute(self, a: float) -> mm.ModelMapper:
"""
Parameters
----------
a
The absolute width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined absolute width.
... | [
"def",
"variable_absolute",
"(",
"self",
",",
"a",
":",
"float",
")",
"->",
"mm",
".",
"ModelMapper",
":",
"return",
"self",
".",
"previous_variable",
".",
"mapper_from_gaussian_tuples",
"(",
"self",
".",
"gaussian_tuples",
",",
"a",
"=",
"a",
")"
] | Parameters
----------
a
The absolute width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined absolute width. | [
"Parameters",
"----------",
"a",
"The",
"absolute",
"width",
"of",
"gaussian",
"priors"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L71-L82 | train | Returns a model mapper created by taking results from this phase and creating priors with the defined absolute width. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | Result.variable_relative | def variable_relative(self, r: float) -> mm.ModelMapper:
"""
Parameters
----------
r
The relative width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined relative width.
... | python | def variable_relative(self, r: float) -> mm.ModelMapper:
"""
Parameters
----------
r
The relative width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined relative width.
... | [
"def",
"variable_relative",
"(",
"self",
",",
"r",
":",
"float",
")",
"->",
"mm",
".",
"ModelMapper",
":",
"return",
"self",
".",
"previous_variable",
".",
"mapper_from_gaussian_tuples",
"(",
"self",
".",
"gaussian_tuples",
",",
"r",
"=",
"r",
")"
] | Parameters
----------
r
The relative width of gaussian priors
Returns
-------
A model mapper created by taking results from this phase and creating priors with the defined relative width. | [
"Parameters",
"----------",
"r",
"The",
"relative",
"width",
"of",
"gaussian",
"priors"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L84-L95 | train | Returns a model mapper created by taking results from this phase and creating priors with the defined relative width. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.backup_path | def backup_path(self) -> str:
"""
The path to the backed up optimizer folder.
"""
return "{}/{}/{}{}/optimizer_backup".format(conf.instance.output_path, self.phase_path, self.phase_name,
self.phase_tag) | python | def backup_path(self) -> str:
"""
The path to the backed up optimizer folder.
"""
return "{}/{}/{}{}/optimizer_backup".format(conf.instance.output_path, self.phase_path, self.phase_name,
self.phase_tag) | [
"def",
"backup_path",
"(",
"self",
")",
"->",
"str",
":",
"return",
"\"{}/{}/{}{}/optimizer_backup\"",
".",
"format",
"(",
"conf",
".",
"instance",
".",
"output_path",
",",
"self",
".",
"phase_path",
",",
"self",
".",
"phase_name",
",",
"self",
".",
"phase_t... | The path to the backed up optimizer folder. | [
"The",
"path",
"to",
"the",
"backed",
"up",
"optimizer",
"folder",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L213-L218 | train | The path to the backup folder. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.backup | def backup(self):
"""
Copy files from the sym-linked optimizer folder to the backup folder in the workspace.
"""
try:
shutil.rmtree(self.backup_path)
except FileNotFoundError:
pass
try:
shutil.copytree(self.opt_path, self.backup_path)
... | python | def backup(self):
"""
Copy files from the sym-linked optimizer folder to the backup folder in the workspace.
"""
try:
shutil.rmtree(self.backup_path)
except FileNotFoundError:
pass
try:
shutil.copytree(self.opt_path, self.backup_path)
... | [
"def",
"backup",
"(",
"self",
")",
":",
"try",
":",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"backup_path",
")",
"except",
"FileNotFoundError",
":",
"pass",
"try",
":",
"shutil",
".",
"copytree",
"(",
"self",
".",
"opt_path",
",",
"self",
".",
"backu... | Copy files from the sym-linked optimizer folder to the backup folder in the workspace. | [
"Copy",
"files",
"from",
"the",
"sym",
"-",
"linked",
"optimizer",
"folder",
"to",
"the",
"backup",
"folder",
"in",
"the",
"workspace",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L256-L267 | train | Copy the files from the sym - linked optimizer folder to the backup folder in the workspace. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.restore | def restore(self):
"""
Copy files from the backup folder to the sym-linked optimizer folder.
"""
if os.path.exists(self.backup_path):
for file in glob.glob(self.backup_path + "/*"):
shutil.copy(file, self.path) | python | def restore(self):
"""
Copy files from the backup folder to the sym-linked optimizer folder.
"""
if os.path.exists(self.backup_path):
for file in glob.glob(self.backup_path + "/*"):
shutil.copy(file, self.path) | [
"def",
"restore",
"(",
"self",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"self",
".",
"backup_path",
")",
":",
"for",
"file",
"in",
"glob",
".",
"glob",
"(",
"self",
".",
"backup_path",
"+",
"\"/*\"",
")",
":",
"shutil",
".",
"copy",
... | Copy files from the backup folder to the sym-linked optimizer folder. | [
"Copy",
"files",
"from",
"the",
"backup",
"folder",
"to",
"the",
"sym",
"-",
"linked",
"optimizer",
"folder",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L269-L275 | train | Copy files from the backup folder to the sym - linked optimizer folder. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.config | def config(self, attribute_name, attribute_type=str):
"""
Get a config field from this optimizer's section in non_linear.ini by a key and value type.
Parameters
----------
attribute_name: str
The analysis_path of the field
attribute_type: type
The... | python | def config(self, attribute_name, attribute_type=str):
"""
Get a config field from this optimizer's section in non_linear.ini by a key and value type.
Parameters
----------
attribute_name: str
The analysis_path of the field
attribute_type: type
The... | [
"def",
"config",
"(",
"self",
",",
"attribute_name",
",",
"attribute_type",
"=",
"str",
")",
":",
"return",
"self",
".",
"named_config",
".",
"get",
"(",
"self",
".",
"__class__",
".",
"__name__",
",",
"attribute_name",
",",
"attribute_type",
")"
] | Get a config field from this optimizer's section in non_linear.ini by a key and value type.
Parameters
----------
attribute_name: str
The analysis_path of the field
attribute_type: type
The type of the value
Returns
-------
attribute
... | [
"Get",
"a",
"config",
"field",
"from",
"this",
"optimizer",
"s",
"section",
"in",
"non_linear",
".",
"ini",
"by",
"a",
"key",
"and",
"value",
"type",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L277-L293 | train | Get a config field from this optimizer s section in non_linear. ini by a key and value type. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.param_labels | def param_labels(self):
"""The param_names vector is a list each parameter's analysis_path, and is used for *GetDist* visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class."""
paramnames_labels... | python | def param_labels(self):
"""The param_names vector is a list each parameter's analysis_path, and is used for *GetDist* visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class."""
paramnames_labels... | [
"def",
"param_labels",
"(",
"self",
")",
":",
"paramnames_labels",
"=",
"[",
"]",
"prior_class_dict",
"=",
"self",
".",
"variable",
".",
"prior_class_dict",
"prior_prior_model_dict",
"=",
"self",
".",
"variable",
".",
"prior_prior_model_dict",
"for",
"prior_name",
... | The param_names vector is a list each parameter's analysis_path, and is used for *GetDist* visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class. | [
"The",
"param_names",
"vector",
"is",
"a",
"list",
"each",
"parameter",
"s",
"analysis_path",
"and",
"is",
"used",
"for",
"*",
"GetDist",
"*",
"visualization",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L312-L330 | train | The param_names vector is a list each parameter s analysis_path and is used for GetDist visualization. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | NonLinearOptimizer.create_paramnames_file | def create_paramnames_file(self):
"""The param_names file lists every parameter's analysis_path and Latex tag, and is used for *GetDist*
visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class."""... | python | def create_paramnames_file(self):
"""The param_names file lists every parameter's analysis_path and Latex tag, and is used for *GetDist*
visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class."""... | [
"def",
"create_paramnames_file",
"(",
"self",
")",
":",
"paramnames_names",
"=",
"self",
".",
"variable",
".",
"param_names",
"paramnames_labels",
"=",
"self",
".",
"param_labels",
"with",
"open",
"(",
"self",
".",
"file_param_names",
",",
"'w'",
")",
"as",
"p... | The param_names file lists every parameter's analysis_path and Latex tag, and is used for *GetDist*
visualization.
The parameter names are determined from the class instance names of the model_mapper. Latex tags are
properties of each model class. | [
"The",
"param_names",
"file",
"lists",
"every",
"parameter",
"s",
"analysis_path",
"and",
"Latex",
"tag",
"and",
"is",
"used",
"for",
"*",
"GetDist",
"*",
"visualization",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L332-L344 | train | The param_names file lists every parameter s analysis_path and Latex tag and is used for GetDist*
visualization. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | MultiNest.gaussian_priors_at_sigma_limit | def gaussian_priors_at_sigma_limit(self, sigma_limit):
"""Compute the Gaussian Priors these results should be initialzed with in the next phase, by taking their \
most probable values (e.g the means of their PDF) and computing the error at an input sigma_limit.
Parameters
-----------
... | python | def gaussian_priors_at_sigma_limit(self, sigma_limit):
"""Compute the Gaussian Priors these results should be initialzed with in the next phase, by taking their \
most probable values (e.g the means of their PDF) and computing the error at an input sigma_limit.
Parameters
-----------
... | [
"def",
"gaussian_priors_at_sigma_limit",
"(",
"self",
",",
"sigma_limit",
")",
":",
"means",
"=",
"self",
".",
"most_probable_from_summary",
"(",
")",
"uppers",
"=",
"self",
".",
"model_at_upper_sigma_limit",
"(",
"sigma_limit",
")",
"lowers",
"=",
"self",
".",
... | Compute the Gaussian Priors these results should be initialzed with in the next phase, by taking their \
most probable values (e.g the means of their PDF) and computing the error at an input sigma_limit.
Parameters
-----------
sigma_limit : float
The sigma limit within which... | [
"Compute",
"the",
"Gaussian",
"Priors",
"these",
"results",
"should",
"be",
"initialzed",
"with",
"in",
"the",
"next",
"phase",
"by",
"taking",
"their",
"\\",
"most",
"probable",
"values",
"(",
"e",
".",
"g",
"the",
"means",
"of",
"their",
"PDF",
")",
"a... | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L666-L684 | train | Compute the Gaussian Priors of the current set of resources at a given sigma limit. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | MultiNest.model_at_upper_sigma_limit | def model_at_upper_sigma_limit(self, sigma_limit):
"""Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
----------... | python | def model_at_upper_sigma_limit(self, sigma_limit):
"""Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
----------... | [
"def",
"model_at_upper_sigma_limit",
"(",
"self",
",",
"sigma_limit",
")",
":",
"return",
"list",
"(",
"map",
"(",
"lambda",
"param",
":",
"param",
"[",
"1",
"]",
",",
"self",
".",
"model_at_sigma_limit",
"(",
"sigma_limit",
")",
")",
")"
] | Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
-----------
sigma_limit : float
The sigma limit with... | [
"Setup",
"1D",
"vectors",
"of",
"the",
"upper",
"and",
"lower",
"limits",
"of",
"the",
"multinest",
"nlo",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L691-L703 | train | Setup 1D vectors of the upper and lower limits of the multinest nlo. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | MultiNest.model_at_lower_sigma_limit | def model_at_lower_sigma_limit(self, sigma_limit):
"""Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
----------... | python | def model_at_lower_sigma_limit(self, sigma_limit):
"""Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
----------... | [
"def",
"model_at_lower_sigma_limit",
"(",
"self",
",",
"sigma_limit",
")",
":",
"return",
"list",
"(",
"map",
"(",
"lambda",
"param",
":",
"param",
"[",
"0",
"]",
",",
"self",
".",
"model_at_sigma_limit",
"(",
"sigma_limit",
")",
")",
")"
] | Setup 1D vectors of the upper and lower limits of the multinest nlo.
These are generated at an input limfrac, which gives the percentage of 1d posterior weighted samples within \
each parameter estimate
Parameters
-----------
sigma_limit : float
The sigma limit with... | [
"Setup",
"1D",
"vectors",
"of",
"the",
"upper",
"and",
"lower",
"limits",
"of",
"the",
"multinest",
"nlo",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L705-L717 | train | Setup 1D vectors of the upper and lower limits of the multinest nlo. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | MultiNest.weighted_sample_instance_from_weighted_samples | def weighted_sample_instance_from_weighted_samples(self, index):
"""Setup a model instance of a weighted sample, including its weight and likelihood.
Parameters
-----------
index : int
The index of the weighted sample to return.
"""
model, weight, likelihood ... | python | def weighted_sample_instance_from_weighted_samples(self, index):
"""Setup a model instance of a weighted sample, including its weight and likelihood.
Parameters
-----------
index : int
The index of the weighted sample to return.
"""
model, weight, likelihood ... | [
"def",
"weighted_sample_instance_from_weighted_samples",
"(",
"self",
",",
"index",
")",
":",
"model",
",",
"weight",
",",
"likelihood",
"=",
"self",
".",
"weighted_sample_model_from_weighted_samples",
"(",
"index",
")",
"self",
".",
"_weighted_sample_model",
"=",
"mo... | Setup a model instance of a weighted sample, including its weight and likelihood.
Parameters
-----------
index : int
The index of the weighted sample to return. | [
"Setup",
"a",
"model",
"instance",
"of",
"a",
"weighted",
"sample",
"including",
"its",
"weight",
"and",
"likelihood",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L724-L736 | train | Setup a model instance of a weighted sample including its weight and likelihood. |
rhayes777/PyAutoFit | autofit/optimize/non_linear.py | MultiNest.weighted_sample_model_from_weighted_samples | def weighted_sample_model_from_weighted_samples(self, index):
"""From a weighted sample return the model, weight and likelihood hood.
NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \
-2.0*likelihood. This routine converts these back to ... | python | def weighted_sample_model_from_weighted_samples(self, index):
"""From a weighted sample return the model, weight and likelihood hood.
NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \
-2.0*likelihood. This routine converts these back to ... | [
"def",
"weighted_sample_model_from_weighted_samples",
"(",
"self",
",",
"index",
")",
":",
"return",
"list",
"(",
"self",
".",
"pdf",
".",
"samples",
"[",
"index",
"]",
")",
",",
"self",
".",
"pdf",
".",
"weights",
"[",
"index",
"]",
",",
"-",
"0.5",
"... | From a weighted sample return the model, weight and likelihood hood.
NOTE: GetDist reads the log likelihood from the weighted_sample.txt file (column 2), which are defined as \
-2.0*likelihood. This routine converts these back to likelihood.
Parameters
-----------
index : int
... | [
"From",
"a",
"weighted",
"sample",
"return",
"the",
"model",
"weight",
"and",
"likelihood",
"hood",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/non_linear.py#L738-L749 | train | This routine returns the model weight and likelihood hood from a weighted sample. |
Riminder/python-riminder-api | riminder/hmacutils.py | compare_digest | def compare_digest(a, b):
"""Compare 2 hash digest."""
py_version = sys.version_info[0]
if py_version >= 3:
return _compare_digest_py3(a, b)
return _compare_digest_py2(a, b) | python | def compare_digest(a, b):
"""Compare 2 hash digest."""
py_version = sys.version_info[0]
if py_version >= 3:
return _compare_digest_py3(a, b)
return _compare_digest_py2(a, b) | [
"def",
"compare_digest",
"(",
"a",
",",
"b",
")",
":",
"py_version",
"=",
"sys",
".",
"version_info",
"[",
"0",
"]",
"if",
"py_version",
">=",
"3",
":",
"return",
"_compare_digest_py3",
"(",
"a",
",",
"b",
")",
"return",
"_compare_digest_py2",
"(",
"a",
... | Compare 2 hash digest. | [
"Compare",
"2",
"hash",
"digest",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/hmacutils.py#L15-L20 | train | Compare 2 hash digest. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_trajectories | def _render_trajectories(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array]) -> None:
'''Prints the first batch of simulated `trajectories`.
Args:
trajectories: NonFluents, states, actions, interms and rewards.
'''
if self._verbose:
... | python | def _render_trajectories(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array]) -> None:
'''Prints the first batch of simulated `trajectories`.
Args:
trajectories: NonFluents, states, actions, interms and rewards.
'''
if self._verbose:
... | [
"def",
"_render_trajectories",
"(",
"self",
",",
"trajectories",
":",
"Tuple",
"[",
"NonFluents",
",",
"Fluents",
",",
"Fluents",
",",
"Fluents",
",",
"np",
".",
"array",
"]",
")",
"->",
"None",
":",
"if",
"self",
".",
"_verbose",
":",
"non_fluents",
","... | Prints the first batch of simulated `trajectories`.
Args:
trajectories: NonFluents, states, actions, interms and rewards. | [
"Prints",
"the",
"first",
"batch",
"of",
"simulated",
"trajectories",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L50-L65 | train | Prints the first batch of simulated trajectories. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_batch | def _render_batch(self,
non_fluents: NonFluents,
states: Fluents, actions: Fluents, interms: Fluents,
rewards: np.array,
horizon: Optional[int] = None) -> None:
'''Prints `non_fluents`, `states`, `actions`, `interms` and `rewards`
for given `horizon`.
... | python | def _render_batch(self,
non_fluents: NonFluents,
states: Fluents, actions: Fluents, interms: Fluents,
rewards: np.array,
horizon: Optional[int] = None) -> None:
'''Prints `non_fluents`, `states`, `actions`, `interms` and `rewards`
for given `horizon`.
... | [
"def",
"_render_batch",
"(",
"self",
",",
"non_fluents",
":",
"NonFluents",
",",
"states",
":",
"Fluents",
",",
"actions",
":",
"Fluents",
",",
"interms",
":",
"Fluents",
",",
"rewards",
":",
"np",
".",
"array",
",",
"horizon",
":",
"Optional",
"[",
"int... | Prints `non_fluents`, `states`, `actions`, `interms` and `rewards`
for given `horizon`.
Args:
states (Sequence[Tuple[str, np.array]]): A state trajectory.
actions (Sequence[Tuple[str, np.array]]): An action trajectory.
interms (Sequence[Tuple[str, np.array]]): An int... | [
"Prints",
"non_fluents",
"states",
"actions",
"interms",
"and",
"rewards",
"for",
"given",
"horizon",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L67-L91 | train | Prints a batch of state actions interms and rewards for given horizon. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_timestep | def _render_timestep(self,
t: int,
s: Fluents, a: Fluents, f: Fluents,
r: np.float32) -> None:
'''Prints fluents and rewards for the given timestep `t`.
Args:
t (int): timestep
s (Sequence[Tuple[str], np.array]: State fluents.
a (S... | python | def _render_timestep(self,
t: int,
s: Fluents, a: Fluents, f: Fluents,
r: np.float32) -> None:
'''Prints fluents and rewards for the given timestep `t`.
Args:
t (int): timestep
s (Sequence[Tuple[str], np.array]: State fluents.
a (S... | [
"def",
"_render_timestep",
"(",
"self",
",",
"t",
":",
"int",
",",
"s",
":",
"Fluents",
",",
"a",
":",
"Fluents",
",",
"f",
":",
"Fluents",
",",
"r",
":",
"np",
".",
"float32",
")",
"->",
"None",
":",
"print",
"(",
"\"============================\"",
... | Prints fluents and rewards for the given timestep `t`.
Args:
t (int): timestep
s (Sequence[Tuple[str], np.array]: State fluents.
a (Sequence[Tuple[str], np.array]: Action fluents.
f (Sequence[Tuple[str], np.array]: Interm state fluents.
r (np.float32)... | [
"Prints",
"fluents",
"and",
"rewards",
"for",
"the",
"given",
"timestep",
"t",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L93-L115 | train | Prints fluents and rewards for the given timestep t. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_fluent_timestep | def _render_fluent_timestep(self,
fluent_type: str,
fluents: Sequence[Tuple[str, np.array]],
fluent_variables: Sequence[Tuple[str, List[str]]]) -> None:
'''Prints `fluents` of given `fluent_type` as list of instantiated variables
with corresponding values.
Ar... | python | def _render_fluent_timestep(self,
fluent_type: str,
fluents: Sequence[Tuple[str, np.array]],
fluent_variables: Sequence[Tuple[str, List[str]]]) -> None:
'''Prints `fluents` of given `fluent_type` as list of instantiated variables
with corresponding values.
Ar... | [
"def",
"_render_fluent_timestep",
"(",
"self",
",",
"fluent_type",
":",
"str",
",",
"fluents",
":",
"Sequence",
"[",
"Tuple",
"[",
"str",
",",
"np",
".",
"array",
"]",
"]",
",",
"fluent_variables",
":",
"Sequence",
"[",
"Tuple",
"[",
"str",
",",
"List",
... | Prints `fluents` of given `fluent_type` as list of instantiated variables
with corresponding values.
Args:
fluent_type (str): Fluent type.
fluents (Sequence[Tuple[str, np.array]]): List of pairs (fluent_name, fluent_values).
fluent_variables (Sequence[Tuple[str, List... | [
"Prints",
"fluents",
"of",
"given",
"fluent_type",
"as",
"list",
"of",
"instantiated",
"variables",
"with",
"corresponding",
"values",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L117-L136 | train | Prints fluents of given fluent_type as list of instantiated variables
with corresponding values. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_reward | def _render_reward(self, r: np.float32) -> None:
'''Prints reward `r`.'''
print("reward = {:.4f}".format(float(r)))
print() | python | def _render_reward(self, r: np.float32) -> None:
'''Prints reward `r`.'''
print("reward = {:.4f}".format(float(r)))
print() | [
"def",
"_render_reward",
"(",
"self",
",",
"r",
":",
"np",
".",
"float32",
")",
"->",
"None",
":",
"print",
"(",
"\"reward = {:.4f}\"",
".",
"format",
"(",
"float",
"(",
"r",
")",
")",
")",
"print",
"(",
")"
] | Prints reward `r`. | [
"Prints",
"reward",
"r",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L138-L141 | train | Prints reward r. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_round_init | def _render_round_init(self, horizon: int, non_fluents: NonFluents) -> None:
'''Prints round init information about `horizon` and `non_fluents`.'''
print('*********************************************************')
print('>>> ROUND INIT, horizon = {}'.format(horizon))
print('************... | python | def _render_round_init(self, horizon: int, non_fluents: NonFluents) -> None:
'''Prints round init information about `horizon` and `non_fluents`.'''
print('*********************************************************')
print('>>> ROUND INIT, horizon = {}'.format(horizon))
print('************... | [
"def",
"_render_round_init",
"(",
"self",
",",
"horizon",
":",
"int",
",",
"non_fluents",
":",
"NonFluents",
")",
"->",
"None",
":",
"print",
"(",
"'*********************************************************'",
")",
"print",
"(",
"'>>> ROUND INIT, horizon = {}'",
".",
... | Prints round init information about `horizon` and `non_fluents`. | [
"Prints",
"round",
"init",
"information",
"about",
"horizon",
"and",
"non_fluents",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L143-L149 | train | Prints round init information about horizon and non_fluents. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/generic_visualizer.py | GenericVisualizer._render_round_end | def _render_round_end(self, rewards: np.array) -> None:
'''Prints round end information about `rewards`.'''
print("*********************************************************")
print(">>> ROUND END")
print("*********************************************************")
total_reward = ... | python | def _render_round_end(self, rewards: np.array) -> None:
'''Prints round end information about `rewards`.'''
print("*********************************************************")
print(">>> ROUND END")
print("*********************************************************")
total_reward = ... | [
"def",
"_render_round_end",
"(",
"self",
",",
"rewards",
":",
"np",
".",
"array",
")",
"->",
"None",
":",
"print",
"(",
"\"*********************************************************\"",
")",
"print",
"(",
"\">>> ROUND END\"",
")",
"print",
"(",
"\"*********************... | Prints round end information about `rewards`. | [
"Prints",
"round",
"end",
"information",
"about",
"rewards",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/generic_visualizer.py#L151-L159 | train | Prints round end information about rewards. |
edx/edx-celeryutils | celery_utils/persist_on_failure.py | _truncate_to_field | def _truncate_to_field(model, field_name, value):
"""
Shorten data to fit in the specified model field.
If the data were too big for the field, it would cause a failure to
insert, so we shorten it, truncating in the middle (because
valuable information often shows up at the end.
"""
field =... | python | def _truncate_to_field(model, field_name, value):
"""
Shorten data to fit in the specified model field.
If the data were too big for the field, it would cause a failure to
insert, so we shorten it, truncating in the middle (because
valuable information often shows up at the end.
"""
field =... | [
"def",
"_truncate_to_field",
"(",
"model",
",",
"field_name",
",",
"value",
")",
":",
"field",
"=",
"model",
".",
"_meta",
".",
"get_field",
"(",
"field_name",
")",
"# pylint: disable=protected-access",
"if",
"len",
"(",
"value",
")",
">",
"field",
".",
"max... | Shorten data to fit in the specified model field.
If the data were too big for the field, it would cause a failure to
insert, so we shorten it, truncating in the middle (because
valuable information often shows up at the end. | [
"Shorten",
"data",
"to",
"fit",
"in",
"the",
"specified",
"model",
"field",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/persist_on_failure.py#L45-L61 | train | Shorten data to fit in the specified model field. |
edx/edx-celeryutils | celery_utils/persist_on_failure.py | PersistOnFailureTask.on_failure | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""
If the task fails, persist a record of the task.
"""
if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists():
FailedTask.objects.create(
task_name=_truncate_to_field(Failed... | python | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""
If the task fails, persist a record of the task.
"""
if not FailedTask.objects.filter(task_id=task_id, datetime_resolved=None).exists():
FailedTask.objects.create(
task_name=_truncate_to_field(Failed... | [
"def",
"on_failure",
"(",
"self",
",",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")",
":",
"if",
"not",
"FailedTask",
".",
"objects",
".",
"filter",
"(",
"task_id",
"=",
"task_id",
",",
"datetime_resolved",
"=",
"None",
")",
".",... | If the task fails, persist a record of the task. | [
"If",
"the",
"task",
"fails",
"persist",
"a",
"record",
"of",
"the",
"task",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/persist_on_failure.py#L22-L34 | train | Persist a record of the task. |
thiagopbueno/tf-rddlsim | tfrddlsim/viz/abstract_visualizer.py | Visualizer.render | def render(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array],
batch: Optional[int] = None) -> None:
'''Renders the simulated `trajectories` for the given `batch`.
Args:
trajectories: NonFluents, states, actions, interms and rewards.
... | python | def render(self,
trajectories: Tuple[NonFluents, Fluents, Fluents, Fluents, np.array],
batch: Optional[int] = None) -> None:
'''Renders the simulated `trajectories` for the given `batch`.
Args:
trajectories: NonFluents, states, actions, interms and rewards.
... | [
"def",
"render",
"(",
"self",
",",
"trajectories",
":",
"Tuple",
"[",
"NonFluents",
",",
"Fluents",
",",
"Fluents",
",",
"Fluents",
",",
"np",
".",
"array",
"]",
",",
"batch",
":",
"Optional",
"[",
"int",
"]",
"=",
"None",
")",
"->",
"None",
":",
"... | Renders the simulated `trajectories` for the given `batch`.
Args:
trajectories: NonFluents, states, actions, interms and rewards.
batch: Number of batches to render. | [
"Renders",
"the",
"simulated",
"trajectories",
"for",
"the",
"given",
"batch",
"."
] | d7102a0ad37d179dbb23141640254ea383d3b43f | https://github.com/thiagopbueno/tf-rddlsim/blob/d7102a0ad37d179dbb23141640254ea383d3b43f/tfrddlsim/viz/abstract_visualizer.py#L41-L50 | train | Renders the simulated trajectories for the given batch. |
grundprinzip/pyxplorer | pyxplorer/types.py | Column.min | def min(self):
"""
:returns the minimum of the column
"""
res = self._qexec("min(%s)" % self._name)
if len(res) > 0:
self._min = res[0][0]
return self._min | python | def min(self):
"""
:returns the minimum of the column
"""
res = self._qexec("min(%s)" % self._name)
if len(res) > 0:
self._min = res[0][0]
return self._min | [
"def",
"min",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"min(%s)\"",
"%",
"self",
".",
"_name",
")",
"if",
"len",
"(",
"res",
")",
">",
"0",
":",
"self",
".",
"_min",
"=",
"res",
"[",
"0",
"]",
"[",
"0",
"]",
"return",
... | :returns the minimum of the column | [
":",
"returns",
"the",
"minimum",
"of",
"the",
"column"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L64-L71 | train | returns the minimum of the column
|
grundprinzip/pyxplorer | pyxplorer/types.py | Column.max | def max(self):
"""
:returns the maximum of the column
"""
res = self._qexec("max(%s)" % self._name)
if len(res) > 0:
self._max = res[0][0]
return self._max | python | def max(self):
"""
:returns the maximum of the column
"""
res = self._qexec("max(%s)" % self._name)
if len(res) > 0:
self._max = res[0][0]
return self._max | [
"def",
"max",
"(",
"self",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"max(%s)\"",
"%",
"self",
".",
"_name",
")",
"if",
"len",
"(",
"res",
")",
">",
"0",
":",
"self",
".",
"_max",
"=",
"res",
"[",
"0",
"]",
"[",
"0",
"]",
"return",
... | :returns the maximum of the column | [
":",
"returns",
"the",
"maximum",
"of",
"the",
"column"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L74-L81 | train | returns the maximum value of the column
|
grundprinzip/pyxplorer | pyxplorer/types.py | Column.distribution | def distribution(self, limit=1024):
"""
Build the distribution of distinct values
"""
res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
order="__cnt DESC LIMIT %d" % limit)
dist = []
cnt = self._table.size()
... | python | def distribution(self, limit=1024):
"""
Build the distribution of distinct values
"""
res = self._qexec("%s, count(*) as __cnt" % self.name(), group="%s" % self.name(),
order="__cnt DESC LIMIT %d" % limit)
dist = []
cnt = self._table.size()
... | [
"def",
"distribution",
"(",
"self",
",",
"limit",
"=",
"1024",
")",
":",
"res",
"=",
"self",
".",
"_qexec",
"(",
"\"%s, count(*) as __cnt\"",
"%",
"self",
".",
"name",
"(",
")",
",",
"group",
"=",
"\"%s\"",
"%",
"self",
".",
"name",
"(",
")",
",",
... | Build the distribution of distinct values | [
"Build",
"the",
"distribution",
"of",
"distinct",
"values"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L91-L105 | train | Build the distribution of distinct values for this object |
grundprinzip/pyxplorer | pyxplorer/types.py | Table.column | def column(self, col):
"""
Given either a column index or name return the column structure
:param col: either index or name
:return: column data structure
"""
if type(col) is str:
for c in self._cols:
if c.name == col:
retur... | python | def column(self, col):
"""
Given either a column index or name return the column structure
:param col: either index or name
:return: column data structure
"""
if type(col) is str:
for c in self._cols:
if c.name == col:
retur... | [
"def",
"column",
"(",
"self",
",",
"col",
")",
":",
"if",
"type",
"(",
"col",
")",
"is",
"str",
":",
"for",
"c",
"in",
"self",
".",
"_cols",
":",
"if",
"c",
".",
"name",
"==",
"col",
":",
"return",
"c",
"else",
":",
"return",
"self",
".",
"_c... | Given either a column index or name return the column structure
:param col: either index or name
:return: column data structure | [
"Given",
"either",
"a",
"column",
"index",
"or",
"name",
"return",
"the",
"column",
"structure",
":",
"param",
"col",
":",
"either",
"index",
"or",
"name",
":",
"return",
":",
"column",
"data",
"structure"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L184-L195 | train | Given either a column index or name return the column structure
|
grundprinzip/pyxplorer | pyxplorer/types.py | Table.columns | def columns(self):
"""
:return: the list of column in this table
"""
c = self._connection.cursor()
c.execute("describe `%s`.`%s`" % (self._db, self._name))
self._cols = []
for col in c.fetchall():
self._cols.append(Column.build(col, table=self, con=sel... | python | def columns(self):
"""
:return: the list of column in this table
"""
c = self._connection.cursor()
c.execute("describe `%s`.`%s`" % (self._db, self._name))
self._cols = []
for col in c.fetchall():
self._cols.append(Column.build(col, table=self, con=sel... | [
"def",
"columns",
"(",
"self",
")",
":",
"c",
"=",
"self",
".",
"_connection",
".",
"cursor",
"(",
")",
"c",
".",
"execute",
"(",
"\"describe `%s`.`%s`\"",
"%",
"(",
"self",
".",
"_db",
",",
"self",
".",
"_name",
")",
")",
"self",
".",
"_cols",
"="... | :return: the list of column in this table | [
":",
"return",
":",
"the",
"list",
"of",
"column",
"in",
"this",
"table"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L215-L224 | train | returns the list of columns in this table |
grundprinzip/pyxplorer | pyxplorer/types.py | Table.distinct_value_fractions | def distinct_value_fractions(self):
"""
:return: returns a data frame of name distinct value fractions
"""
return pd.DataFrame([c.dcount() / float(self.size()) for c in self.columns()],
index=[c.name() for c in self.columns()], columns=["fraction"]) | python | def distinct_value_fractions(self):
"""
:return: returns a data frame of name distinct value fractions
"""
return pd.DataFrame([c.dcount() / float(self.size()) for c in self.columns()],
index=[c.name() for c in self.columns()], columns=["fraction"]) | [
"def",
"distinct_value_fractions",
"(",
"self",
")",
":",
"return",
"pd",
".",
"DataFrame",
"(",
"[",
"c",
".",
"dcount",
"(",
")",
"/",
"float",
"(",
"self",
".",
"size",
"(",
")",
")",
"for",
"c",
"in",
"self",
".",
"columns",
"(",
")",
"]",
",... | :return: returns a data frame of name distinct value fractions | [
":",
"return",
":",
"returns",
"a",
"data",
"frame",
"of",
"name",
"distinct",
"value",
"fractions"
] | 34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2 | https://github.com/grundprinzip/pyxplorer/blob/34c1d166cfef4a94aeb6d5fcb3cbb726d48146e2/pyxplorer/types.py#L262-L267 | train | returns a data frame of name distinct value fractions |
gofed/gofedlib | gofedlib/distribution/distributionnameparser.py | DistributionNameParser.parse | def parse(self, name):
"""Parse distribution string
:param name: distribution string, e.g. "Fedora 23"
:type name: string
"""
name = name.strip()
groups = self._parseFedora(name)
if groups:
self._signature = DistributionNameSignature("Fedora", groups.group(1))
return self
raise ValueError("Dist... | python | def parse(self, name):
"""Parse distribution string
:param name: distribution string, e.g. "Fedora 23"
:type name: string
"""
name = name.strip()
groups = self._parseFedora(name)
if groups:
self._signature = DistributionNameSignature("Fedora", groups.group(1))
return self
raise ValueError("Dist... | [
"def",
"parse",
"(",
"self",
",",
"name",
")",
":",
"name",
"=",
"name",
".",
"strip",
"(",
")",
"groups",
"=",
"self",
".",
"_parseFedora",
"(",
"name",
")",
"if",
"groups",
":",
"self",
".",
"_signature",
"=",
"DistributionNameSignature",
"(",
"\"Fed... | Parse distribution string
:param name: distribution string, e.g. "Fedora 23"
:type name: string | [
"Parse",
"distribution",
"string"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/distribution/distributionnameparser.py#L52-L64 | train | Parse a distribution string and return a Distribution object |
gofed/gofedlib | gofedlib/repository/githubclient.py | GithubClient.branches | def branches(self):
"""Return a list of branches for given repository
Raises GithubException if rate limit is exceeded
:return: [str]
"""
if self.github.get_rate_limit().rate.limit == 0:
raise GithubException
branches = self.repo.get_branches()
return [x.name for x in branches] | python | def branches(self):
"""Return a list of branches for given repository
Raises GithubException if rate limit is exceeded
:return: [str]
"""
if self.github.get_rate_limit().rate.limit == 0:
raise GithubException
branches = self.repo.get_branches()
return [x.name for x in branches] | [
"def",
"branches",
"(",
"self",
")",
":",
"if",
"self",
".",
"github",
".",
"get_rate_limit",
"(",
")",
".",
"rate",
".",
"limit",
"==",
"0",
":",
"raise",
"GithubException",
"branches",
"=",
"self",
".",
"repo",
".",
"get_branches",
"(",
")",
"return"... | Return a list of branches for given repository
Raises GithubException if rate limit is exceeded
:return: [str] | [
"Return",
"a",
"list",
"of",
"branches",
"for",
"given",
"repository"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/githubclient.py#L19-L30 | train | Return a list of branches for given repository
Raises GithubException if rate limit is exceeded
|
gofed/gofedlib | gofedlib/repository/githubclient.py | GithubClient._commitData | def _commitData(self, commit):
"""Get data from a commit object
:param commit: commit object
:type commit: github.Commit.Commit
"""
return {
"hexsha": commit.sha,
"adate": time.mktime(commit.commit.author.date.timetuple()),
"cdate": time.mktime(commit.commit.committer.date.timetuple()),
"author"... | python | def _commitData(self, commit):
"""Get data from a commit object
:param commit: commit object
:type commit: github.Commit.Commit
"""
return {
"hexsha": commit.sha,
"adate": time.mktime(commit.commit.author.date.timetuple()),
"cdate": time.mktime(commit.commit.committer.date.timetuple()),
"author"... | [
"def",
"_commitData",
"(",
"self",
",",
"commit",
")",
":",
"return",
"{",
"\"hexsha\"",
":",
"commit",
".",
"sha",
",",
"\"adate\"",
":",
"time",
".",
"mktime",
"(",
"commit",
".",
"commit",
".",
"author",
".",
"date",
".",
"timetuple",
"(",
")",
")... | Get data from a commit object
:param commit: commit object
:type commit: github.Commit.Commit | [
"Get",
"data",
"from",
"a",
"commit",
"object"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/githubclient.py#L32-L44 | train | Get data from a commit object
|
gofed/gofedlib | gofedlib/repository/githubclient.py | GithubClient.commits | def commits(self, branch, since=0, to=int(time.time()) + 86400):
"""For given branch return a list of commits.
Each commit contains basic information about itself.
Raises GithubException if rate limit is exceeded
:param branch: git branch
:type branch: str
:param since: minimal timestamp for commit's com... | python | def commits(self, branch, since=0, to=int(time.time()) + 86400):
"""For given branch return a list of commits.
Each commit contains basic information about itself.
Raises GithubException if rate limit is exceeded
:param branch: git branch
:type branch: str
:param since: minimal timestamp for commit's com... | [
"def",
"commits",
"(",
"self",
",",
"branch",
",",
"since",
"=",
"0",
",",
"to",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"+",
"86400",
")",
":",
"if",
"self",
".",
"github",
".",
"get_rate_limit",
"(",
")",
".",
"rate",
".",
"limit... | For given branch return a list of commits.
Each commit contains basic information about itself.
Raises GithubException if rate limit is exceeded
:param branch: git branch
:type branch: str
:param since: minimal timestamp for commit's commit date
:type since: int
:param to: maximal timestamp for commit... | [
"For",
"given",
"branch",
"return",
"a",
"list",
"of",
"commits",
".",
"Each",
"commit",
"contains",
"basic",
"information",
"about",
"itself",
"."
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/githubclient.py#L46-L67 | train | For given branch return a list of commits. |
gofed/gofedlib | gofedlib/repository/githubclient.py | GithubClient.commit | def commit(self, commit):
"""Get data for a given commit
Raises KeyError if a commit is not found or not parsed.
:param commit: repository commit
:type commit: string
"""
try:
return self._commitData(self.repo.get_commit(commit))
except (ValueError, KeyError, GithubException):
raise KeyError("Com... | python | def commit(self, commit):
"""Get data for a given commit
Raises KeyError if a commit is not found or not parsed.
:param commit: repository commit
:type commit: string
"""
try:
return self._commitData(self.repo.get_commit(commit))
except (ValueError, KeyError, GithubException):
raise KeyError("Com... | [
"def",
"commit",
"(",
"self",
",",
"commit",
")",
":",
"try",
":",
"return",
"self",
".",
"_commitData",
"(",
"self",
".",
"repo",
".",
"get_commit",
"(",
"commit",
")",
")",
"except",
"(",
"ValueError",
",",
"KeyError",
",",
"GithubException",
")",
":... | Get data for a given commit
Raises KeyError if a commit is not found or not parsed.
:param commit: repository commit
:type commit: string | [
"Get",
"data",
"for",
"a",
"given",
"commit"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/githubclient.py#L69-L80 | train | Get data for a given commit. |
zalando-stups/lizzy-client | lizzy_client/token.py | get_token | def get_token(url: str, scopes: str, credentials_dir: str) -> dict:
"""
Get access token info.
"""
tokens.configure(url=url, dir=credentials_dir)
tokens.manage('lizzy', [scopes])
tokens.start()
return tokens.get('lizzy') | python | def get_token(url: str, scopes: str, credentials_dir: str) -> dict:
"""
Get access token info.
"""
tokens.configure(url=url, dir=credentials_dir)
tokens.manage('lizzy', [scopes])
tokens.start()
return tokens.get('lizzy') | [
"def",
"get_token",
"(",
"url",
":",
"str",
",",
"scopes",
":",
"str",
",",
"credentials_dir",
":",
"str",
")",
"->",
"dict",
":",
"tokens",
".",
"configure",
"(",
"url",
"=",
"url",
",",
"dir",
"=",
"credentials_dir",
")",
"tokens",
".",
"manage",
"... | Get access token info. | [
"Get",
"access",
"token",
"info",
"."
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/token.py#L4-L13 | train | Get access token info. |
peterbe/gg | gg/builtins/config.py | config | def config(config, fork_name="", origin_name=""):
"""Setting various configuration options"""
state = read(config.configfile)
any_set = False
if fork_name:
update(config.configfile, {"FORK_NAME": fork_name})
success_out("fork-name set to: {}".format(fork_name))
any_set = True
... | python | def config(config, fork_name="", origin_name=""):
"""Setting various configuration options"""
state = read(config.configfile)
any_set = False
if fork_name:
update(config.configfile, {"FORK_NAME": fork_name})
success_out("fork-name set to: {}".format(fork_name))
any_set = True
... | [
"def",
"config",
"(",
"config",
",",
"fork_name",
"=",
"\"\"",
",",
"origin_name",
"=",
"\"\"",
")",
":",
"state",
"=",
"read",
"(",
"config",
".",
"configfile",
")",
"any_set",
"=",
"False",
"if",
"fork_name",
":",
"update",
"(",
"config",
".",
"confi... | Setting various configuration options | [
"Setting",
"various",
"configuration",
"options"
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/config.py#L22-L35 | train | Set various configuration options |
eventifyio/eventify | eventify/persist/__init__.py | persist_event | async def persist_event(topic, event, pool):
"""
Track event to prevent duplication of work
and potential loss of event
:param topic: The event topic
:param event: The event object
"""
# Event to json
json_event = json.dumps(event.__dict__)
# Connect to database or create and connec... | python | async def persist_event(topic, event, pool):
"""
Track event to prevent duplication of work
and potential loss of event
:param topic: The event topic
:param event: The event object
"""
# Event to json
json_event = json.dumps(event.__dict__)
# Connect to database or create and connec... | [
"async",
"def",
"persist_event",
"(",
"topic",
",",
"event",
",",
"pool",
")",
":",
"# Event to json",
"json_event",
"=",
"json",
".",
"dumps",
"(",
"event",
".",
"__dict__",
")",
"# Connect to database or create and connect if non existent",
"conn",
"=",
"await",
... | Track event to prevent duplication of work
and potential loss of event
:param topic: The event topic
:param event: The event object | [
"Track",
"event",
"to",
"prevent",
"duplication",
"of",
"work",
"and",
"potential",
"loss",
"of",
"event",
":",
"param",
"topic",
":",
"The",
"event",
"topic",
":",
"param",
"event",
":",
"The",
"event",
"object"
] | 0e519964a56bd07a879b266f21f177749c63aaed | https://github.com/eventifyio/eventify/blob/0e519964a56bd07a879b266f21f177749c63aaed/eventify/persist/__init__.py#L16-L50 | train | Persist an event into the database. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.set_area_to_sip_signature | def set_area_to_sip_signature(self, xmin, xmax, zmin, zmax, spectrum):
"""Parameterize the eit instance by supplying one
SIP spectrum and the area to apply to.
Parameters
----------
xmin : float
Minimum x coordinate of the area
xmax : float
Maximu... | python | def set_area_to_sip_signature(self, xmin, xmax, zmin, zmax, spectrum):
"""Parameterize the eit instance by supplying one
SIP spectrum and the area to apply to.
Parameters
----------
xmin : float
Minimum x coordinate of the area
xmax : float
Maximu... | [
"def",
"set_area_to_sip_signature",
"(",
"self",
",",
"xmin",
",",
"xmax",
",",
"zmin",
",",
"zmax",
",",
"spectrum",
")",
":",
"assert",
"isinstance",
"(",
"spectrum",
",",
"(",
"sip_response",
",",
"sip_response2",
")",
")",
"assert",
"np",
".",
"all",
... | Parameterize the eit instance by supplying one
SIP spectrum and the area to apply to.
Parameters
----------
xmin : float
Minimum x coordinate of the area
xmax : float
Maximum x coordinate of the area
zmin : float
Minimum z coordinate o... | [
"Parameterize",
"the",
"eit",
"instance",
"by",
"supplying",
"one",
"SIP",
"spectrum",
"and",
"the",
"area",
"to",
"apply",
"to",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L163-L188 | train | Parameterize the oneCOOKIE with the area to apply to the SIP spectrum and the area to apply to. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.add_homogeneous_model | def add_homogeneous_model(self, magnitude, phase=0, frequency=None):
"""Add homogeneous models to one or all tomodirs. Register those as
forward models
Parameters
----------
magnitude : float
Value of homogeneous magnitude model
phase : float, optional
... | python | def add_homogeneous_model(self, magnitude, phase=0, frequency=None):
"""Add homogeneous models to one or all tomodirs. Register those as
forward models
Parameters
----------
magnitude : float
Value of homogeneous magnitude model
phase : float, optional
... | [
"def",
"add_homogeneous_model",
"(",
"self",
",",
"magnitude",
",",
"phase",
"=",
"0",
",",
"frequency",
"=",
"None",
")",
":",
"if",
"frequency",
"is",
"None",
":",
"frequencies",
"=",
"self",
".",
"frequencies",
"else",
":",
"assert",
"isinstance",
"(",
... | Add homogeneous models to one or all tomodirs. Register those as
forward models
Parameters
----------
magnitude : float
Value of homogeneous magnitude model
phase : float, optional
Value of homogeneous phase model. Default 0
frequency : float, opt... | [
"Add",
"homogeneous",
"models",
"to",
"one",
"or",
"all",
"tomodirs",
".",
"Register",
"those",
"as",
"forward",
"models"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L195-L218 | train | Add homogeneous models to one or all tomodirs. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.load_data_crt_files | def load_data_crt_files(self, data_dict):
"""Load sEIT data from .ctr files (volt.dat files readable by CRTomo,
produced by CRMod)
Parameters
----------
data_dict : dict
Data files that are imported. See example down below
Examples
--------
... | python | def load_data_crt_files(self, data_dict):
"""Load sEIT data from .ctr files (volt.dat files readable by CRTomo,
produced by CRMod)
Parameters
----------
data_dict : dict
Data files that are imported. See example down below
Examples
--------
... | [
"def",
"load_data_crt_files",
"(",
"self",
",",
"data_dict",
")",
":",
"if",
"isinstance",
"(",
"data_dict",
",",
"str",
")",
":",
"raise",
"Exception",
"(",
"'Parameter must be a dict!'",
")",
"frequency_data",
"=",
"data_dict",
"[",
"'frequencies'",
"]",
"if",... | Load sEIT data from .ctr files (volt.dat files readable by CRTomo,
produced by CRMod)
Parameters
----------
data_dict : dict
Data files that are imported. See example down below
Examples
--------
>>> import glob
data_files = {}
... | [
"Load",
"sEIT",
"data",
"from",
".",
"ctr",
"files",
"(",
"volt",
".",
"dat",
"files",
"readable",
"by",
"CRTomo",
"produced",
"by",
"CRMod",
")"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L220-L271 | train | Load sEIT data from. ctr files. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.apply_crtomo_cfg | def apply_crtomo_cfg(self):
"""Set the global crtomo_cfg for all frequencies
"""
for key in sorted(self.tds.keys()):
self.tds[key].crtomo_cfg = self.crtomo_cfg.copy() | python | def apply_crtomo_cfg(self):
"""Set the global crtomo_cfg for all frequencies
"""
for key in sorted(self.tds.keys()):
self.tds[key].crtomo_cfg = self.crtomo_cfg.copy() | [
"def",
"apply_crtomo_cfg",
"(",
"self",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"self",
".",
"tds",
".",
"keys",
"(",
")",
")",
":",
"self",
".",
"tds",
"[",
"key",
"]",
".",
"crtomo_cfg",
"=",
"self",
".",
"crtomo_cfg",
".",
"copy",
"(",
")... | Set the global crtomo_cfg for all frequencies | [
"Set",
"the",
"global",
"crtomo_cfg",
"for",
"all",
"frequencies"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L273-L277 | train | Set the global crtomo_cfg for all frequencies
|
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.apply_noise_models | def apply_noise_models(self):
"""Set the global noise_model for all frequencies
"""
for key in sorted(self.tds.keys()):
self.tds[key].noise_model = self.noise_model | python | def apply_noise_models(self):
"""Set the global noise_model for all frequencies
"""
for key in sorted(self.tds.keys()):
self.tds[key].noise_model = self.noise_model | [
"def",
"apply_noise_models",
"(",
"self",
")",
":",
"for",
"key",
"in",
"sorted",
"(",
"self",
".",
"tds",
".",
"keys",
"(",
")",
")",
":",
"self",
".",
"tds",
"[",
"key",
"]",
".",
"noise_model",
"=",
"self",
".",
"noise_model"
] | Set the global noise_model for all frequencies | [
"Set",
"the",
"global",
"noise_model",
"for",
"all",
"frequencies"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L279-L283 | train | Set the global noise_model for all frequencies
|
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.save_to_eitdir | def save_to_eitdir(self, directory):
"""Save the eit data into a eit/sip directory structure
Parameters
----------
directory: string|path
output directory
"""
if os.path.isdir(directory):
raise Exception('output directory already exists')
... | python | def save_to_eitdir(self, directory):
"""Save the eit data into a eit/sip directory structure
Parameters
----------
directory: string|path
output directory
"""
if os.path.isdir(directory):
raise Exception('output directory already exists')
... | [
"def",
"save_to_eitdir",
"(",
"self",
",",
"directory",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"raise",
"Exception",
"(",
"'output directory already exists'",
")",
"os",
".",
"makedirs",
"(",
"directory",
")",
"np",
".... | Save the eit data into a eit/sip directory structure
Parameters
----------
directory: string|path
output directory | [
"Save",
"the",
"eit",
"data",
"into",
"a",
"eit",
"/",
"sip",
"directory",
"structure"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L285-L303 | train | Save the eit data into a eit directory structure |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.load_inversion_results | def load_inversion_results(self, sipdir):
"""Given an sEIT inversion directory, load inversion results and store
the corresponding parameter ids in self.assignments
Note that all previous data stored in this instance of the eitManager
will be overwritten, if required!
"""
... | python | def load_inversion_results(self, sipdir):
"""Given an sEIT inversion directory, load inversion results and store
the corresponding parameter ids in self.assignments
Note that all previous data stored in this instance of the eitManager
will be overwritten, if required!
"""
... | [
"def",
"load_inversion_results",
"(",
"self",
",",
"sipdir",
")",
":",
"# load frequencies and initialize tomodir objects for all frequencies",
"frequency_file",
"=",
"sipdir",
"+",
"os",
".",
"sep",
"+",
"'frequencies.dat'",
"frequencies",
"=",
"np",
".",
"loadtxt",
"(... | Given an sEIT inversion directory, load inversion results and store
the corresponding parameter ids in self.assignments
Note that all previous data stored in this instance of the eitManager
will be overwritten, if required! | [
"Given",
"an",
"sEIT",
"inversion",
"directory",
"load",
"inversion",
"results",
"and",
"store",
"the",
"corresponding",
"parameter",
"ids",
"in",
"self",
".",
"assignments"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L305-L341 | train | Load the inversion results and store them in self. a |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.plot_forward_models | def plot_forward_models(self, maglim=None, phalim=None, **kwargs):
"""Create plots of the forward models
Returns
-------
mag_fig: dict
Dictionary containing the figure and axes objects of the magnitude
plots
"""
return_dict = {}
N = len(... | python | def plot_forward_models(self, maglim=None, phalim=None, **kwargs):
"""Create plots of the forward models
Returns
-------
mag_fig: dict
Dictionary containing the figure and axes objects of the magnitude
plots
"""
return_dict = {}
N = len(... | [
"def",
"plot_forward_models",
"(",
"self",
",",
"maglim",
"=",
"None",
",",
"phalim",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"return_dict",
"=",
"{",
"}",
"N",
"=",
"len",
"(",
"self",
".",
"frequencies",
")",
"nrx",
"=",
"min",
"(",
"N",
... | Create plots of the forward models
Returns
-------
mag_fig: dict
Dictionary containing the figure and axes objects of the magnitude
plots | [
"Create",
"plots",
"of",
"the",
"forward",
"models"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L402-L460 | train | Create plots of the forward models of the magnitude and phalim. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.add_to_configs | def add_to_configs(self, configs):
"""Add configurations to all tomodirs
Parameters
----------
configs : :class:`numpy.ndarray`
Nx4 numpy array with abmn configurations
"""
for f, td in self.tds.items():
td.configs.add_to_configs(configs) | python | def add_to_configs(self, configs):
"""Add configurations to all tomodirs
Parameters
----------
configs : :class:`numpy.ndarray`
Nx4 numpy array with abmn configurations
"""
for f, td in self.tds.items():
td.configs.add_to_configs(configs) | [
"def",
"add_to_configs",
"(",
"self",
",",
"configs",
")",
":",
"for",
"f",
",",
"td",
"in",
"self",
".",
"tds",
".",
"items",
"(",
")",
":",
"td",
".",
"configs",
".",
"add_to_configs",
"(",
"configs",
")"
] | Add configurations to all tomodirs
Parameters
----------
configs : :class:`numpy.ndarray`
Nx4 numpy array with abmn configurations | [
"Add",
"configurations",
"to",
"all",
"tomodirs"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L462-L472 | train | Adds configurations to all tomodirs with abmn configurations. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.model | def model(self, **kwargs):
"""Run the forward modeling for all frequencies.
Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the
resulting synthetic measurement spectra.
Parameters
----------
**kwargs : dict, optional
All kwargs are directly ... | python | def model(self, **kwargs):
"""Run the forward modeling for all frequencies.
Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the
resulting synthetic measurement spectra.
Parameters
----------
**kwargs : dict, optional
All kwargs are directly ... | [
"def",
"model",
"(",
"self",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"key",
",",
"td",
"in",
"self",
".",
"tds",
".",
"items",
"(",
")",
":",
"td",
".",
"model",
"(",
"*",
"*",
"kwargs",
")"
] | Run the forward modeling for all frequencies.
Use :py:func:`crtomo.eitManager.eitMan.measurements` to retrieve the
resulting synthetic measurement spectra.
Parameters
----------
**kwargs : dict, optional
All kwargs are directly provide to the underlying
... | [
"Run",
"the",
"forward",
"modeling",
"for",
"all",
"frequencies",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L474-L488 | train | Run the forward modeling for all frequencies. |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.measurements | def measurements(self):
"""Return modeled measurements
1. dimension: frequency
2. dimension: config-number
3. dimension: 2: magnitude and phase (resistivity)
"""
m_all = np.array([self.tds[key].measurements() for key in
sorted(self.tds.keys())]... | python | def measurements(self):
"""Return modeled measurements
1. dimension: frequency
2. dimension: config-number
3. dimension: 2: magnitude and phase (resistivity)
"""
m_all = np.array([self.tds[key].measurements() for key in
sorted(self.tds.keys())]... | [
"def",
"measurements",
"(",
"self",
")",
":",
"m_all",
"=",
"np",
".",
"array",
"(",
"[",
"self",
".",
"tds",
"[",
"key",
"]",
".",
"measurements",
"(",
")",
"for",
"key",
"in",
"sorted",
"(",
"self",
".",
"tds",
".",
"keys",
"(",
")",
")",
"]"... | Return modeled measurements
1. dimension: frequency
2. dimension: config-number
3. dimension: 2: magnitude and phase (resistivity) | [
"Return",
"modeled",
"measurements"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L490-L500 | train | Return a list of all measurements in the current TDS |
geophysics-ubonn/crtomo_tools | lib/crtomo/eitManager.py | eitMan.get_measurement_responses | def get_measurement_responses(self):
"""Return a dictionary of sip_responses for the modeled SIP spectra
Note that this function does NOT check that each frequency contains the
same configurations!
Returns
-------
responses : dict
Dictionary with configurati... | python | def get_measurement_responses(self):
"""Return a dictionary of sip_responses for the modeled SIP spectra
Note that this function does NOT check that each frequency contains the
same configurations!
Returns
-------
responses : dict
Dictionary with configurati... | [
"def",
"get_measurement_responses",
"(",
"self",
")",
":",
"# take configurations from first tomodir",
"configs",
"=",
"self",
".",
"tds",
"[",
"sorted",
"(",
"self",
".",
"tds",
".",
"keys",
"(",
")",
")",
"[",
"0",
"]",
"]",
".",
"configs",
".",
"configs... | Return a dictionary of sip_responses for the modeled SIP spectra
Note that this function does NOT check that each frequency contains the
same configurations!
Returns
-------
responses : dict
Dictionary with configurations as keys | [
"Return",
"a",
"dictionary",
"of",
"sip_responses",
"for",
"the",
"modeled",
"SIP",
"spectra"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/eitManager.py#L502-L527 | train | Return a dictionary of SIP spectra with the modeled SIP spectra as keys
|
scottphilip/google-token | GoogleToken/Main.py | get_google_token | def get_google_token(account_email,
oauth_client_id,
oauth_redirect_uri,
oauth_scope,
account_password=None,
account_otp_secret=None,
**kwargs):
"""
:param account_email: (REQUIRED)
... | python | def get_google_token(account_email,
oauth_client_id,
oauth_redirect_uri,
oauth_scope,
account_password=None,
account_otp_secret=None,
**kwargs):
"""
:param account_email: (REQUIRED)
... | [
"def",
"get_google_token",
"(",
"account_email",
",",
"oauth_client_id",
",",
"oauth_redirect_uri",
",",
"oauth_scope",
",",
"account_password",
"=",
"None",
",",
"account_otp_secret",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"items",
"=",
"{",
"\"account... | :param account_email: (REQUIRED)
:param oauth_client_id: (REQUIRED)
:param oauth_redirect_uri: (REQUIRED)
:param oauth_scope: (REQUIRED)
:param account_password: Necessary for first use.
:param account_otp_secret: Necessary for first use if enabled on account
:return: generated token | [
":",
"param",
"account_email",
":",
"(",
"REQUIRED",
")",
":",
"param",
"oauth_client_id",
":",
"(",
"REQUIRED",
")",
":",
"param",
"oauth_redirect_uri",
":",
"(",
"REQUIRED",
")",
":",
"param",
"oauth_scope",
":",
"(",
"REQUIRED",
")",
":",
"param",
"acco... | 5b7d5078d291980f686bd8b9f2129f8dfa2addb3 | https://github.com/scottphilip/google-token/blob/5b7d5078d291980f686bd8b9f2129f8dfa2addb3/GoogleToken/Main.py#L8-L36 | train | Returns a Google token for the given account. |
reorx/torext | examples/formal_project/manage.py | create_database | def create_database(name, number=1, force_clear=False):
"""Command to create a database
"""
print 'Got:'
print 'name', name, type(name)
print 'number', number, type(number)
print 'force_clear', force_clear, type(force_clear) | python | def create_database(name, number=1, force_clear=False):
"""Command to create a database
"""
print 'Got:'
print 'name', name, type(name)
print 'number', number, type(number)
print 'force_clear', force_clear, type(force_clear) | [
"def",
"create_database",
"(",
"name",
",",
"number",
"=",
"1",
",",
"force_clear",
"=",
"False",
")",
":",
"print",
"'Got:'",
"print",
"'name'",
",",
"name",
",",
"type",
"(",
"name",
")",
"print",
"'number'",
",",
"number",
",",
"type",
"(",
"number"... | Command to create a database | [
"Command",
"to",
"create",
"a",
"database"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/examples/formal_project/manage.py#L10-L16 | train | Command to create a database |
reorx/torext | examples/formal_project/manage.py | run | def run(**kwargs):
"""Command to run server, pass `--PORT 9000`, `--TEMPLATE_PATH templates`
as arguments to affect on global settings object.
"""
from sampleproject.app import app
app.update_settings(**kwargs)
app.run() | python | def run(**kwargs):
"""Command to run server, pass `--PORT 9000`, `--TEMPLATE_PATH templates`
as arguments to affect on global settings object.
"""
from sampleproject.app import app
app.update_settings(**kwargs)
app.run() | [
"def",
"run",
"(",
"*",
"*",
"kwargs",
")",
":",
"from",
"sampleproject",
".",
"app",
"import",
"app",
"app",
".",
"update_settings",
"(",
"*",
"*",
"kwargs",
")",
"app",
".",
"run",
"(",
")"
] | Command to run server, pass `--PORT 9000`, `--TEMPLATE_PATH templates`
as arguments to affect on global settings object. | [
"Command",
"to",
"run",
"server",
"pass",
"--",
"PORT",
"9000",
"--",
"TEMPLATE_PATH",
"templates",
"as",
"arguments",
"to",
"affect",
"on",
"global",
"settings",
"object",
"."
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/examples/formal_project/manage.py#L20-L27 | train | Command to run server |
pgxcentre/geneparse | geneparse/readers/dataframe.py | DataFrameReader.iter_genotypes | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
# Parsing each column of the dataframe
for variant in self.df.columns:
genotypes = self.df.loc[:, variant].values
info = self.map_info.loc[variant, ... | python | def iter_genotypes(self):
"""Iterates on available markers.
Returns:
Genotypes instances.
"""
# Parsing each column of the dataframe
for variant in self.df.columns:
genotypes = self.df.loc[:, variant].values
info = self.map_info.loc[variant, ... | [
"def",
"iter_genotypes",
"(",
"self",
")",
":",
"# Parsing each column of the dataframe",
"for",
"variant",
"in",
"self",
".",
"df",
".",
"columns",
":",
"genotypes",
"=",
"self",
".",
"df",
".",
"loc",
"[",
":",
",",
"variant",
"]",
".",
"values",
"info",... | Iterates on available markers.
Returns:
Genotypes instances. | [
"Iterates",
"on",
"available",
"markers",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/dataframe.py#L50-L68 | train | Iterates on available markers. |
pgxcentre/geneparse | geneparse/readers/dataframe.py | DataFrameReader.get_variant_by_name | def get_variant_by_name(self, name):
"""Get the genotypes for a given variant (by name).
Args:
name (str): The name of the variant to retrieve the genotypes.
Returns:
list: A list of Genotypes. This is a list in order to keep the same
behaviour as the other ... | python | def get_variant_by_name(self, name):
"""Get the genotypes for a given variant (by name).
Args:
name (str): The name of the variant to retrieve the genotypes.
Returns:
list: A list of Genotypes. This is a list in order to keep the same
behaviour as the other ... | [
"def",
"get_variant_by_name",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"geno",
"=",
"self",
".",
"df",
".",
"loc",
"[",
":",
",",
"name",
"]",
".",
"values",
"info",
"=",
"self",
".",
"map_info",
".",
"loc",
"[",
"name",
",",
":",
"]",
"... | Get the genotypes for a given variant (by name).
Args:
name (str): The name of the variant to retrieve the genotypes.
Returns:
list: A list of Genotypes. This is a list in order to keep the same
behaviour as the other functions. | [
"Get",
"the",
"genotypes",
"for",
"a",
"given",
"variant",
"(",
"by",
"name",
")",
"."
] | f698f9708af4c7962d384a70a5a14006b1cb7108 | https://github.com/pgxcentre/geneparse/blob/f698f9708af4c7962d384a70a5a14006b1cb7108/geneparse/readers/dataframe.py#L70-L98 | train | Get the genotypes for a given variant name. |
NiklasRosenstein/py-bundler | bundler/nativedeps/windll.py | _get_long_path_name | def _get_long_path_name(path):
"""
Returns the long path name for a Windows path, i.e. the properly cased
path of an existing file or directory.
"""
# Thanks to http://stackoverflow.com/a/3694799/791713
buf = ctypes.create_unicode_buffer(len(path) + 1)
GetLongPathNameW = ctypes.windll.kernel32.GetLongPat... | python | def _get_long_path_name(path):
"""
Returns the long path name for a Windows path, i.e. the properly cased
path of an existing file or directory.
"""
# Thanks to http://stackoverflow.com/a/3694799/791713
buf = ctypes.create_unicode_buffer(len(path) + 1)
GetLongPathNameW = ctypes.windll.kernel32.GetLongPat... | [
"def",
"_get_long_path_name",
"(",
"path",
")",
":",
"# Thanks to http://stackoverflow.com/a/3694799/791713",
"buf",
"=",
"ctypes",
".",
"create_unicode_buffer",
"(",
"len",
"(",
"path",
")",
"+",
"1",
")",
"GetLongPathNameW",
"=",
"ctypes",
".",
"windll",
".",
"k... | Returns the long path name for a Windows path, i.e. the properly cased
path of an existing file or directory. | [
"Returns",
"the",
"long",
"path",
"name",
"for",
"a",
"Windows",
"path",
"i",
".",
"e",
".",
"the",
"properly",
"cased",
"path",
"of",
"an",
"existing",
"file",
"or",
"directory",
"."
] | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L44-L57 | train | Get the long path name for a Windows path. |
NiklasRosenstein/py-bundler | bundler/nativedeps/windll.py | get_dependency_walker | def get_dependency_walker():
"""
Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
and extracted to a temporary directory. Note that the file will not be
deleted afterwards.
Returns the path to the Dependency Walker executable.
"""
for dirname in os.getenv('PATH', '').split(os... | python | def get_dependency_walker():
"""
Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
and extracted to a temporary directory. Note that the file will not be
deleted afterwards.
Returns the path to the Dependency Walker executable.
"""
for dirname in os.getenv('PATH', '').split(os... | [
"def",
"get_dependency_walker",
"(",
")",
":",
"for",
"dirname",
"in",
"os",
".",
"getenv",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
"'de... | Checks if `depends.exe` is in the system PATH. If not, it will be downloaded
and extracted to a temporary directory. Note that the file will not be
deleted afterwards.
Returns the path to the Dependency Walker executable. | [
"Checks",
"if",
"depends",
".",
"exe",
"is",
"in",
"the",
"system",
"PATH",
".",
"If",
"not",
"it",
"will",
"be",
"downloaded",
"and",
"extracted",
"to",
"a",
"temporary",
"directory",
".",
"Note",
"that",
"the",
"file",
"will",
"not",
"be",
"deleted",
... | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L60-L94 | train | Checks if the Dependency Walker is in the system PATH and if not it will be downloaded and extracted to a temporary directory. |
NiklasRosenstein/py-bundler | bundler/nativedeps/windll.py | get_dependencies | def get_dependencies(pefile):
"""
Uses Dependency Walker to get a list of dependencies for the specified
PE file (a Windows executable or dynamic link library).
"""
# Check if we already analyzed this file before.
hasher = hashlib.sha1(os.path.normpath(pefile).encode('utf8'))
cachefile = hasher.hexdigest... | python | def get_dependencies(pefile):
"""
Uses Dependency Walker to get a list of dependencies for the specified
PE file (a Windows executable or dynamic link library).
"""
# Check if we already analyzed this file before.
hasher = hashlib.sha1(os.path.normpath(pefile).encode('utf8'))
cachefile = hasher.hexdigest... | [
"def",
"get_dependencies",
"(",
"pefile",
")",
":",
"# Check if we already analyzed this file before.",
"hasher",
"=",
"hashlib",
".",
"sha1",
"(",
"os",
".",
"path",
".",
"normpath",
"(",
"pefile",
")",
".",
"encode",
"(",
"'utf8'",
")",
")",
"cachefile",
"="... | Uses Dependency Walker to get a list of dependencies for the specified
PE file (a Windows executable or dynamic link library). | [
"Uses",
"Dependency",
"Walker",
"to",
"get",
"a",
"list",
"of",
"dependencies",
"for",
"the",
"specified",
"PE",
"file",
"(",
"a",
"Windows",
"executable",
"or",
"dynamic",
"link",
"library",
")",
"."
] | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L97-L132 | train | Returns a list of Dependency objects for the specified PE file. |
NiklasRosenstein/py-bundler | bundler/nativedeps/windll.py | resolve_dependency | def resolve_dependency(dep):
"""
Attempts to find the #Dependency on the system. Returns the filename of the
native library or None if it can not be found.
"""
for dirname in os.getenv('PATH', '').split(os.pathsep):
filename = os.path.join(dirname, dep.name)
if os.path.isfile(filename):
return ... | python | def resolve_dependency(dep):
"""
Attempts to find the #Dependency on the system. Returns the filename of the
native library or None if it can not be found.
"""
for dirname in os.getenv('PATH', '').split(os.pathsep):
filename = os.path.join(dirname, dep.name)
if os.path.isfile(filename):
return ... | [
"def",
"resolve_dependency",
"(",
"dep",
")",
":",
"for",
"dirname",
"in",
"os",
".",
"getenv",
"(",
"'PATH'",
",",
"''",
")",
".",
"split",
"(",
"os",
".",
"pathsep",
")",
":",
"filename",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dirname",
",",
... | Attempts to find the #Dependency on the system. Returns the filename of the
native library or None if it can not be found. | [
"Attempts",
"to",
"find",
"the",
"#Dependency",
"on",
"the",
"system",
".",
"Returns",
"the",
"filename",
"of",
"the",
"native",
"library",
"or",
"None",
"if",
"it",
"can",
"not",
"be",
"found",
"."
] | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/nativedeps/windll.py#L135-L145 | train | Resolves the dependency on the system. |
reorx/torext | torext/script.py | Manager.print_usage | def print_usage(self, hint=None):
"""Usage format should be like:
Lineno | Content
1 | Script description (__doc__)
2 | Usage: {script name} [COMMAND] [ARGUMENTS]
3 | \n
4 | Commands:
5 | cmd1 cmd1 description.
... | python | def print_usage(self, hint=None):
"""Usage format should be like:
Lineno | Content
1 | Script description (__doc__)
2 | Usage: {script name} [COMMAND] [ARGUMENTS]
3 | \n
4 | Commands:
5 | cmd1 cmd1 description.
... | [
"def",
"print_usage",
"(",
"self",
",",
"hint",
"=",
"None",
")",
":",
"buf",
"=",
"[",
"]",
"# Description",
"if",
"__doc__",
":",
"buf",
".",
"append",
"(",
"__doc__",
")",
"# Usage",
"script_name",
"=",
"sys",
".",
"argv",
"[",
"0",
"]",
"buf",
... | Usage format should be like:
Lineno | Content
1 | Script description (__doc__)
2 | Usage: {script name} [COMMAND] [ARGUMENTS]
3 | \n
4 | Commands:
5 | cmd1 cmd1 description.
6 | cmd2isverylong cmd2 description, a... | [
"Usage",
"format",
"should",
"be",
"like",
":",
"Lineno",
"|",
"Content",
"1",
"|",
"Script",
"description",
"(",
"__doc__",
")",
"2",
"|",
"Usage",
":",
"{",
"script",
"name",
"}",
"[",
"COMMAND",
"]",
"[",
"ARGUMENTS",
"]",
"3",
"|",
"\\",
"n",
"... | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/script.py#L175-L218 | train | Prints the usage of the command line. |
reorx/torext | torext/script.py | Manager.prepare | def prepare(self, setup_func):
"""This decorator wrap a function which setup a environment before
running a command
@manager.prepare(setup_func)
def some_command():
pass
"""
assert inspect.isfunction(setup_func)
argsspec = inspect.getargspec(setup_func... | python | def prepare(self, setup_func):
"""This decorator wrap a function which setup a environment before
running a command
@manager.prepare(setup_func)
def some_command():
pass
"""
assert inspect.isfunction(setup_func)
argsspec = inspect.getargspec(setup_func... | [
"def",
"prepare",
"(",
"self",
",",
"setup_func",
")",
":",
"assert",
"inspect",
".",
"isfunction",
"(",
"setup_func",
")",
"argsspec",
"=",
"inspect",
".",
"getargspec",
"(",
"setup_func",
")",
"if",
"argsspec",
".",
"args",
":",
"raise",
"ValueError",
"(... | This decorator wrap a function which setup a environment before
running a command
@manager.prepare(setup_func)
def some_command():
pass | [
"This",
"decorator",
"wrap",
"a",
"function",
"which",
"setup",
"a",
"environment",
"before",
"running",
"a",
"command"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/script.py#L220-L239 | train | This is a decorator which setup a environment before
running a command |
reorx/torext | torext/script.py | Manager.command | def command(self, profile=False):
"""This is a Flask-Script like decorator, provide functionality like
@manager.command
def foo():
pass
@manager.command
def foo(first_arg, second_arg, first_option=True, second_option=3):
pass
"""
def wrape... | python | def command(self, profile=False):
"""This is a Flask-Script like decorator, provide functionality like
@manager.command
def foo():
pass
@manager.command
def foo(first_arg, second_arg, first_option=True, second_option=3):
pass
"""
def wrape... | [
"def",
"command",
"(",
"self",
",",
"profile",
"=",
"False",
")",
":",
"def",
"wraped",
"(",
"func",
")",
":",
"assert",
"inspect",
".",
"isfunction",
"(",
"func",
")",
"self",
".",
"_commands",
"[",
"func",
".",
"__name__",
"]",
"=",
"Command",
"(",... | This is a Flask-Script like decorator, provide functionality like
@manager.command
def foo():
pass
@manager.command
def foo(first_arg, second_arg, first_option=True, second_option=3):
pass | [
"This",
"is",
"a",
"Flask",
"-",
"Script",
"like",
"decorator",
"provide",
"functionality",
"like",
"@manager",
".",
"command",
"def",
"foo",
"()",
":",
"pass"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/script.py#L241-L258 | train | A decorator that provides functionality for command based on the current locale. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/utils.py | _addPort | def _addPort(n: LNode, lp: LPort, intf: Interface,
reverseDirection=False):
"""
add port to LPort for interface
"""
origin = originObjOfPort(intf)
d = intf._direction
d = PortTypeFromDir(d)
if reverseDirection:
d = PortType.opposite(d)
new_lp = LPort(lp, d, lp.side... | python | def _addPort(n: LNode, lp: LPort, intf: Interface,
reverseDirection=False):
"""
add port to LPort for interface
"""
origin = originObjOfPort(intf)
d = intf._direction
d = PortTypeFromDir(d)
if reverseDirection:
d = PortType.opposite(d)
new_lp = LPort(lp, d, lp.side... | [
"def",
"_addPort",
"(",
"n",
":",
"LNode",
",",
"lp",
":",
"LPort",
",",
"intf",
":",
"Interface",
",",
"reverseDirection",
"=",
"False",
")",
":",
"origin",
"=",
"originObjOfPort",
"(",
"intf",
")",
"d",
"=",
"intf",
".",
"_direction",
"d",
"=",
"Po... | add port to LPort for interface | [
"add",
"port",
"to",
"LPort",
"for",
"interface"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/utils.py#L187-L211 | train | add port to LNode |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/utils.py | addPort | def addPort(n: LNode, intf: Interface):
"""
Add LayoutExternalPort for interface
"""
d = PortTypeFromDir(intf._direction)
ext_p = LayoutExternalPort(
n, name=intf._name, direction=d, node2lnode=n._node2lnode)
ext_p.originObj = originObjOfPort(intf)
n.children.append(ext_p)
addPor... | python | def addPort(n: LNode, intf: Interface):
"""
Add LayoutExternalPort for interface
"""
d = PortTypeFromDir(intf._direction)
ext_p = LayoutExternalPort(
n, name=intf._name, direction=d, node2lnode=n._node2lnode)
ext_p.originObj = originObjOfPort(intf)
n.children.append(ext_p)
addPor... | [
"def",
"addPort",
"(",
"n",
":",
"LNode",
",",
"intf",
":",
"Interface",
")",
":",
"d",
"=",
"PortTypeFromDir",
"(",
"intf",
".",
"_direction",
")",
"ext_p",
"=",
"LayoutExternalPort",
"(",
"n",
",",
"name",
"=",
"intf",
".",
"_name",
",",
"direction",... | Add LayoutExternalPort for interface | [
"Add",
"LayoutExternalPort",
"for",
"interface"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/utils.py#L231-L241 | train | Add a LayoutExternalPort for interface
|
Nic30/hwtGraph | hwtGraph/elk/fromHwt/utils.py | NetCtxs.getDefault | def getDefault(self, k):
"""
:return: tuple (value, True if key was there before else False)
"""
try:
return self[k], True
except KeyError:
v = self[k] = NetCtx(self, k)
return v, False | python | def getDefault(self, k):
"""
:return: tuple (value, True if key was there before else False)
"""
try:
return self[k], True
except KeyError:
v = self[k] = NetCtx(self, k)
return v, False | [
"def",
"getDefault",
"(",
"self",
",",
"k",
")",
":",
"try",
":",
"return",
"self",
"[",
"k",
"]",
",",
"True",
"except",
"KeyError",
":",
"v",
"=",
"self",
"[",
"k",
"]",
"=",
"NetCtx",
"(",
"self",
",",
"k",
")",
"return",
"v",
",",
"False"
] | :return: tuple (value, True if key was there before else False) | [
":",
"return",
":",
"tuple",
"(",
"value",
"True",
"if",
"key",
"was",
"there",
"before",
"else",
"False",
")"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/utils.py#L84-L92 | train | get default value for key k |
flo-compbio/xlmhg | xlmhg/result.py | mHGResult.v | def v(self):
"""(property) Returns the list as a `numpy.ndarray`
(with dtype ``np.uint8``).
"""
v = np.zeros(self.N, dtype=np.uint8)
v[self.indices] = 1
return v | python | def v(self):
"""(property) Returns the list as a `numpy.ndarray`
(with dtype ``np.uint8``).
"""
v = np.zeros(self.N, dtype=np.uint8)
v[self.indices] = 1
return v | [
"def",
"v",
"(",
"self",
")",
":",
"v",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"N",
",",
"dtype",
"=",
"np",
".",
"uint8",
")",
"v",
"[",
"self",
".",
"indices",
"]",
"=",
"1",
"return",
"v"
] | (property) Returns the list as a `numpy.ndarray`
(with dtype ``np.uint8``). | [
"(",
"property",
")",
"Returns",
"the",
"list",
"as",
"a",
"numpy",
".",
"ndarray",
"(",
"with",
"dtype",
"np",
".",
"uint8",
")",
"."
] | 8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1 | https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/result.py#L145-L151 | train | Returns the list as a numpy. ndarray. |
flo-compbio/xlmhg | xlmhg/result.py | mHGResult.hash | def hash(self):
"""(property) Returns a unique hash value for the result."""
data_str = ';'.join(
[str(repr(var)) for var in
[self.N, self.K, self.X, self.L,
self.stat, self.cutoff, self.pval,
self.pval_thresh, self.escore_pval_thresh]])
data_... | python | def hash(self):
"""(property) Returns a unique hash value for the result."""
data_str = ';'.join(
[str(repr(var)) for var in
[self.N, self.K, self.X, self.L,
self.stat, self.cutoff, self.pval,
self.pval_thresh, self.escore_pval_thresh]])
data_... | [
"def",
"hash",
"(",
"self",
")",
":",
"data_str",
"=",
"';'",
".",
"join",
"(",
"[",
"str",
"(",
"repr",
"(",
"var",
")",
")",
"for",
"var",
"in",
"[",
"self",
".",
"N",
",",
"self",
".",
"K",
",",
"self",
".",
"X",
",",
"self",
".",
"L",
... | (property) Returns a unique hash value for the result. | [
"(",
"property",
")",
"Returns",
"a",
"unique",
"hash",
"value",
"for",
"the",
"result",
"."
] | 8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1 | https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/result.py#L164-L173 | train | ( property ) Returns a unique hash value for the result. |
flo-compbio/xlmhg | xlmhg/result.py | mHGResult.fold_enrichment | def fold_enrichment(self):
"""(property) Returns the fold enrichment at the XL-mHG cutoff."""
return self.k / (self.K*(self.cutoff/float(self.N))) | python | def fold_enrichment(self):
"""(property) Returns the fold enrichment at the XL-mHG cutoff."""
return self.k / (self.K*(self.cutoff/float(self.N))) | [
"def",
"fold_enrichment",
"(",
"self",
")",
":",
"return",
"self",
".",
"k",
"/",
"(",
"self",
".",
"K",
"*",
"(",
"self",
".",
"cutoff",
"/",
"float",
"(",
"self",
".",
"N",
")",
")",
")"
] | (property) Returns the fold enrichment at the XL-mHG cutoff. | [
"(",
"property",
")",
"Returns",
"the",
"fold",
"enrichment",
"at",
"the",
"XL",
"-",
"mHG",
"cutoff",
"."
] | 8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1 | https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/result.py#L176-L178 | train | Returns the fold enrichment at the XL - mHG cutoff. |
flo-compbio/xlmhg | xlmhg/result.py | mHGResult.escore | def escore(self):
"""(property) Returns the E-score associated with the result."""
hg_pval_thresh = self.escore_pval_thresh or self.pval
escore_tol = self.escore_tol or mhg_cython.get_default_tol()
es = mhg_cython.get_xlmhg_escore(
self.indices, self.N, self.K, self.X, self.L... | python | def escore(self):
"""(property) Returns the E-score associated with the result."""
hg_pval_thresh = self.escore_pval_thresh or self.pval
escore_tol = self.escore_tol or mhg_cython.get_default_tol()
es = mhg_cython.get_xlmhg_escore(
self.indices, self.N, self.K, self.X, self.L... | [
"def",
"escore",
"(",
"self",
")",
":",
"hg_pval_thresh",
"=",
"self",
".",
"escore_pval_thresh",
"or",
"self",
".",
"pval",
"escore_tol",
"=",
"self",
".",
"escore_tol",
"or",
"mhg_cython",
".",
"get_default_tol",
"(",
")",
"es",
"=",
"mhg_cython",
".",
"... | (property) Returns the E-score associated with the result. | [
"(",
"property",
")",
"Returns",
"the",
"E",
"-",
"score",
"associated",
"with",
"the",
"result",
"."
] | 8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1 | https://github.com/flo-compbio/xlmhg/blob/8e5929ee1dc91b95e343b7a2b1b1d6664c4540a1/xlmhg/result.py#L181-L188 | train | ( property ) Returns the E - score associated with the result. |
tslight/treepick | treepick/draw.py | Draw.drawtree | def drawtree(self):
'''
Loop over the object, process path attribute sets, and drawlines based
on their current contents.
'''
self.win.erase()
self.line = 0
for child, depth in self.traverse():
child.curline = self.curline
child.picked = se... | python | def drawtree(self):
'''
Loop over the object, process path attribute sets, and drawlines based
on their current contents.
'''
self.win.erase()
self.line = 0
for child, depth in self.traverse():
child.curline = self.curline
child.picked = se... | [
"def",
"drawtree",
"(",
"self",
")",
":",
"self",
".",
"win",
".",
"erase",
"(",
")",
"self",
".",
"line",
"=",
"0",
"for",
"child",
",",
"depth",
"in",
"self",
".",
"traverse",
"(",
")",
":",
"child",
".",
"curline",
"=",
"self",
".",
"curline",... | Loop over the object, process path attribute sets, and drawlines based
on their current contents. | [
"Loop",
"over",
"the",
"object",
"process",
"path",
"attribute",
"sets",
"and",
"drawlines",
"based",
"on",
"their",
"current",
"contents",
"."
] | 7adf838900f11e8845e17d8c79bb2b23617aec2c | https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/draw.py#L64-L90 | train | This method draws the tree of the object. |
albert12132/templar | templar/api/config.py | import_config | def import_config(config_path):
"""Import a Config from a given path, relative to the current directory.
The module specified by the config file must contain a variable called `configuration` that is
assigned to a Config object.
"""
if not os.path.isfile(config_path):
raise ConfigBuilderErr... | python | def import_config(config_path):
"""Import a Config from a given path, relative to the current directory.
The module specified by the config file must contain a variable called `configuration` that is
assigned to a Config object.
"""
if not os.path.isfile(config_path):
raise ConfigBuilderErr... | [
"def",
"import_config",
"(",
"config_path",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"config_path",
")",
":",
"raise",
"ConfigBuilderError",
"(",
"'Could not find config file: '",
"+",
"config_path",
")",
"loader",
"=",
"importlib",
".",
"... | Import a Config from a given path, relative to the current directory.
The module specified by the config file must contain a variable called `configuration` that is
assigned to a Config object. | [
"Import",
"a",
"Config",
"from",
"a",
"given",
"path",
"relative",
"to",
"the",
"current",
"directory",
"."
] | 39851c89730ab69e5c73d0a46adca2a44ecc4165 | https://github.com/albert12132/templar/blob/39851c89730ab69e5c73d0a46adca2a44ecc4165/templar/api/config.py#L216-L233 | train | Imports a Config from a given path relative to the current directory. |
rhayes777/PyAutoFit | autofit/optimize/optimizer.py | grid | def grid(fitness_function, no_dimensions, step_size):
"""
Grid search using a fitness function over a given number of dimensions and a given step size between inclusive
limits of 0 and 1.
Parameters
----------
fitness_function: function
A function that takes a tuple of floats as an argu... | python | def grid(fitness_function, no_dimensions, step_size):
"""
Grid search using a fitness function over a given number of dimensions and a given step size between inclusive
limits of 0 and 1.
Parameters
----------
fitness_function: function
A function that takes a tuple of floats as an argu... | [
"def",
"grid",
"(",
"fitness_function",
",",
"no_dimensions",
",",
"step_size",
")",
":",
"best_fitness",
"=",
"float",
"(",
"\"-inf\"",
")",
"best_arguments",
"=",
"None",
"for",
"arguments",
"in",
"make_lists",
"(",
"no_dimensions",
",",
"step_size",
")",
":... | Grid search using a fitness function over a given number of dimensions and a given step size between inclusive
limits of 0 and 1.
Parameters
----------
fitness_function: function
A function that takes a tuple of floats as an argument
no_dimensions: int
The number of dimensions of th... | [
"Grid",
"search",
"using",
"a",
"fitness",
"function",
"over",
"a",
"given",
"number",
"of",
"dimensions",
"and",
"a",
"given",
"step",
"size",
"between",
"inclusive",
"limits",
"of",
"0",
"and",
"1",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/optimizer.py#L1-L29 | train | This function searches for a given number of dimensions and a given step size over a given number of dimensions and returns the arguments that gave the highest fitness. |
rhayes777/PyAutoFit | autofit/optimize/optimizer.py | make_lists | def make_lists(no_dimensions, step_size, centre_steps=True):
"""
Create a list of lists of floats covering every combination across no_dimensions of points of integer step size
between 0 and 1 inclusive.
Parameters
----------
no_dimensions: int
The number of dimensions, that is the leng... | python | def make_lists(no_dimensions, step_size, centre_steps=True):
"""
Create a list of lists of floats covering every combination across no_dimensions of points of integer step size
between 0 and 1 inclusive.
Parameters
----------
no_dimensions: int
The number of dimensions, that is the leng... | [
"def",
"make_lists",
"(",
"no_dimensions",
",",
"step_size",
",",
"centre_steps",
"=",
"True",
")",
":",
"if",
"no_dimensions",
"==",
"0",
":",
"return",
"[",
"[",
"]",
"]",
"sub_lists",
"=",
"make_lists",
"(",
"no_dimensions",
"-",
"1",
",",
"step_size",
... | Create a list of lists of floats covering every combination across no_dimensions of points of integer step size
between 0 and 1 inclusive.
Parameters
----------
no_dimensions: int
The number of dimensions, that is the length of the lists
step_size: float
The step size
centre_ste... | [
"Create",
"a",
"list",
"of",
"lists",
"of",
"floats",
"covering",
"every",
"combination",
"across",
"no_dimensions",
"of",
"points",
"of",
"integer",
"step",
"size",
"between",
"0",
"and",
"1",
"inclusive",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/optimize/optimizer.py#L32-L55 | train | Creates a list of lists of floats covering every combination across no_dimensions of points of integer step size. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | getRootIntfPort | def getRootIntfPort(port: LPort):
"""
:return: most top port which contains this port
"""
while True:
if isinstance(port.parent, LNode):
return port
else:
port = port.parent | python | def getRootIntfPort(port: LPort):
"""
:return: most top port which contains this port
"""
while True:
if isinstance(port.parent, LNode):
return port
else:
port = port.parent | [
"def",
"getRootIntfPort",
"(",
"port",
":",
"LPort",
")",
":",
"while",
"True",
":",
"if",
"isinstance",
"(",
"port",
".",
"parent",
",",
"LNode",
")",
":",
"return",
"port",
"else",
":",
"port",
"=",
"port",
".",
"parent"
] | :return: most top port which contains this port | [
":",
"return",
":",
"most",
"top",
"port",
"which",
"contains",
"this",
"port"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L32-L40 | train | Returns the root edge of the given port |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | portCnt | def portCnt(port):
"""
recursively count number of ports without children
"""
if port.children:
return sum(map(lambda p: portCnt(p), port.children))
else:
return 1 | python | def portCnt(port):
"""
recursively count number of ports without children
"""
if port.children:
return sum(map(lambda p: portCnt(p), port.children))
else:
return 1 | [
"def",
"portCnt",
"(",
"port",
")",
":",
"if",
"port",
".",
"children",
":",
"return",
"sum",
"(",
"map",
"(",
"lambda",
"p",
":",
"portCnt",
"(",
"p",
")",
",",
"port",
".",
"children",
")",
")",
"else",
":",
"return",
"1"
] | recursively count number of ports without children | [
"recursively",
"count",
"number",
"of",
"ports",
"without",
"children"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L43-L50 | train | Count the number of ports without children |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | _copyPort | def _copyPort(port: LPort, targetParent: Union[LPort], reverseDirection):
"""
add port to LPort for interface
"""
d = port.direction
side = port.side
if reverseDirection:
d = PortType.opposite(d)
side = PortSide.opposite(side)
newP = LPort(targetParent.parentNode, d, side, n... | python | def _copyPort(port: LPort, targetParent: Union[LPort], reverseDirection):
"""
add port to LPort for interface
"""
d = port.direction
side = port.side
if reverseDirection:
d = PortType.opposite(d)
side = PortSide.opposite(side)
newP = LPort(targetParent.parentNode, d, side, n... | [
"def",
"_copyPort",
"(",
"port",
":",
"LPort",
",",
"targetParent",
":",
"Union",
"[",
"LPort",
"]",
",",
"reverseDirection",
")",
":",
"d",
"=",
"port",
".",
"direction",
"side",
"=",
"port",
".",
"side",
"if",
"reverseDirection",
":",
"d",
"=",
"Port... | add port to LPort for interface | [
"add",
"port",
"to",
"LPort",
"for",
"interface"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L53-L73 | train | Copy a port to another LPort |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | copyPort | def copyPort(port, targetLNode, reverseDir, topPortName=None):
"""
Create identical port on targetNode
"""
newP = _copyPort(port, targetLNode, reverseDir)
if topPortName is not None:
newP.name = topPortName
return newP | python | def copyPort(port, targetLNode, reverseDir, topPortName=None):
"""
Create identical port on targetNode
"""
newP = _copyPort(port, targetLNode, reverseDir)
if topPortName is not None:
newP.name = topPortName
return newP | [
"def",
"copyPort",
"(",
"port",
",",
"targetLNode",
",",
"reverseDir",
",",
"topPortName",
"=",
"None",
")",
":",
"newP",
"=",
"_copyPort",
"(",
"port",
",",
"targetLNode",
",",
"reverseDir",
")",
"if",
"topPortName",
"is",
"not",
"None",
":",
"newP",
".... | Create identical port on targetNode | [
"Create",
"identical",
"port",
"on",
"targetNode"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L76-L85 | train | Copy a port on targetNode |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | walkSignalPorts | def walkSignalPorts(rootPort: LPort):
"""
recursively walk ports without any children
"""
if rootPort.children:
for ch in rootPort.children:
yield from walkSignalPorts(ch)
else:
yield rootPort | python | def walkSignalPorts(rootPort: LPort):
"""
recursively walk ports without any children
"""
if rootPort.children:
for ch in rootPort.children:
yield from walkSignalPorts(ch)
else:
yield rootPort | [
"def",
"walkSignalPorts",
"(",
"rootPort",
":",
"LPort",
")",
":",
"if",
"rootPort",
".",
"children",
":",
"for",
"ch",
"in",
"rootPort",
".",
"children",
":",
"yield",
"from",
"walkSignalPorts",
"(",
"ch",
")",
"else",
":",
"yield",
"rootPort"
] | recursively walk ports without any children | [
"recursively",
"walk",
"ports",
"without",
"any",
"children"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L88-L96 | train | Walks the ports recursively and yields all the ports with any children. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | reconnectPorts | def reconnectPorts(root: LNode, srcPort: LPort,
oldSplits: List[Tuple[LNode, LEdge]],
newSplitNode: LNode):
"""
:ivar root: top LNode instance in which are nodes and links stored
:ivar srcPort: for SLICE it is port which is connected to input of SLICE node
for C... | python | def reconnectPorts(root: LNode, srcPort: LPort,
oldSplits: List[Tuple[LNode, LEdge]],
newSplitNode: LNode):
"""
:ivar root: top LNode instance in which are nodes and links stored
:ivar srcPort: for SLICE it is port which is connected to input of SLICE node
for C... | [
"def",
"reconnectPorts",
"(",
"root",
":",
"LNode",
",",
"srcPort",
":",
"LPort",
",",
"oldSplits",
":",
"List",
"[",
"Tuple",
"[",
"LNode",
",",
"LEdge",
"]",
"]",
",",
"newSplitNode",
":",
"LNode",
")",
":",
"# sort oldSplit nodes because they are not in sam... | :ivar root: top LNode instance in which are nodes and links stored
:ivar srcPort: for SLICE it is port which is connected to input of SLICE node
for CONCAT it is port which is connected to output of CONCAT
:ivar oldSplits: list of tuples (node, edge) which should be disconnected from graph
:ivar new... | [
":",
"ivar",
"root",
":",
"top",
"LNode",
"instance",
"in",
"which",
"are",
"nodes",
"and",
"links",
"stored",
":",
"ivar",
"srcPort",
":",
"for",
"SLICE",
"it",
"is",
"port",
"which",
"is",
"connected",
"to",
"input",
"of",
"SLICE",
"node",
"for",
"CO... | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L99-L167 | train | re - connects ports from one node to another. |
Nic30/hwtGraph | hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py | mergeSplitsOnInterfaces | def mergeSplitsOnInterfaces(root: LNode):
"""
collect all split/concatenation nodes and group them by target interface
"""
for ch in root.children:
if ch.children:
mergeSplitsOnInterfaces(ch)
ctx = MergeSplitsOnInterfacesCtx()
for ch in root.children:
srcPorts = None... | python | def mergeSplitsOnInterfaces(root: LNode):
"""
collect all split/concatenation nodes and group them by target interface
"""
for ch in root.children:
if ch.children:
mergeSplitsOnInterfaces(ch)
ctx = MergeSplitsOnInterfacesCtx()
for ch in root.children:
srcPorts = None... | [
"def",
"mergeSplitsOnInterfaces",
"(",
"root",
":",
"LNode",
")",
":",
"for",
"ch",
"in",
"root",
".",
"children",
":",
"if",
"ch",
".",
"children",
":",
"mergeSplitsOnInterfaces",
"(",
"ch",
")",
"ctx",
"=",
"MergeSplitsOnInterfacesCtx",
"(",
")",
"for",
... | collect all split/concatenation nodes and group them by target interface | [
"collect",
"all",
"split",
"/",
"concatenation",
"nodes",
"and",
"group",
"them",
"by",
"target",
"interface"
] | 6b7d4fdd759f263a0fdd2736f02f123e44e4354f | https://github.com/Nic30/hwtGraph/blob/6b7d4fdd759f263a0fdd2736f02f123e44e4354f/hwtGraph/elk/fromHwt/mergeSplitsOnInterfaces.py#L170-L216 | train | Merge all split and concatenation nodes and group them by target interface. |
Robpol86/Flask-JIRA-Helper | setup.py | get_metadata | def get_metadata(main_file):
"""Get metadata about the package/module.
Positional arguments:
main_file -- python file path within `HERE` which has __author__ and the others defined as global variables.
Returns:
Dictionary to be passed into setuptools.setup().
"""
with open(os.path.join(HER... | python | def get_metadata(main_file):
"""Get metadata about the package/module.
Positional arguments:
main_file -- python file path within `HERE` which has __author__ and the others defined as global variables.
Returns:
Dictionary to be passed into setuptools.setup().
"""
with open(os.path.join(HER... | [
"def",
"get_metadata",
"(",
"main_file",
")",
":",
"with",
"open",
"(",
"os",
".",
"path",
".",
"join",
"(",
"HERE",
",",
"'README.md'",
")",
",",
"encoding",
"=",
"'utf-8'",
")",
"as",
"f",
":",
"long_description",
"=",
"f",
".",
"read",
"(",
")",
... | Get metadata about the package/module.
Positional arguments:
main_file -- python file path within `HERE` which has __author__ and the others defined as global variables.
Returns:
Dictionary to be passed into setuptools.setup(). | [
"Get",
"metadata",
"about",
"the",
"package",
"/",
"module",
"."
] | 646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a | https://github.com/Robpol86/Flask-JIRA-Helper/blob/646d32e6fccee8ab7d55e6401b9fbcb9cf52dc7a/setup.py#L17-L38 | train | Get metadata about the package and module. |
zalando-stups/lizzy-client | lizzy_client/cli.py | main_with_metrics | def main_with_metrics():
"""
Runs main() and reports success and failure metrics
"""
try:
main()
except Exception:
report_metric("bus.lizzy-client.failed", 1)
raise
except SystemExit as sys_exit:
if sys_exit.code == 0:
report_metric("bus.lizzy-client.s... | python | def main_with_metrics():
"""
Runs main() and reports success and failure metrics
"""
try:
main()
except Exception:
report_metric("bus.lizzy-client.failed", 1)
raise
except SystemExit as sys_exit:
if sys_exit.code == 0:
report_metric("bus.lizzy-client.s... | [
"def",
"main_with_metrics",
"(",
")",
":",
"try",
":",
"main",
"(",
")",
"except",
"Exception",
":",
"report_metric",
"(",
"\"bus.lizzy-client.failed\"",
",",
"1",
")",
"raise",
"except",
"SystemExit",
"as",
"sys_exit",
":",
"if",
"sys_exit",
".",
"code",
"=... | Runs main() and reports success and failure metrics | [
"Runs",
"main",
"()",
"and",
"reports",
"success",
"and",
"failure",
"metrics"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L70-L86 | train | Runs main and reports success and failure metrics |
zalando-stups/lizzy-client | lizzy_client/cli.py | agent_error | def agent_error(e: requests.HTTPError, fatal=True):
"""
Prints an agent error and exits
"""
try:
data = e.response.json()
details = data['detail'] # type: str
except JSONDecodeError:
details = e.response.text or str(e.response)
lines = ('[AGENT] {}'.format(line) for lin... | python | def agent_error(e: requests.HTTPError, fatal=True):
"""
Prints an agent error and exits
"""
try:
data = e.response.json()
details = data['detail'] # type: str
except JSONDecodeError:
details = e.response.text or str(e.response)
lines = ('[AGENT] {}'.format(line) for lin... | [
"def",
"agent_error",
"(",
"e",
":",
"requests",
".",
"HTTPError",
",",
"fatal",
"=",
"True",
")",
":",
"try",
":",
"data",
"=",
"e",
".",
"response",
".",
"json",
"(",
")",
"details",
"=",
"data",
"[",
"'detail'",
"]",
"# type: str",
"except",
"JSON... | Prints an agent error and exits | [
"Prints",
"an",
"agent",
"error",
"and",
"exits"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L99-L115 | train | Prints an agent error and exits
|
zalando-stups/lizzy-client | lizzy_client/cli.py | fetch_token | def fetch_token(token_url: str, scopes: str, credentials_dir: str) -> str:
"""
Common function to fetch token
:return:
"""
with Action('Fetching authentication token..') as action:
try:
access_token = get_token(token_url, scopes, credentials_dir)
action.progress()
... | python | def fetch_token(token_url: str, scopes: str, credentials_dir: str) -> str:
"""
Common function to fetch token
:return:
"""
with Action('Fetching authentication token..') as action:
try:
access_token = get_token(token_url, scopes, credentials_dir)
action.progress()
... | [
"def",
"fetch_token",
"(",
"token_url",
":",
"str",
",",
"scopes",
":",
"str",
",",
"credentials_dir",
":",
"str",
")",
"->",
"str",
":",
"with",
"Action",
"(",
"'Fetching authentication token..'",
")",
"as",
"action",
":",
"try",
":",
"access_token",
"=",
... | Common function to fetch token
:return: | [
"Common",
"function",
"to",
"fetch",
"token",
":",
"return",
":"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L132-L144 | train | Common function to fetch token from token_url |
zalando-stups/lizzy-client | lizzy_client/cli.py | parse_stack_refs | def parse_stack_refs(stack_references: List[str]) -> List[str]:
'''
Check if items included in `stack_references` are Senza definition
file paths or stack name reference. If Senza definition file path,
substitute the definition file path by the stack name in the same
position on the list.
'''
... | python | def parse_stack_refs(stack_references: List[str]) -> List[str]:
'''
Check if items included in `stack_references` are Senza definition
file paths or stack name reference. If Senza definition file path,
substitute the definition file path by the stack name in the same
position on the list.
'''
... | [
"def",
"parse_stack_refs",
"(",
"stack_references",
":",
"List",
"[",
"str",
"]",
")",
"->",
"List",
"[",
"str",
"]",
":",
"stack_names",
"=",
"[",
"]",
"references",
"=",
"list",
"(",
"stack_references",
")",
"references",
".",
"reverse",
"(",
")",
"whi... | Check if items included in `stack_references` are Senza definition
file paths or stack name reference. If Senza definition file path,
substitute the definition file path by the stack name in the same
position on the list. | [
"Check",
"if",
"items",
"included",
"in",
"stack_references",
"are",
"Senza",
"definition",
"file",
"paths",
"or",
"stack",
"name",
"reference",
".",
"If",
"Senza",
"definition",
"file",
"path",
"substitute",
"the",
"definition",
"file",
"path",
"by",
"the",
"... | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L147-L171 | train | Parse stack_references list. |
zalando-stups/lizzy-client | lizzy_client/cli.py | create | def create(definition: dict, version: str, parameter: tuple,
region: str,
disable_rollback: bool,
dry_run: bool,
force: bool,
tag: List[str],
timeout: int,
keep_stacks: Optional[int],
traffic: int,
verbose: bool,
... | python | def create(definition: dict, version: str, parameter: tuple,
region: str,
disable_rollback: bool,
dry_run: bool,
force: bool,
tag: List[str],
timeout: int,
keep_stacks: Optional[int],
traffic: int,
verbose: bool,
... | [
"def",
"create",
"(",
"definition",
":",
"dict",
",",
"version",
":",
"str",
",",
"parameter",
":",
"tuple",
",",
"region",
":",
"str",
",",
"disable_rollback",
":",
"bool",
",",
"dry_run",
":",
"bool",
",",
"force",
":",
"bool",
",",
"tag",
":",
"Li... | Create a new Cloud Formation stack from the given Senza definition file | [
"Create",
"a",
"new",
"Cloud",
"Formation",
"stack",
"from",
"the",
"given",
"Senza",
"definition",
"file"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L215-L336 | train | Create a new Cloud Formation stack from a Senza definition file. |
zalando-stups/lizzy-client | lizzy_client/cli.py | list_stacks | def list_stacks(stack_ref: List[str], all: bool, remote: str, region: str,
watch: int, output: str):
"""List Lizzy stacks"""
lizzy = setup_lizzy_client(remote)
stack_references = parse_stack_refs(stack_ref)
while True:
rows = []
for stack in lizzy.get_stacks(stack_refere... | python | def list_stacks(stack_ref: List[str], all: bool, remote: str, region: str,
watch: int, output: str):
"""List Lizzy stacks"""
lizzy = setup_lizzy_client(remote)
stack_references = parse_stack_refs(stack_ref)
while True:
rows = []
for stack in lizzy.get_stacks(stack_refere... | [
"def",
"list_stacks",
"(",
"stack_ref",
":",
"List",
"[",
"str",
"]",
",",
"all",
":",
"bool",
",",
"remote",
":",
"str",
",",
"region",
":",
"str",
",",
"watch",
":",
"int",
",",
"output",
":",
"str",
")",
":",
"lizzy",
"=",
"setup_lizzy_client",
... | List Lizzy stacks | [
"List",
"Lizzy",
"stacks"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L348-L374 | train | List Lizzy stacks. |
zalando-stups/lizzy-client | lizzy_client/cli.py | traffic | def traffic(stack_name: str,
stack_version: Optional[str],
percentage: Optional[int],
region: Optional[str],
remote: Optional[str],
output: Optional[str]):
'''Manage stack traffic'''
lizzy = setup_lizzy_client(remote)
if percentage is None:
... | python | def traffic(stack_name: str,
stack_version: Optional[str],
percentage: Optional[int],
region: Optional[str],
remote: Optional[str],
output: Optional[str]):
'''Manage stack traffic'''
lizzy = setup_lizzy_client(remote)
if percentage is None:
... | [
"def",
"traffic",
"(",
"stack_name",
":",
"str",
",",
"stack_version",
":",
"Optional",
"[",
"str",
"]",
",",
"percentage",
":",
"Optional",
"[",
"int",
"]",
",",
"region",
":",
"Optional",
"[",
"str",
"]",
",",
"remote",
":",
"Optional",
"[",
"str",
... | Manage stack traffic | [
"Manage",
"stack",
"traffic"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L387-L418 | train | Manage stack traffic |
zalando-stups/lizzy-client | lizzy_client/cli.py | scale | def scale(stack_name: str,
stack_version: Optional[str],
new_scale: int,
region: Optional[str],
remote: Optional[str]):
'''Rescale a stack'''
lizzy = setup_lizzy_client(remote)
with Action('Requesting rescale..'):
stack_id = '{stack_name}-{stack_version}'.for... | python | def scale(stack_name: str,
stack_version: Optional[str],
new_scale: int,
region: Optional[str],
remote: Optional[str]):
'''Rescale a stack'''
lizzy = setup_lizzy_client(remote)
with Action('Requesting rescale..'):
stack_id = '{stack_name}-{stack_version}'.for... | [
"def",
"scale",
"(",
"stack_name",
":",
"str",
",",
"stack_version",
":",
"Optional",
"[",
"str",
"]",
",",
"new_scale",
":",
"int",
",",
"region",
":",
"Optional",
"[",
"str",
"]",
",",
"remote",
":",
"Optional",
"[",
"str",
"]",
")",
":",
"lizzy",
... | Rescale a stack | [
"Rescale",
"a",
"stack"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L428-L438 | train | Rescale a stack |
zalando-stups/lizzy-client | lizzy_client/cli.py | delete | def delete(stack_ref: List[str],
region: str, dry_run: bool, force: bool, remote: str):
"""Delete Cloud Formation stacks"""
lizzy = setup_lizzy_client(remote)
stack_refs = get_stack_refs(stack_ref)
all_with_version = all(stack.version is not None
for stack in stack_... | python | def delete(stack_ref: List[str],
region: str, dry_run: bool, force: bool, remote: str):
"""Delete Cloud Formation stacks"""
lizzy = setup_lizzy_client(remote)
stack_refs = get_stack_refs(stack_ref)
all_with_version = all(stack.version is not None
for stack in stack_... | [
"def",
"delete",
"(",
"stack_ref",
":",
"List",
"[",
"str",
"]",
",",
"region",
":",
"str",
",",
"dry_run",
":",
"bool",
",",
"force",
":",
"bool",
",",
"remote",
":",
"str",
")",
":",
"lizzy",
"=",
"setup_lizzy_client",
"(",
"remote",
")",
"stack_re... | Delete Cloud Formation stacks | [
"Delete",
"Cloud",
"Formation",
"stacks"
] | 0af9733ca5a25ebd0a9dc1453f2a7592efcee56a | https://github.com/zalando-stups/lizzy-client/blob/0af9733ca5a25ebd0a9dc1453f2a7592efcee56a/lizzy_client/cli.py#L449-L478 | train | Delete a single stack in a given region. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | py2dict | def py2dict(elements):
"""Convert a Python object into a Python dictionary."""
metadata_dict = {}
# Loop through all elements in the Python object.
for element in elements.children:
# Start an empty element list if an entry for the element
# list hasn't been made in the dictionary.
... | python | def py2dict(elements):
"""Convert a Python object into a Python dictionary."""
metadata_dict = {}
# Loop through all elements in the Python object.
for element in elements.children:
# Start an empty element list if an entry for the element
# list hasn't been made in the dictionary.
... | [
"def",
"py2dict",
"(",
"elements",
")",
":",
"metadata_dict",
"=",
"{",
"}",
"# Loop through all elements in the Python object.",
"for",
"element",
"in",
"elements",
".",
"children",
":",
"# Start an empty element list if an entry for the element",
"# list hasn't been made in t... | Convert a Python object into a Python dictionary. | [
"Convert",
"a",
"Python",
"object",
"into",
"a",
"Python",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L27-L56 | train | Convert a Python object into a Python dictionary. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | etd_ms_py2dict | def etd_ms_py2dict(elements):
"""Convert a Python object into a Python dictionary."""
metadata_dict = {}
# Loop through all elements in the Python object.
for element in elements.children:
# Start an empty element list if an entry for the element
# list hasn't been made in the dictionary... | python | def etd_ms_py2dict(elements):
"""Convert a Python object into a Python dictionary."""
metadata_dict = {}
# Loop through all elements in the Python object.
for element in elements.children:
# Start an empty element list if an entry for the element
# list hasn't been made in the dictionary... | [
"def",
"etd_ms_py2dict",
"(",
"elements",
")",
":",
"metadata_dict",
"=",
"{",
"}",
"# Loop through all elements in the Python object.",
"for",
"element",
"in",
"elements",
".",
"children",
":",
"# Start an empty element list if an entry for the element",
"# list hasn't been ma... | Convert a Python object into a Python dictionary. | [
"Convert",
"a",
"Python",
"object",
"into",
"a",
"Python",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L59-L93 | train | Convert a Python object into a Python dictionary. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | pydict2xml | def pydict2xml(filename, metadata_dict, **kwargs):
"""Create an XML file.
Takes a path to where the XML file should be created
and a metadata dictionary.
"""
try:
f = open(filename, 'w')
f.write(pydict2xmlstring(metadata_dict, **kwargs).encode('utf-8'))
f.close()
except:... | python | def pydict2xml(filename, metadata_dict, **kwargs):
"""Create an XML file.
Takes a path to where the XML file should be created
and a metadata dictionary.
"""
try:
f = open(filename, 'w')
f.write(pydict2xmlstring(metadata_dict, **kwargs).encode('utf-8'))
f.close()
except:... | [
"def",
"pydict2xml",
"(",
"filename",
",",
"metadata_dict",
",",
"*",
"*",
"kwargs",
")",
":",
"try",
":",
"f",
"=",
"open",
"(",
"filename",
",",
"'w'",
")",
"f",
".",
"write",
"(",
"pydict2xmlstring",
"(",
"metadata_dict",
",",
"*",
"*",
"kwargs",
... | Create an XML file.
Takes a path to where the XML file should be created
and a metadata dictionary. | [
"Create",
"an",
"XML",
"file",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L96-L109 | train | Create an XML file. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | pydict2xmlstring | def pydict2xmlstring(metadata_dict, **kwargs):
"""Create an XML string from a metadata dictionary."""
ordering = kwargs.get('ordering', UNTL_XML_ORDER)
root_label = kwargs.get('root_label', 'metadata')
root_namespace = kwargs.get('root_namespace', None)
elements_namespace = kwargs.get('elements_name... | python | def pydict2xmlstring(metadata_dict, **kwargs):
"""Create an XML string from a metadata dictionary."""
ordering = kwargs.get('ordering', UNTL_XML_ORDER)
root_label = kwargs.get('root_label', 'metadata')
root_namespace = kwargs.get('root_namespace', None)
elements_namespace = kwargs.get('elements_name... | [
"def",
"pydict2xmlstring",
"(",
"metadata_dict",
",",
"*",
"*",
"kwargs",
")",
":",
"ordering",
"=",
"kwargs",
".",
"get",
"(",
"'ordering'",
",",
"UNTL_XML_ORDER",
")",
"root_label",
"=",
"kwargs",
".",
"get",
"(",
"'root_label'",
",",
"'metadata'",
")",
... | Create an XML string from a metadata dictionary. | [
"Create",
"an",
"XML",
"string",
"from",
"a",
"metadata",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L112-L170 | train | Create an XML string from a metadata dictionary. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | create_dict_subelement | def create_dict_subelement(root, subelement, content, **kwargs):
"""Create a XML subelement from a Python dictionary."""
attribs = kwargs.get('attribs', None)
namespace = kwargs.get('namespace', None)
key = subelement
# Add subelement's namespace and attributes.
if namespace and attribs:
... | python | def create_dict_subelement(root, subelement, content, **kwargs):
"""Create a XML subelement from a Python dictionary."""
attribs = kwargs.get('attribs', None)
namespace = kwargs.get('namespace', None)
key = subelement
# Add subelement's namespace and attributes.
if namespace and attribs:
... | [
"def",
"create_dict_subelement",
"(",
"root",
",",
"subelement",
",",
"content",
",",
"*",
"*",
"kwargs",
")",
":",
"attribs",
"=",
"kwargs",
".",
"get",
"(",
"'attribs'",
",",
"None",
")",
"namespace",
"=",
"kwargs",
".",
"get",
"(",
"'namespace'",
",",... | Create a XML subelement from a Python dictionary. | [
"Create",
"a",
"XML",
"subelement",
"from",
"a",
"Python",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L173-L201 | train | Create a XML subelement from a Python dictionary. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | highwiredict2xmlstring | def highwiredict2xmlstring(highwire_elements, ordering=HIGHWIRE_ORDER):
"""Create an XML string from the highwire data dictionary."""
# Sort the elements by the ordering list.
highwire_elements.sort(key=lambda obj: ordering.index(obj.name))
root = Element('metadata')
for element in highwire_elements... | python | def highwiredict2xmlstring(highwire_elements, ordering=HIGHWIRE_ORDER):
"""Create an XML string from the highwire data dictionary."""
# Sort the elements by the ordering list.
highwire_elements.sort(key=lambda obj: ordering.index(obj.name))
root = Element('metadata')
for element in highwire_elements... | [
"def",
"highwiredict2xmlstring",
"(",
"highwire_elements",
",",
"ordering",
"=",
"HIGHWIRE_ORDER",
")",
":",
"# Sort the elements by the ordering list.",
"highwire_elements",
".",
"sort",
"(",
"key",
"=",
"lambda",
"obj",
":",
"ordering",
".",
"index",
"(",
"obj",
"... | Create an XML string from the highwire data dictionary. | [
"Create",
"an",
"XML",
"string",
"from",
"the",
"highwire",
"data",
"dictionary",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L204-L216 | train | Create an XML string from the highwire data dictionary. |
unt-libraries/pyuntl | pyuntl/metadata_generator.py | writeANVLString | def writeANVLString(ANVLDict, ordering=UNTL_XML_ORDER):
"""Take a dictionary and write out the key/value pairs
in ANVL format.
"""
lines = []
# Loop through the ordering for the data.
for key in ordering:
# Make sure the element exists in the data set.
if key in ANVLDict:
... | python | def writeANVLString(ANVLDict, ordering=UNTL_XML_ORDER):
"""Take a dictionary and write out the key/value pairs
in ANVL format.
"""
lines = []
# Loop through the ordering for the data.
for key in ordering:
# Make sure the element exists in the data set.
if key in ANVLDict:
... | [
"def",
"writeANVLString",
"(",
"ANVLDict",
",",
"ordering",
"=",
"UNTL_XML_ORDER",
")",
":",
"lines",
"=",
"[",
"]",
"# Loop through the ordering for the data.",
"for",
"key",
"in",
"ordering",
":",
"# Make sure the element exists in the data set.",
"if",
"key",
"in",
... | Take a dictionary and write out the key/value pairs
in ANVL format. | [
"Take",
"a",
"dictionary",
"and",
"write",
"out",
"the",
"key",
"/",
"value",
"pairs",
"in",
"ANVL",
"format",
"."
] | f92413302897dab948aac18ee9e482ace0187bd4 | https://github.com/unt-libraries/pyuntl/blob/f92413302897dab948aac18ee9e482ace0187bd4/pyuntl/metadata_generator.py#L240-L257 | train | Take a dictionary and write out the key value pairs
in ANVL format. |
geophysics-ubonn/crtomo_tools | lib/crtomo/binaries.py | get | def get(binary_name):
"""return a valid path to the given binary. Return an error if no existing
binary can be found.
Parameters
----------
binary_name: string
a binary name used as a key in the 'binaries' dictionary above
Return
------
string
full path to binary
""... | python | def get(binary_name):
"""return a valid path to the given binary. Return an error if no existing
binary can be found.
Parameters
----------
binary_name: string
a binary name used as a key in the 'binaries' dictionary above
Return
------
string
full path to binary
""... | [
"def",
"get",
"(",
"binary_name",
")",
":",
"if",
"binary_name",
"not",
"in",
"binaries",
":",
"raise",
"Exception",
"(",
"'binary_name: {0} not found'",
".",
"format",
"(",
"binary_name",
")",
")",
"system",
"=",
"platform",
".",
"system",
"(",
")",
"binary... | return a valid path to the given binary. Return an error if no existing
binary can be found.
Parameters
----------
binary_name: string
a binary name used as a key in the 'binaries' dictionary above
Return
------
string
full path to binary | [
"return",
"a",
"valid",
"path",
"to",
"the",
"given",
"binary",
".",
"Return",
"an",
"error",
"if",
"no",
"existing",
"binary",
"can",
"be",
"found",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/binaries.py#L79-L103 | train | return a valid path to the given binary |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.