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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.physical_vector_from_hypercube_vector | def physical_vector_from_hypercube_vector(self, hypercube_vector):
"""
Parameters
----------
hypercube_vector: [float]
A unit hypercube vector
Returns
-------
values: [float]
A vector with values output by priors
"""
return... | python | def physical_vector_from_hypercube_vector(self, hypercube_vector):
"""
Parameters
----------
hypercube_vector: [float]
A unit hypercube vector
Returns
-------
values: [float]
A vector with values output by priors
"""
return... | [
"def",
"physical_vector_from_hypercube_vector",
"(",
"self",
",",
"hypercube_vector",
")",
":",
"return",
"list",
"(",
"map",
"(",
"lambda",
"prior_tuple",
",",
"unit",
":",
"prior_tuple",
".",
"prior",
".",
"value_for",
"(",
"unit",
")",
",",
"self",
".",
"... | Parameters
----------
hypercube_vector: [float]
A unit hypercube vector
Returns
-------
values: [float]
A vector with values output by priors | [
"Parameters",
"----------",
"hypercube_vector",
":",
"[",
"float",
"]",
"A",
"unit",
"hypercube",
"vector"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L264-L278 | train | Returns a list of physical vector values for the given hypercube vector. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.physical_values_ordered_by_class | def physical_values_ordered_by_class(self, hypercube_vector):
"""
Parameters
----------
hypercube_vector: [float]
A unit vector
Returns
-------
physical_values: [float]
A list of physical values constructed by passing the values in the hyp... | python | def physical_values_ordered_by_class(self, hypercube_vector):
"""
Parameters
----------
hypercube_vector: [float]
A unit vector
Returns
-------
physical_values: [float]
A list of physical values constructed by passing the values in the hyp... | [
"def",
"physical_values_ordered_by_class",
"(",
"self",
",",
"hypercube_vector",
")",
":",
"model_instance",
"=",
"self",
".",
"instance_from_unit_vector",
"(",
"hypercube_vector",
")",
"result",
"=",
"[",
"]",
"for",
"instance_key",
"in",
"sorted",
"(",
"model_inst... | Parameters
----------
hypercube_vector: [float]
A unit vector
Returns
-------
physical_values: [float]
A list of physical values constructed by passing the values in the hypercube vector through associated
priors. | [
"Parameters",
"----------",
"hypercube_vector",
":",
"[",
"float",
"]",
"A",
"unit",
"vector"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L280-L305 | train | Returns a list of all the values in the associated object that are in the same class as the given hypercube vector. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.instance_from_unit_vector | def instance_from_unit_vector(self, unit_vector):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a unit vector of parameter values, converting each to physical values via ... | python | def instance_from_unit_vector(self, unit_vector):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a unit vector of parameter values, converting each to physical values via ... | [
"def",
"instance_from_unit_vector",
"(",
"self",
",",
"unit_vector",
")",
":",
"arguments",
"=",
"dict",
"(",
"map",
"(",
"lambda",
"prior_tuple",
",",
"unit",
":",
"(",
"prior_tuple",
".",
"prior",
",",
"prior_tuple",
".",
"prior",
".",
"value_for",
"(",
... | Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a unit vector of parameter values, converting each to physical values via their \
priors.
Parameters
----------
... | [
"Creates",
"a",
"ModelInstance",
"which",
"has",
"an",
"attribute",
"and",
"class",
"instance",
"corresponding",
"to",
"every",
"PriorModel",
"\\",
"attributed",
"to",
"this",
"instance",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L329-L352 | train | This method creates a ModelInstance from a unit vector of parameter values. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.instance_from_physical_vector | def instance_from_physical_vector(self, physical_vector):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a physical vector of parameter values, thus omitting the use of pr... | python | def instance_from_physical_vector(self, physical_vector):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a physical vector of parameter values, thus omitting the use of pr... | [
"def",
"instance_from_physical_vector",
"(",
"self",
",",
"physical_vector",
")",
":",
"arguments",
"=",
"dict",
"(",
"map",
"(",
"lambda",
"prior_tuple",
",",
"physical_unit",
":",
"(",
"prior_tuple",
".",
"prior",
",",
"physical_unit",
")",
",",
"self",
".",... | Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel \
attributed to this instance.
This method takes as input a physical vector of parameter values, thus omitting the use of priors.
Parameters
----------
physical_vector: [float]
... | [
"Creates",
"a",
"ModelInstance",
"which",
"has",
"an",
"attribute",
"and",
"class",
"instance",
"corresponding",
"to",
"every",
"PriorModel",
"\\",
"attributed",
"to",
"this",
"instance",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L354-L376 | train | Creates a ModelInstance from a vector of parameter values. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.instance_for_arguments | def instance_for_arguments(self, arguments):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel
attributed to this instance.
Parameters
----------
arguments : dict
The dictionary representation of prior an... | python | def instance_for_arguments(self, arguments):
"""
Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel
attributed to this instance.
Parameters
----------
arguments : dict
The dictionary representation of prior an... | [
"def",
"instance_for_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"model_instance",
"=",
"ModelInstance",
"(",
")",
"for",
"prior_model_tuple",
"in",
"self",
".",
"prior_model_tuples",
":",
"setattr",
"(",
"model_instance",
",",
"prior_model_tuple",
".",
"... | Creates a ModelInstance, which has an attribute and class instance corresponding to every PriorModel
attributed to this instance.
Parameters
----------
arguments : dict
The dictionary representation of prior and parameter values. This is created in the model_instance_from_*
... | [
"Creates",
"a",
"ModelInstance",
"which",
"has",
"an",
"attribute",
"and",
"class",
"instance",
"corresponding",
"to",
"every",
"PriorModel",
"attributed",
"to",
"this",
"instance",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L378-L402 | train | Creates a ModelInstance which is created for every PriorModel
corresponding to every PriorModel
whose attribute and class instance corresponding to every PriorModel
whose attribute and class instance corresponding to every PriorModel
whose parameter values are arguments. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.mapper_from_partial_prior_arguments | def mapper_from_partial_prior_arguments(self, arguments):
"""
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing
priors where no mapping is provided.
Parameters
----------
arguments: {Prior: Prior}
A di... | python | def mapper_from_partial_prior_arguments(self, arguments):
"""
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing
priors where no mapping is provided.
Parameters
----------
arguments: {Prior: Prior}
A di... | [
"def",
"mapper_from_partial_prior_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"original_prior_dict",
"=",
"{",
"prior",
":",
"prior",
"for",
"prior",
"in",
"self",
".",
"priors",
"}",
"return",
"self",
".",
"mapper_from_prior_arguments",
"(",
"{",
"*",
... | Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors, keeping existing
priors where no mapping is provided.
Parameters
----------
arguments: {Prior: Prior}
A dictionary mapping_matrix priors to priors
Returns
-------
... | [
"Creates",
"a",
"new",
"model",
"mapper",
"from",
"a",
"dictionary",
"mapping_matrix",
"existing",
"priors",
"to",
"new",
"priors",
"keeping",
"existing",
"priors",
"where",
"no",
"mapping",
"is",
"provided",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L404-L420 | train | Creates a new model mapper from a dictionary mapping existing priors to new priors keeping existing priors where no mapping is provided. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.mapper_from_prior_arguments | def mapper_from_prior_arguments(self, arguments):
"""
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors.
Parameters
----------
arguments: {Prior: Prior}
A dictionary mapping_matrix priors to priors
Returns
----... | python | def mapper_from_prior_arguments(self, arguments):
"""
Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors.
Parameters
----------
arguments: {Prior: Prior}
A dictionary mapping_matrix priors to priors
Returns
----... | [
"def",
"mapper_from_prior_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"mapper",
"=",
"copy",
".",
"deepcopy",
"(",
"self",
")",
"for",
"prior_model_tuple",
"in",
"self",
".",
"prior_model_tuples",
":",
"setattr",
"(",
"mapper",
",",
"prior_model_tuple",... | Creates a new model mapper from a dictionary mapping_matrix existing priors to new priors.
Parameters
----------
arguments: {Prior: Prior}
A dictionary mapping_matrix priors to priors
Returns
-------
model_mapper: ModelMapper
A new model mapper w... | [
"Creates",
"a",
"new",
"model",
"mapper",
"from",
"a",
"dictionary",
"mapping_matrix",
"existing",
"priors",
"to",
"new",
"priors",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L422-L442 | train | Creates a new model mapper from a dictionary mapping priors to new priors. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.mapper_from_gaussian_tuples | def mapper_from_gaussian_tuples(self, tuples, a=None, r=None):
"""
Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \
of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \
order ... | python | def mapper_from_gaussian_tuples(self, tuples, a=None, r=None):
"""
Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \
of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \
order ... | [
"def",
"mapper_from_gaussian_tuples",
"(",
"self",
",",
"tuples",
",",
"a",
"=",
"None",
",",
"r",
"=",
"None",
")",
":",
"prior_tuples",
"=",
"self",
".",
"prior_tuples_ordered_by_id",
"prior_class_dict",
"=",
"self",
".",
"prior_class_dict",
"arguments",
"=",
... | Creates a new model mapper from a list of floats describing the mean values of gaussian priors. The widths \
of the new priors are taken from the width_config. The new gaussian priors must be provided in the same \
order as the priors associated with model.
If a is not None then all priors are ... | [
"Creates",
"a",
"new",
"model",
"mapper",
"from",
"a",
"list",
"of",
"floats",
"describing",
"the",
"mean",
"values",
"of",
"gaussian",
"priors",
".",
"The",
"widths",
"\\",
"of",
"the",
"new",
"priors",
"are",
"taken",
"from",
"the",
"width_config",
".",
... | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L444-L499 | train | Creates a new model mapper from a list of floats describing the mean values of gaussian priors. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.info | def info(self):
"""
Use the priors that make up the model_mapper to generate information on each parameter of the overall model.
This information is extracted from each priors *model_info* property.
"""
info = []
for prior_model_name, prior_model in self.prior_model_tup... | python | def info(self):
"""
Use the priors that make up the model_mapper to generate information on each parameter of the overall model.
This information is extracted from each priors *model_info* property.
"""
info = []
for prior_model_name, prior_model in self.prior_model_tup... | [
"def",
"info",
"(",
"self",
")",
":",
"info",
"=",
"[",
"]",
"for",
"prior_model_name",
",",
"prior_model",
"in",
"self",
".",
"prior_model_tuples",
":",
"info",
".",
"append",
"(",
"prior_model",
".",
"name",
"+",
"'\\n'",
")",
"info",
".",
"extend",
... | Use the priors that make up the model_mapper to generate information on each parameter of the overall model.
This information is extracted from each priors *model_info* property. | [
"Use",
"the",
"priors",
"that",
"make",
"up",
"the",
"model_mapper",
"to",
"generate",
"information",
"on",
"each",
"parameter",
"of",
"the",
"overall",
"model",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/model_mapper.py#L520-L532 | train | Return the information for each resource in the overall model. |
rhayes777/PyAutoFit | autofit/mapper/model_mapper.py | ModelMapper.param_names | def param_names(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."""
return [self.nam... | python | def param_names(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."""
return [self.nam... | [
"def",
"param_names",
"(",
"self",
")",
":",
"return",
"[",
"self",
".",
"name_for_prior",
"(",
"prior",
")",
"for",
"prior",
"in",
"sorted",
"(",
"self",
".",
"priors",
",",
"key",
"=",
"lambda",
"prior",
":",
"prior",
".",
"id",
")",
"]"
] | 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/mapper/model_mapper.py#L541-L547 | train | The param_names vector is a list each parameter s analysis_path is used for GetDist visualization. |
gofed/gofedlib | gofedlib/projectsignature/signature.py | ProjectSignatureGenerator.generate | def generate(self, resource_provider, resource):
"""Generate project (snapshot) signature
:param resource_provider: project provider
:type resource_provider: dict
:param resource: project resource
:type resource: ProjectResource
"""
provider = resource_provider["provider"]
if provider == "github":
... | python | def generate(self, resource_provider, resource):
"""Generate project (snapshot) signature
:param resource_provider: project provider
:type resource_provider: dict
:param resource: project resource
:type resource: ProjectResource
"""
provider = resource_provider["provider"]
if provider == "github":
... | [
"def",
"generate",
"(",
"self",
",",
"resource_provider",
",",
"resource",
")",
":",
"provider",
"=",
"resource_provider",
"[",
"\"provider\"",
"]",
"if",
"provider",
"==",
"\"github\"",
":",
"return",
"self",
".",
"generateGithubRepositorySignature",
"(",
"resour... | Generate project (snapshot) signature
:param resource_provider: project provider
:type resource_provider: dict
:param resource: project resource
:type resource: ProjectResource | [
"Generate",
"project",
"(",
"snapshot",
")",
"signature"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/projectsignature/signature.py#L176-L192 | train | Generate project signature |
peterbe/gg | gg/builtins/push/gg_push.py | push | def push(config, force=False):
"""Create push the current branch."""
repo = config.repo
active_branch = repo.active_branch
if active_branch.name == "master":
error_out(
"Can't commit when on the master branch. "
"You really ought to do work in branches."
)
s... | python | def push(config, force=False):
"""Create push the current branch."""
repo = config.repo
active_branch = repo.active_branch
if active_branch.name == "master":
error_out(
"Can't commit when on the master branch. "
"You really ought to do work in branches."
)
s... | [
"def",
"push",
"(",
"config",
",",
"force",
"=",
"False",
")",
":",
"repo",
"=",
"config",
".",
"repo",
"active_branch",
"=",
"repo",
".",
"active_branch",
"if",
"active_branch",
".",
"name",
"==",
"\"master\"",
":",
"error_out",
"(",
"\"Can't commit when on... | Create push the current branch. | [
"Create",
"push",
"the",
"current",
"branch",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/push/gg_push.py#L12-L52 | train | Create push the current branch. |
geophysics-ubonn/crtomo_tools | lib/crtomo/mpl.py | setup | def setup():
"""import the matplotlib modules and set the style
"""
import sys
already_loaded = 'matplotlib' in sys.modules
# just make sure we can access matplotlib as mpl
import matplotlib as mpl
if not already_loaded:
mpl.use('Agg')
import matplotlib.pyplot as plt
plt.... | python | def setup():
"""import the matplotlib modules and set the style
"""
import sys
already_loaded = 'matplotlib' in sys.modules
# just make sure we can access matplotlib as mpl
import matplotlib as mpl
if not already_loaded:
mpl.use('Agg')
import matplotlib.pyplot as plt
plt.... | [
"def",
"setup",
"(",
")",
":",
"import",
"sys",
"already_loaded",
"=",
"'matplotlib'",
"in",
"sys",
".",
"modules",
"# just make sure we can access matplotlib as mpl",
"import",
"matplotlib",
"as",
"mpl",
"if",
"not",
"already_loaded",
":",
"mpl",
".",
"use",
"(",... | import the matplotlib modules and set the style | [
"import",
"the",
"matplotlib",
"modules",
"and",
"set",
"the",
"style"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/mpl.py#L15-L35 | train | set the matplotlib modules and the style of the Seaborn Seaborn |
geophysics-ubonn/crtomo_tools | lib/crtomo/mpl.py | general_settings | def general_settings():
"""general settings
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.size'] = 7.0
mpl.rcParams['axes.labelsize'] = 7.0
mpl.rcParams['xtick.labelsize'] = 7.0
mpl.rcParams['ytick.labelsize'] = 7.0
mpl.rcParams["lines.linewidth"] = ... | python | def general_settings():
"""general settings
"""
import matplotlib as mpl
import matplotlib.pyplot as plt
mpl.rcParams['font.size'] = 7.0
mpl.rcParams['axes.labelsize'] = 7.0
mpl.rcParams['xtick.labelsize'] = 7.0
mpl.rcParams['ytick.labelsize'] = 7.0
mpl.rcParams["lines.linewidth"] = ... | [
"def",
"general_settings",
"(",
")",
":",
"import",
"matplotlib",
"as",
"mpl",
"import",
"matplotlib",
".",
"pyplot",
"as",
"plt",
"mpl",
".",
"rcParams",
"[",
"'font.size'",
"]",
"=",
"7.0",
"mpl",
".",
"rcParams",
"[",
"'axes.labelsize'",
"]",
"=",
"7.0"... | general settings | [
"general",
"settings"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/mpl.py#L38-L69 | train | general settings for the
|
tslight/treepick | treepick/__main__.py | chkpath | def chkpath(path):
"""
Checks if a path exists.
"""
if os.path.exists(path):
return path
else:
msg = "{0} does not exist.".format(path)
raise argparse.ArgumentTypeError(msg) | python | def chkpath(path):
"""
Checks if a path exists.
"""
if os.path.exists(path):
return path
else:
msg = "{0} does not exist.".format(path)
raise argparse.ArgumentTypeError(msg) | [
"def",
"chkpath",
"(",
"path",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"path",
")",
":",
"return",
"path",
"else",
":",
"msg",
"=",
"\"{0} does not exist.\"",
".",
"format",
"(",
"path",
")",
"raise",
"argparse",
".",
"ArgumentTypeError",
... | Checks if a path exists. | [
"Checks",
"if",
"a",
"path",
"exists",
"."
] | 7adf838900f11e8845e17d8c79bb2b23617aec2c | https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/__main__.py#L14-L22 | train | Checks if a path exists. |
tslight/treepick | treepick/__main__.py | getargs | def getargs():
"""
Return a list of valid arguments.
"""
parser = argparse.ArgumentParser(description='\
Select paths from a directory tree.')
parser.add_argument("-a", "--hidden", action="store_false",
help="Show all hidden paths too.")
parser.add_argument("-r", "--r... | python | def getargs():
"""
Return a list of valid arguments.
"""
parser = argparse.ArgumentParser(description='\
Select paths from a directory tree.')
parser.add_argument("-a", "--hidden", action="store_false",
help="Show all hidden paths too.")
parser.add_argument("-r", "--r... | [
"def",
"getargs",
"(",
")",
":",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"'\\\n Select paths from a directory tree.'",
")",
"parser",
".",
"add_argument",
"(",
"\"-a\"",
",",
"\"--hidden\"",
",",
"action",
"=",
"\"store_false\""... | Return a list of valid arguments. | [
"Return",
"a",
"list",
"of",
"valid",
"arguments",
"."
] | 7adf838900f11e8845e17d8c79bb2b23617aec2c | https://github.com/tslight/treepick/blob/7adf838900f11e8845e17d8c79bb2b23617aec2c/treepick/__main__.py#L25-L37 | train | Return a list of valid arguments. |
geophysics-ubonn/crtomo_tools | src/volt_correct_temperature.py | handle_options | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(aniso=False)
parser.add_option("--dobs",
dest="d_obs",
help="field data",
metavar="file",
default="mod/volt.dat",
... | python | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(aniso=False)
parser.add_option("--dobs",
dest="d_obs",
help="field data",
metavar="file",
default="mod/volt.dat",
... | [
"def",
"handle_options",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"set_defaults",
"(",
"aniso",
"=",
"False",
")",
"parser",
".",
"add_option",
"(",
"\"--dobs\"",
",",
"dest",
"=",
"\"d_obs\"",
",",
"help",
"=",
"\"field data\... | Handle options. | [
"Handle",
"options",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L21-L53 | train | Handle options.
|
geophysics-ubonn/crtomo_tools | src/volt_correct_temperature.py | readin_volt | def readin_volt(filename):
"""Read in measurement data from a volt.dat file and return electrodes and
measured resistance.
"""
with open(filename, 'r') as fid:
content = np.loadtxt(fid, skiprows=1, usecols=[0, 1, 2])
volt = content[:, 2]
elecs = content[:, 0:2]
return elecs, ... | python | def readin_volt(filename):
"""Read in measurement data from a volt.dat file and return electrodes and
measured resistance.
"""
with open(filename, 'r') as fid:
content = np.loadtxt(fid, skiprows=1, usecols=[0, 1, 2])
volt = content[:, 2]
elecs = content[:, 0:2]
return elecs, ... | [
"def",
"readin_volt",
"(",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"fid",
":",
"content",
"=",
"np",
".",
"loadtxt",
"(",
"fid",
",",
"skiprows",
"=",
"1",
",",
"usecols",
"=",
"[",
"0",
",",
"1",
",",
"2",
... | Read in measurement data from a volt.dat file and return electrodes and
measured resistance. | [
"Read",
"in",
"measurement",
"data",
"from",
"a",
"volt",
".",
"dat",
"file",
"and",
"return",
"electrodes",
"and",
"measured",
"resistance",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L56-L64 | train | Read in measurement data from a volt. dat file and return electrodes and measured resistance. |
geophysics-ubonn/crtomo_tools | src/volt_correct_temperature.py | calc_correction | def calc_correction(volt1, volt2, volt3):
"""Remove the temperature effect from field data using inversion results of
that data:
print(volt[0])
d_obs^TC = d_obs + (d_est^TC - d_est)
Parameters
----------
d_obs:
measured field data to correct (volt1)
d_est:
synth... | python | def calc_correction(volt1, volt2, volt3):
"""Remove the temperature effect from field data using inversion results of
that data:
print(volt[0])
d_obs^TC = d_obs + (d_est^TC - d_est)
Parameters
----------
d_obs:
measured field data to correct (volt1)
d_est:
synth... | [
"def",
"calc_correction",
"(",
"volt1",
",",
"volt2",
",",
"volt3",
")",
":",
"volt",
"=",
"np",
".",
"array",
"(",
"[",
"a",
"-",
"b",
"+",
"c",
"for",
"a",
",",
"b",
",",
"c",
"in",
"zip",
"(",
"volt1",
",",
"volt2",
",",
"volt3",
")",
"]",... | Remove the temperature effect from field data using inversion results of
that data:
print(volt[0])
d_obs^TC = d_obs + (d_est^TC - d_est)
Parameters
----------
d_obs:
measured field data to correct (volt1)
d_est:
synthetic data of inversion result from d_obs (volt2)
... | [
"Remove",
"the",
"temperature",
"effect",
"from",
"field",
"data",
"using",
"inversion",
"results",
"of",
"that",
"data",
":"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L67-L87 | train | Calculate the temperature effect correction of the current time series using inversion results of the current time series. |
geophysics-ubonn/crtomo_tools | src/volt_correct_temperature.py | save_volt | def save_volt(elecs, volt, filename):
"""Save the values in volt-format.
"""
# bring data in shape
content = np.column_stack((elecs, volt, np.zeros(len(volt))))
# save datapoints
with open(filename, 'w') as fid:
fid.write('{0}\n'.format(content.shape[0]))
with open(filename, 'ab') a... | python | def save_volt(elecs, volt, filename):
"""Save the values in volt-format.
"""
# bring data in shape
content = np.column_stack((elecs, volt, np.zeros(len(volt))))
# save datapoints
with open(filename, 'w') as fid:
fid.write('{0}\n'.format(content.shape[0]))
with open(filename, 'ab') a... | [
"def",
"save_volt",
"(",
"elecs",
",",
"volt",
",",
"filename",
")",
":",
"# bring data in shape",
"content",
"=",
"np",
".",
"column_stack",
"(",
"(",
"elecs",
",",
"volt",
",",
"np",
".",
"zeros",
"(",
"len",
"(",
"volt",
")",
")",
")",
")",
"# sav... | Save the values in volt-format. | [
"Save",
"the",
"values",
"in",
"volt",
"-",
"format",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L90-L100 | train | Save the values in volt - format. |
geophysics-ubonn/crtomo_tools | src/volt_correct_temperature.py | main | def main():
"""Function to remove temperature effect from field data
"""
options = handle_options()
# read in observed and synthetic data
elecs, d_obs = readin_volt(options.d_obs)
elecs, d_est = readin_volt(options.d_est)
elecs, d_estTC = readin_volt(options.d_estTC)
# calculate correct... | python | def main():
"""Function to remove temperature effect from field data
"""
options = handle_options()
# read in observed and synthetic data
elecs, d_obs = readin_volt(options.d_obs)
elecs, d_est = readin_volt(options.d_est)
elecs, d_estTC = readin_volt(options.d_estTC)
# calculate correct... | [
"def",
"main",
"(",
")",
":",
"options",
"=",
"handle_options",
"(",
")",
"# read in observed and synthetic data",
"elecs",
",",
"d_obs",
"=",
"readin_volt",
"(",
"options",
".",
"d_obs",
")",
"elecs",
",",
"d_est",
"=",
"readin_volt",
"(",
"options",
".",
"... | Function to remove temperature effect from field data | [
"Function",
"to",
"remove",
"temperature",
"effect",
"from",
"field",
"data"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/volt_correct_temperature.py#L103-L121 | train | Function to remove temperature effect from field data
|
rhayes777/PyAutoFit | autofit/mapper/prior.py | TuplePrior.prior_tuples | def prior_tuples(self):
"""
Returns
-------
priors: [(String, Prior)]
A list of priors contained in this tuple
"""
return list(filter(lambda t: isinstance(t[1], Prior), self.__dict__.items())) | python | def prior_tuples(self):
"""
Returns
-------
priors: [(String, Prior)]
A list of priors contained in this tuple
"""
return list(filter(lambda t: isinstance(t[1], Prior), self.__dict__.items())) | [
"def",
"prior_tuples",
"(",
"self",
")",
":",
"return",
"list",
"(",
"filter",
"(",
"lambda",
"t",
":",
"isinstance",
"(",
"t",
"[",
"1",
"]",
",",
"Prior",
")",
",",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
")",
")"
] | Returns
-------
priors: [(String, Prior)]
A list of priors contained in this tuple | [
"Returns",
"-------",
"priors",
":",
"[",
"(",
"String",
"Prior",
")",
"]",
"A",
"list",
"of",
"priors",
"contained",
"in",
"this",
"tuple"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior.py#L82-L89 | train | Returns a list of priors contained in this tuple |
rhayes777/PyAutoFit | autofit/mapper/prior.py | TuplePrior.constant_tuples | def constant_tuples(self):
"""
Returns
-------
constants: [(String, Constant)]
A list of constants
"""
return list(sorted(filter(lambda t: isinstance(t[1], Constant), self.__dict__.items()), key=lambda tup: tup[0])) | python | def constant_tuples(self):
"""
Returns
-------
constants: [(String, Constant)]
A list of constants
"""
return list(sorted(filter(lambda t: isinstance(t[1], Constant), self.__dict__.items()), key=lambda tup: tup[0])) | [
"def",
"constant_tuples",
"(",
"self",
")",
":",
"return",
"list",
"(",
"sorted",
"(",
"filter",
"(",
"lambda",
"t",
":",
"isinstance",
"(",
"t",
"[",
"1",
"]",
",",
"Constant",
")",
",",
"self",
".",
"__dict__",
".",
"items",
"(",
")",
")",
",",
... | Returns
-------
constants: [(String, Constant)]
A list of constants | [
"Returns",
"-------",
"constants",
":",
"[",
"(",
"String",
"Constant",
")",
"]",
"A",
"list",
"of",
"constants"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior.py#L93-L100 | train | Returns a list of tuples of all Constant objects in the current object |
rhayes777/PyAutoFit | autofit/mapper/prior.py | TuplePrior.value_for_arguments | def value_for_arguments(self, arguments):
"""
Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple: (float,...)
A tuple of float values
"""
def convert(tup):
if hasatt... | python | def value_for_arguments(self, arguments):
"""
Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple: (float,...)
A tuple of float values
"""
def convert(tup):
if hasatt... | [
"def",
"value_for_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"def",
"convert",
"(",
"tup",
")",
":",
"if",
"hasattr",
"(",
"tup",
",",
"\"prior\"",
")",
":",
"return",
"arguments",
"[",
"tup",
".",
"prior",
"]",
"return",
"tup",
".",
"constan... | Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple: (float,...)
A tuple of float values | [
"Parameters",
"----------",
"arguments",
":",
"{",
"Prior",
":",
"float",
"}",
"A",
"dictionary",
"of",
"arguments"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior.py#L102-L120 | train | Returns the value of the passed in arguments. |
rhayes777/PyAutoFit | autofit/mapper/prior.py | TuplePrior.gaussian_tuple_prior_for_arguments | def gaussian_tuple_prior_for_arguments(self, arguments):
"""
Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple_prior: TuplePrior
A new tuple prior with gaussian priors
"""
tuple... | python | def gaussian_tuple_prior_for_arguments(self, arguments):
"""
Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple_prior: TuplePrior
A new tuple prior with gaussian priors
"""
tuple... | [
"def",
"gaussian_tuple_prior_for_arguments",
"(",
"self",
",",
"arguments",
")",
":",
"tuple_prior",
"=",
"TuplePrior",
"(",
")",
"for",
"prior_tuple",
"in",
"self",
".",
"prior_tuples",
":",
"setattr",
"(",
"tuple_prior",
",",
"prior_tuple",
".",
"name",
",",
... | Parameters
----------
arguments: {Prior: float}
A dictionary of arguments
Returns
-------
tuple_prior: TuplePrior
A new tuple prior with gaussian priors | [
"Parameters",
"----------",
"arguments",
":",
"{",
"Prior",
":",
"float",
"}",
"A",
"dictionary",
"of",
"arguments"
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/prior.py#L122-L137 | train | Returns a new tuple prior with gaussian priors for the given arguments. |
Maples7/dict-recursive-update | dict_recursive_update/__init__.py | recursive_update | def recursive_update(default, custom):
'''Return a dict merged from default and custom
>>> recursive_update('a', 'b')
Traceback (most recent call last):
...
TypeError: Params of recursive_update should be dicts
>>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}})
{'a': [2... | python | def recursive_update(default, custom):
'''Return a dict merged from default and custom
>>> recursive_update('a', 'b')
Traceback (most recent call last):
...
TypeError: Params of recursive_update should be dicts
>>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}})
{'a': [2... | [
"def",
"recursive_update",
"(",
"default",
",",
"custom",
")",
":",
"if",
"not",
"isinstance",
"(",
"default",
",",
"dict",
")",
"or",
"not",
"isinstance",
"(",
"custom",
",",
"dict",
")",
":",
"raise",
"TypeError",
"(",
"'Params of recursive_update should be ... | Return a dict merged from default and custom
>>> recursive_update('a', 'b')
Traceback (most recent call last):
...
TypeError: Params of recursive_update should be dicts
>>> recursive_update({'a': [1]}, {'a': [2], 'c': {'d': {'c': 3}}})
{'a': [2], 'c': {'d': {'c': 3}}}
>>> recursive_up... | [
"Return",
"a",
"dict",
"merged",
"from",
"default",
"and",
"custom"
] | 07204cdab891ac4123b19fe3fa148c3dd1c93992 | https://github.com/Maples7/dict-recursive-update/blob/07204cdab891ac4123b19fe3fa148c3dd1c93992/dict_recursive_update/__init__.py#L11-L38 | train | Recursive update of a dict with a dict merged from default and custom |
peterbe/gg | gg/builtins/cleanup/gg_cleanup.py | cleanup | def cleanup(config, searchstring, force=False):
"""Deletes a found branch locally and remotely."""
repo = config.repo
branches_ = list(find(repo, searchstring))
if not branches_:
error_out("No branches found")
elif len(branches_) > 1:
error_out(
"More than one branch fou... | python | def cleanup(config, searchstring, force=False):
"""Deletes a found branch locally and remotely."""
repo = config.repo
branches_ = list(find(repo, searchstring))
if not branches_:
error_out("No branches found")
elif len(branches_) > 1:
error_out(
"More than one branch fou... | [
"def",
"cleanup",
"(",
"config",
",",
"searchstring",
",",
"force",
"=",
"False",
")",
":",
"repo",
"=",
"config",
".",
"repo",
"branches_",
"=",
"list",
"(",
"find",
"(",
"repo",
",",
"searchstring",
")",
")",
"if",
"not",
"branches_",
":",
"error_out... | Deletes a found branch locally and remotely. | [
"Deletes",
"a",
"found",
"branch",
"locally",
"and",
"remotely",
"."
] | 2aace5bdb4a9b1cb65bea717784edf54c63b7bad | https://github.com/peterbe/gg/blob/2aace5bdb4a9b1cb65bea717784edf54c63b7bad/gg/builtins/cleanup/gg_cleanup.py#L13-L84 | train | Deletes a found branch locally and remotely. |
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | handle_options | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(add=False)
parser.set_defaults(rhofile=False)
parser.set_defaults(aniso=False)
parser.add_option("-m",
dest="m",
type="float",
help="Use... | python | def handle_options():
'''Handle options.
'''
parser = OptionParser()
parser.set_defaults(add=False)
parser.set_defaults(rhofile=False)
parser.set_defaults(aniso=False)
parser.add_option("-m",
dest="m",
type="float",
help="Use... | [
"def",
"handle_options",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"set_defaults",
"(",
"add",
"=",
"False",
")",
"parser",
".",
"set_defaults",
"(",
"rhofile",
"=",
"False",
")",
"parser",
".",
"set_defaults",
"(",
"aniso",
... | Handle options. | [
"Handle",
"options",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L27-L89 | train | Handle options.
|
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | readin_temp | def readin_temp(temp_file):
"""The temperature file should be in mag-format: header + 3 columns with
coordinates and value of temperature. The coordinates have to be the same
as from the resistivity data.
Such a temperature file can be produced with #############
"""
with open(temp_file, 'r') a... | python | def readin_temp(temp_file):
"""The temperature file should be in mag-format: header + 3 columns with
coordinates and value of temperature. The coordinates have to be the same
as from the resistivity data.
Such a temperature file can be produced with #############
"""
with open(temp_file, 'r') a... | [
"def",
"readin_temp",
"(",
"temp_file",
")",
":",
"with",
"open",
"(",
"temp_file",
",",
"'r'",
")",
"as",
"fid",
":",
"temp",
"=",
"np",
".",
"loadtxt",
"(",
"fid",
",",
"skiprows",
"=",
"1",
",",
"usecols",
"=",
"[",
"2",
"]",
")",
"return",
"t... | The temperature file should be in mag-format: header + 3 columns with
coordinates and value of temperature. The coordinates have to be the same
as from the resistivity data.
Such a temperature file can be produced with ############# | [
"The",
"temperature",
"file",
"should",
"be",
"in",
"mag",
"-",
"format",
":",
"header",
"+",
"3",
"columns",
"with",
"coordinates",
"and",
"value",
"of",
"temperature",
".",
"The",
"coordinates",
"have",
"to",
"be",
"the",
"same",
"as",
"from",
"the",
"... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L92-L101 | train | Reads in the temperature file and returns a numpy array of the temperature |
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | read_iter | def read_iter():
'''Return the path to the final rho*.mag file from the tomodir.
'''
filename = 'exe/inv.lastmod'
linestring = open(filename, 'r').readline().strip()
linestring = linestring.replace('\n', '')
linestring = linestring.replace('../', '')
return linestring | python | def read_iter():
'''Return the path to the final rho*.mag file from the tomodir.
'''
filename = 'exe/inv.lastmod'
linestring = open(filename, 'r').readline().strip()
linestring = linestring.replace('\n', '')
linestring = linestring.replace('../', '')
return linestring | [
"def",
"read_iter",
"(",
")",
":",
"filename",
"=",
"'exe/inv.lastmod'",
"linestring",
"=",
"open",
"(",
"filename",
",",
"'r'",
")",
".",
"readline",
"(",
")",
".",
"strip",
"(",
")",
"linestring",
"=",
"linestring",
".",
"replace",
"(",
"'\\n'",
",",
... | Return the path to the final rho*.mag file from the tomodir. | [
"Return",
"the",
"path",
"to",
"the",
"final",
"rho",
"*",
".",
"mag",
"file",
"from",
"the",
"tomodir",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L104-L111 | train | Return the path to the final rho. mag file from the tomodir.
|
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | readin_rho | def readin_rho(filename, rhofile=True, aniso=False):
"""Read in the values of the resistivity in Ohmm.
The format is variable: rho-file or mag-file.
"""
if aniso:
a = [[0, 1, 2], [2, 3, 4]]
else:
a = [0, 2]
if rhofile:
if filename is None:
filename = 'rho/rho.... | python | def readin_rho(filename, rhofile=True, aniso=False):
"""Read in the values of the resistivity in Ohmm.
The format is variable: rho-file or mag-file.
"""
if aniso:
a = [[0, 1, 2], [2, 3, 4]]
else:
a = [0, 2]
if rhofile:
if filename is None:
filename = 'rho/rho.... | [
"def",
"readin_rho",
"(",
"filename",
",",
"rhofile",
"=",
"True",
",",
"aniso",
"=",
"False",
")",
":",
"if",
"aniso",
":",
"a",
"=",
"[",
"[",
"0",
",",
"1",
",",
"2",
"]",
",",
"[",
"2",
",",
"3",
",",
"4",
"]",
"]",
"else",
":",
"a",
... | Read in the values of the resistivity in Ohmm.
The format is variable: rho-file or mag-file. | [
"Read",
"in",
"the",
"values",
"of",
"the",
"resistivity",
"in",
"Ohmm",
".",
"The",
"format",
"is",
"variable",
":",
"rho",
"-",
"file",
"or",
"mag",
"-",
"file",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L114-L134 | train | Read in the values of the resistivity in Ohmm. |
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | calc_correction | def calc_correction(temp, mag, add=False, T_std=10, m=0.021):
"""Function to add or substract the temperature effect to given data. The
function can be called in python scripts. For application via command line
in a file system use the script td_correct_temperature.py. The data is
taken and given in Ohm... | python | def calc_correction(temp, mag, add=False, T_std=10, m=0.021):
"""Function to add or substract the temperature effect to given data. The
function can be called in python scripts. For application via command line
in a file system use the script td_correct_temperature.py. The data is
taken and given in Ohm... | [
"def",
"calc_correction",
"(",
"temp",
",",
"mag",
",",
"add",
"=",
"False",
",",
"T_std",
"=",
"10",
",",
"m",
"=",
"0.021",
")",
":",
"if",
"mag",
".",
"shape",
"[",
"1",
"]",
"==",
"3",
":",
"if",
"add",
":",
"data_x",
"=",
"(",
"m",
"*",
... | Function to add or substract the temperature effect to given data. The
function can be called in python scripts. For application via command line
in a file system use the script td_correct_temperature.py. The data is
taken and given in Ohmm.
rho_std_i = (m * (T_i - 25°) + 1) / (m * (T_std - 25°) + 1) *... | [
"Function",
"to",
"add",
"or",
"substract",
"the",
"temperature",
"effect",
"to",
"given",
"data",
".",
"The",
"function",
"can",
"be",
"called",
"in",
"python",
"scripts",
".",
"For",
"application",
"via",
"command",
"line",
"in",
"a",
"file",
"system",
"... | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L137-L173 | train | Function to calculate the correction of the individual resistivity of the system. |
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | save_mag_to_file | def save_mag_to_file(mag, filename, rhofile):
"""Save the values in rho- or mag-format.
"""
if rhofile:
# bring data in shape
null = np.zeros(len(mag))
if mag.shape[1] == 3:
null = np.column_stack((null, null, null, null))
result = np.column_stack((mag, null))
... | python | def save_mag_to_file(mag, filename, rhofile):
"""Save the values in rho- or mag-format.
"""
if rhofile:
# bring data in shape
null = np.zeros(len(mag))
if mag.shape[1] == 3:
null = np.column_stack((null, null, null, null))
result = np.column_stack((mag, null))
... | [
"def",
"save_mag_to_file",
"(",
"mag",
",",
"filename",
",",
"rhofile",
")",
":",
"if",
"rhofile",
":",
"# bring data in shape",
"null",
"=",
"np",
".",
"zeros",
"(",
"len",
"(",
"mag",
")",
")",
"if",
"mag",
".",
"shape",
"[",
"1",
"]",
"==",
"3",
... | Save the values in rho- or mag-format. | [
"Save",
"the",
"values",
"in",
"rho",
"-",
"or",
"mag",
"-",
"format",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L176-L210 | train | Save the values in rho - or mag - format. |
geophysics-ubonn/crtomo_tools | src/td_correct_temperature.py | main | def main():
"""Function to add or substract the temperature effect to data in a tomodir
"""
options = handle_options()
# read in temperature and resistivity data
tempdata = readin_temp(options.temp_file)
magdata = readin_rho(options.filename,
options.rhofile,
... | python | def main():
"""Function to add or substract the temperature effect to data in a tomodir
"""
options = handle_options()
# read in temperature and resistivity data
tempdata = readin_temp(options.temp_file)
magdata = readin_rho(options.filename,
options.rhofile,
... | [
"def",
"main",
"(",
")",
":",
"options",
"=",
"handle_options",
"(",
")",
"# read in temperature and resistivity data",
"tempdata",
"=",
"readin_temp",
"(",
"options",
".",
"temp_file",
")",
"magdata",
"=",
"readin_rho",
"(",
"options",
".",
"filename",
",",
"op... | Function to add or substract the temperature effect to data in a tomodir | [
"Function",
"to",
"add",
"or",
"substract",
"the",
"temperature",
"effect",
"to",
"data",
"in",
"a",
"tomodir"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_correct_temperature.py#L213-L232 | train | Function to add or substract the temperature effect to data in a tomodir
|
lalinsky/mbdata | mbdata/api/utils.py | singular | def singular(plural):
"""
Take a plural English word and turn it into singular
Obviously, this doesn't work in general. It know just enough words to
generate XML tag names for list items. For example, if we have an element
called 'tracks' in the response, it will be serialized as a list without
... | python | def singular(plural):
"""
Take a plural English word and turn it into singular
Obviously, this doesn't work in general. It know just enough words to
generate XML tag names for list items. For example, if we have an element
called 'tracks' in the response, it will be serialized as a list without
... | [
"def",
"singular",
"(",
"plural",
")",
":",
"if",
"plural",
".",
"endswith",
"(",
"'ies'",
")",
":",
"return",
"plural",
"[",
":",
"-",
"3",
"]",
"+",
"'y'",
"if",
"plural",
".",
"endswith",
"(",
"'s'",
")",
":",
"return",
"plural",
"[",
":",
"-"... | Take a plural English word and turn it into singular
Obviously, this doesn't work in general. It know just enough words to
generate XML tag names for list items. For example, if we have an element
called 'tracks' in the response, it will be serialized as a list without
named items in JSON, but we need ... | [
"Take",
"a",
"plural",
"English",
"word",
"and",
"turn",
"it",
"into",
"singular"
] | 1ec788834047ced8614ad9763e430afe1d1e65e7 | https://github.com/lalinsky/mbdata/blob/1ec788834047ced8614ad9763e430afe1d1e65e7/mbdata/api/utils.py#L56-L70 | train | Takes a plural English word and turn it into singular
|
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.plot_single_configuration | def plot_single_configuration(self, config_nr, sens_file):
"""
plot sensitivity distribution with center of mass for
a single configuration. The electrodes used are colored.
Parameters
----------
config_nr: int
number of configuration
sens_file: strin... | python | def plot_single_configuration(self, config_nr, sens_file):
"""
plot sensitivity distribution with center of mass for
a single configuration. The electrodes used are colored.
Parameters
----------
config_nr: int
number of configuration
sens_file: strin... | [
"def",
"plot_single_configuration",
"(",
"self",
",",
"config_nr",
",",
"sens_file",
")",
":",
"indices",
"=",
"elem",
".",
"load_column_file_to_elements_advanced",
"(",
"sens_file",
",",
"[",
"2",
",",
"3",
"]",
",",
"False",
",",
"False",
")",
"elem",
".",... | plot sensitivity distribution with center of mass for
a single configuration. The electrodes used are colored.
Parameters
----------
config_nr: int
number of configuration
sens_file: string, file path
filename to sensitvity file | [
"plot",
"sensitivity",
"distribution",
"with",
"center",
"of",
"mass",
"for",
"a",
"single",
"configuration",
".",
"The",
"electrodes",
"used",
"are",
"colored",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L168-L220 | train | Plot sensitivity distribution with center of mass for a single configuration. |
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.plot_sens_center | def plot_sens_center(self, frequency=2):
"""
plot sensitivity center distribution for all configurations in
config.dat. The centers of mass are colored by the data given in
volt_file.
"""
try:
colors = np.loadtxt(self.volt_file, skiprows=1)
except IOE... | python | def plot_sens_center(self, frequency=2):
"""
plot sensitivity center distribution for all configurations in
config.dat. The centers of mass are colored by the data given in
volt_file.
"""
try:
colors = np.loadtxt(self.volt_file, skiprows=1)
except IOE... | [
"def",
"plot_sens_center",
"(",
"self",
",",
"frequency",
"=",
"2",
")",
":",
"try",
":",
"colors",
"=",
"np",
".",
"loadtxt",
"(",
"self",
".",
"volt_file",
",",
"skiprows",
"=",
"1",
")",
"except",
"IOError",
":",
"print",
"(",
"'IOError opening {0}'",... | plot sensitivity center distribution for all configurations in
config.dat. The centers of mass are colored by the data given in
volt_file. | [
"plot",
"sensitivity",
"center",
"distribution",
"for",
"all",
"configurations",
"in",
"config",
".",
"dat",
".",
"The",
"centers",
"of",
"mass",
"are",
"colored",
"by",
"the",
"data",
"given",
"in",
"volt_file",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L222-L269 | train | Plot sensitivity center distribution for all configurations in
config. dat. |
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.color_electrodes | def color_electrodes(self, config_nr, ax):
"""
Color the electrodes used in specific configuration.
Voltage electrodes are yellow, Current electrodes are red ?!
"""
electrodes = np.loadtxt(options.config_file, skiprows=1)
electrodes = self.configs[~np.isnan(self.configs).... | python | def color_electrodes(self, config_nr, ax):
"""
Color the electrodes used in specific configuration.
Voltage electrodes are yellow, Current electrodes are red ?!
"""
electrodes = np.loadtxt(options.config_file, skiprows=1)
electrodes = self.configs[~np.isnan(self.configs).... | [
"def",
"color_electrodes",
"(",
"self",
",",
"config_nr",
",",
"ax",
")",
":",
"electrodes",
"=",
"np",
".",
"loadtxt",
"(",
"options",
".",
"config_file",
",",
"skiprows",
"=",
"1",
")",
"electrodes",
"=",
"self",
".",
"configs",
"[",
"~",
"np",
".",
... | Color the electrodes used in specific configuration.
Voltage electrodes are yellow, Current electrodes are red ?! | [
"Color",
"the",
"electrodes",
"used",
"in",
"specific",
"configuration",
".",
"Voltage",
"electrodes",
"are",
"yellow",
"Current",
"electrodes",
"are",
"red",
"?!"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L271-L291 | train | Color the electrodes used in specific configuration. |
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.compute_sens | def compute_sens(self, elem_file, elec_file, configs):
"""
Compute the sensitivities for the given input data.
A CRMod instance is called to create the sensitivity files.
"""
CRMod_config = CRMod.config()
# activate 2D mode and set sink nr
if self.options.sink is ... | python | def compute_sens(self, elem_file, elec_file, configs):
"""
Compute the sensitivities for the given input data.
A CRMod instance is called to create the sensitivity files.
"""
CRMod_config = CRMod.config()
# activate 2D mode and set sink nr
if self.options.sink is ... | [
"def",
"compute_sens",
"(",
"self",
",",
"elem_file",
",",
"elec_file",
",",
"configs",
")",
":",
"CRMod_config",
"=",
"CRMod",
".",
"config",
"(",
")",
"# activate 2D mode and set sink nr",
"if",
"self",
".",
"options",
".",
"sink",
"is",
"not",
"None",
":"... | Compute the sensitivities for the given input data.
A CRMod instance is called to create the sensitivity files. | [
"Compute",
"the",
"sensitivities",
"for",
"the",
"given",
"input",
"data",
".",
"A",
"CRMod",
"instance",
"is",
"called",
"to",
"create",
"the",
"sensitivity",
"files",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L293-L328 | train | Compute the sensitivities for the given input data. |
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.compute_center_of_mass | def compute_center_of_mass(self, filename):
"""
Center of mass is computed using the sensitivity data output from CRMod
Data weights can be applied using command line options
"""
sens = np.loadtxt(filename, skiprows=1)
X = sens[:, 0]
Z = sens[:, 1]
# C = ... | python | def compute_center_of_mass(self, filename):
"""
Center of mass is computed using the sensitivity data output from CRMod
Data weights can be applied using command line options
"""
sens = np.loadtxt(filename, skiprows=1)
X = sens[:, 0]
Z = sens[:, 1]
# C = ... | [
"def",
"compute_center_of_mass",
"(",
"self",
",",
"filename",
")",
":",
"sens",
"=",
"np",
".",
"loadtxt",
"(",
"filename",
",",
"skiprows",
"=",
"1",
")",
"X",
"=",
"sens",
"[",
":",
",",
"0",
"]",
"Z",
"=",
"sens",
"[",
":",
",",
"1",
"]",
"... | Center of mass is computed using the sensitivity data output from CRMod
Data weights can be applied using command line options | [
"Center",
"of",
"mass",
"is",
"computed",
"using",
"the",
"sensitivity",
"data",
"output",
"from",
"CRMod",
"Data",
"weights",
"can",
"be",
"applied",
"using",
"command",
"line",
"options"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L330-L366 | train | Compute the center of mass of the modular entry. |
geophysics-ubonn/crtomo_tools | src/sens_center_plot.py | sens_center.remove_tmp_dir | def remove_tmp_dir(self, directory):
"""
Remove the directory if it is located in /tmp
"""
if(not directory.startswith('/tmp/')):
print('Directory not in /tmp')
exit()
print('Deleting directory: ' + directory)
shutil.rmtree(directory) | python | def remove_tmp_dir(self, directory):
"""
Remove the directory if it is located in /tmp
"""
if(not directory.startswith('/tmp/')):
print('Directory not in /tmp')
exit()
print('Deleting directory: ' + directory)
shutil.rmtree(directory) | [
"def",
"remove_tmp_dir",
"(",
"self",
",",
"directory",
")",
":",
"if",
"(",
"not",
"directory",
".",
"startswith",
"(",
"'/tmp/'",
")",
")",
":",
"print",
"(",
"'Directory not in /tmp'",
")",
"exit",
"(",
")",
"print",
"(",
"'Deleting directory: '",
"+",
... | Remove the directory if it is located in /tmp | [
"Remove",
"the",
"directory",
"if",
"it",
"is",
"located",
"in",
"/",
"tmp"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/sens_center_plot.py#L406-L416 | train | Remove the directory if it is located in tmp |
geophysics-ubonn/crtomo_tools | src/td_init.py | handle_cmd_options | def handle_cmd_options():
'''
Get the options from the command line.
'''
parser = OptionParser()
parser.add_option("-s", "--silent", action="store_true", dest="silent",
help="print any warnings", default=False)
(options, args) = parser.parse_args()
return options, args | python | def handle_cmd_options():
'''
Get the options from the command line.
'''
parser = OptionParser()
parser.add_option("-s", "--silent", action="store_true", dest="silent",
help="print any warnings", default=False)
(options, args) = parser.parse_args()
return options, args | [
"def",
"handle_cmd_options",
"(",
")",
":",
"parser",
"=",
"OptionParser",
"(",
")",
"parser",
".",
"add_option",
"(",
"\"-s\"",
",",
"\"--silent\"",
",",
"action",
"=",
"\"store_true\"",
",",
"dest",
"=",
"\"silent\"",
",",
"help",
"=",
"\"print any warnings\... | Get the options from the command line. | [
"Get",
"the",
"options",
"from",
"the",
"command",
"line",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_init.py#L18-L26 | train | Get the options from the command line. |
geophysics-ubonn/crtomo_tools | src/td_init.py | move | def move(fname, folder, options):
"""Move file to dir if existing
"""
if os.path.isfile(fname):
shutil.move(fname, folder)
else:
if options.silent is False:
print('{0} missing'.format(fname)) | python | def move(fname, folder, options):
"""Move file to dir if existing
"""
if os.path.isfile(fname):
shutil.move(fname, folder)
else:
if options.silent is False:
print('{0} missing'.format(fname)) | [
"def",
"move",
"(",
"fname",
",",
"folder",
",",
"options",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"fname",
")",
":",
"shutil",
".",
"move",
"(",
"fname",
",",
"folder",
")",
"else",
":",
"if",
"options",
".",
"silent",
"is",
"Fal... | Move file to dir if existing | [
"Move",
"file",
"to",
"dir",
"if",
"existing"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/td_init.py#L29-L36 | train | Move file to folder if existing |
rhayes777/PyAutoFit | autofit/mapper/link.py | path_for | def path_for(path):
"""
Generate a path in the ~/.autolens directory by taking the provided path, base64 encoding it and extracting the
first and last five characters.
Parameters
----------
path: str
The path where multinest output is apparently saved
Returns
-------
actual... | python | def path_for(path):
"""
Generate a path in the ~/.autolens directory by taking the provided path, base64 encoding it and extracting the
first and last five characters.
Parameters
----------
path: str
The path where multinest output is apparently saved
Returns
-------
actual... | [
"def",
"path_for",
"(",
"path",
")",
":",
"start",
"=",
"int",
"(",
"SUB_PATH_LENGTH",
"/",
"2",
")",
"end",
"=",
"SUB_PATH_LENGTH",
"-",
"start",
"encoded_string",
"=",
"str",
"(",
"hashlib",
".",
"sha224",
"(",
"path",
".",
"encode",
"(",
"\"utf-8\"",
... | Generate a path in the ~/.autolens directory by taking the provided path, base64 encoding it and extracting the
first and last five characters.
Parameters
----------
path: str
The path where multinest output is apparently saved
Returns
-------
actual_path: str
The path wher... | [
"Generate",
"a",
"path",
"in",
"the",
"~",
"/",
".",
"autolens",
"directory",
"by",
"taking",
"the",
"provided",
"path",
"base64",
"encoding",
"it",
"and",
"extracting",
"the",
"first",
"and",
"last",
"five",
"characters",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/link.py#L23-L41 | train | Generates a path in the ~. automolens directory by taking the provided path base64 encoding it and extracting the first and last five characters. |
rhayes777/PyAutoFit | autofit/mapper/link.py | make_linked_folder | def make_linked_folder(sym_path):
"""
Create a folder in the ~/.autolens directory and create a sym link to it at the provided path.
If both folders already exist then nothing is changed. If the source folder exists but the destination folder does
not then the source folder is removed and replaced so a... | python | def make_linked_folder(sym_path):
"""
Create a folder in the ~/.autolens directory and create a sym link to it at the provided path.
If both folders already exist then nothing is changed. If the source folder exists but the destination folder does
not then the source folder is removed and replaced so a... | [
"def",
"make_linked_folder",
"(",
"sym_path",
")",
":",
"source_path",
"=",
"path_for",
"(",
"sym_path",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"source_path",
")",
"and",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"sym_path",
")",
":",
"l... | Create a folder in the ~/.autolens directory and create a sym link to it at the provided path.
If both folders already exist then nothing is changed. If the source folder exists but the destination folder does
not then the source folder is removed and replaced so as to conform to the behaviour that the user wo... | [
"Create",
"a",
"folder",
"in",
"the",
"~",
"/",
".",
"autolens",
"directory",
"and",
"create",
"a",
"sym",
"link",
"to",
"it",
"at",
"the",
"provided",
"path",
"."
] | a9e6144abb08edfc6a6906c4030d7119bf8d3e14 | https://github.com/rhayes777/PyAutoFit/blob/a9e6144abb08edfc6a6906c4030d7119bf8d3e14/autofit/mapper/link.py#L44-L80 | train | Create a folder in the ~. autocolens directory and create a symlink to it at the provided path. |
Infinidat/infi.traceback | src/infi/traceback/__init__.py | print_tb | def print_tb(tb, limit=None, file=None):
"""Print up to 'limit' stack trace entries from the traceback 'tb'.
If 'limit' is omitted or None, all entries are printed. If 'file'
is omitted or None, the output goes to sys.stderr; otherwise
'file' should be an open file or file-like object with a write()
... | python | def print_tb(tb, limit=None, file=None):
"""Print up to 'limit' stack trace entries from the traceback 'tb'.
If 'limit' is omitted or None, all entries are printed. If 'file'
is omitted or None, the output goes to sys.stderr; otherwise
'file' should be an open file or file-like object with a write()
... | [
"def",
"print_tb",
"(",
"tb",
",",
"limit",
"=",
"None",
",",
"file",
"=",
"None",
")",
":",
"if",
"file",
"is",
"None",
":",
"file",
"=",
"sys",
".",
"stderr",
"if",
"limit",
"is",
"None",
":",
"if",
"hasattr",
"(",
"sys",
",",
"'tracebacklimit'",... | Print up to 'limit' stack trace entries from the traceback 'tb'.
If 'limit' is omitted or None, all entries are printed. If 'file'
is omitted or None, the output goes to sys.stderr; otherwise
'file' should be an open file or file-like object with a write()
method. | [
"Print",
"up",
"to",
"limit",
"stack",
"trace",
"entries",
"from",
"the",
"traceback",
"tb",
"."
] | ae25455ec451c136458d2781fea876964375bf8b | https://github.com/Infinidat/infi.traceback/blob/ae25455ec451c136458d2781fea876964375bf8b/src/infi/traceback/__init__.py#L85-L98 | train | Print up to limit stack trace entries from the traceback tb. |
Infinidat/infi.traceback | src/infi/traceback/__init__.py | print_exception | def print_exception(etype, value, tb, limit=None, file=None, chain=True):
"""Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
traceback is not None, it prints a header "Traceback (most recent
call last):"; (2) it prints th... | python | def print_exception(etype, value, tb, limit=None, file=None, chain=True):
"""Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
traceback is not None, it prints a header "Traceback (most recent
call last):"; (2) it prints th... | [
"def",
"print_exception",
"(",
"etype",
",",
"value",
",",
"tb",
",",
"limit",
"=",
"None",
",",
"file",
"=",
"None",
",",
"chain",
"=",
"True",
")",
":",
"import",
"traceback",
"if",
"file",
"is",
"None",
":",
"file",
"=",
"sys",
".",
"stderr",
"i... | Print exception up to 'limit' stack trace entries from 'tb' to 'file'.
This differs from print_tb() in the following ways: (1) if
traceback is not None, it prints a header "Traceback (most recent
call last):"; (2) it prints the exception type and value after the
stack trace; (3) if type is SyntaxError ... | [
"Print",
"exception",
"up",
"to",
"limit",
"stack",
"trace",
"entries",
"from",
"tb",
"to",
"file",
"."
] | ae25455ec451c136458d2781fea876964375bf8b | https://github.com/Infinidat/infi.traceback/blob/ae25455ec451c136458d2781fea876964375bf8b/src/infi/traceback/__init__.py#L168-L187 | train | Print an exception to file. |
gofed/gofedlib | gofedlib/go/projectinfo.py | ProjectInfo.construct | def construct(self, data):
"""Construct info about a project from artefact
:param data: golang-project-packages artefact
:type data: json/dict
"""
occurrences = {}
main_occurrences = {}
# occurrences of devel packages
for pkg in data["data"]["dependencies"]:
package = pkg["package"]
for item in... | python | def construct(self, data):
"""Construct info about a project from artefact
:param data: golang-project-packages artefact
:type data: json/dict
"""
occurrences = {}
main_occurrences = {}
# occurrences of devel packages
for pkg in data["data"]["dependencies"]:
package = pkg["package"]
for item in... | [
"def",
"construct",
"(",
"self",
",",
"data",
")",
":",
"occurrences",
"=",
"{",
"}",
"main_occurrences",
"=",
"{",
"}",
"# occurrences of devel packages",
"for",
"pkg",
"in",
"data",
"[",
"\"data\"",
"]",
"[",
"\"dependencies\"",
"]",
":",
"package",
"=",
... | Construct info about a project from artefact
:param data: golang-project-packages artefact
:type data: json/dict | [
"Construct",
"info",
"about",
"a",
"project",
"from",
"artefact"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/go/projectinfo.py#L43-L103 | train | Construct info about a project from artefact - project - packages data. |
NiklasRosenstein/py-bundler | bundler/modules.py | get_imports | def get_imports(filename, source=None):
"""
Returns a list of #ImportInfo tuples for all module imports in the specified
Python source file or the *source* string.
"""
if source is None:
with open(filename, 'rb') as fp:
source = fp.read()
module = ast.parse(source, filename)
result = []
for... | python | def get_imports(filename, source=None):
"""
Returns a list of #ImportInfo tuples for all module imports in the specified
Python source file or the *source* string.
"""
if source is None:
with open(filename, 'rb') as fp:
source = fp.read()
module = ast.parse(source, filename)
result = []
for... | [
"def",
"get_imports",
"(",
"filename",
",",
"source",
"=",
"None",
")",
":",
"if",
"source",
"is",
"None",
":",
"with",
"open",
"(",
"filename",
",",
"'rb'",
")",
"as",
"fp",
":",
"source",
"=",
"fp",
".",
"read",
"(",
")",
"module",
"=",
"ast",
... | Returns a list of #ImportInfo tuples for all module imports in the specified
Python source file or the *source* string. | [
"Returns",
"a",
"list",
"of",
"#ImportInfo",
"tuples",
"for",
"all",
"module",
"imports",
"in",
"the",
"specified",
"Python",
"source",
"file",
"or",
"the",
"*",
"source",
"*",
"string",
"."
] | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/modules.py#L105-L126 | train | Returns a list of ImportInfo tuples for all module imports in the specified
Python source file or the source string. |
NiklasRosenstein/py-bundler | bundler/modules.py | ModuleInfo.join_import_from | def join_import_from(self, import_spec):
"""
Joins a relative import like `from .foo import bar` with this module as
its parent module. If the module is not a root module or package root,
it will be joined with the package root.
"""
if not self.isroot and not self.ispkg:
parent = self.nam... | python | def join_import_from(self, import_spec):
"""
Joins a relative import like `from .foo import bar` with this module as
its parent module. If the module is not a root module or package root,
it will be joined with the package root.
"""
if not self.isroot and not self.ispkg:
parent = self.nam... | [
"def",
"join_import_from",
"(",
"self",
",",
"import_spec",
")",
":",
"if",
"not",
"self",
".",
"isroot",
"and",
"not",
"self",
".",
"ispkg",
":",
"parent",
"=",
"self",
".",
"name",
".",
"rpartition",
"(",
"'.'",
")",
"[",
"0",
"]",
"else",
":",
"... | Joins a relative import like `from .foo import bar` with this module as
its parent module. If the module is not a root module or package root,
it will be joined with the package root. | [
"Joins",
"a",
"relative",
"import",
"like",
"from",
".",
"foo",
"import",
"bar",
"with",
"this",
"module",
"as",
"its",
"parent",
"module",
".",
"If",
"the",
"module",
"is",
"not",
"a",
"root",
"module",
"or",
"package",
"root",
"it",
"will",
"be",
"jo... | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/modules.py#L80-L91 | train | Joins a relative import like from. foo import bar with this module as
|
NiklasRosenstein/py-bundler | bundler/modules.py | ModuleFinder.find_module | def find_module(self, module_name):
"""
Attempts to find the module specified by *module_name* in the
ModuleFinder's search path and returns a #ModuleInfo object.
For builtin modules, the #ModuleInfo.filename will be None. Note that
the #ModuleInfo.imported_from is not filled by this method. It is ... | python | def find_module(self, module_name):
"""
Attempts to find the module specified by *module_name* in the
ModuleFinder's search path and returns a #ModuleInfo object.
For builtin modules, the #ModuleInfo.filename will be None. Note that
the #ModuleInfo.imported_from is not filled by this method. It is ... | [
"def",
"find_module",
"(",
"self",
",",
"module_name",
")",
":",
"if",
"not",
"module_name",
":",
"raise",
"ValueError",
"(",
"'empty module name'",
")",
"if",
"module_name",
"in",
"sys",
".",
"builtin_module_names",
":",
"return",
"ModuleInfo",
"(",
"module_nam... | Attempts to find the module specified by *module_name* in the
ModuleFinder's search path and returns a #ModuleInfo object.
For builtin modules, the #ModuleInfo.filename will be None. Note that
the #ModuleInfo.imported_from is not filled by this method. It is used
with #ModuleFinder.iter_modules(). | [
"Attempts",
"to",
"find",
"the",
"module",
"specified",
"by",
"*",
"module_name",
"*",
"in",
"the",
"ModuleFinder",
"s",
"search",
"path",
"and",
"returns",
"a",
"#ModuleInfo",
"object",
"."
] | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/modules.py#L164-L207 | train | Finds the module specified by module_name in the module finder s search path and returns a ModuleInfo object. |
NiklasRosenstein/py-bundler | bundler/modules.py | ModuleFinder.iter_modules | def iter_modules(self, module=None, filename=None, source=None, excludes=None):
"""
An iterator for the modules that are imported by the specified *module*
or Python source file. The returned #ModuleInfo objects have their
*imported_from* member filled in order to be able to track how a module
was i... | python | def iter_modules(self, module=None, filename=None, source=None, excludes=None):
"""
An iterator for the modules that are imported by the specified *module*
or Python source file. The returned #ModuleInfo objects have their
*imported_from* member filled in order to be able to track how a module
was i... | [
"def",
"iter_modules",
"(",
"self",
",",
"module",
"=",
"None",
",",
"filename",
"=",
"None",
",",
"source",
"=",
"None",
",",
"excludes",
"=",
"None",
")",
":",
"if",
"excludes",
"is",
"None",
":",
"excludes",
"=",
"self",
".",
"excludes",
"if",
"no... | An iterator for the modules that are imported by the specified *module*
or Python source file. The returned #ModuleInfo objects have their
*imported_from* member filled in order to be able to track how a module
was imported. | [
"An",
"iterator",
"for",
"the",
"modules",
"that",
"are",
"imported",
"by",
"the",
"specified",
"*",
"module",
"*",
"or",
"Python",
"source",
"file",
".",
"The",
"returned",
"#ModuleInfo",
"objects",
"have",
"their",
"*",
"imported_from",
"*",
"member",
"fil... | 80dd6dc971667ba015f7f67481417c45cc757231 | https://github.com/NiklasRosenstein/py-bundler/blob/80dd6dc971667ba015f7f67481417c45cc757231/bundler/modules.py#L209-L251 | train | Iterate over the modules that are imported by the specified module or Python source file. |
geophysics-ubonn/crtomo_tools | lib/crtomo/status.py | is_tomodir | def is_tomodir(directory):
"""Check if the supplied directory is a tomodir
Parameters
----------
directory: string
Check if the supplied path is a valid tomodir
Returns
-------
is_tomodir: bool
True if the supplied directory is a tomodir directory
"""
if os.path.isd... | python | def is_tomodir(directory):
"""Check if the supplied directory is a tomodir
Parameters
----------
directory: string
Check if the supplied path is a valid tomodir
Returns
-------
is_tomodir: bool
True if the supplied directory is a tomodir directory
"""
if os.path.isd... | [
"def",
"is_tomodir",
"(",
"directory",
")",
":",
"if",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
")",
":",
"if",
"(",
"os",
".",
"path",
".",
"isdir",
"(",
"directory",
"+",
"\"/exe\"",
")",
"and",
"os",
".",
"path",
".",
"isdir",
"(",
"... | Check if the supplied directory is a tomodir
Parameters
----------
directory: string
Check if the supplied path is a valid tomodir
Returns
-------
is_tomodir: bool
True if the supplied directory is a tomodir directory | [
"Check",
"if",
"the",
"supplied",
"directory",
"is",
"a",
"tomodir"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L9-L32 | train | Checks if the supplied directory is a tomodir directory and returns a boolean indicating if the directory is a tomodir. |
geophysics-ubonn/crtomo_tools | lib/crtomo/status.py | td_is_finished | def td_is_finished(tomodir):
"""Return the state of modeling and inversion for a given tomodir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
tomodir: string
Directory to check
Returns
-------
crmo... | python | def td_is_finished(tomodir):
"""Return the state of modeling and inversion for a given tomodir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
tomodir: string
Directory to check
Returns
-------
crmo... | [
"def",
"td_is_finished",
"(",
"tomodir",
")",
":",
"if",
"not",
"is_tomodir",
"(",
"tomodir",
")",
":",
"raise",
"Exception",
"(",
"'Supplied directory is not a tomodir!'",
")",
"# crmod finished is determined by:",
"# config.dat/rho.dat/crmod.cfg are present",
"# volt.dat is... | Return the state of modeling and inversion for a given tomodir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
tomodir: string
Directory to check
Returns
-------
crmod_is_finished: bool
True if ... | [
"Return",
"the",
"state",
"of",
"modeling",
"and",
"inversion",
"for",
"a",
"given",
"tomodir",
".",
"The",
"result",
"does",
"not",
"take",
"into",
"account",
"sensitivities",
"or",
"potentials",
"as",
"optionally",
"generated",
"by",
"CRMod",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L35-L91 | train | Return the state of modeling and inversion for a given tomodir. |
geophysics-ubonn/crtomo_tools | lib/crtomo/status.py | is_sipdir | def is_sipdir(directory):
""" Simple check if the supplied directory is a SIP directory.
Parameters
----------
directory: string
Check if the supplied path is a valid SIP directory
Returns
-------
is_sipdir: bool
True if the supplied directory is a SIP directory
"""
... | python | def is_sipdir(directory):
""" Simple check if the supplied directory is a SIP directory.
Parameters
----------
directory: string
Check if the supplied path is a valid SIP directory
Returns
-------
is_sipdir: bool
True if the supplied directory is a SIP directory
"""
... | [
"def",
"is_sipdir",
"(",
"directory",
")",
":",
"is_sipdir",
"=",
"True",
"if",
"(",
"not",
"os",
".",
"path",
".",
"isfile",
"(",
"directory",
"+",
"os",
".",
"sep",
"+",
"'frequencies.dat'",
")",
")",
":",
"is_sipdir",
"=",
"False",
"if",
"(",
"not... | Simple check if the supplied directory is a SIP directory.
Parameters
----------
directory: string
Check if the supplied path is a valid SIP directory
Returns
-------
is_sipdir: bool
True if the supplied directory is a SIP directory | [
"Simple",
"check",
"if",
"the",
"supplied",
"directory",
"is",
"a",
"SIP",
"directory",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L94-L116 | train | Simple check if the supplied directory is a SIP directory. |
geophysics-ubonn/crtomo_tools | lib/crtomo/status.py | sipdir_is_finished | def sipdir_is_finished(sipdir):
"""Return the state of modeling and inversion for a given SIP dir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
sipdir: string
Directory to check
Returns
-------
cr... | python | def sipdir_is_finished(sipdir):
"""Return the state of modeling and inversion for a given SIP dir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
sipdir: string
Directory to check
Returns
-------
cr... | [
"def",
"sipdir_is_finished",
"(",
"sipdir",
")",
":",
"if",
"not",
"is_sipdir",
"(",
"sipdir",
")",
":",
"raise",
"Exception",
"(",
"'Directory is not a valid SIP directory!'",
")",
"subdirs_raw",
"=",
"sorted",
"(",
"glob",
".",
"glob",
"(",
"sipdir",
"+",
"o... | Return the state of modeling and inversion for a given SIP dir. The
result does not take into account sensitivities or potentials, as
optionally generated by CRMod.
Parameters
----------
sipdir: string
Directory to check
Returns
-------
crmod_is_finished: bool
True if a... | [
"Return",
"the",
"state",
"of",
"modeling",
"and",
"inversion",
"for",
"a",
"given",
"SIP",
"dir",
".",
"The",
"result",
"does",
"not",
"take",
"into",
"account",
"sensitivities",
"or",
"potentials",
"as",
"optionally",
"generated",
"by",
"CRMod",
"."
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/lib/crtomo/status.py#L119-L154 | train | Returns the state of modeling and inversion for a given SIP directory. |
gofed/gofedlib | gofedlib/repository/mercuriallocalclient.py | MercurialLocalClient.branches | def branches(self):
"""Return a list of branches for given repository
:return: [str]
"""
# TODO(jchaloup): find out of all branches are listed (even remote)
# if there is a concept of remote branch
return map(lambda (b, r, n): b, self.repo.branches()) | python | def branches(self):
"""Return a list of branches for given repository
:return: [str]
"""
# TODO(jchaloup): find out of all branches are listed (even remote)
# if there is a concept of remote branch
return map(lambda (b, r, n): b, self.repo.branches()) | [
"def",
"branches",
"(",
"self",
")",
":",
"# TODO(jchaloup): find out of all branches are listed (even remote)",
"# if there is a concept of remote branch",
"return",
"map",
"(",
"lambda",
"(",
"b",
",",
"r",
",",
"n",
")",
":",
"b",
",",
"self",
".",
"repo",
".",
... | Return a list of branches for given repository
:return: [str] | [
"Return",
"a",
"list",
"of",
"branches",
"for",
"given",
"repository"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/mercuriallocalclient.py#L23-L30 | train | Return a list of branches for given repository
|
gofed/gofedlib | gofedlib/repository/mercuriallocalclient.py | MercurialLocalClient._commitData | def _commitData(self, changeset):
"""Get data from a commit object
:param changeset: tuple with changeset data
:type changeset: tuple
"""
(rev, node, tags, branch, author, desc, date) = changeset
ts = int(time.mktime(date.timetuple()))
return {
"hexsha": node,
"adate": ts,
"cdate": ts,
"auth... | python | def _commitData(self, changeset):
"""Get data from a commit object
:param changeset: tuple with changeset data
:type changeset: tuple
"""
(rev, node, tags, branch, author, desc, date) = changeset
ts = int(time.mktime(date.timetuple()))
return {
"hexsha": node,
"adate": ts,
"cdate": ts,
"auth... | [
"def",
"_commitData",
"(",
"self",
",",
"changeset",
")",
":",
"(",
"rev",
",",
"node",
",",
"tags",
",",
"branch",
",",
"author",
",",
"desc",
",",
"date",
")",
"=",
"changeset",
"ts",
"=",
"int",
"(",
"time",
".",
"mktime",
"(",
"date",
".",
"t... | Get data from a commit object
:param changeset: tuple with changeset data
:type changeset: tuple | [
"Get",
"data",
"from",
"a",
"commit",
"object"
] | 0674c248fe3d8706f98f912996b65af469f96b10 | https://github.com/gofed/gofedlib/blob/0674c248fe3d8706f98f912996b65af469f96b10/gofedlib/repository/mercuriallocalclient.py#L32-L46 | train | Get data from a commit object |
gofed/gofedlib | gofedlib/repository/mercuriallocalclient.py | MercurialLocalClient.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.
:param branch: git branch
:type branch: [str]{}
:param since: minimal timestamp for commit's commit date
:type since: int
:param to: ma... | 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.
:param branch: git branch
:type branch: [str]{}
:param since: minimal timestamp for commit's commit date
:type since: int
:param to: ma... | [
"def",
"commits",
"(",
"self",
",",
"branch",
",",
"since",
"=",
"0",
",",
"to",
"=",
"int",
"(",
"time",
".",
"time",
"(",
")",
")",
"+",
"86400",
")",
":",
"commits",
"=",
"{",
"}",
"for",
"changeset",
"in",
"self",
".",
"repo",
".",
"log",
... | For given branch return a list of commits.
Each commit contains basic information about itself.
: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's commit date
:type to: int | [
"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/mercuriallocalclient.py#L48-L71 | train | For given branch return a list of commits. |
gofed/gofedlib | gofedlib/repository/mercuriallocalclient.py | MercurialLocalClient.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:
changesets = self.repo.log(revrange=commit)
except error.CommandError:
raise KeyError("Commit %s not found" % commit)
... | 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:
changesets = self.repo.log(revrange=commit)
except error.CommandError:
raise KeyError("Commit %s not found" % commit)
... | [
"def",
"commit",
"(",
"self",
",",
"commit",
")",
":",
"try",
":",
"changesets",
"=",
"self",
".",
"repo",
".",
"log",
"(",
"revrange",
"=",
"commit",
")",
"except",
"error",
".",
"CommandError",
":",
"raise",
"KeyError",
"(",
"\"Commit %s not found\"",
... | 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/mercuriallocalclient.py#L73-L86 | train | Get data for a given commit. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/file.py | BufferedFile.read | def read(self, size=None):
"""
Read at most ``size`` bytes from the file (less if we hit the end of the
file first). If the ``size`` argument is negative or omitted, read all
the remaining data in the file.
.. note::
``'b'`` mode flag is ignored (``self.FLAG_BINARY`... | python | def read(self, size=None):
"""
Read at most ``size`` bytes from the file (less if we hit the end of the
file first). If the ``size`` argument is negative or omitted, read all
the remaining data in the file.
.. note::
``'b'`` mode flag is ignored (``self.FLAG_BINARY`... | [
"def",
"read",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"if",
"self",
".",
"_closed",
":",
"raise",
"IOError",
"(",
"'File is closed'",
")",
"if",
"not",
"(",
"self",
".",
"_flags",
"&",
"self",
".",
"FLAG_READ",
")",
":",
"raise",
"IOError",... | Read at most ``size`` bytes from the file (less if we hit the end of the
file first). If the ``size`` argument is negative or omitted, read all
the remaining data in the file.
.. note::
``'b'`` mode flag is ignored (``self.FLAG_BINARY`` in
``self._flags``), because SSH ... | [
"Read",
"at",
"most",
"size",
"bytes",
"from",
"the",
"file",
"(",
"less",
"if",
"we",
"hit",
"the",
"end",
"of",
"the",
"file",
"first",
")",
".",
"If",
"the",
"size",
"argument",
"is",
"negative",
"or",
"omitted",
"read",
"all",
"the",
"remaining",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/file.py#L121-L178 | train | Reads at most size bytes from the file. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/file.py | BufferedFile.readline | def readline(self, size=None):
"""
Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the tr... | python | def readline(self, size=None):
"""
Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the tr... | [
"def",
"readline",
"(",
"self",
",",
"size",
"=",
"None",
")",
":",
"# it's almost silly how complex this function is.",
"if",
"self",
".",
"_closed",
":",
"raise",
"IOError",
"(",
"'File is closed'",
")",
"if",
"not",
"(",
"self",
".",
"_flags",
"&",
"self",
... | Read one entire line from the file. A trailing newline character is
kept in the string (but may be absent when a file ends with an
incomplete line). If the size argument is present and non-negative, it
is a maximum byte count (including the trailing newline) and an
incomplete line may ... | [
"Read",
"one",
"entire",
"line",
"from",
"the",
"file",
".",
"A",
"trailing",
"newline",
"character",
"is",
"kept",
"in",
"the",
"string",
"(",
"but",
"may",
"be",
"absent",
"when",
"a",
"file",
"ends",
"with",
"an",
"incomplete",
"line",
")",
".",
"If... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/file.py#L180-L261 | train | Read one entire line from the file. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_undercloud.py | OVBUndercloud.enable_neutron_hack | def enable_neutron_hack(self, os_username, os_password, os_project_id, os_auth_url):
"""Enable the neutron hack on the undercloud.
This script will watch the undercloud and copy any relevant network
configuration in the host OpenStack. This is required to avoid the
firewall limitations ... | python | def enable_neutron_hack(self, os_username, os_password, os_project_id, os_auth_url):
"""Enable the neutron hack on the undercloud.
This script will watch the undercloud and copy any relevant network
configuration in the host OpenStack. This is required to avoid the
firewall limitations ... | [
"def",
"enable_neutron_hack",
"(",
"self",
",",
"os_username",
",",
"os_password",
",",
"os_project_id",
",",
"os_auth_url",
")",
":",
"self",
".",
"yum_install",
"(",
"[",
"'python-neutronclient'",
"]",
")",
"self",
".",
"send_file",
"(",
"pkg_data_filename",
"... | Enable the neutron hack on the undercloud.
This script will watch the undercloud and copy any relevant network
configuration in the host OpenStack. This is required to avoid the
firewall limitations (no-spoofing and DHCP restriction). | [
"Enable",
"the",
"neutron",
"hack",
"on",
"the",
"undercloud",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_undercloud.py#L96-L126 | train | Enable the neutron hack on the undercloud. |
redhat-openstack/python-tripleo-helper | tripleohelper/ovb_undercloud.py | OVBUndercloud.patch_ironic_ramdisk | def patch_ironic_ramdisk(self):
"""Clean the disk before flushing the new image.
See: https://bugs.launchpad.net/ironic-lib/+bug/1550604
"""
tmpdir = self.run('mktemp -d')[0].rstrip('\n')
self.run('cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'.format(tmp... | python | def patch_ironic_ramdisk(self):
"""Clean the disk before flushing the new image.
See: https://bugs.launchpad.net/ironic-lib/+bug/1550604
"""
tmpdir = self.run('mktemp -d')[0].rstrip('\n')
self.run('cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'.format(tmp... | [
"def",
"patch_ironic_ramdisk",
"(",
"self",
")",
":",
"tmpdir",
"=",
"self",
".",
"run",
"(",
"'mktemp -d'",
")",
"[",
"0",
"]",
".",
"rstrip",
"(",
"'\\n'",
")",
"self",
".",
"run",
"(",
"'cd {tmpdir}; zcat /home/stack/ironic-python-agent.initramfs| cpio -id'",
... | Clean the disk before flushing the new image.
See: https://bugs.launchpad.net/ironic-lib/+bug/1550604 | [
"Clean",
"the",
"disk",
"before",
"flushing",
"the",
"new",
"image",
"."
] | bfa165538335edb1088170c7a92f097167225c81 | https://github.com/redhat-openstack/python-tripleo-helper/blob/bfa165538335edb1088170c7a92f097167225c81/tripleohelper/ovb_undercloud.py#L128-L137 | train | Patch the ironic - ramdisk to allow the new image to be written. |
elifiner/termenu | termenu/menu.py | show_menu | def show_menu(title, options, default=None, height=None, width=None, multiselect=False, precolored=False):
"""
Shows an interactive menu in the terminal.
Arguments:
options: list of menu options
default: initial option to highlight
height: maximum height of the menu
width: m... | python | def show_menu(title, options, default=None, height=None, width=None, multiselect=False, precolored=False):
"""
Shows an interactive menu in the terminal.
Arguments:
options: list of menu options
default: initial option to highlight
height: maximum height of the menu
width: m... | [
"def",
"show_menu",
"(",
"title",
",",
"options",
",",
"default",
"=",
"None",
",",
"height",
"=",
"None",
",",
"width",
"=",
"None",
",",
"multiselect",
"=",
"False",
",",
"precolored",
"=",
"False",
")",
":",
"plugins",
"=",
"[",
"FilterPlugin",
"(",... | Shows an interactive menu in the terminal.
Arguments:
options: list of menu options
default: initial option to highlight
height: maximum height of the menu
width: maximum width of the menu
multiselect: allow multiple items to be selected?
precolored: allow strings wi... | [
"Shows",
"an",
"interactive",
"menu",
"in",
"the",
"terminal",
"."
] | a7a57a1b07d8451003ee750704cdf0d904e9e272 | https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L6-L39 | train | Show an interactive menu in the terminal. |
elifiner/termenu | termenu/menu.py | pluggable | def pluggable(method):
"""
Mark a class method as extendable with plugins.
"""
def wrapped(self, *args, **kwargs):
if hasattr(self, "_plugins"):
# call the last plugin, it may call the previous via self.parent.method
# creating a call call chain
return getattr... | python | def pluggable(method):
"""
Mark a class method as extendable with plugins.
"""
def wrapped(self, *args, **kwargs):
if hasattr(self, "_plugins"):
# call the last plugin, it may call the previous via self.parent.method
# creating a call call chain
return getattr... | [
"def",
"pluggable",
"(",
"method",
")",
":",
"def",
"wrapped",
"(",
"self",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"hasattr",
"(",
"self",
",",
"\"_plugins\"",
")",
":",
"# call the last plugin, it may call the previous via self.parent.method... | Mark a class method as extendable with plugins. | [
"Mark",
"a",
"class",
"method",
"as",
"extendable",
"with",
"plugins",
"."
] | a7a57a1b07d8451003ee750704cdf0d904e9e272 | https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L46-L58 | train | Mark a class method as extendable with plugins.
|
elifiner/termenu | termenu/menu.py | register_plugin | def register_plugin(host, plugin):
"""
Register a plugin with a host object. Some @pluggable methods in the host
will have their behaviour altered by the plugin.
"""
class OriginalMethods(object):
def __getattr__(self, name):
return lambda *args, **kwargs: getattr(host, name).ori... | python | def register_plugin(host, plugin):
"""
Register a plugin with a host object. Some @pluggable methods in the host
will have their behaviour altered by the plugin.
"""
class OriginalMethods(object):
def __getattr__(self, name):
return lambda *args, **kwargs: getattr(host, name).ori... | [
"def",
"register_plugin",
"(",
"host",
",",
"plugin",
")",
":",
"class",
"OriginalMethods",
"(",
"object",
")",
":",
"def",
"__getattr__",
"(",
"self",
",",
"name",
")",
":",
"return",
"lambda",
"*",
"args",
",",
"*",
"*",
"kwargs",
":",
"getattr",
"("... | Register a plugin with a host object. Some @pluggable methods in the host
will have their behaviour altered by the plugin. | [
"Register",
"a",
"plugin",
"with",
"a",
"host",
"object",
".",
"Some"
] | a7a57a1b07d8451003ee750704cdf0d904e9e272 | https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L60-L72 | train | Register a plugin with a host object. |
elifiner/termenu | termenu/menu.py | redirect_std | def redirect_std():
"""
Connect stdin/stdout to controlling terminal even if the scripts input and output
were redirected. This is useful in utilities based on termenu.
"""
stdin = sys.stdin
stdout = sys.stdout
if not sys.stdin.isatty():
sys.stdin = open_raw("/dev/tty", "r", 0)
i... | python | def redirect_std():
"""
Connect stdin/stdout to controlling terminal even if the scripts input and output
were redirected. This is useful in utilities based on termenu.
"""
stdin = sys.stdin
stdout = sys.stdout
if not sys.stdin.isatty():
sys.stdin = open_raw("/dev/tty", "r", 0)
i... | [
"def",
"redirect_std",
"(",
")",
":",
"stdin",
"=",
"sys",
".",
"stdin",
"stdout",
"=",
"sys",
".",
"stdout",
"if",
"not",
"sys",
".",
"stdin",
".",
"isatty",
"(",
")",
":",
"sys",
".",
"stdin",
"=",
"open_raw",
"(",
"\"/dev/tty\"",
",",
"\"r\"",
"... | Connect stdin/stdout to controlling terminal even if the scripts input and output
were redirected. This is useful in utilities based on termenu. | [
"Connect",
"stdin",
"/",
"stdout",
"to",
"controlling",
"terminal",
"even",
"if",
"the",
"scripts",
"input",
"and",
"output",
"were",
"redirected",
".",
"This",
"is",
"useful",
"in",
"utilities",
"based",
"on",
"termenu",
"."
] | a7a57a1b07d8451003ee750704cdf0d904e9e272 | https://github.com/elifiner/termenu/blob/a7a57a1b07d8451003ee750704cdf0d904e9e272/termenu/menu.py#L562-L574 | train | Redirect standard input to controlling terminal. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | _to_unicode | def _to_unicode(s):
"""
decode a string as ascii or utf8 if possible (as required by the sftp
protocol). if neither works, just return a byte string because the server
probably doesn't know the filename's encoding.
"""
try:
return s.encode('ascii')
except (UnicodeError, AttributeErr... | python | def _to_unicode(s):
"""
decode a string as ascii or utf8 if possible (as required by the sftp
protocol). if neither works, just return a byte string because the server
probably doesn't know the filename's encoding.
"""
try:
return s.encode('ascii')
except (UnicodeError, AttributeErr... | [
"def",
"_to_unicode",
"(",
"s",
")",
":",
"try",
":",
"return",
"s",
".",
"encode",
"(",
"'ascii'",
")",
"except",
"(",
"UnicodeError",
",",
"AttributeError",
")",
":",
"try",
":",
"return",
"s",
".",
"decode",
"(",
"'utf-8'",
")",
"except",
"UnicodeEr... | decode a string as ascii or utf8 if possible (as required by the sftp
protocol). if neither works, just return a byte string because the server
probably doesn't know the filename's encoding. | [
"decode",
"a",
"string",
"as",
"ascii",
"or",
"utf8",
"if",
"possible",
"(",
"as",
"required",
"by",
"the",
"sftp",
"protocol",
")",
".",
"if",
"neither",
"works",
"just",
"return",
"a",
"byte",
"string",
"because",
"the",
"server",
"probably",
"doesn",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L44-L56 | train | Decode a string as ascii or utf8 if possible. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | SFTPClient.open | def open(self, filename, mode='r', bufsize=-1):
"""
Open a file on the remote server. The arguments are the same as for
Python's built-in `python:file` (aka `python:open`). A file-like
object is returned, which closely mimics the behavior of a normal
Python file object, includi... | python | def open(self, filename, mode='r', bufsize=-1):
"""
Open a file on the remote server. The arguments are the same as for
Python's built-in `python:file` (aka `python:open`). A file-like
object is returned, which closely mimics the behavior of a normal
Python file object, includi... | [
"def",
"open",
"(",
"self",
",",
"filename",
",",
"mode",
"=",
"'r'",
",",
"bufsize",
"=",
"-",
"1",
")",
":",
"filename",
"=",
"self",
".",
"_adjust_cwd",
"(",
"filename",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'open(%r, %r)'",
"%",
"(",
"f... | Open a file on the remote server. The arguments are the same as for
Python's built-in `python:file` (aka `python:open`). A file-like
object is returned, which closely mimics the behavior of a normal
Python file object, including the ability to be used as a context
manager.
The... | [
"Open",
"a",
"file",
"on",
"the",
"remote",
"server",
".",
"The",
"arguments",
"are",
"the",
"same",
"as",
"for",
"Python",
"s",
"built",
"-",
"in",
"python",
":",
"file",
"(",
"aka",
"python",
":",
"open",
")",
".",
"A",
"file",
"-",
"like",
"obje... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L199-L250 | train | Open a file on the remote server. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | SFTPClient.symlink | def symlink(self, source, dest):
"""
Create a symbolic link (shortcut) of the ``source`` path at
``destination``.
:param str source: path of the original file
:param str dest: path of the newly created symlink
"""
dest = self._adjust_cwd(dest)
self._log(D... | python | def symlink(self, source, dest):
"""
Create a symbolic link (shortcut) of the ``source`` path at
``destination``.
:param str source: path of the original file
:param str dest: path of the newly created symlink
"""
dest = self._adjust_cwd(dest)
self._log(D... | [
"def",
"symlink",
"(",
"self",
",",
"source",
",",
"dest",
")",
":",
"dest",
"=",
"self",
".",
"_adjust_cwd",
"(",
"dest",
")",
"self",
".",
"_log",
"(",
"DEBUG",
",",
"'symlink(%r, %r)'",
"%",
"(",
"source",
",",
"dest",
")",
")",
"source",
"=",
"... | Create a symbolic link (shortcut) of the ``source`` path at
``destination``.
:param str source: path of the original file
:param str dest: path of the newly created symlink | [
"Create",
"a",
"symbolic",
"link",
"(",
"shortcut",
")",
"of",
"the",
"source",
"path",
"at",
"destination",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L354-L365 | train | Create a symbolic link of the source path at
dest. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | SFTPClient.chdir | def chdir(self, path=None):
"""
Change the "current directory" of this SFTP session. Since SFTP
doesn't really have the concept of a current working directory, this is
emulated by Paramiko. Once you use this method to set a working
directory, all operations on this `.SFTPClient... | python | def chdir(self, path=None):
"""
Change the "current directory" of this SFTP session. Since SFTP
doesn't really have the concept of a current working directory, this is
emulated by Paramiko. Once you use this method to set a working
directory, all operations on this `.SFTPClient... | [
"def",
"chdir",
"(",
"self",
",",
"path",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"self",
".",
"_cwd",
"=",
"None",
"return",
"if",
"not",
"stat",
".",
"S_ISDIR",
"(",
"self",
".",
"stat",
"(",
"path",
")",
".",
"st_mode",
")",
... | Change the "current directory" of this SFTP session. Since SFTP
doesn't really have the concept of a current working directory, this is
emulated by Paramiko. Once you use this method to set a working
directory, all operations on this `.SFTPClient` object will be relative
to that path. ... | [
"Change",
"the",
"current",
"directory",
"of",
"this",
"SFTP",
"session",
".",
"Since",
"SFTP",
"doesn",
"t",
"really",
"have",
"the",
"concept",
"of",
"a",
"current",
"working",
"directory",
"this",
"is",
"emulated",
"by",
"Paramiko",
".",
"Once",
"you",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L480-L500 | train | Change the current directory of this SFTP session. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | SFTPClient.putfo | def putfo(self, fl, remotepath, file_size=0, callback=None, confirm=True):
"""
Copy the contents of an open file object (``fl``) to the SFTP server as
``remotepath``. Any exception raised by operations will be passed
through.
The SFTP operations use pipelining for speed.
... | python | def putfo(self, fl, remotepath, file_size=0, callback=None, confirm=True):
"""
Copy the contents of an open file object (``fl``) to the SFTP server as
``remotepath``. Any exception raised by operations will be passed
through.
The SFTP operations use pipelining for speed.
... | [
"def",
"putfo",
"(",
"self",
",",
"fl",
",",
"remotepath",
",",
"file_size",
"=",
"0",
",",
"callback",
"=",
"None",
",",
"confirm",
"=",
"True",
")",
":",
"with",
"self",
".",
"file",
"(",
"remotepath",
",",
"'wb'",
")",
"as",
"fr",
":",
"fr",
"... | Copy the contents of an open file object (``fl``) to the SFTP server as
``remotepath``. Any exception raised by operations will be passed
through.
The SFTP operations use pipelining for speed.
:param file fl: opened file or file-like object to copy
:param str remotepath: the de... | [
"Copy",
"the",
"contents",
"of",
"an",
"open",
"file",
"object",
"(",
"fl",
")",
"to",
"the",
"SFTP",
"server",
"as",
"remotepath",
".",
"Any",
"exception",
"raised",
"by",
"operations",
"will",
"be",
"passed",
"through",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L512-L556 | train | Copy the contents of a file object to the server and return a new SFTPAttributes object containing the attributes about the file. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/sftp_client.py | SFTPClient.getfo | def getfo(self, remotepath, fl, callback=None):
"""
Copy a remote file (``remotepath``) from the SFTP server and write to
an open file or file-like object, ``fl``. Any exception raised by
operations will be passed through. This method is primarily provided
as a convenience.
... | python | def getfo(self, remotepath, fl, callback=None):
"""
Copy a remote file (``remotepath``) from the SFTP server and write to
an open file or file-like object, ``fl``. Any exception raised by
operations will be passed through. This method is primarily provided
as a convenience.
... | [
"def",
"getfo",
"(",
"self",
",",
"remotepath",
",",
"fl",
",",
"callback",
"=",
"None",
")",
":",
"with",
"self",
".",
"open",
"(",
"remotepath",
",",
"'rb'",
")",
"as",
"fr",
":",
"file_size",
"=",
"self",
".",
"stat",
"(",
"remotepath",
")",
"."... | Copy a remote file (``remotepath``) from the SFTP server and write to
an open file or file-like object, ``fl``. Any exception raised by
operations will be passed through. This method is primarily provided
as a convenience.
:param object remotepath: opened file or file-like object to c... | [
"Copy",
"a",
"remote",
"file",
"(",
"remotepath",
")",
"from",
"the",
"SFTP",
"server",
"and",
"write",
"to",
"an",
"open",
"file",
"or",
"file",
"-",
"like",
"object",
"fl",
".",
"Any",
"exception",
"raised",
"by",
"operations",
"will",
"be",
"passed",
... | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/sftp_client.py#L589-L618 | train | Copy a remote file from the SFTP server and write it to the specified file - like object fl. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/message.py | Message.get_int | def get_int(self):
"""
Fetch an int from the stream.
:return: a 32-bit unsigned `int`.
"""
byte = self.get_bytes(1)
if byte == max_byte:
return util.inflate_long(self.get_binary())
byte += self.get_bytes(3)
return struct.unpack('>I', byte)[0] | python | def get_int(self):
"""
Fetch an int from the stream.
:return: a 32-bit unsigned `int`.
"""
byte = self.get_bytes(1)
if byte == max_byte:
return util.inflate_long(self.get_binary())
byte += self.get_bytes(3)
return struct.unpack('>I', byte)[0] | [
"def",
"get_int",
"(",
"self",
")",
":",
"byte",
"=",
"self",
".",
"get_bytes",
"(",
"1",
")",
"if",
"byte",
"==",
"max_byte",
":",
"return",
"util",
".",
"inflate_long",
"(",
"self",
".",
"get_binary",
"(",
")",
")",
"byte",
"+=",
"self",
".",
"ge... | Fetch an int from the stream.
:return: a 32-bit unsigned `int`. | [
"Fetch",
"an",
"int",
"from",
"the",
"stream",
"."
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/message.py#L132-L142 | train | Fetch an int from the stream. |
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/message.py | Message.add_size | def add_size(self, n):
"""
Add an integer to the stream.
:param int n: integer to add
"""
self.packet.write(struct.pack('>I', n))
return self | python | def add_size(self, n):
"""
Add an integer to the stream.
:param int n: integer to add
"""
self.packet.write(struct.pack('>I', n))
return self | [
"def",
"add_size",
"(",
"self",
",",
"n",
")",
":",
"self",
".",
"packet",
".",
"write",
"(",
"struct",
".",
"pack",
"(",
"'>I'",
",",
"n",
")",
")",
"return",
"self"
] | Add an integer to the stream.
:param int n: integer to add | [
"Add",
"an",
"integer",
"to",
"the",
"stream",
".",
":",
"param",
"int",
"n",
":",
"integer",
"to",
"add"
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/message.py#L238-L245 | train | Add an integer to the stream.
|
NikolayDachev/jadm | lib/paramiko-1.14.1/paramiko/message.py | Message.add_string | def add_string(self, s):
"""
Add a string to the stream.
:param str s: string to add
"""
s = asbytes(s)
self.add_size(len(s))
self.packet.write(s)
return self | python | def add_string(self, s):
"""
Add a string to the stream.
:param str s: string to add
"""
s = asbytes(s)
self.add_size(len(s))
self.packet.write(s)
return self | [
"def",
"add_string",
"(",
"self",
",",
"s",
")",
":",
"s",
"=",
"asbytes",
"(",
"s",
")",
"self",
".",
"add_size",
"(",
"len",
"(",
"s",
")",
")",
"self",
".",
"packet",
".",
"write",
"(",
"s",
")",
"return",
"self"
] | Add a string to the stream.
:param str s: string to add | [
"Add",
"a",
"string",
"to",
"the",
"stream",
".",
":",
"param",
"str",
"s",
":",
"string",
"to",
"add"
] | 12bb550445edfcd87506f7cba7a6a35d413c5511 | https://github.com/NikolayDachev/jadm/blob/12bb550445edfcd87506f7cba7a6a35d413c5511/lib/paramiko-1.14.1/paramiko/message.py#L279-L288 | train | Add a string to the stream. |
reorx/torext | torext/log.py | set_logger | def set_logger(name,
level='INFO',
fmt=None,
datefmt=None,
propagate=1,
remove_handlers=False):
"""
This function will clear the previous handlers and set only one handler,
which will only be StreamHandler for the logger.
This f... | python | def set_logger(name,
level='INFO',
fmt=None,
datefmt=None,
propagate=1,
remove_handlers=False):
"""
This function will clear the previous handlers and set only one handler,
which will only be StreamHandler for the logger.
This f... | [
"def",
"set_logger",
"(",
"name",
",",
"level",
"=",
"'INFO'",
",",
"fmt",
"=",
"None",
",",
"datefmt",
"=",
"None",
",",
"propagate",
"=",
"1",
",",
"remove_handlers",
"=",
"False",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"name",
... | This function will clear the previous handlers and set only one handler,
which will only be StreamHandler for the logger.
This function is designed to be able to called multiple times in a context.
Note that if a logger has no handlers, it will be added a handler automatically when it is used. | [
"This",
"function",
"will",
"clear",
"the",
"previous",
"handlers",
"and",
"set",
"only",
"one",
"handler",
"which",
"will",
"only",
"be",
"StreamHandler",
"for",
"the",
"logger",
"."
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/log.py#L152-L188 | train | This function sets a logger to the given name. |
reorx/torext | torext/log.py | BaseFormatter.format | def format(self, record):
"""
return log in unicode
"""
self._format_record(record)
record_dict = {}
for k, v in record.__dict__.items():
if isinstance(k, str):
k = decode_(k, 'utf8')
if isinstance(v, str):
v = deco... | python | def format(self, record):
"""
return log in unicode
"""
self._format_record(record)
record_dict = {}
for k, v in record.__dict__.items():
if isinstance(k, str):
k = decode_(k, 'utf8')
if isinstance(v, str):
v = deco... | [
"def",
"format",
"(",
"self",
",",
"record",
")",
":",
"self",
".",
"_format_record",
"(",
"record",
")",
"record_dict",
"=",
"{",
"}",
"for",
"k",
",",
"v",
"in",
"record",
".",
"__dict__",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"k"... | return log in unicode | [
"return",
"log",
"in",
"unicode"
] | 84c4300ebc7fab0dbd11cf8b020bc7d4d1570171 | https://github.com/reorx/torext/blob/84c4300ebc7fab0dbd11cf8b020bc7d4d1570171/torext/log.py#L108-L134 | train | Format a log entry into unicode. |
Riminder/python-riminder-api | riminder/profile.py | Profile.list | def list(self, source_ids=None, seniority="all", stage=None,
date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None,
page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None):
"""
Retreive all profiles that match the query param.
Args:
... | python | def list(self, source_ids=None, seniority="all", stage=None,
date_start="1494539999", date_end=TIMESTAMP_NOW, filter_id=None,
page=1, limit=30, sort_by='ranking', filter_reference=None, order_by=None):
"""
Retreive all profiles that match the query param.
Args:
... | [
"def",
"list",
"(",
"self",
",",
"source_ids",
"=",
"None",
",",
"seniority",
"=",
"\"all\"",
",",
"stage",
"=",
"None",
",",
"date_start",
"=",
"\"1494539999\"",
",",
"date_end",
"=",
"TIMESTAMP_NOW",
",",
"filter_id",
"=",
"None",
",",
"page",
"=",
"1"... | Retreive all profiles that match the query param.
Args:
date_end: <string> REQUIRED (default to timestamp of now)
profiles' last date of reception
date_start: <string> REQUIRED (default to "1494539999")
profiles' first date of reception
... | [
"Retreive",
"all",
"profiles",
"that",
"match",
"the",
"query",
"param",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L68-L110 | train | Returns a list of all the profiles in the database. |
Riminder/python-riminder-api | riminder/profile.py | Profile.add | def add(self, source_id=None, file_path=None, profile_reference="",
timestamp_reception=None, training_metadata=[]):
"""
Add a profile resume to a sourced id.
Args:
source_id: <string>
source id
file_path: ... | python | def add(self, source_id=None, file_path=None, profile_reference="",
timestamp_reception=None, training_metadata=[]):
"""
Add a profile resume to a sourced id.
Args:
source_id: <string>
source id
file_path: ... | [
"def",
"add",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"file_path",
"=",
"None",
",",
"profile_reference",
"=",
"\"\"",
",",
"timestamp_reception",
"=",
"None",
",",
"training_metadata",
"=",
"[",
"]",
")",
":",
"data",
"=",
"{",
"}",
"data",
"... | Add a profile resume to a sourced id.
Args:
source_id: <string>
source id
file_path: <string>
local path to resume file
profile_reference: <string> (default to "")
... | [
"Add",
"a",
"profile",
"resume",
"to",
"a",
"sourced",
"id",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L112-L142 | train | Add a profile resume to a sourced id. |
Riminder/python-riminder-api | riminder/profile.py | Profile.addList | def addList(self, source_id, dir_path, is_recurcive=False, timestamp_reception=None, training_metadata=[]):
"""Add all profile from a given directory."""
if not path.isdir(dir_path):
raise ValueError(dir_path + ' is not a directory')
files_to_send = _get_files_from_dir(dir_path, is_r... | python | def addList(self, source_id, dir_path, is_recurcive=False, timestamp_reception=None, training_metadata=[]):
"""Add all profile from a given directory."""
if not path.isdir(dir_path):
raise ValueError(dir_path + ' is not a directory')
files_to_send = _get_files_from_dir(dir_path, is_r... | [
"def",
"addList",
"(",
"self",
",",
"source_id",
",",
"dir_path",
",",
"is_recurcive",
"=",
"False",
",",
"timestamp_reception",
"=",
"None",
",",
"training_metadata",
"=",
"[",
"]",
")",
":",
"if",
"not",
"path",
".",
"isdir",
"(",
"dir_path",
")",
":",... | Add all profile from a given directory. | [
"Add",
"all",
"profile",
"from",
"a",
"given",
"directory",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L144-L166 | train | Add all profiles from a given directory. |
Riminder/python-riminder-api | riminder/profile.py | Profile.get | def get(self, source_id=None, profile_id=None, profile_reference=None):
"""
Retrieve the profile information associated with profile id.
Args:
source_id: <string>
source id
profile_id: <string>
... | python | def get(self, source_id=None, profile_id=None, profile_reference=None):
"""
Retrieve the profile information associated with profile id.
Args:
source_id: <string>
source id
profile_id: <string>
... | [
"def",
"get",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"profile_id",
"=",
"None",
",",
"profile_reference",
"=",
"None",
")",
":",
"query_params",
"=",
"{",
"}",
"query_params",
"[",
"\"source_id\"",
"]",
"=",
"_validate_source_id",
"(",
"source_id",... | Retrieve the profile information associated with profile id.
Args:
source_id: <string>
source id
profile_id: <string>
profile id
Returns
profile information | [
"Retrieve",
"the",
"profile",
"information",
"associated",
"with",
"profile",
"id",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L168-L189 | train | Retrieve the profile information associated with source id. |
Riminder/python-riminder-api | riminder/profile.py | ProfileStage.set | def set(self, source_id=None, profile_id=None, filter_id=None, stage=None, profile_reference=None, filter_reference=None):
"""
Edit the profile stage given a filter.
Args:
profile_id: <string>
profile id
body params:
... | python | def set(self, source_id=None, profile_id=None, filter_id=None, stage=None, profile_reference=None, filter_reference=None):
"""
Edit the profile stage given a filter.
Args:
profile_id: <string>
profile id
body params:
... | [
"def",
"set",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"profile_id",
"=",
"None",
",",
"filter_id",
"=",
"None",
",",
"stage",
"=",
"None",
",",
"profile_reference",
"=",
"None",
",",
"filter_reference",
"=",
"None",
")",
":",
"data",
"=",
"{",... | Edit the profile stage given a filter.
Args:
profile_id: <string>
profile id
body params:
source_id: <string>
source id associated to the profile
filter_id: ... | [
"Edit",
"the",
"profile",
"stage",
"given",
"a",
"filter",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L292-L326 | train | Edit the profile stage given a filter. |
Riminder/python-riminder-api | riminder/profile.py | ProfileRevealing.get | def get(self, source_id=None, profile_id=None, profile_reference=None, filter_id=None, filter_reference=None):
"""
Retrieve the interpretability information.
Args:
source_id: <string>
source id
profile_id: <str... | python | def get(self, source_id=None, profile_id=None, profile_reference=None, filter_id=None, filter_reference=None):
"""
Retrieve the interpretability information.
Args:
source_id: <string>
source id
profile_id: <str... | [
"def",
"get",
"(",
"self",
",",
"source_id",
"=",
"None",
",",
"profile_id",
"=",
"None",
",",
"profile_reference",
"=",
"None",
",",
"filter_id",
"=",
"None",
",",
"filter_reference",
"=",
"None",
")",
":",
"query_params",
"=",
"{",
"}",
"query_params",
... | Retrieve the interpretability information.
Args:
source_id: <string>
source id
profile_id: <string>
profile id
filter_id: <string>
... | [
"Retrieve",
"the",
"interpretability",
"information",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L380-L407 | train | Retrieve the interpretability information. |
Riminder/python-riminder-api | riminder/profile.py | ProfileJson.check | def check(self, profile_data, training_metadata=[]):
"""Use the api to check weither the profile_data are valid."""
data = {
"profile_json": _validate_dict(profile_data, "profile_data"),
"training_metadata": _validate_training_metadata(training_metadata),
}
respon... | python | def check(self, profile_data, training_metadata=[]):
"""Use the api to check weither the profile_data are valid."""
data = {
"profile_json": _validate_dict(profile_data, "profile_data"),
"training_metadata": _validate_training_metadata(training_metadata),
}
respon... | [
"def",
"check",
"(",
"self",
",",
"profile_data",
",",
"training_metadata",
"=",
"[",
"]",
")",
":",
"data",
"=",
"{",
"\"profile_json\"",
":",
"_validate_dict",
"(",
"profile_data",
",",
"\"profile_data\"",
")",
",",
"\"training_metadata\"",
":",
"_validate_tra... | Use the api to check weither the profile_data are valid. | [
"Use",
"the",
"api",
"to",
"check",
"weither",
"the",
"profile_data",
"are",
"valid",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L417-L424 | train | Use the api to check weither the profile_data are valid. |
Riminder/python-riminder-api | riminder/profile.py | ProfileJson.add | def add(self, source_id, profile_data, training_metadata=[], profile_reference=None, timestamp_reception=None):
"""Use the api to add a new profile using profile_data."""
data = {
"source_id": _validate_source_id(source_id),
"profile_json": _validate_dict(profile_data, "profile_d... | python | def add(self, source_id, profile_data, training_metadata=[], profile_reference=None, timestamp_reception=None):
"""Use the api to add a new profile using profile_data."""
data = {
"source_id": _validate_source_id(source_id),
"profile_json": _validate_dict(profile_data, "profile_d... | [
"def",
"add",
"(",
"self",
",",
"source_id",
",",
"profile_data",
",",
"training_metadata",
"=",
"[",
"]",
",",
"profile_reference",
"=",
"None",
",",
"timestamp_reception",
"=",
"None",
")",
":",
"data",
"=",
"{",
"\"source_id\"",
":",
"_validate_source_id",
... | Use the api to add a new profile using profile_data. | [
"Use",
"the",
"api",
"to",
"add",
"a",
"new",
"profile",
"using",
"profile_data",
"."
] | 01279f0ece08cf3d1dd45f76de6d9edf7fafec90 | https://github.com/Riminder/python-riminder-api/blob/01279f0ece08cf3d1dd45f76de6d9edf7fafec90/riminder/profile.py#L426-L440 | train | Use the api to add a new profile using profile_data. |
usc-isi-i2/dig-sandpaper | digsandpaper/sandpaper_utils.py | convert_jsonld_cdr | def convert_jsonld_cdr(doc):
"""
converts json ld output of etk to cdr object
:param doc: the input Knowledge graph in json ld format
:return: a cdr object with embedded knowledge graph and doc_id.
# TODO DIG UI needs a @timestamp_crawl(?) add this too
"""
new_docs = list()
new_doc = dic... | python | def convert_jsonld_cdr(doc):
"""
converts json ld output of etk to cdr object
:param doc: the input Knowledge graph in json ld format
:return: a cdr object with embedded knowledge graph and doc_id.
# TODO DIG UI needs a @timestamp_crawl(?) add this too
"""
new_docs = list()
new_doc = dic... | [
"def",
"convert_jsonld_cdr",
"(",
"doc",
")",
":",
"new_docs",
"=",
"list",
"(",
")",
"new_doc",
"=",
"dict",
"(",
")",
"kg",
"=",
"dict",
"(",
")",
"for",
"key",
"in",
"list",
"(",
"doc",
")",
":",
"if",
"key",
"==",
"'@id'",
":",
"new_doc",
"["... | converts json ld output of etk to cdr object
:param doc: the input Knowledge graph in json ld format
:return: a cdr object with embedded knowledge graph and doc_id.
# TODO DIG UI needs a @timestamp_crawl(?) add this too | [
"converts",
"json",
"ld",
"output",
"of",
"etk",
"to",
"cdr",
"object",
":",
"param",
"doc",
":",
"the",
"input",
"Knowledge",
"graph",
"in",
"json",
"ld",
"format",
":",
"return",
":",
"a",
"cdr",
"object",
"with",
"embedded",
"knowledge",
"graph",
"and... | c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6 | https://github.com/usc-isi-i2/dig-sandpaper/blob/c7a905ceec28ad0cc9e7da7ede2fd3d2fc93c3d6/digsandpaper/sandpaper_utils.py#L12-L51 | train | converts json ld output of etk to cdr object |
kwlzn/blast | blast/scanner.py | DirScanner.md5sum | def md5sum(self, f):
''' md5sums a file, returning the hex digest
Parameters:
- f filename string
'''
m = hashlib.md5()
fh = open(f, 'r')
while 1:
chunk = fh.read(BUF_SIZE)
if not chunk: break
m.update(chunk)
... | python | def md5sum(self, f):
''' md5sums a file, returning the hex digest
Parameters:
- f filename string
'''
m = hashlib.md5()
fh = open(f, 'r')
while 1:
chunk = fh.read(BUF_SIZE)
if not chunk: break
m.update(chunk)
... | [
"def",
"md5sum",
"(",
"self",
",",
"f",
")",
":",
"m",
"=",
"hashlib",
".",
"md5",
"(",
")",
"fh",
"=",
"open",
"(",
"f",
",",
"'r'",
")",
"while",
"1",
":",
"chunk",
"=",
"fh",
".",
"read",
"(",
"BUF_SIZE",
")",
"if",
"not",
"chunk",
":",
... | md5sums a file, returning the hex digest
Parameters:
- f filename string | [
"md5sums",
"a",
"file",
"returning",
"the",
"hex",
"digest"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/scanner.py#L16-L29 | train | md5sums a file returning the hex digest |
kwlzn/blast | blast/scanner.py | DirScanner.iteritems | def iteritems(self, path=None, want_files=True, want_dirs=True, func=None, filt=None):
''' streaming item iterator that can optionally run a function / filter function on each item (files/dirs)
Parameters:
- path path to iterate on (note: this is called recursively)
... | python | def iteritems(self, path=None, want_files=True, want_dirs=True, func=None, filt=None):
''' streaming item iterator that can optionally run a function / filter function on each item (files/dirs)
Parameters:
- path path to iterate on (note: this is called recursively)
... | [
"def",
"iteritems",
"(",
"self",
",",
"path",
"=",
"None",
",",
"want_files",
"=",
"True",
",",
"want_dirs",
"=",
"True",
",",
"func",
"=",
"None",
",",
"filt",
"=",
"None",
")",
":",
"if",
"path",
"is",
"None",
":",
"iter_path",
"=",
"self",
".",
... | streaming item iterator that can optionally run a function / filter function on each item (files/dirs)
Parameters:
- path path to iterate on (note: this is called recursively)
- want_files True if you want file results in the iteration, False if you don't
... | [
"streaming",
"item",
"iterator",
"that",
"can",
"optionally",
"run",
"a",
"function",
"/",
"filter",
"function",
"on",
"each",
"item",
"(",
"files",
"/",
"dirs",
")"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/scanner.py#L31-L69 | train | streaming item iterator that can optionally run a function and filter function on each item |
kwlzn/blast | blast/scanner.py | DirScanner.iterdupes | def iterdupes(self, compare=None, filt=None):
''' streaming item iterator with low overhead duplicate file detection
Parameters:
- compare compare function between files (defaults to md5sum)
'''
if not compare: compare = self.md5sum
seen_siz = {} ... | python | def iterdupes(self, compare=None, filt=None):
''' streaming item iterator with low overhead duplicate file detection
Parameters:
- compare compare function between files (defaults to md5sum)
'''
if not compare: compare = self.md5sum
seen_siz = {} ... | [
"def",
"iterdupes",
"(",
"self",
",",
"compare",
"=",
"None",
",",
"filt",
"=",
"None",
")",
":",
"if",
"not",
"compare",
":",
"compare",
"=",
"self",
".",
"md5sum",
"seen_siz",
"=",
"{",
"}",
"## store size -> first seen filename",
"seen_sum",
"=",
"{",... | streaming item iterator with low overhead duplicate file detection
Parameters:
- compare compare function between files (defaults to md5sum) | [
"streaming",
"item",
"iterator",
"with",
"low",
"overhead",
"duplicate",
"file",
"detection"
] | ae18a19182a6884c453bf9b2a3c6386bd3b2655a | https://github.com/kwlzn/blast/blob/ae18a19182a6884c453bf9b2a3c6386bd3b2655a/blast/scanner.py#L71-L102 | train | streaming item iterator with low overhead duplicate file detection
|
gebn/wood | wood/integrations/s3.py | objects_to_root | def objects_to_root(objects: List) -> Root:
"""
Convert a list of s3 ObjectSummaries into a directory tree.
:param objects: The list of objects, e.g. the result of calling
`.objects.all()` on a bucket.
:return: The tree structure, contained within a root node.
"""
def _to_t... | python | def objects_to_root(objects: List) -> Root:
"""
Convert a list of s3 ObjectSummaries into a directory tree.
:param objects: The list of objects, e.g. the result of calling
`.objects.all()` on a bucket.
:return: The tree structure, contained within a root node.
"""
def _to_t... | [
"def",
"objects_to_root",
"(",
"objects",
":",
"List",
")",
"->",
"Root",
":",
"def",
"_to_tree",
"(",
"objs",
":",
"Iterable",
")",
"->",
"Dict",
":",
"\"\"\"\n Build a tree structure from a flat list of objects.\n\n :param objs: The raw iterable of S3 `ObjectS... | Convert a list of s3 ObjectSummaries into a directory tree.
:param objects: The list of objects, e.g. the result of calling
`.objects.all()` on a bucket.
:return: The tree structure, contained within a root node. | [
"Convert",
"a",
"list",
"of",
"s3",
"ObjectSummaries",
"into",
"a",
"directory",
"tree",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L16-L77 | train | Converts a list of s3 ObjectSummaries into a directory tree. |
gebn/wood | wood/integrations/s3.py | Syncer._delete | def _delete(self, paths: Iterable[str]) -> None:
"""
Delete a collection of paths from S3.
:param paths: The paths to delete. The prefix will be prepended to each
one.
:raises ClientError: If any request fails.
"""
for chunk in util.chunk(paths, sel... | python | def _delete(self, paths: Iterable[str]) -> None:
"""
Delete a collection of paths from S3.
:param paths: The paths to delete. The prefix will be prepended to each
one.
:raises ClientError: If any request fails.
"""
for chunk in util.chunk(paths, sel... | [
"def",
"_delete",
"(",
"self",
",",
"paths",
":",
"Iterable",
"[",
"str",
"]",
")",
"->",
"None",
":",
"for",
"chunk",
"in",
"util",
".",
"chunk",
"(",
"paths",
",",
"self",
".",
"_MAX_DELETES_PER_REQUEST",
")",
":",
"keys",
"=",
"list",
"(",
"[",
... | Delete a collection of paths from S3.
:param paths: The paths to delete. The prefix will be prepended to each
one.
:raises ClientError: If any request fails. | [
"Delete",
"a",
"collection",
"of",
"paths",
"from",
"S3",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L101-L116 | train | Delete a collection of paths from S3. |
gebn/wood | wood/integrations/s3.py | Syncer._upload | def _upload(self, items: Iterable[Tuple[str, str]]) -> None:
"""
Upload a collection of paths to S3.
:param items: An iterable of pairs containing the local path of the
file to upload, and the remote path to upload it to. The
prefix will be appended t... | python | def _upload(self, items: Iterable[Tuple[str, str]]) -> None:
"""
Upload a collection of paths to S3.
:param items: An iterable of pairs containing the local path of the
file to upload, and the remote path to upload it to. The
prefix will be appended t... | [
"def",
"_upload",
"(",
"self",
",",
"items",
":",
"Iterable",
"[",
"Tuple",
"[",
"str",
",",
"str",
"]",
"]",
")",
"->",
"None",
":",
"for",
"src",
",",
"key",
"in",
"items",
":",
"logger",
".",
"info",
"(",
"f'Uploading {src} to {key}'",
")",
"mimet... | Upload a collection of paths to S3.
:param items: An iterable of pairs containing the local path of the
file to upload, and the remote path to upload it to. The
prefix will be appended to each remote path. | [
"Upload",
"a",
"collection",
"of",
"paths",
"to",
"S3",
"."
] | efc71879890dbd2f2d7a0b1a65ed22a0843139dd | https://github.com/gebn/wood/blob/efc71879890dbd2f2d7a0b1a65ed22a0843139dd/wood/integrations/s3.py#L118-L136 | train | Uploads a collection of paths to S3. |
geophysics-ubonn/crtomo_tools | src/grid_rotate.py | rotmat | def rotmat(alpha):
"""Rotate around z-axis
"""
R = np.array(((np.cos(alpha), -np.sin(alpha)),
(np.sin(alpha), np.cos(alpha))))
return R | python | def rotmat(alpha):
"""Rotate around z-axis
"""
R = np.array(((np.cos(alpha), -np.sin(alpha)),
(np.sin(alpha), np.cos(alpha))))
return R | [
"def",
"rotmat",
"(",
"alpha",
")",
":",
"R",
"=",
"np",
".",
"array",
"(",
"(",
"(",
"np",
".",
"cos",
"(",
"alpha",
")",
",",
"-",
"np",
".",
"sin",
"(",
"alpha",
")",
")",
",",
"(",
"np",
".",
"sin",
"(",
"alpha",
")",
",",
"np",
".",
... | Rotate around z-axis | [
"Rotate",
"around",
"z",
"-",
"axis"
] | 27c3e21a557f8df1c12455b96c4c2e00e08a5b4a | https://github.com/geophysics-ubonn/crtomo_tools/blob/27c3e21a557f8df1c12455b96c4c2e00e08a5b4a/src/grid_rotate.py#L37-L43 | train | Rotate around z - axis
|
edx/edx-celeryutils | celery_utils/logged_task.py | LoggedTask.apply_async | def apply_async(self, args=None, kwargs=None, **options): # pylint: disable=arguments-differ
"""
Emit a log statement when the task is submitted.
"""
result = super(LoggedTask, self).apply_async(args=args, kwargs=kwargs, **options)
log.info('Task {}[{}] submitted with arguments ... | python | def apply_async(self, args=None, kwargs=None, **options): # pylint: disable=arguments-differ
"""
Emit a log statement when the task is submitted.
"""
result = super(LoggedTask, self).apply_async(args=args, kwargs=kwargs, **options)
log.info('Task {}[{}] submitted with arguments ... | [
"def",
"apply_async",
"(",
"self",
",",
"args",
"=",
"None",
",",
"kwargs",
"=",
"None",
",",
"*",
"*",
"options",
")",
":",
"# pylint: disable=arguments-differ",
"result",
"=",
"super",
"(",
"LoggedTask",
",",
"self",
")",
".",
"apply_async",
"(",
"args",... | Emit a log statement when the task is submitted. | [
"Emit",
"a",
"log",
"statement",
"when",
"the",
"task",
"is",
"submitted",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L22-L33 | train | Emits a log statement when the task is submitted. |
edx/edx-celeryutils | celery_utils/logged_task.py | LoggedTask.on_retry | def on_retry(self, exc, task_id, args, kwargs, einfo):
"""
Capture the exception that caused the task to be retried, if any.
"""
super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo)
log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', No... | python | def on_retry(self, exc, task_id, args, kwargs, einfo):
"""
Capture the exception that caused the task to be retried, if any.
"""
super(LoggedTask, self).on_retry(exc, task_id, args, kwargs, einfo)
log.warning('[{}] retried due to {}'.format(task_id, getattr(einfo, 'traceback', No... | [
"def",
"on_retry",
"(",
"self",
",",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")",
":",
"super",
"(",
"LoggedTask",
",",
"self",
")",
".",
"on_retry",
"(",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")"... | Capture the exception that caused the task to be retried, if any. | [
"Capture",
"the",
"exception",
"that",
"caused",
"the",
"task",
"to",
"be",
"retried",
"if",
"any",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L35-L40 | train | Called when a task is retried. |
edx/edx-celeryutils | celery_utils/logged_task.py | LoggedTask.on_failure | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""
Capture the exception that caused the task to fail, if any.
"""
log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo) | python | def on_failure(self, exc, task_id, args, kwargs, einfo):
"""
Capture the exception that caused the task to fail, if any.
"""
log.error('[{}] failed due to {}'.format(task_id, getattr(einfo, 'traceback', None)))
super(LoggedTask, self).on_failure(exc, task_id, args, kwargs, einfo) | [
"def",
"on_failure",
"(",
"self",
",",
"exc",
",",
"task_id",
",",
"args",
",",
"kwargs",
",",
"einfo",
")",
":",
"log",
".",
"error",
"(",
"'[{}] failed due to {}'",
".",
"format",
"(",
"task_id",
",",
"getattr",
"(",
"einfo",
",",
"'traceback'",
",",
... | Capture the exception that caused the task to fail, if any. | [
"Capture",
"the",
"exception",
"that",
"caused",
"the",
"task",
"to",
"fail",
"if",
"any",
"."
] | d8745f5f0929ad154fad779a19fbefe7f51e9498 | https://github.com/edx/edx-celeryutils/blob/d8745f5f0929ad154fad779a19fbefe7f51e9498/celery_utils/logged_task.py#L42-L47 | train | Log the exception that caused the task to fail. |
hotzenklotz/pybeerxml | pybeerxml/parser.py | Parser.nodes_to_object | def nodes_to_object(self, node, object):
"Map all child nodes to one object's attributes"
for n in list(node):
self.node_to_object(n, object) | python | def nodes_to_object(self, node, object):
"Map all child nodes to one object's attributes"
for n in list(node):
self.node_to_object(n, object) | [
"def",
"nodes_to_object",
"(",
"self",
",",
"node",
",",
"object",
")",
":",
"for",
"n",
"in",
"list",
"(",
"node",
")",
":",
"self",
".",
"node_to_object",
"(",
"n",
",",
"object",
")"
] | Map all child nodes to one object's attributes | [
"Map",
"all",
"child",
"nodes",
"to",
"one",
"object",
"s",
"attributes"
] | e9cf8d6090b1e01e5bbb101e255792b134affbe0 | https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L15-L19 | train | Map all child nodes to one object s attributes |
hotzenklotz/pybeerxml | pybeerxml/parser.py | Parser.node_to_object | def node_to_object(self, node, object):
"Map a single node to one object's attributes"
attribute = self.to_lower(node.tag)
# Yield is a protected keyword in Python, so let's rename it
attribute = "_yield" if attribute == "yield" else attribute
try:
valueString = no... | python | def node_to_object(self, node, object):
"Map a single node to one object's attributes"
attribute = self.to_lower(node.tag)
# Yield is a protected keyword in Python, so let's rename it
attribute = "_yield" if attribute == "yield" else attribute
try:
valueString = no... | [
"def",
"node_to_object",
"(",
"self",
",",
"node",
",",
"object",
")",
":",
"attribute",
"=",
"self",
".",
"to_lower",
"(",
"node",
".",
"tag",
")",
"# Yield is a protected keyword in Python, so let's rename it",
"attribute",
"=",
"\"_yield\"",
"if",
"attribute",
... | Map a single node to one object's attributes | [
"Map",
"a",
"single",
"node",
"to",
"one",
"object",
"s",
"attributes"
] | e9cf8d6090b1e01e5bbb101e255792b134affbe0 | https://github.com/hotzenklotz/pybeerxml/blob/e9cf8d6090b1e01e5bbb101e255792b134affbe0/pybeerxml/parser.py#L21-L38 | train | Map a single node to one object s attributes |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.