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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py | ShexShapeDefinitionParser.visitQualifier | def visitQualifier(self, ctx: ShExDocParser.QualifierContext):
""" qualifier: includeSet | extraPropertySet | KW_CLOSED """
if ctx.includeSet():
if self.shape.inherit is None:
self.shape.inherit = []
self.shape.inherit += [self.context.tripleexprlabel_to_iriref(te... | python | def visitQualifier(self, ctx: ShExDocParser.QualifierContext):
""" qualifier: includeSet | extraPropertySet | KW_CLOSED """
if ctx.includeSet():
if self.shape.inherit is None:
self.shape.inherit = []
self.shape.inherit += [self.context.tripleexprlabel_to_iriref(te... | [
"def",
"visitQualifier",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"QualifierContext",
")",
":",
"if",
"ctx",
".",
"includeSet",
"(",
")",
":",
"if",
"self",
".",
"shape",
".",
"inherit",
"is",
"None",
":",
"self",
".",
"shape",
".",
"inherit... | qualifier: includeSet | extraPropertySet | KW_CLOSED | [
"qualifier",
":",
"includeSet",
"|",
"extraPropertySet",
"|",
"KW_CLOSED"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_definition_parser.py#L74-L87 | train | visit Qualifier | qualifier| |
evolbioinfo/pastml | pastml/acr.py | reconstruct_ancestral_states | def reconstruct_ancestral_states(tree, character, states, prediction_method=MPPA, model=F81,
params=None, avg_br_len=None, num_nodes=None, num_tips=None,
force_joint=True):
"""
Reconstructs ancestral states for the given character on the given tr... | python | def reconstruct_ancestral_states(tree, character, states, prediction_method=MPPA, model=F81,
params=None, avg_br_len=None, num_nodes=None, num_tips=None,
force_joint=True):
"""
Reconstructs ancestral states for the given character on the given tr... | [
"def",
"reconstruct_ancestral_states",
"(",
"tree",
",",
"character",
",",
"states",
",",
"prediction_method",
"=",
"MPPA",
",",
"model",
"=",
"F81",
",",
"params",
"=",
"None",
",",
"avg_br_len",
"=",
"None",
",",
"num_nodes",
"=",
"None",
",",
"num_tips",
... | Reconstructs ancestral states for the given character on the given tree.
:param character: character whose ancestral states are to be reconstructed.
:type character: str
:param tree: tree whose ancestral state are to be reconstructed,
annotated with the feature specified as `character` containing n... | [
"Reconstructs",
"ancestral",
"states",
"for",
"the",
"given",
"character",
"on",
"the",
"given",
"tree",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/acr.py#L137-L197 | train | Reconstructs the ancestral states for a given character on the given tree. |
evolbioinfo/pastml | pastml/acr.py | acr | def acr(tree, df, prediction_method=MPPA, model=F81, column2parameters=None, force_joint=True):
"""
Reconstructs ancestral states for the given tree and
all the characters specified as columns of the given annotation dataframe.
:param df: dataframe indexed with tree node names
and containing ch... | python | def acr(tree, df, prediction_method=MPPA, model=F81, column2parameters=None, force_joint=True):
"""
Reconstructs ancestral states for the given tree and
all the characters specified as columns of the given annotation dataframe.
:param df: dataframe indexed with tree node names
and containing ch... | [
"def",
"acr",
"(",
"tree",
",",
"df",
",",
"prediction_method",
"=",
"MPPA",
",",
"model",
"=",
"F81",
",",
"column2parameters",
"=",
"None",
",",
"force_joint",
"=",
"True",
")",
":",
"for",
"c",
"in",
"df",
".",
"columns",
":",
"df",
"[",
"c",
"]... | Reconstructs ancestral states for the given tree and
all the characters specified as columns of the given annotation dataframe.
:param df: dataframe indexed with tree node names
and containing characters for which ACR should be performed as columns.
:type df: pandas.DataFrame
:param tree: tree ... | [
"Reconstructs",
"ancestral",
"states",
"for",
"the",
"given",
"tree",
"and",
"all",
"the",
"characters",
"specified",
"as",
"columns",
"of",
"the",
"given",
"annotation",
"dataframe",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/acr.py#L200-L276 | train | Reconstructs ancestral states for the given tree and a given annotation dataframe. |
evolbioinfo/pastml | pastml/acr.py | pastml_pipeline | def pastml_pipeline(tree, data, data_sep='\t', id_index=0,
columns=None, prediction_method=MPPA, model=F81, parameters=None,
name_column=None, date_column=None, tip_size_threshold=REASONABLE_NUMBER_OF_TIPS,
out_data=None, html_compressed=None, html=None, work_... | python | def pastml_pipeline(tree, data, data_sep='\t', id_index=0,
columns=None, prediction_method=MPPA, model=F81, parameters=None,
name_column=None, date_column=None, tip_size_threshold=REASONABLE_NUMBER_OF_TIPS,
out_data=None, html_compressed=None, html=None, work_... | [
"def",
"pastml_pipeline",
"(",
"tree",
",",
"data",
",",
"data_sep",
"=",
"'\\t'",
",",
"id_index",
"=",
"0",
",",
"columns",
"=",
"None",
",",
"prediction_method",
"=",
"MPPA",
",",
"model",
"=",
"F81",
",",
"parameters",
"=",
"None",
",",
"name_column"... | Applies PASTML to the given tree with the specified states and visualizes the result (as html maps).
:param tree: path to the input tree in newick format (must be rooted).
:type tree: str
:param data: path to the annotation file in tab/csv format with the first row containing the column names.
:type d... | [
"Applies",
"PASTML",
"to",
"the",
"given",
"tree",
"with",
"the",
"specified",
"states",
"and",
"visualizes",
"the",
"result",
"(",
"as",
"html",
"maps",
")",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/acr.py#L283-L451 | train | Applies PASTML to the given tree. |
evolbioinfo/pastml | pastml/acr.py | main | def main():
"""
Entry point, calling :py:func:`pastml.acr.pastml_pipeline` with command-line arguments.
:return: void
"""
import argparse
parser = argparse.ArgumentParser(description="Ancestral character reconstruction and visualisation "
"for r... | python | def main():
"""
Entry point, calling :py:func:`pastml.acr.pastml_pipeline` with command-line arguments.
:return: void
"""
import argparse
parser = argparse.ArgumentParser(description="Ancestral character reconstruction and visualisation "
"for r... | [
"def",
"main",
"(",
")",
":",
"import",
"argparse",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"description",
"=",
"\"Ancestral character reconstruction and visualisation \"",
"\"for rooted phylogenetic trees.\"",
",",
"prog",
"=",
"'pastml'",
")",
"tree_group... | Entry point, calling :py:func:`pastml.acr.pastml_pipeline` with command-line arguments.
:return: void | [
"Entry",
"point",
"calling",
":",
"py",
":",
"func",
":",
"pastml",
".",
"acr",
".",
"pastml_pipeline",
"with",
"command",
"-",
"line",
"arguments",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/acr.py#L612-L740 | train | Entry point for the main function of the main function of the main function of the main function. |
geophysics-ubonn/reda | lib/reda/utils/eit_fzj_utils.py | compute_correction_factors | def compute_correction_factors(data, true_conductivity, elem_file, elec_file):
"""Compute correction factors for 2D rhizotron geometries, following
Weigand and Kemna, 2017, Biogeosciences
https://doi.org/10.5194/bg-14-921-2017
Parameters
----------
data : :py:class:`pandas.DataFrame`
m... | python | def compute_correction_factors(data, true_conductivity, elem_file, elec_file):
"""Compute correction factors for 2D rhizotron geometries, following
Weigand and Kemna, 2017, Biogeosciences
https://doi.org/10.5194/bg-14-921-2017
Parameters
----------
data : :py:class:`pandas.DataFrame`
m... | [
"def",
"compute_correction_factors",
"(",
"data",
",",
"true_conductivity",
",",
"elem_file",
",",
"elec_file",
")",
":",
"settings",
"=",
"{",
"'rho'",
":",
"100",
",",
"'pha'",
":",
"0",
",",
"'elem'",
":",
"'elem.dat'",
",",
"'elec'",
":",
"'elec.dat'",
... | Compute correction factors for 2D rhizotron geometries, following
Weigand and Kemna, 2017, Biogeosciences
https://doi.org/10.5194/bg-14-921-2017
Parameters
----------
data : :py:class:`pandas.DataFrame`
measured data
true_conductivity : float
Conductivity in S/m
elem_file :... | [
"Compute",
"correction",
"factors",
"for",
"2D",
"rhizotron",
"geometries",
"following",
"Weigand",
"and",
"Kemna",
"2017",
"Biogeosciences"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/eit_fzj_utils.py#L12-L62 | train | Compute correction factors for 2D rhizotron geometries following
Weigand and Kemna 2017 2017 |
geophysics-ubonn/reda | lib/reda/utils/eit_fzj_utils.py | check_resistor_board_measurements | def check_resistor_board_measurements(data_file, reference_data_file=None,
create_plot=True, **kwargs):
""" To check basic system function a test board was built with multiple
resistors attached to for connectors each. Measurements can thus be
validated against known el... | python | def check_resistor_board_measurements(data_file, reference_data_file=None,
create_plot=True, **kwargs):
""" To check basic system function a test board was built with multiple
resistors attached to for connectors each. Measurements can thus be
validated against known el... | [
"def",
"check_resistor_board_measurements",
"(",
"data_file",
",",
"reference_data_file",
"=",
"None",
",",
"create_plot",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"# reference_data = np.loadtxt(reference_data_file)",
"# configs = reference_data[:, 0:4]",
"column_names... | To check basic system function a test board was built with multiple
resistors attached to for connectors each. Measurements can thus be
validated against known electrical (ohmic) resistances.
Note that the normal-reciprocal difference is not yet analyzed!
The referenc_data_file should have the followi... | [
"To",
"check",
"basic",
"system",
"function",
"a",
"test",
"board",
"was",
"built",
"with",
"multiple",
"resistors",
"attached",
"to",
"for",
"connectors",
"each",
".",
"Measurements",
"can",
"thus",
"be",
"validated",
"against",
"known",
"electrical",
"(",
"o... | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/eit_fzj_utils.py#L143-L270 | train | This function checks the basic system function of the resistor boards for resistor boards that are not yet built. |
evolbioinfo/pastml | pastml/visualisation/cytoscape_manager.py | get_scaling_function | def get_scaling_function(y_m, y_M, x_m, x_M):
"""
Returns a linear function y = k x + b, where y \in [m, M]
:param y_m:
:param y_M:
:param x_m:
:param x_M:
:return:
"""
if x_M <= x_m:
return lambda _: y_m
k = (y_M - y_m) / (x_M - x_m)
b = y_m - k * x_m
return lamb... | python | def get_scaling_function(y_m, y_M, x_m, x_M):
"""
Returns a linear function y = k x + b, where y \in [m, M]
:param y_m:
:param y_M:
:param x_m:
:param x_M:
:return:
"""
if x_M <= x_m:
return lambda _: y_m
k = (y_M - y_m) / (x_M - x_m)
b = y_m - k * x_m
return lamb... | [
"def",
"get_scaling_function",
"(",
"y_m",
",",
"y_M",
",",
"x_m",
",",
"x_M",
")",
":",
"if",
"x_M",
"<=",
"x_m",
":",
"return",
"lambda",
"_",
":",
"y_m",
"k",
"=",
"(",
"y_M",
"-",
"y_m",
")",
"/",
"(",
"x_M",
"-",
"x_m",
")",
"b",
"=",
"y... | Returns a linear function y = k x + b, where y \in [m, M]
:param y_m:
:param y_M:
:param x_m:
:param x_M:
:return: | [
"Returns",
"a",
"linear",
"function",
"y",
"=",
"k",
"x",
"+",
"b",
"where",
"y",
"\\",
"in",
"[",
"m",
"M",
"]",
":",
"param",
"y_m",
":",
":",
"param",
"y_M",
":",
":",
"param",
"x_m",
":",
":",
"param",
"x_M",
":",
":",
"return",
":"
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/visualisation/cytoscape_manager.py#L56-L69 | train | Returns a linear function y = k x + b where y = y_m x = x_M |
evolbioinfo/pastml | pastml/visualisation/cytoscape_manager.py | save_as_cytoscape_html | def save_as_cytoscape_html(tree, out_html, column2states, layout='dagre', name_feature='name',
name2colour=None, n2tooltip=None, years=None, is_compressed=True, n2date=None,
date_column='Dist. to root'):
"""
Converts a tree to an html representation using Cy... | python | def save_as_cytoscape_html(tree, out_html, column2states, layout='dagre', name_feature='name',
name2colour=None, n2tooltip=None, years=None, is_compressed=True, n2date=None,
date_column='Dist. to root'):
"""
Converts a tree to an html representation using Cy... | [
"def",
"save_as_cytoscape_html",
"(",
"tree",
",",
"out_html",
",",
"column2states",
",",
"layout",
"=",
"'dagre'",
",",
"name_feature",
"=",
"'name'",
",",
"name2colour",
"=",
"None",
",",
"n2tooltip",
"=",
"None",
",",
"years",
"=",
"None",
",",
"is_compre... | Converts a tree to an html representation using Cytoscape.js.
If categories are specified they are visualised as pie-charts inside the nodes,
given that each node contains features corresponding to these categories with values being the percentage.
For instance, given categories ['A', 'B', 'C'], a node wit... | [
"Converts",
"a",
"tree",
"to",
"an",
"html",
"representation",
"using",
"Cytoscape",
".",
"js",
"."
] | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/visualisation/cytoscape_manager.py#L245-L298 | train | Converts a tree to an html representation using Cytoscape. js. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/generate_shexj.py | do_parse | def do_parse(infilename: str, jsonfilename: Optional[str], rdffilename: Optional[str], rdffmt: str,
context: Optional[str] = None) -> bool:
"""
Parse the jsg in infilename and save the results in outfilename
:param infilename: name of the file containing the ShExC
:param jsonfilename: targe... | python | def do_parse(infilename: str, jsonfilename: Optional[str], rdffilename: Optional[str], rdffmt: str,
context: Optional[str] = None) -> bool:
"""
Parse the jsg in infilename and save the results in outfilename
:param infilename: name of the file containing the ShExC
:param jsonfilename: targe... | [
"def",
"do_parse",
"(",
"infilename",
":",
"str",
",",
"jsonfilename",
":",
"Optional",
"[",
"str",
"]",
",",
"rdffilename",
":",
"Optional",
"[",
"str",
"]",
",",
"rdffmt",
":",
"str",
",",
"context",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
"... | Parse the jsg in infilename and save the results in outfilename
:param infilename: name of the file containing the ShExC
:param jsonfilename: target ShExJ equivalent
:param rdffilename: target ShExR equivalent
:param rdffmt: target RDF format
:param context: @context to use for rdf generation. If No... | [
"Parse",
"the",
"jsg",
"in",
"infilename",
"and",
"save",
"the",
"results",
"in",
"outfilename",
":",
"param",
"infilename",
":",
"name",
"of",
"the",
"file",
"containing",
"the",
"ShExC",
":",
"param",
"jsonfilename",
":",
"target",
"ShExJ",
"equivalent",
"... | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/generate_shexj.py#L85-L106 | train | Parse the jsg in infilename and save the results in outfilename
|
shexSpec/grammar | parsers/python/pyshexc/parser_impl/generate_shexj.py | parse | def parse(input_: Union[str, FileStream], default_base: Optional[str]=None) -> Optional[Schema]:
"""
Parse the text in infile and return the resulting schema
:param input_: text or input stream to parse
:param default_base_: base URI for relative URI's in schema
:return: ShExJ Schema object. None i... | python | def parse(input_: Union[str, FileStream], default_base: Optional[str]=None) -> Optional[Schema]:
"""
Parse the text in infile and return the resulting schema
:param input_: text or input stream to parse
:param default_base_: base URI for relative URI's in schema
:return: ShExJ Schema object. None i... | [
"def",
"parse",
"(",
"input_",
":",
"Union",
"[",
"str",
",",
"FileStream",
"]",
",",
"default_base",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"Schema",
"]",
":",
"# Step 1: Tokenize the input stream",
"error_listener",
"=",... | Parse the text in infile and return the resulting schema
:param input_: text or input stream to parse
:param default_base_: base URI for relative URI's in schema
:return: ShExJ Schema object. None if error. | [
"Parse",
"the",
"text",
"in",
"infile",
"and",
"return",
"the",
"resulting",
"schema",
":",
"param",
"input_",
":",
"text",
"or",
"input",
"stream",
"to",
"parse",
":",
"param",
"default_base_",
":",
"base",
"URI",
"for",
"relative",
"URI",
"s",
"in",
"s... | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/generate_shexj.py#L109-L140 | train | Parse the input text and return the resulting schema. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/generate_shexj.py | rdf_suffix | def rdf_suffix(fmt: str) -> str:
""" Map the RDF format to the approproate suffix """
for k, v in SUFFIX_FORMAT_MAP.items():
if fmt == v:
return k
return 'rdf' | python | def rdf_suffix(fmt: str) -> str:
""" Map the RDF format to the approproate suffix """
for k, v in SUFFIX_FORMAT_MAP.items():
if fmt == v:
return k
return 'rdf' | [
"def",
"rdf_suffix",
"(",
"fmt",
":",
"str",
")",
"->",
"str",
":",
"for",
"k",
",",
"v",
"in",
"SUFFIX_FORMAT_MAP",
".",
"items",
"(",
")",
":",
"if",
"fmt",
"==",
"v",
":",
"return",
"k",
"return",
"'rdf'"
] | Map the RDF format to the approproate suffix | [
"Map",
"the",
"RDF",
"format",
"to",
"the",
"approproate",
"suffix"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/generate_shexj.py#L143-L148 | train | Map the RDF format to the approproate suffix |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/generate_shexj.py | genargs | def genargs() -> ArgumentParser:
"""
Create a command line parser
:return: parser
"""
parser = ArgumentParser()
parser.add_argument("infile", help="Input ShExC specification")
parser.add_argument("-nj", "--nojson", help="Do not produce json output", action="store_true")
parser.add_argume... | python | def genargs() -> ArgumentParser:
"""
Create a command line parser
:return: parser
"""
parser = ArgumentParser()
parser.add_argument("infile", help="Input ShExC specification")
parser.add_argument("-nj", "--nojson", help="Do not produce json output", action="store_true")
parser.add_argume... | [
"def",
"genargs",
"(",
")",
"->",
"ArgumentParser",
":",
"parser",
"=",
"ArgumentParser",
"(",
")",
"parser",
".",
"add_argument",
"(",
"\"infile\"",
",",
"help",
"=",
"\"Input ShExC specification\"",
")",
"parser",
".",
"add_argument",
"(",
"\"-nj\"",
",",
"\... | Create a command line parser
:return: parser | [
"Create",
"a",
"command",
"line",
"parser",
":",
"return",
":",
"parser"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/generate_shexj.py#L151-L167 | train | Create a command line parser for the
command line. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/generate_shexj.py | generate | def generate(argv: List[str]) -> bool:
"""
Transform ShExC to ShExJ
:param argv: Command line arguments
:return: True if successful
"""
opts = genargs().parse_args(argv)
filebase = os.path.dirname(opts.infile) + str(os.path.basename(opts.infile).rsplit('.', 1)[0])
if opts.nojson:
... | python | def generate(argv: List[str]) -> bool:
"""
Transform ShExC to ShExJ
:param argv: Command line arguments
:return: True if successful
"""
opts = genargs().parse_args(argv)
filebase = os.path.dirname(opts.infile) + str(os.path.basename(opts.infile).rsplit('.', 1)[0])
if opts.nojson:
... | [
"def",
"generate",
"(",
"argv",
":",
"List",
"[",
"str",
"]",
")",
"->",
"bool",
":",
"opts",
"=",
"genargs",
"(",
")",
".",
"parse_args",
"(",
"argv",
")",
"filebase",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"opts",
".",
"infile",
")",
"+",... | Transform ShExC to ShExJ
:param argv: Command line arguments
:return: True if successful | [
"Transform",
"ShExC",
"to",
"ShExJ",
":",
"param",
"argv",
":",
"Command",
"line",
"arguments",
":",
"return",
":",
"True",
"if",
"successful"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/generate_shexj.py#L170-L194 | train | Transform ShExC to ShExJ
|
geophysics-ubonn/reda | lib/reda/exporters/bert.py | export_bert | def export_bert(data, electrodes, filename):
"""Export to unified data format used in pyGIMLi & BERT.
Parameters
----------
data : :py:class:`pandas.DataFrame`
DataFrame with at least a, b, m, n and r.
electrodes : :py:class:`pandas.DataFrame`
DataFrame with electrode positions.
... | python | def export_bert(data, electrodes, filename):
"""Export to unified data format used in pyGIMLi & BERT.
Parameters
----------
data : :py:class:`pandas.DataFrame`
DataFrame with at least a, b, m, n and r.
electrodes : :py:class:`pandas.DataFrame`
DataFrame with electrode positions.
... | [
"def",
"export_bert",
"(",
"data",
",",
"electrodes",
",",
"filename",
")",
":",
"# Check for multiple timesteps",
"if",
"has_multiple_timesteps",
"(",
"data",
")",
":",
"for",
"i",
",",
"timestep",
"in",
"enumerate",
"(",
"split_timesteps",
"(",
"data",
")",
... | Export to unified data format used in pyGIMLi & BERT.
Parameters
----------
data : :py:class:`pandas.DataFrame`
DataFrame with at least a, b, m, n and r.
electrodes : :py:class:`pandas.DataFrame`
DataFrame with electrode positions.
filename : str
String of the output filenam... | [
"Export",
"to",
"unified",
"data",
"format",
"used",
"in",
"pyGIMLi",
"&",
"BERT",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/exporters/bert.py#L4-L73 | train | Export to unified data format used in pyGIMLi & BERT. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitShapeOr | def visitShapeOr(self, ctx: ShExDocParser.ShapeOrContext):
""" shapeOr: shapeAnd (KW_OR shapeAnd)* """
if len(ctx.shapeAnd()) > 1:
self.expr = ShapeOr(id=self.label, shapeExprs=[])
for sa in ctx.shapeAnd():
sep = ShexShapeExpressionParser(self.context)
... | python | def visitShapeOr(self, ctx: ShExDocParser.ShapeOrContext):
""" shapeOr: shapeAnd (KW_OR shapeAnd)* """
if len(ctx.shapeAnd()) > 1:
self.expr = ShapeOr(id=self.label, shapeExprs=[])
for sa in ctx.shapeAnd():
sep = ShexShapeExpressionParser(self.context)
... | [
"def",
"visitShapeOr",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ShapeOrContext",
")",
":",
"if",
"len",
"(",
"ctx",
".",
"shapeAnd",
"(",
")",
")",
">",
"1",
":",
"self",
".",
"expr",
"=",
"ShapeOr",
"(",
"id",
"=",
"self",
".",
"label"... | shapeOr: shapeAnd (KW_OR shapeAnd)* | [
"shapeOr",
":",
"shapeAnd",
"(",
"KW_OR",
"shapeAnd",
")",
"*"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L46-L55 | train | shapeAnd | | |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitInlineShapeOr | def visitInlineShapeOr(self, ctx: ShExDocParser.InlineShapeOrContext):
""" inlineShapeOr: inlineShapeAnd (KW_OR inlineShapeAnd)* """
if len(ctx.inlineShapeAnd()) > 1:
self.expr = ShapeOr(id=self.label, shapeExprs=[])
for sa in ctx.inlineShapeAnd():
sep = ShexShape... | python | def visitInlineShapeOr(self, ctx: ShExDocParser.InlineShapeOrContext):
""" inlineShapeOr: inlineShapeAnd (KW_OR inlineShapeAnd)* """
if len(ctx.inlineShapeAnd()) > 1:
self.expr = ShapeOr(id=self.label, shapeExprs=[])
for sa in ctx.inlineShapeAnd():
sep = ShexShape... | [
"def",
"visitInlineShapeOr",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"InlineShapeOrContext",
")",
":",
"if",
"len",
"(",
"ctx",
".",
"inlineShapeAnd",
"(",
")",
")",
">",
"1",
":",
"self",
".",
"expr",
"=",
"ShapeOr",
"(",
"id",
"=",
"self"... | inlineShapeOr: inlineShapeAnd (KW_OR inlineShapeAnd)* | [
"inlineShapeOr",
":",
"inlineShapeAnd",
"(",
"KW_OR",
"inlineShapeAnd",
")",
"*"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L57-L66 | train | inlineShapeAnd is a list of keywords? | | |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitShapeAnd | def visitShapeAnd(self, ctx: ShExDocParser.ShapeAndContext):
""" shapeAnd: shapeNot (KW_AND shapeNot)* """
if len(ctx.shapeNot()) > 1:
self.expr = ShapeAnd(id=self.label, shapeExprs=[])
for sa in ctx.shapeNot():
sep = ShexShapeExpressionParser(self.context)
... | python | def visitShapeAnd(self, ctx: ShExDocParser.ShapeAndContext):
""" shapeAnd: shapeNot (KW_AND shapeNot)* """
if len(ctx.shapeNot()) > 1:
self.expr = ShapeAnd(id=self.label, shapeExprs=[])
for sa in ctx.shapeNot():
sep = ShexShapeExpressionParser(self.context)
... | [
"def",
"visitShapeAnd",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ShapeAndContext",
")",
":",
"if",
"len",
"(",
"ctx",
".",
"shapeNot",
"(",
")",
")",
">",
"1",
":",
"self",
".",
"expr",
"=",
"ShapeAnd",
"(",
"id",
"=",
"self",
".",
"lab... | shapeAnd: shapeNot (KW_AND shapeNot)* | [
"shapeAnd",
":",
"shapeNot",
"(",
"KW_AND",
"shapeNot",
")",
"*"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L68-L77 | train | shapeAnd | shapeNot | | |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitInlineShapeAnd | def visitInlineShapeAnd(self, ctx: ShExDocParser.InlineShapeAndContext):
""" inlineShapeAnd: inlineShapeNot (KW_AND inlineShapeNot)* """
if len(ctx.inlineShapeNot()) > 1:
self.expr = ShapeAnd(id=self.label, shapeExprs=[])
for sa in ctx.inlineShapeNot():
sep = Shex... | python | def visitInlineShapeAnd(self, ctx: ShExDocParser.InlineShapeAndContext):
""" inlineShapeAnd: inlineShapeNot (KW_AND inlineShapeNot)* """
if len(ctx.inlineShapeNot()) > 1:
self.expr = ShapeAnd(id=self.label, shapeExprs=[])
for sa in ctx.inlineShapeNot():
sep = Shex... | [
"def",
"visitInlineShapeAnd",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"InlineShapeAndContext",
")",
":",
"if",
"len",
"(",
"ctx",
".",
"inlineShapeNot",
"(",
")",
")",
">",
"1",
":",
"self",
".",
"expr",
"=",
"ShapeAnd",
"(",
"id",
"=",
"se... | inlineShapeAnd: inlineShapeNot (KW_AND inlineShapeNot)* | [
"inlineShapeAnd",
":",
"inlineShapeNot",
"(",
"KW_AND",
"inlineShapeNot",
")",
"*"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L79-L88 | train | inlineShapeAnd is a wrapper for ShexShapeExpressionParser. inlineShapeAnd |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser._and_collapser | def _and_collapser(container: ShapeAnd, containee: shapeExpr) -> None:
""" For various nefarious reaons, the reference parser has decided to implement
And(And(a, b), c) --> And(a, b, c). We've got to do the same
"""
if isinstance(containee, ShapeAnd):
for expr in contain... | python | def _and_collapser(container: ShapeAnd, containee: shapeExpr) -> None:
""" For various nefarious reaons, the reference parser has decided to implement
And(And(a, b), c) --> And(a, b, c). We've got to do the same
"""
if isinstance(containee, ShapeAnd):
for expr in contain... | [
"def",
"_and_collapser",
"(",
"container",
":",
"ShapeAnd",
",",
"containee",
":",
"shapeExpr",
")",
"->",
"None",
":",
"if",
"isinstance",
"(",
"containee",
",",
"ShapeAnd",
")",
":",
"for",
"expr",
"in",
"containee",
".",
"shapeExprs",
":",
"container",
... | For various nefarious reaons, the reference parser has decided to implement
And(And(a, b), c) --> And(a, b, c). We've got to do the same | [
"For",
"various",
"nefarious",
"reaons",
"the",
"reference",
"parser",
"has",
"decided",
"to",
"implement",
"And",
"(",
"And",
"(",
"a",
"b",
")",
"c",
")",
"--",
">",
"And",
"(",
"a",
"b",
"c",
")",
".",
"We",
"ve",
"got",
"to",
"do",
"the",
"sa... | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L91-L99 | train | Collapser the containee with the container. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitShapeNot | def visitShapeNot(self, ctx: ShExDocParser.ShapeNotContext):
""" shapeNot: negation? shapeAtom """
if ctx.negation():
self.expr = ShapeNot(id=self.label)
sn = ShexShapeExpressionParser(self.context)
sn.visit(ctx.shapeAtom())
self.expr.shapeExpr = sn.expr i... | python | def visitShapeNot(self, ctx: ShExDocParser.ShapeNotContext):
""" shapeNot: negation? shapeAtom """
if ctx.negation():
self.expr = ShapeNot(id=self.label)
sn = ShexShapeExpressionParser(self.context)
sn.visit(ctx.shapeAtom())
self.expr.shapeExpr = sn.expr i... | [
"def",
"visitShapeNot",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ShapeNotContext",
")",
":",
"if",
"ctx",
".",
"negation",
"(",
")",
":",
"self",
".",
"expr",
"=",
"ShapeNot",
"(",
"id",
"=",
"self",
".",
"label",
")",
"sn",
"=",
"ShexSha... | shapeNot: negation? shapeAtom | [
"shapeNot",
":",
"negation?",
"shapeAtom"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L101-L109 | train | shapeNot is a helper method that creates a shapeNot expression if it is not a negation shapeAtom |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitInlineShapeNot | def visitInlineShapeNot(self, ctx: ShExDocParser.InlineShapeNotContext):
""" inlineShapeNot: negation? inlineShapeAtom """
if ctx.negation():
self.expr = ShapeNot(id=self.label)
sn = ShexShapeExpressionParser(self.context)
ctx.inlineShapeAtom()
sn.visit(ct... | python | def visitInlineShapeNot(self, ctx: ShExDocParser.InlineShapeNotContext):
""" inlineShapeNot: negation? inlineShapeAtom """
if ctx.negation():
self.expr = ShapeNot(id=self.label)
sn = ShexShapeExpressionParser(self.context)
ctx.inlineShapeAtom()
sn.visit(ct... | [
"def",
"visitInlineShapeNot",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"InlineShapeNotContext",
")",
":",
"if",
"ctx",
".",
"negation",
"(",
")",
":",
"self",
".",
"expr",
"=",
"ShapeNot",
"(",
"id",
"=",
"self",
".",
"label",
")",
"sn",
"="... | inlineShapeNot: negation? inlineShapeAtom | [
"inlineShapeNot",
":",
"negation?",
"inlineShapeAtom"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L111-L120 | train | inlineShapeNot is a helper method to create a shapeNot expression |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitShapeAtomNodeConstraint | def visitShapeAtomNodeConstraint(self, ctx: ShExDocParser.ShapeAtomNodeConstraintContext):
""" shapeAtomNodeConstraint: nodeConstraint shapeOrRef? # shapeAtomNodeConstraint """
nc = ShexNodeExpressionParser(self.context)
nc.visit(ctx.nodeConstraint())
if ctx.shapeOrRef():
s... | python | def visitShapeAtomNodeConstraint(self, ctx: ShExDocParser.ShapeAtomNodeConstraintContext):
""" shapeAtomNodeConstraint: nodeConstraint shapeOrRef? # shapeAtomNodeConstraint """
nc = ShexNodeExpressionParser(self.context)
nc.visit(ctx.nodeConstraint())
if ctx.shapeOrRef():
s... | [
"def",
"visitShapeAtomNodeConstraint",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ShapeAtomNodeConstraintContext",
")",
":",
"nc",
"=",
"ShexNodeExpressionParser",
"(",
"self",
".",
"context",
")",
"nc",
".",
"visit",
"(",
"ctx",
".",
"nodeConstraint",
... | shapeAtomNodeConstraint: nodeConstraint shapeOrRef? # shapeAtomNodeConstraint | [
"shapeAtomNodeConstraint",
":",
"nodeConstraint",
"shapeOrRef?",
"#",
"shapeAtomNodeConstraint"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L122-L137 | train | visit a shapeAtomNodeConstraintContext |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitShapeOrRef | def visitShapeOrRef(self, ctx: ShExDocParser.ShapeOrRefContext):
""" shapeOrRef: shapeDefinition | shapeRef """
if ctx.shapeDefinition():
from pyshexc.parser_impl.shex_shape_definition_parser import ShexShapeDefinitionParser
shdef_parser = ShexShapeDefinitionParser(self.context, ... | python | def visitShapeOrRef(self, ctx: ShExDocParser.ShapeOrRefContext):
""" shapeOrRef: shapeDefinition | shapeRef """
if ctx.shapeDefinition():
from pyshexc.parser_impl.shex_shape_definition_parser import ShexShapeDefinitionParser
shdef_parser = ShexShapeDefinitionParser(self.context, ... | [
"def",
"visitShapeOrRef",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ShapeOrRefContext",
")",
":",
"if",
"ctx",
".",
"shapeDefinition",
"(",
")",
":",
"from",
"pyshexc",
".",
"parser_impl",
".",
"shex_shape_definition_parser",
"import",
"ShexShapeDefinit... | shapeOrRef: shapeDefinition | shapeRef | [
"shapeOrRef",
":",
"shapeDefinition",
"|",
"shapeRef"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L154-L162 | train | shapeOrRef is a single entry point for shapeDefinition | shapeRef |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py | ShexShapeExpressionParser.visitInlineShapeOrRef | def visitInlineShapeOrRef(self, ctx: ShExDocParser.InlineShapeOrRefContext):
""" inlineShapeOrRef: inlineShapeDefinition | shapeRef """
if ctx.inlineShapeDefinition():
from pyshexc.parser_impl.shex_shape_definition_parser import ShexShapeDefinitionParser
shdef_parser = ShexShapeD... | python | def visitInlineShapeOrRef(self, ctx: ShExDocParser.InlineShapeOrRefContext):
""" inlineShapeOrRef: inlineShapeDefinition | shapeRef """
if ctx.inlineShapeDefinition():
from pyshexc.parser_impl.shex_shape_definition_parser import ShexShapeDefinitionParser
shdef_parser = ShexShapeD... | [
"def",
"visitInlineShapeOrRef",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"InlineShapeOrRefContext",
")",
":",
"if",
"ctx",
".",
"inlineShapeDefinition",
"(",
")",
":",
"from",
"pyshexc",
".",
"parser_impl",
".",
"shex_shape_definition_parser",
"import",
... | inlineShapeOrRef: inlineShapeDefinition | shapeRef | [
"inlineShapeOrRef",
":",
"inlineShapeDefinition",
"|",
"shapeRef"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_shape_expression_parser.py#L164-L172 | train | inlineShapeOrRef is a special case for inlineShapeDefinition | shapeRef |
cfobel/webcam-recorder | webcam_recorder/view.py | VideoSelectorView.reset | def reset(self, index=None):
'''
Reset the points for the specified index position. If no index is
specified, reset points for all point handlers.
'''
points_handler_count = len(self.registration_view.points)
if index is None:
indexes = range(points_handler_c... | python | def reset(self, index=None):
'''
Reset the points for the specified index position. If no index is
specified, reset points for all point handlers.
'''
points_handler_count = len(self.registration_view.points)
if index is None:
indexes = range(points_handler_c... | [
"def",
"reset",
"(",
"self",
",",
"index",
"=",
"None",
")",
":",
"points_handler_count",
"=",
"len",
"(",
"self",
".",
"registration_view",
".",
"points",
")",
"if",
"index",
"is",
"None",
":",
"indexes",
"=",
"range",
"(",
"points_handler_count",
")",
... | Reset the points for the specified index position. If no index is
specified, reset points for all point handlers. | [
"Reset",
"the",
"points",
"for",
"the",
"specified",
"index",
"position",
".",
"If",
"no",
"index",
"is",
"specified",
"reset",
"points",
"for",
"all",
"point",
"handlers",
"."
] | ffeb57c9044033fbea6372b3e642b83fd42dea87 | https://github.com/cfobel/webcam-recorder/blob/ffeb57c9044033fbea6372b3e642b83fd42dea87/webcam_recorder/view.py#L102-L118 | train | Reset the points for the specified index position. |
geophysics-ubonn/reda | lib/reda/importers/res2dinv.py | _read_file | def _read_file(filename):
"""
Read a res2dinv-file and return the header
Parameters
----------
filename : string
Data filename
Returns
------
type : int
type of array extracted from header
file_data : :py:class:`StringIO.StringIO`
content of file in a String... | python | def _read_file(filename):
"""
Read a res2dinv-file and return the header
Parameters
----------
filename : string
Data filename
Returns
------
type : int
type of array extracted from header
file_data : :py:class:`StringIO.StringIO`
content of file in a String... | [
"def",
"_read_file",
"(",
"filename",
")",
":",
"# read data",
"with",
"open",
"(",
"filename",
",",
"'r'",
")",
"as",
"fid2",
":",
"abem_data_orig",
"=",
"fid2",
".",
"read",
"(",
")",
"fid",
"=",
"StringIO",
"(",
")",
"fid",
".",
"write",
"(",
"abe... | Read a res2dinv-file and return the header
Parameters
----------
filename : string
Data filename
Returns
------
type : int
type of array extracted from header
file_data : :py:class:`StringIO.StringIO`
content of file in a StringIO object | [
"Read",
"a",
"res2dinv",
"-",
"file",
"and",
"return",
"the",
"header"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/res2dinv.py#L15-L46 | train | Read a res2dinv - file and return the header and the file object |
geophysics-ubonn/reda | lib/reda/importers/res2dinv.py | _read_general_type | def _read_general_type(content, settings):
"""Read a type 11 (general type) RES2DINV data block
Parameters
----------
content : :py:class:`StringIO.StringIO`
Content of data file
settings : dict
Settings for the importer. Not used at the moment
Returns
-------
"""
... | python | def _read_general_type(content, settings):
"""Read a type 11 (general type) RES2DINV data block
Parameters
----------
content : :py:class:`StringIO.StringIO`
Content of data file
settings : dict
Settings for the importer. Not used at the moment
Returns
-------
"""
... | [
"def",
"_read_general_type",
"(",
"content",
",",
"settings",
")",
":",
"header_raw",
"=",
"[",
"]",
"index",
"=",
"0",
"while",
"index",
"<",
"9",
":",
"line",
"=",
"content",
".",
"readline",
"(",
")",
"# filter comments",
"if",
"line",
".",
"startswit... | Read a type 11 (general type) RES2DINV data block
Parameters
----------
content : :py:class:`StringIO.StringIO`
Content of data file
settings : dict
Settings for the importer. Not used at the moment
Returns
------- | [
"Read",
"a",
"type",
"11",
"(",
"general",
"type",
")",
"RES2DINV",
"data",
"block"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/res2dinv.py#L49-L138 | train | Read a general RES2DINV data block. |
geophysics-ubonn/reda | lib/reda/importers/res2dinv.py | add_dat_file | def add_dat_file(filename, settings, container=None, **kwargs):
""" Read a RES2DINV-style file produced by the ABEM export program.
"""
# each type is read by a different function
importers = {
# general array type
11: _read_general_type,
}
file_type, content = _read_file(filena... | python | def add_dat_file(filename, settings, container=None, **kwargs):
""" Read a RES2DINV-style file produced by the ABEM export program.
"""
# each type is read by a different function
importers = {
# general array type
11: _read_general_type,
}
file_type, content = _read_file(filena... | [
"def",
"add_dat_file",
"(",
"filename",
",",
"settings",
",",
"container",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"# each type is read by a different function",
"importers",
"=",
"{",
"# general array type",
"11",
":",
"_read_general_type",
",",
"}",
"fil... | Read a RES2DINV-style file produced by the ABEM export program. | [
"Read",
"a",
"RES2DINV",
"-",
"style",
"file",
"produced",
"by",
"the",
"ABEM",
"export",
"program",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/res2dinv.py#L142-L170 | train | Read a RES2DINV - style file produced by the ABEM export program. |
lambdalisue/notify | src/notify/wizard.py | console_input | def console_input(default, validation=None, allow_empty=False):
"""
Get user input value from stdin
Parameters
----------
default : string
A default value. It will be used when user input nothing.
validation : callable
A validation function. The validation function must raise an... | python | def console_input(default, validation=None, allow_empty=False):
"""
Get user input value from stdin
Parameters
----------
default : string
A default value. It will be used when user input nothing.
validation : callable
A validation function. The validation function must raise an... | [
"def",
"console_input",
"(",
"default",
",",
"validation",
"=",
"None",
",",
"allow_empty",
"=",
"False",
")",
":",
"value",
"=",
"raw_input",
"(",
"\"> \"",
")",
"or",
"default",
"if",
"value",
"==",
"\"\"",
"and",
"not",
"allow_empty",
":",
"print",
"\... | Get user input value from stdin
Parameters
----------
default : string
A default value. It will be used when user input nothing.
validation : callable
A validation function. The validation function must raise an error
when validation has failed.
Returns
-------
stri... | [
"Get",
"user",
"input",
"value",
"from",
"stdin"
] | 1b6d7d1faa2cea13bfaa1f35130f279a0115e686 | https://github.com/lambdalisue/notify/blob/1b6d7d1faa2cea13bfaa1f35130f279a0115e686/src/notify/wizard.py#L22-L49 | train | Get user input value from stdin. |
south-coast-science/scs_core | src/scs_core/gas/a4_temp_comp.py | A4TempComp.correct | def correct(self, calib, temp, we_t, ae_t):
"""
Compute weC from weT, aeT
"""
if not A4TempComp.in_range(temp):
return None
if self.__algorithm == 1:
return self.__eq1(temp, we_t, ae_t)
if self.__algorithm == 2:
return self.__eq2(temp... | python | def correct(self, calib, temp, we_t, ae_t):
"""
Compute weC from weT, aeT
"""
if not A4TempComp.in_range(temp):
return None
if self.__algorithm == 1:
return self.__eq1(temp, we_t, ae_t)
if self.__algorithm == 2:
return self.__eq2(temp... | [
"def",
"correct",
"(",
"self",
",",
"calib",
",",
"temp",
",",
"we_t",
",",
"ae_t",
")",
":",
"if",
"not",
"A4TempComp",
".",
"in_range",
"(",
"temp",
")",
":",
"return",
"None",
"if",
"self",
".",
"__algorithm",
"==",
"1",
":",
"return",
"self",
"... | Compute weC from weT, aeT | [
"Compute",
"weC",
"from",
"weT",
"aeT"
] | a4152b0bbed6acbbf257e1bba6a912f6ebe578e5 | https://github.com/south-coast-science/scs_core/blob/a4152b0bbed6acbbf257e1bba6a912f6ebe578e5/src/scs_core/gas/a4_temp_comp.py#L82-L101 | train | Compute weC from weT aeT |
south-coast-science/scs_core | src/scs_core/gas/a4_temp_comp.py | A4TempComp.cf_t | def cf_t(self, temp):
"""
Compute the linear-interpolated temperature compensation factor.
"""
index = int((temp - A4TempComp.__MIN_TEMP) // A4TempComp.__INTERVAL) # index of start of interval
# on boundary...
if temp % A4TempComp.__INTERVAL == 0:
retu... | python | def cf_t(self, temp):
"""
Compute the linear-interpolated temperature compensation factor.
"""
index = int((temp - A4TempComp.__MIN_TEMP) // A4TempComp.__INTERVAL) # index of start of interval
# on boundary...
if temp % A4TempComp.__INTERVAL == 0:
retu... | [
"def",
"cf_t",
"(",
"self",
",",
"temp",
")",
":",
"index",
"=",
"int",
"(",
"(",
"temp",
"-",
"A4TempComp",
".",
"__MIN_TEMP",
")",
"//",
"A4TempComp",
".",
"__INTERVAL",
")",
"# index of start of interval",
"# on boundary...",
"if",
"temp",
"%",
"A4TempCom... | Compute the linear-interpolated temperature compensation factor. | [
"Compute",
"the",
"linear",
"-",
"interpolated",
"temperature",
"compensation",
"factor",
"."
] | a4152b0bbed6acbbf257e1bba6a912f6ebe578e5 | https://github.com/south-coast-science/scs_core/blob/a4152b0bbed6acbbf257e1bba6a912f6ebe578e5/src/scs_core/gas/a4_temp_comp.py#L152-L175 | train | Compute the linear - interpolated temperature compensation factor. |
cloudbase/python-hnvclient | hnv/common/utils.py | run_once | def run_once(function, state={}, errors={}):
"""A memoization decorator, whose purpose is to cache calls."""
@six.wraps(function)
def _wrapper(*args, **kwargs):
if function in errors:
# Deliberate use of LBYL.
six.reraise(*errors[function])
try:
return st... | python | def run_once(function, state={}, errors={}):
"""A memoization decorator, whose purpose is to cache calls."""
@six.wraps(function)
def _wrapper(*args, **kwargs):
if function in errors:
# Deliberate use of LBYL.
six.reraise(*errors[function])
try:
return st... | [
"def",
"run_once",
"(",
"function",
",",
"state",
"=",
"{",
"}",
",",
"errors",
"=",
"{",
"}",
")",
":",
"@",
"six",
".",
"wraps",
"(",
"function",
")",
"def",
"_wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"function",
"... | A memoization decorator, whose purpose is to cache calls. | [
"A",
"memoization",
"decorator",
"whose",
"purpose",
"is",
"to",
"cache",
"calls",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/common/utils.py#L187-L204 | train | A memoization decorator that can be used to cache calls. |
cloudbase/python-hnvclient | hnv/common/utils.py | get_client | def get_client(url, username, password, allow_insecure, ca_bundle):
"""Create a new client for the HNV REST API."""
return _HNVClient(url, username, password, allow_insecure, ca_bundle) | python | def get_client(url, username, password, allow_insecure, ca_bundle):
"""Create a new client for the HNV REST API."""
return _HNVClient(url, username, password, allow_insecure, ca_bundle) | [
"def",
"get_client",
"(",
"url",
",",
"username",
",",
"password",
",",
"allow_insecure",
",",
"ca_bundle",
")",
":",
"return",
"_HNVClient",
"(",
"url",
",",
"username",
",",
"password",
",",
"allow_insecure",
",",
"ca_bundle",
")"
] | Create a new client for the HNV REST API. | [
"Create",
"a",
"new",
"client",
"for",
"the",
"HNV",
"REST",
"API",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/common/utils.py#L208-L210 | train | Create a new client for the HNV REST API. |
cloudbase/python-hnvclient | hnv/common/utils.py | _HNVClient._session | def _session(self):
"""The current session used by the client.
The Session object allows you to persist certain parameters across
requests. It also persists cookies across all requests made from
the Session instance, and will use urllib3's connection pooling.
So if you're making... | python | def _session(self):
"""The current session used by the client.
The Session object allows you to persist certain parameters across
requests. It also persists cookies across all requests made from
the Session instance, and will use urllib3's connection pooling.
So if you're making... | [
"def",
"_session",
"(",
"self",
")",
":",
"if",
"self",
".",
"_http_session",
"is",
"None",
":",
"self",
".",
"_http_session",
"=",
"requests",
".",
"Session",
"(",
")",
"self",
".",
"_http_session",
".",
"headers",
".",
"update",
"(",
"self",
".",
"_g... | The current session used by the client.
The Session object allows you to persist certain parameters across
requests. It also persists cookies across all requests made from
the Session instance, and will use urllib3's connection pooling.
So if you're making several requests to the same h... | [
"The",
"current",
"session",
"used",
"by",
"the",
"client",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/common/utils.py#L59-L79 | train | Returns a new requests. Session object that can be used to access the current session. |
cloudbase/python-hnvclient | hnv/common/utils.py | _HNVClient.get_resource | def get_resource(self, path):
"""Getting the required information from the API."""
response = self._http_request(path)
try:
return response.json()
except ValueError:
raise exception.ServiceException("Invalid service response.") | python | def get_resource(self, path):
"""Getting the required information from the API."""
response = self._http_request(path)
try:
return response.json()
except ValueError:
raise exception.ServiceException("Invalid service response.") | [
"def",
"get_resource",
"(",
"self",
",",
"path",
")",
":",
"response",
"=",
"self",
".",
"_http_request",
"(",
"path",
")",
"try",
":",
"return",
"response",
".",
"json",
"(",
")",
"except",
"ValueError",
":",
"raise",
"exception",
".",
"ServiceException",... | Getting the required information from the API. | [
"Getting",
"the",
"required",
"information",
"from",
"the",
"API",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/common/utils.py#L164-L170 | train | Gets the required information from the API. |
cloudbase/python-hnvclient | hnv/common/utils.py | _HNVClient.update_resource | def update_resource(self, path, data, if_match=None):
"""Update the required resource."""
response = self._http_request(resource=path, method="PUT", body=data,
if_match=if_match)
try:
return response.json()
except ValueError:
... | python | def update_resource(self, path, data, if_match=None):
"""Update the required resource."""
response = self._http_request(resource=path, method="PUT", body=data,
if_match=if_match)
try:
return response.json()
except ValueError:
... | [
"def",
"update_resource",
"(",
"self",
",",
"path",
",",
"data",
",",
"if_match",
"=",
"None",
")",
":",
"response",
"=",
"self",
".",
"_http_request",
"(",
"resource",
"=",
"path",
",",
"method",
"=",
"\"PUT\"",
",",
"body",
"=",
"data",
",",
"if_matc... | Update the required resource. | [
"Update",
"the",
"required",
"resource",
"."
] | b019452af01db22629809b8930357a2ebf6494be | https://github.com/cloudbase/python-hnvclient/blob/b019452af01db22629809b8930357a2ebf6494be/hnv/common/utils.py#L172-L179 | train | Update the required resource. |
Metatab/geoid | geoid/civick.py | GVid.summarize | def summarize(self):
"""Convert all of the values to their max values. This form is used to represent the summary level"""
s = str(self.allval())
return self.parse(s[:2]+ ''.join(['Z']*len(s[2:]))) | python | def summarize(self):
"""Convert all of the values to their max values. This form is used to represent the summary level"""
s = str(self.allval())
return self.parse(s[:2]+ ''.join(['Z']*len(s[2:]))) | [
"def",
"summarize",
"(",
"self",
")",
":",
"s",
"=",
"str",
"(",
"self",
".",
"allval",
"(",
")",
")",
"return",
"self",
".",
"parse",
"(",
"s",
"[",
":",
"2",
"]",
"+",
"''",
".",
"join",
"(",
"[",
"'Z'",
"]",
"*",
"len",
"(",
"s",
"[",
... | Convert all of the values to their max values. This form is used to represent the summary level | [
"Convert",
"all",
"of",
"the",
"values",
"to",
"their",
"max",
"values",
".",
"This",
"form",
"is",
"used",
"to",
"represent",
"the",
"summary",
"level"
] | 4b7769406b00e59376fb6046b42a2f8ed706b33b | https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/civick.py#L41-L46 | train | Convert all of the values to their max values. This form is used to represent the summary level |
geophysics-ubonn/reda | lib/reda/utils/filter_config_types.py | _filter_schlumberger | def _filter_schlumberger(configs):
"""Filter Schlumberger configurations
Schlumberger configurations are selected using the following criteria:
* For a given voltage dipole, there need to be at least two current
injections with electrodes located on the left and the right of the
voltage dipole... | python | def _filter_schlumberger(configs):
"""Filter Schlumberger configurations
Schlumberger configurations are selected using the following criteria:
* For a given voltage dipole, there need to be at least two current
injections with electrodes located on the left and the right of the
voltage dipole... | [
"def",
"_filter_schlumberger",
"(",
"configs",
")",
":",
"# sort configs",
"configs_sorted",
"=",
"np",
".",
"hstack",
"(",
"(",
"np",
".",
"sort",
"(",
"configs",
"[",
":",
",",
"0",
":",
"2",
"]",
",",
"axis",
"=",
"1",
")",
",",
"np",
".",
"sort... | Filter Schlumberger configurations
Schlumberger configurations are selected using the following criteria:
* For a given voltage dipole, there need to be at least two current
injections with electrodes located on the left and the right of the
voltage dipole.
* The distance between the current e... | [
"Filter",
"Schlumberger",
"configurations"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/filter_config_types.py#L17-L97 | train | Filter Schlumberger configurations based on the given configurations. |
geophysics-ubonn/reda | lib/reda/utils/filter_config_types.py | _filter_dipole_dipole | def _filter_dipole_dipole(configs):
"""Filter dipole-dipole configurations
A dipole-dipole configuration is defined using the following criteria:
* equal distance between the two current electrodes and between the two
voltage electrodes
* no overlap of dipoles
Parameters
---... | python | def _filter_dipole_dipole(configs):
"""Filter dipole-dipole configurations
A dipole-dipole configuration is defined using the following criteria:
* equal distance between the two current electrodes and between the two
voltage electrodes
* no overlap of dipoles
Parameters
---... | [
"def",
"_filter_dipole_dipole",
"(",
"configs",
")",
":",
"# check that dipoles have equal size",
"dist_ab",
"=",
"np",
".",
"abs",
"(",
"configs",
"[",
":",
",",
"0",
"]",
"-",
"configs",
"[",
":",
",",
"1",
"]",
")",
"dist_mn",
"=",
"np",
".",
"abs",
... | Filter dipole-dipole configurations
A dipole-dipole configuration is defined using the following criteria:
* equal distance between the two current electrodes and between the two
voltage electrodes
* no overlap of dipoles
Parameters
----------
configs: numpy.ndarray
... | [
"Filter",
"dipole",
"-",
"dipole",
"configurations"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/filter_config_types.py#L100-L155 | train | Filter dipole - dipole configurations based on the given configurations. |
geophysics-ubonn/reda | lib/reda/utils/filter_config_types.py | _sort_dd_skips | def _sort_dd_skips(configs, dd_indices_all):
"""Given a set of dipole-dipole configurations, sort them according to
their current skip.
Parameters
----------
configs: Nx4 numpy.ndarray
Dipole-Dipole configurations
Returns
-------
dd_configs_sorted: dict
dictionary with ... | python | def _sort_dd_skips(configs, dd_indices_all):
"""Given a set of dipole-dipole configurations, sort them according to
their current skip.
Parameters
----------
configs: Nx4 numpy.ndarray
Dipole-Dipole configurations
Returns
-------
dd_configs_sorted: dict
dictionary with ... | [
"def",
"_sort_dd_skips",
"(",
"configs",
",",
"dd_indices_all",
")",
":",
"config_current_skips",
"=",
"np",
".",
"abs",
"(",
"configs",
"[",
":",
",",
"1",
"]",
"-",
"configs",
"[",
":",
",",
"0",
"]",
")",
"if",
"np",
".",
"all",
"(",
"np",
".",
... | Given a set of dipole-dipole configurations, sort them according to
their current skip.
Parameters
----------
configs: Nx4 numpy.ndarray
Dipole-Dipole configurations
Returns
-------
dd_configs_sorted: dict
dictionary with the skip as keys, and arrays/lists with indices to
... | [
"Given",
"a",
"set",
"of",
"dipole",
"-",
"dipole",
"configurations",
"sort",
"them",
"according",
"to",
"their",
"current",
"skip",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/filter_config_types.py#L158-L189 | train | Given a set of dipole - dipole configurations sort them according to
their current skip. |
geophysics-ubonn/reda | lib/reda/utils/filter_config_types.py | filter | def filter(configs, settings):
"""Main entry function to filtering configuration types
Parameters
----------
configs: Nx4 array
array containing A-B-M-N configurations
settings: dict
'only_types': ['dd', 'other'], # filter only for those types
Returns
-------
dict
... | python | def filter(configs, settings):
"""Main entry function to filtering configuration types
Parameters
----------
configs: Nx4 array
array containing A-B-M-N configurations
settings: dict
'only_types': ['dd', 'other'], # filter only for those types
Returns
-------
dict
... | [
"def",
"filter",
"(",
"configs",
",",
"settings",
")",
":",
"if",
"isinstance",
"(",
"configs",
",",
"pd",
".",
"DataFrame",
")",
":",
"configs",
"=",
"configs",
"[",
"[",
"'a'",
",",
"'b'",
",",
"'m'",
",",
"'n'",
"]",
"]",
".",
"values",
"# assig... | Main entry function to filtering configuration types
Parameters
----------
configs: Nx4 array
array containing A-B-M-N configurations
settings: dict
'only_types': ['dd', 'other'], # filter only for those types
Returns
-------
dict
results dict containing filter res... | [
"Main",
"entry",
"function",
"to",
"filtering",
"configuration",
"types"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/utils/filter_config_types.py#L192-L241 | train | Filter the configuration types for all registered A - B - M - N configurations. |
Starlink/palpy | support/sst2pydoc.py | read_prologs | def read_prologs(filename):
"""
Given a filename, search for SST prologues
and returns a dict where the keys are the name of the
prolog (from the "Name" field) and the keys are another
dict with keys correspding fo the SST labels in lowercase.
prologs = read_prologs( filename )
Common SST ... | python | def read_prologs(filename):
"""
Given a filename, search for SST prologues
and returns a dict where the keys are the name of the
prolog (from the "Name" field) and the keys are another
dict with keys correspding fo the SST labels in lowercase.
prologs = read_prologs( filename )
Common SST ... | [
"def",
"read_prologs",
"(",
"filename",
")",
":",
"results",
"=",
"{",
"}",
"prolog",
"=",
"{",
"}",
"heading_re",
"=",
"re",
".",
"compile",
"(",
"r\"^\\* ([A-Z].*):$\"",
")",
"heading",
"=",
"\"\"",
"content",
"=",
"\"\"",
"counter",
"=",
"0",
"for",
... | Given a filename, search for SST prologues
and returns a dict where the keys are the name of the
prolog (from the "Name" field) and the keys are another
dict with keys correspding fo the SST labels in lowercase.
prologs = read_prologs( filename )
Common SST labels are: name, purpose, lanugage, inv... | [
"Given",
"a",
"filename",
"search",
"for",
"SST",
"prologues",
"and",
"returns",
"a",
"dict",
"where",
"the",
"keys",
"are",
"the",
"name",
"of",
"the",
"prolog",
"(",
"from",
"the",
"Name",
"field",
")",
"and",
"the",
"keys",
"are",
"another",
"dict",
... | a7ad77058614a93b29a004bbad6bc0e61c73b6e0 | https://github.com/Starlink/palpy/blob/a7ad77058614a93b29a004bbad6bc0e61c73b6e0/support/sst2pydoc.py#L34-L107 | train | Given a filename search for SST prologues
and returns a dict where the keys are the name of the SST prolog and the keys are the content of the SST prologues containing the SST labels. |
geophysics-ubonn/reda | lib/reda/exporters/crtomo.py | save_block_to_crt | def save_block_to_crt(filename, group, norrec='all', store_errors=False):
"""Save a dataset to a CRTomo-compatible .crt file
Parameters
----------
filename : string
Output filename
group : pandas.group
Data group
norrec : string
Which data to export Possible values: all|... | python | def save_block_to_crt(filename, group, norrec='all', store_errors=False):
"""Save a dataset to a CRTomo-compatible .crt file
Parameters
----------
filename : string
Output filename
group : pandas.group
Data group
norrec : string
Which data to export Possible values: all|... | [
"def",
"save_block_to_crt",
"(",
"filename",
",",
"group",
",",
"norrec",
"=",
"'all'",
",",
"store_errors",
"=",
"False",
")",
":",
"if",
"norrec",
"!=",
"'all'",
":",
"group",
"=",
"group",
".",
"query",
"(",
"'norrec == \"{0}\"'",
".",
"format",
"(",
... | Save a dataset to a CRTomo-compatible .crt file
Parameters
----------
filename : string
Output filename
group : pandas.group
Data group
norrec : string
Which data to export Possible values: all|nor|rec
store_errors : bool
If true, store errors of the data in a se... | [
"Save",
"a",
"dataset",
"to",
"a",
"CRTomo",
"-",
"compatible",
".",
"crt",
"file"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/exporters/crtomo.py#L7-L53 | train | Save a block of data to a CRTomo - compatible. crt file. |
geophysics-ubonn/reda | lib/reda/exporters/crtomo.py | write_files_to_directory | def write_files_to_directory(df, directory, **kwargs):
"""Write sEIT data ta files. Data of each frequency is written in a
separate file that conforms to the CRMod/CRTomo standard, and can directly
be used for inversions using CRTomo.
Parameters
----------
df : pandas.DataFrame
Data
... | python | def write_files_to_directory(df, directory, **kwargs):
"""Write sEIT data ta files. Data of each frequency is written in a
separate file that conforms to the CRMod/CRTomo standard, and can directly
be used for inversions using CRTomo.
Parameters
----------
df : pandas.DataFrame
Data
... | [
"def",
"write_files_to_directory",
"(",
"df",
",",
"directory",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"'frequency'",
"in",
"df",
".",
"columns",
":",
"group_key",
"=",
"'frequency'",
"elif",
"'frequency_[Hz]'",
"in",
"df",
".",
"columns",
":",
"group_key"... | Write sEIT data ta files. Data of each frequency is written in a
separate file that conforms to the CRMod/CRTomo standard, and can directly
be used for inversions using CRTomo.
Parameters
----------
df : pandas.DataFrame
Data
directory : string
Output directory. Will be created ... | [
"Write",
"sEIT",
"data",
"ta",
"files",
".",
"Data",
"of",
"each",
"frequency",
"is",
"written",
"in",
"a",
"separate",
"file",
"that",
"conforms",
"to",
"the",
"CRMod",
"/",
"CRTomo",
"standard",
"and",
"can",
"directly",
"be",
"used",
"for",
"inversions"... | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/exporters/crtomo.py#L56-L116 | train | Write sEIT data ta files to a directory. |
geophysics-ubonn/reda | lib/reda/eis/units.py | get_label | def get_label(parameter, ptype, flavor=None, mpl=None):
"""Return the label of a given SIP parameter
Parameters
----------
parameter: string
type of parameter, e.g. rmag|rpha|cre|cim
ptype: string
material|meas. Either return the material property (e.g. resistivity)
or the m... | python | def get_label(parameter, ptype, flavor=None, mpl=None):
"""Return the label of a given SIP parameter
Parameters
----------
parameter: string
type of parameter, e.g. rmag|rpha|cre|cim
ptype: string
material|meas. Either return the material property (e.g. resistivity)
or the m... | [
"def",
"get_label",
"(",
"parameter",
",",
"ptype",
",",
"flavor",
"=",
"None",
",",
"mpl",
"=",
"None",
")",
":",
"# determine flavor",
"if",
"flavor",
"is",
"not",
"None",
":",
"if",
"flavor",
"not",
"in",
"(",
"'latex'",
",",
"'mathml'",
")",
":",
... | Return the label of a given SIP parameter
Parameters
----------
parameter: string
type of parameter, e.g. rmag|rpha|cre|cim
ptype: string
material|meas. Either return the material property (e.g. resistivity)
or the measurement parameter (e.g., impedance)
flavor: string, opti... | [
"Return",
"the",
"label",
"of",
"a",
"given",
"SIP",
"parameter"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/units.py#L47-L90 | train | Returns the label of a given parameter |
geophysics-ubonn/reda | lib/reda/eis/plots.py | sip_response._add_labels | def _add_labels(self, axes, dtype):
"""Given a 2x2 array of axes, add x and y labels
Parameters
----------
axes: numpy.ndarray, 2x2
A numpy array containing the four principal axes of an SIP plot
dtype: string
Can be either 'rho' or 'r', indicating the ty... | python | def _add_labels(self, axes, dtype):
"""Given a 2x2 array of axes, add x and y labels
Parameters
----------
axes: numpy.ndarray, 2x2
A numpy array containing the four principal axes of an SIP plot
dtype: string
Can be either 'rho' or 'r', indicating the ty... | [
"def",
"_add_labels",
"(",
"self",
",",
"axes",
",",
"dtype",
")",
":",
"for",
"ax",
"in",
"axes",
"[",
"1",
",",
":",
"]",
".",
"flat",
":",
"ax",
".",
"set_xlabel",
"(",
"'frequency [Hz]'",
")",
"if",
"dtype",
"==",
"'rho'",
":",
"axes",
"[",
"... | Given a 2x2 array of axes, add x and y labels
Parameters
----------
axes: numpy.ndarray, 2x2
A numpy array containing the four principal axes of an SIP plot
dtype: string
Can be either 'rho' or 'r', indicating the type of data that is
plotted: 'rho' s... | [
"Given",
"a",
"2x2",
"array",
"of",
"axes",
"add",
"x",
"and",
"y",
"labels"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/plots.py#L78-L108 | train | Adds x and y labels to the axes that are used to plot the logarithmic logarithm. |
geophysics-ubonn/reda | lib/reda/eis/plots.py | sip_response._plot | def _plot(self, title=None, reciprocal=None, limits=None, dtype='rho',
**kwargs):
"""Standard plot of spectrum
Parameters
----------
title: string|None, optional
Title of plot
reciprocal: sip_response object|None, optional
If provided, plot ... | python | def _plot(self, title=None, reciprocal=None, limits=None, dtype='rho',
**kwargs):
"""Standard plot of spectrum
Parameters
----------
title: string|None, optional
Title of plot
reciprocal: sip_response object|None, optional
If provided, plot ... | [
"def",
"_plot",
"(",
"self",
",",
"title",
"=",
"None",
",",
"reciprocal",
"=",
"None",
",",
"limits",
"=",
"None",
",",
"dtype",
"=",
"'rho'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"limits",
"is",
"None",
":",
"limits",
"=",
"{",
"}",
"fig",
... | Standard plot of spectrum
Parameters
----------
title: string|None, optional
Title of plot
reciprocal: sip_response object|None, optional
If provided, plot this spectrum with another color
limits: dict|None, optional
used to set ylimits of the... | [
"Standard",
"plot",
"of",
"spectrum"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/plots.py#L110-L248 | train | General function to plot the object of the specific type of object. |
geophysics-ubonn/reda | lib/reda/eis/plots.py | sip_response.plot | def plot(self, filename, title=None, reciprocal=None, limits=None,
dtype='rho', return_fig=False, **kwargs):
"""Standard plot of spectrum
Parameters
----------
filename: string
Output filename. Include the ending to specify the filetype
(usually .pdf... | python | def plot(self, filename, title=None, reciprocal=None, limits=None,
dtype='rho', return_fig=False, **kwargs):
"""Standard plot of spectrum
Parameters
----------
filename: string
Output filename. Include the ending to specify the filetype
(usually .pdf... | [
"def",
"plot",
"(",
"self",
",",
"filename",
",",
"title",
"=",
"None",
",",
"reciprocal",
"=",
"None",
",",
"limits",
"=",
"None",
",",
"dtype",
"=",
"'rho'",
",",
"return_fig",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"fig",
",",
"axes",
... | Standard plot of spectrum
Parameters
----------
filename: string
Output filename. Include the ending to specify the filetype
(usually .pdf or .png)
title: string, optional
Title for the plot
reciprocal: :class:`reda.eis.plots.sip_response`, op... | [
"Standard",
"plot",
"of",
"spectrum"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/plots.py#L250-L321 | train | Plot the current state of the object in the file. |
geophysics-ubonn/reda | lib/reda/eis/plots.py | multi_sip_response.add | def add(self, response, label=None):
"""add one response object to the list
"""
if not isinstance(response, sip_response.sip_response):
raise Exception(
'can only add sip_reponse.sip_response objects'
)
self.objects.append(response)
if lab... | python | def add(self, response, label=None):
"""add one response object to the list
"""
if not isinstance(response, sip_response.sip_response):
raise Exception(
'can only add sip_reponse.sip_response objects'
)
self.objects.append(response)
if lab... | [
"def",
"add",
"(",
"self",
",",
"response",
",",
"label",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"response",
",",
"sip_response",
".",
"sip_response",
")",
":",
"raise",
"Exception",
"(",
"'can only add sip_reponse.sip_response objects'",
")",
... | add one response object to the list | [
"add",
"one",
"response",
"object",
"to",
"the",
"list"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/plots.py#L358-L370 | train | add one response object to the list |
geophysics-ubonn/reda | lib/reda/eis/plots.py | multi_sip_response.plot_rpha | def plot_rpha(self, filename, pmin=None, pmax=None, title=None):
"""plot all resistance/resistivity phase spectra
"""
cmap = mpl.cm.get_cmap('viridis')
SM = mpl.cm.ScalarMappable(norm=None, cmap=cmap)
colors = SM.to_rgba(np.linspace(0, 1, len(self.objects)))
fig, ax = plt... | python | def plot_rpha(self, filename, pmin=None, pmax=None, title=None):
"""plot all resistance/resistivity phase spectra
"""
cmap = mpl.cm.get_cmap('viridis')
SM = mpl.cm.ScalarMappable(norm=None, cmap=cmap)
colors = SM.to_rgba(np.linspace(0, 1, len(self.objects)))
fig, ax = plt... | [
"def",
"plot_rpha",
"(",
"self",
",",
"filename",
",",
"pmin",
"=",
"None",
",",
"pmax",
"=",
"None",
",",
"title",
"=",
"None",
")",
":",
"cmap",
"=",
"mpl",
".",
"cm",
".",
"get_cmap",
"(",
"'viridis'",
")",
"SM",
"=",
"mpl",
".",
"cm",
".",
... | plot all resistance/resistivity phase spectra | [
"plot",
"all",
"resistance",
"/",
"resistivity",
"phase",
"spectra"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/plots.py#L409-L434 | train | plot all resistance and resistivity phase spectra |
evolbioinfo/pastml | pastml/file.py | get_pastml_parameter_file | def get_pastml_parameter_file(method, model, column):
"""
Get the filename where the PastML parameters are saved
(for non-ML methods and input parameters will be None, as they have no parameters).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: ... | python | def get_pastml_parameter_file(method, model, column):
"""
Get the filename where the PastML parameters are saved
(for non-ML methods and input parameters will be None, as they have no parameters).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: ... | [
"def",
"get_pastml_parameter_file",
"(",
"method",
",",
"model",
",",
"column",
")",
":",
"ml",
"=",
"is_ml",
"(",
"method",
")",
"template",
"=",
"PASTML_ML_PARAMS_TAB",
"if",
"ml",
"else",
"PASTML_MP_PARAMS_TAB",
"column",
",",
"method",
"=",
"get_column_metho... | Get the filename where the PastML parameters are saved
(for non-ML methods and input parameters will be None, as they have no parameters).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: str, the ancestral state prediction method used by PASTML.
:pa... | [
"Get",
"the",
"filename",
"where",
"the",
"PastML",
"parameters",
"are",
"saved",
"(",
"for",
"non",
"-",
"ML",
"methods",
"and",
"input",
"parameters",
"will",
"be",
"None",
"as",
"they",
"have",
"no",
"parameters",
")",
".",
"This",
"file",
"is",
"insi... | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/file.py#L28-L42 | train | Get the filename where the PastML parameters are saved. |
evolbioinfo/pastml | pastml/file.py | get_pastml_marginal_prob_file | def get_pastml_marginal_prob_file(method, model, column):
"""
Get the filename where the PastML marginal probabilities of node states are saved (will be None for non-marginal methods).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: str, the ancestr... | python | def get_pastml_marginal_prob_file(method, model, column):
"""
Get the filename where the PastML marginal probabilities of node states are saved (will be None for non-marginal methods).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: str, the ancestr... | [
"def",
"get_pastml_marginal_prob_file",
"(",
"method",
",",
"model",
",",
"column",
")",
":",
"if",
"not",
"is_marginal",
"(",
"method",
")",
":",
"return",
"None",
"column",
",",
"method",
"=",
"get_column_method",
"(",
"column",
",",
"method",
")",
"return... | Get the filename where the PastML marginal probabilities of node states are saved (will be None for non-marginal methods).
This file is inside the work_dir that can be specified for the pastml_pipeline method.
:param method: str, the ancestral state prediction method used by PASTML.
:param model: str, the ... | [
"Get",
"the",
"filename",
"where",
"the",
"PastML",
"marginal",
"probabilities",
"of",
"node",
"states",
"are",
"saved",
"(",
"will",
"be",
"None",
"for",
"non",
"-",
"marginal",
"methods",
")",
".",
"This",
"file",
"is",
"inside",
"the",
"work_dir",
"that... | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/file.py#L76-L89 | train | Get the filename where the PastML marginal probabilities of node states are saved. |
geophysics-ubonn/reda | lib/reda/eis/convert.py | split_data | def split_data(data, squeeze=False):
"""
Split 1D or 2D into two parts, using the last axis
Parameters
----------
data:
squeeze : squeeze results to remove unnecessary dimensions
"""
vdata = np.atleast_2d(data)
nr_freqs = int(vdata.shape[1] / 2)
part1 = vdata[:, 0:nr_freqs]
... | python | def split_data(data, squeeze=False):
"""
Split 1D or 2D into two parts, using the last axis
Parameters
----------
data:
squeeze : squeeze results to remove unnecessary dimensions
"""
vdata = np.atleast_2d(data)
nr_freqs = int(vdata.shape[1] / 2)
part1 = vdata[:, 0:nr_freqs]
... | [
"def",
"split_data",
"(",
"data",
",",
"squeeze",
"=",
"False",
")",
":",
"vdata",
"=",
"np",
".",
"atleast_2d",
"(",
"data",
")",
"nr_freqs",
"=",
"int",
"(",
"vdata",
".",
"shape",
"[",
"1",
"]",
"/",
"2",
")",
"part1",
"=",
"vdata",
"[",
":",
... | Split 1D or 2D into two parts, using the last axis
Parameters
----------
data:
squeeze : squeeze results to remove unnecessary dimensions | [
"Split",
"1D",
"or",
"2D",
"into",
"two",
"parts",
"using",
"the",
"last",
"axis"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/convert.py#L14-L30 | train | Split data into two parts. |
geophysics-ubonn/reda | lib/reda/eis/convert.py | generic_magpha_to_reim | def generic_magpha_to_reim(mag, pha):
"""
Generically convert magnitude and phase to real and imaginary part using
the formula :math:`mag \cdot exp(1j / 1000 * pha)`
Thus it is suitable for resistivities, multiply conductivity phases with -1
"""
complex_nr = to_complex(mag, pha)
real_part =... | python | def generic_magpha_to_reim(mag, pha):
"""
Generically convert magnitude and phase to real and imaginary part using
the formula :math:`mag \cdot exp(1j / 1000 * pha)`
Thus it is suitable for resistivities, multiply conductivity phases with -1
"""
complex_nr = to_complex(mag, pha)
real_part =... | [
"def",
"generic_magpha_to_reim",
"(",
"mag",
",",
"pha",
")",
":",
"complex_nr",
"=",
"to_complex",
"(",
"mag",
",",
"pha",
")",
"real_part",
"=",
"np",
".",
"real",
"(",
"complex_nr",
")",
"imag_part",
"=",
"np",
".",
"imag",
"(",
"complex_nr",
")",
"... | Generically convert magnitude and phase to real and imaginary part using
the formula :math:`mag \cdot exp(1j / 1000 * pha)`
Thus it is suitable for resistivities, multiply conductivity phases with -1 | [
"Generically",
"convert",
"magnitude",
"and",
"phase",
"to",
"real",
"and",
"imaginary",
"part",
"using",
"the",
"formula",
":",
"math",
":",
"mag",
"\\",
"cdot",
"exp",
"(",
"1j",
"/",
"1000",
"*",
"pha",
")"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/convert.py#L38-L48 | train | Convert magnitude and phase to real and imaginary part using the formula. |
geophysics-ubonn/reda | lib/reda/eis/convert.py | convert | def convert(input_format, output_format, data, one_spectrum=False):
"""
Convert from the given format to the requested format
Parameters
----------
input_format : format of input data (parameter 'data')
output_format : format of output data
data : numpy array containing data in specified in... | python | def convert(input_format, output_format, data, one_spectrum=False):
"""
Convert from the given format to the requested format
Parameters
----------
input_format : format of input data (parameter 'data')
output_format : format of output data
data : numpy array containing data in specified in... | [
"def",
"convert",
"(",
"input_format",
",",
"output_format",
",",
"data",
",",
"one_spectrum",
"=",
"False",
")",
":",
"if",
"input_format",
"==",
"output_format",
":",
"return",
"data",
"if",
"input_format",
"not",
"in",
"from_converters",
":",
"raise",
"KeyE... | Convert from the given format to the requested format
Parameters
----------
input_format : format of input data (parameter 'data')
output_format : format of output data
data : numpy array containing data in specified input format
one_spectrum : True|False, the input data comprises one spectrum.... | [
"Convert",
"from",
"the",
"given",
"format",
"to",
"the",
"requested",
"format"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/eis/convert.py#L233-L311 | train | Convert from the input format to the output format. |
pennlabs/penn-sdk-python | penn/directory.py | Directory.search | def search(self, params, standardize=False):
"""Get a list of person objects for the given search params.
:param params: Dictionary specifying the query parameters
:param standardize: Whether to standardize names and other features,
currently disabled for backwards compatibility. Cu... | python | def search(self, params, standardize=False):
"""Get a list of person objects for the given search params.
:param params: Dictionary specifying the query parameters
:param standardize: Whether to standardize names and other features,
currently disabled for backwards compatibility. Cu... | [
"def",
"search",
"(",
"self",
",",
"params",
",",
"standardize",
"=",
"False",
")",
":",
"resp",
"=",
"self",
".",
"_request",
"(",
"ENDPOINTS",
"[",
"'SEARCH'",
"]",
",",
"params",
")",
"if",
"not",
"standardize",
":",
"return",
"resp",
"# Standardizati... | Get a list of person objects for the given search params.
:param params: Dictionary specifying the query parameters
:param standardize: Whether to standardize names and other features,
currently disabled for backwards compatibility. Currently
standardizes names, lowercases email... | [
"Get",
"a",
"list",
"of",
"person",
"objects",
"for",
"the",
"given",
"search",
"params",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/directory.py#L41-L58 | train | Search for a list of person objects for the given search parameters. |
pennlabs/penn-sdk-python | penn/directory.py | Directory.detail_search | def detail_search(self, params, standardize=False):
"""Get a detailed list of person objects for the given search params.
:param params:
Dictionary specifying the query parameters
>>> people_detailed = d.detail_search({'first_name': 'tobias', 'last_name': 'funke'})
"""
... | python | def detail_search(self, params, standardize=False):
"""Get a detailed list of person objects for the given search params.
:param params:
Dictionary specifying the query parameters
>>> people_detailed = d.detail_search({'first_name': 'tobias', 'last_name': 'funke'})
"""
... | [
"def",
"detail_search",
"(",
"self",
",",
"params",
",",
"standardize",
"=",
"False",
")",
":",
"response",
"=",
"self",
".",
"_request",
"(",
"ENDPOINTS",
"[",
"'SEARCH'",
"]",
",",
"params",
")",
"result_data",
"=",
"[",
"]",
"for",
"person",
"in",
"... | Get a detailed list of person objects for the given search params.
:param params:
Dictionary specifying the query parameters
>>> people_detailed = d.detail_search({'first_name': 'tobias', 'last_name': 'funke'}) | [
"Get",
"a",
"detailed",
"list",
"of",
"person",
"objects",
"for",
"the",
"given",
"search",
"params",
"."
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/directory.py#L60-L81 | train | Get a detailed list of person objects for the given search params. |
pennlabs/penn-sdk-python | penn/directory.py | Directory.person_details | def person_details(self, person_id, standardize=False):
"""Get a detailed person object
:param person_id:
String corresponding to the person's id.
>>> instructor = d.person('jhs878sfd03b38b0d463b16320b5e438')
"""
resp = self._request(path.join(ENDPOINTS['DETAILS'], ... | python | def person_details(self, person_id, standardize=False):
"""Get a detailed person object
:param person_id:
String corresponding to the person's id.
>>> instructor = d.person('jhs878sfd03b38b0d463b16320b5e438')
"""
resp = self._request(path.join(ENDPOINTS['DETAILS'], ... | [
"def",
"person_details",
"(",
"self",
",",
"person_id",
",",
"standardize",
"=",
"False",
")",
":",
"resp",
"=",
"self",
".",
"_request",
"(",
"path",
".",
"join",
"(",
"ENDPOINTS",
"[",
"'DETAILS'",
"]",
",",
"person_id",
")",
")",
"if",
"standardize",
... | Get a detailed person object
:param person_id:
String corresponding to the person's id.
>>> instructor = d.person('jhs878sfd03b38b0d463b16320b5e438') | [
"Get",
"a",
"detailed",
"person",
"object"
] | 31ff12c20d69438d63bc7a796f83ce4f4c828396 | https://github.com/pennlabs/penn-sdk-python/blob/31ff12c20d69438d63bc7a796f83ce4f4c828396/penn/directory.py#L83-L94 | train | Get a detailed person object |
geophysics-ubonn/reda | lib/reda/importers/radic_sip256c.py | _parse_radic_header | def _parse_radic_header(header_group, dipole_mode="all"):
"""
Parameters
----------
dipole_mode: Which dipoles should be extracted
"all"
"before"
"between"
"after"
"""
header = ''.join(header_group[1])
nr_of_electrodes = _get_nr_of_electrodes(header.split('\n... | python | def _parse_radic_header(header_group, dipole_mode="all"):
"""
Parameters
----------
dipole_mode: Which dipoles should be extracted
"all"
"before"
"between"
"after"
"""
header = ''.join(header_group[1])
nr_of_electrodes = _get_nr_of_electrodes(header.split('\n... | [
"def",
"_parse_radic_header",
"(",
"header_group",
",",
"dipole_mode",
"=",
"\"all\"",
")",
":",
"header",
"=",
"''",
".",
"join",
"(",
"header_group",
"[",
"1",
"]",
")",
"nr_of_electrodes",
"=",
"_get_nr_of_electrodes",
"(",
"header",
".",
"split",
"(",
"'... | Parameters
----------
dipole_mode: Which dipoles should be extracted
"all"
"before"
"between"
"after" | [
"Parameters",
"----------",
"dipole_mode",
":",
"Which",
"dipoles",
"should",
"be",
"extracted",
"all",
"before",
"between",
"after"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/radic_sip256c.py#L27-L98 | train | Parses the radic header into a single tree structure. |
geophysics-ubonn/reda | lib/reda/importers/radic_sip256c.py | parse_radic_file | def parse_radic_file(filename, settings, selection_mode="after",
reciprocal=None):
"""Import one result file as produced by the SIP256c SIP measuring device
(Radic Research)
Full settings dictionary: ::
settings = {
'filter_skip': (integer) skip dipoles we are inte... | python | def parse_radic_file(filename, settings, selection_mode="after",
reciprocal=None):
"""Import one result file as produced by the SIP256c SIP measuring device
(Radic Research)
Full settings dictionary: ::
settings = {
'filter_skip': (integer) skip dipoles we are inte... | [
"def",
"parse_radic_file",
"(",
"filename",
",",
"settings",
",",
"selection_mode",
"=",
"\"after\"",
",",
"reciprocal",
"=",
"None",
")",
":",
"try",
":",
"with",
"open",
"(",
"filename",
",",
"'r'",
",",
"encoding",
"=",
"'latin-1'",
")",
"as",
"fid",
... | Import one result file as produced by the SIP256c SIP measuring device
(Radic Research)
Full settings dictionary: ::
settings = {
'filter_skip': (integer) skip dipoles we are interested in
'quadrupole_mode': ['after'|'between'|'before'| 'all']
whi... | [
"Import",
"one",
"result",
"file",
"as",
"produced",
"by",
"the",
"SIP256c",
"SIP",
"measuring",
"device",
"(",
"Radic",
"Research",
")"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/radic_sip256c.py#L350-L450 | train | Parse a single result file as produced by the SIP256c SIP measuring device and return a pandas. DataFrame containing the data contained in the SIP256c SIP measuring device and the SIP - specific information about the device. |
geophysics-ubonn/reda | lib/reda/plotters/pseudoplots.py | plot_pseudosection_type2 | def plot_pseudosection_type2(dataobj, column, **kwargs):
"""Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltage dipole
... | python | def plot_pseudosection_type2(dataobj, column, **kwargs):
"""Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltage dipole
... | [
"def",
"plot_pseudosection_type2",
"(",
"dataobj",
",",
"column",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"dataobj",
",",
"pd",
".",
"DataFrame",
")",
":",
"df",
"=",
"dataobj",
"else",
":",
"df",
"=",
"dataobj",
".",
"data",
"c",
... | Create a pseudosection plot of type 2.
For a given measurement data set, create plots that graphically show
the data in a 2D color plot. Hereby, x and y coordinates in the plot
are determined by the current dipole (x-axis) and voltage dipole
(y-axis) of the corresponding measurement configurations.
... | [
"Create",
"a",
"pseudosection",
"plot",
"of",
"type",
"2",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/pseudoplots.py#L62-L311 | train | Create a pseudosection plot of type 2. |
geophysics-ubonn/reda | lib/reda/plotters/pseudoplots.py | plot_ps_extra | def plot_ps_extra(dataobj, key, **kwargs):
"""Create grouped pseudoplots for one or more time steps
Parameters
----------
dataobj: :class:`reda.containers.ERT`
An ERT container with loaded data
key: string
The column name to plot
subquery: string, optional
cbmin: float, opti... | python | def plot_ps_extra(dataobj, key, **kwargs):
"""Create grouped pseudoplots for one or more time steps
Parameters
----------
dataobj: :class:`reda.containers.ERT`
An ERT container with loaded data
key: string
The column name to plot
subquery: string, optional
cbmin: float, opti... | [
"def",
"plot_ps_extra",
"(",
"dataobj",
",",
"key",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"isinstance",
"(",
"dataobj",
",",
"pd",
".",
"DataFrame",
")",
":",
"df_raw",
"=",
"dataobj",
"else",
":",
"df_raw",
"=",
"dataobj",
".",
"data",
"if",
"kwa... | Create grouped pseudoplots for one or more time steps
Parameters
----------
dataobj: :class:`reda.containers.ERT`
An ERT container with loaded data
key: string
The column name to plot
subquery: string, optional
cbmin: float, optional
cbmax: float, optional
Examples
... | [
"Create",
"grouped",
"pseudoplots",
"for",
"one",
"or",
"more",
"time",
"steps"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/pseudoplots.py#L314-L385 | train | Create grouped pseudoplots for one or more time steps. |
fuzeman/PyUPnP | pyupnp/util.py | twisted_absolute_path | def twisted_absolute_path(path, request):
"""Hack to fix twisted not accepting absolute URIs"""
parsed = urlparse.urlparse(request.uri)
if parsed.scheme != '':
path_parts = parsed.path.lstrip('/').split('/')
request.prepath = path_parts[0:1]
request.postpath = path_parts[1:]
... | python | def twisted_absolute_path(path, request):
"""Hack to fix twisted not accepting absolute URIs"""
parsed = urlparse.urlparse(request.uri)
if parsed.scheme != '':
path_parts = parsed.path.lstrip('/').split('/')
request.prepath = path_parts[0:1]
request.postpath = path_parts[1:]
... | [
"def",
"twisted_absolute_path",
"(",
"path",
",",
"request",
")",
":",
"parsed",
"=",
"urlparse",
".",
"urlparse",
"(",
"request",
".",
"uri",
")",
"if",
"parsed",
".",
"scheme",
"!=",
"''",
":",
"path_parts",
"=",
"parsed",
".",
"path",
".",
"lstrip",
... | Hack to fix twisted not accepting absolute URIs | [
"Hack",
"to",
"fix",
"twisted",
"not",
"accepting",
"absolute",
"URIs"
] | 6dea64be299952346a14300ab6cc7dac42736433 | https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/util.py#L24-L32 | train | Hack to fix twisted not accepting absolute URIs |
geophysics-ubonn/reda | lib/reda/importers/legacy/eit40.py | _add_rhoa | def _add_rhoa(df, spacing):
"""a simple wrapper to compute K factors and add rhoa
"""
df['k'] = redaK.compute_K_analytical(df, spacing=spacing)
df['rho_a'] = df['r'] * df['k']
if 'Zt' in df.columns:
df['rho_a_complex'] = df['Zt'] * df['k']
return df | python | def _add_rhoa(df, spacing):
"""a simple wrapper to compute K factors and add rhoa
"""
df['k'] = redaK.compute_K_analytical(df, spacing=spacing)
df['rho_a'] = df['r'] * df['k']
if 'Zt' in df.columns:
df['rho_a_complex'] = df['Zt'] * df['k']
return df | [
"def",
"_add_rhoa",
"(",
"df",
",",
"spacing",
")",
":",
"df",
"[",
"'k'",
"]",
"=",
"redaK",
".",
"compute_K_analytical",
"(",
"df",
",",
"spacing",
"=",
"spacing",
")",
"df",
"[",
"'rho_a'",
"]",
"=",
"df",
"[",
"'r'",
"]",
"*",
"df",
"[",
"'k'... | a simple wrapper to compute K factors and add rhoa | [
"a",
"simple",
"wrapper",
"to",
"compute",
"K",
"factors",
"and",
"add",
"rhoa"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/legacy/eit40.py#L52-L59 | train | a simple wrapper to compute K factors and add rhoa
|
geophysics-ubonn/reda | lib/reda/importers/legacy/eit40.py | _read_mat_mnu0 | def _read_mat_mnu0(filename):
"""Import a .mat file with single potentials (A B M) into a pandas
DataFrame
Also export some variables of the md struct into a separate structure
"""
print('read_mag_single_file')
mat = sio.loadmat(filename)
df_emd = _extract_emd(mat)
return df_emd | python | def _read_mat_mnu0(filename):
"""Import a .mat file with single potentials (A B M) into a pandas
DataFrame
Also export some variables of the md struct into a separate structure
"""
print('read_mag_single_file')
mat = sio.loadmat(filename)
df_emd = _extract_emd(mat)
return df_emd | [
"def",
"_read_mat_mnu0",
"(",
"filename",
")",
":",
"print",
"(",
"'read_mag_single_file'",
")",
"mat",
"=",
"sio",
".",
"loadmat",
"(",
"filename",
")",
"df_emd",
"=",
"_extract_emd",
"(",
"mat",
")",
"return",
"df_emd"
] | Import a .mat file with single potentials (A B M) into a pandas
DataFrame
Also export some variables of the md struct into a separate structure | [
"Import",
"a",
".",
"mat",
"file",
"with",
"single",
"potentials",
"(",
"A",
"B",
"M",
")",
"into",
"a",
"pandas",
"DataFrame"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/importers/legacy/eit40.py#L138-L150 | train | Read a. mat file with single potentials A B M and return a pandas DataFrame containing the MNUs. |
Metatab/geoid | geoid/util.py | simplify | def simplify(geoids):
"""
Given a list of geoids, reduce it to a simpler set. If there are five or more geoids at one summary level
convert them to a single geoid at the higher level.
:param geoids:
:return:
"""
from collections import defaultdict
aggregated = defaultdict(set)
d ... | python | def simplify(geoids):
"""
Given a list of geoids, reduce it to a simpler set. If there are five or more geoids at one summary level
convert them to a single geoid at the higher level.
:param geoids:
:return:
"""
from collections import defaultdict
aggregated = defaultdict(set)
d ... | [
"def",
"simplify",
"(",
"geoids",
")",
":",
"from",
"collections",
"import",
"defaultdict",
"aggregated",
"=",
"defaultdict",
"(",
"set",
")",
"d",
"=",
"{",
"}",
"for",
"g",
"in",
"geoids",
":",
"if",
"not",
"bool",
"(",
"g",
")",
":",
"continue",
"... | Given a list of geoids, reduce it to a simpler set. If there are five or more geoids at one summary level
convert them to a single geoid at the higher level.
:param geoids:
:return: | [
"Given",
"a",
"list",
"of",
"geoids",
"reduce",
"it",
"to",
"a",
"simpler",
"set",
".",
"If",
"there",
"are",
"five",
"or",
"more",
"geoids",
"at",
"one",
"summary",
"level",
"convert",
"them",
"to",
"a",
"single",
"geoid",
"at",
"the",
"higher",
"leve... | 4b7769406b00e59376fb6046b42a2f8ed706b33b | https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/util.py#L3-L38 | train | Given a list of geoids reduce it to a simpler set. |
Metatab/geoid | geoid/util.py | isimplify | def isimplify(geoids):
"""Iteratively simplify until the set stops getting smaller. """
s0 = list(geoids)
for i in range(10):
s1 = simplify(s0)
if len(s1) == len(s0):
return s1
s0 = s1 | python | def isimplify(geoids):
"""Iteratively simplify until the set stops getting smaller. """
s0 = list(geoids)
for i in range(10):
s1 = simplify(s0)
if len(s1) == len(s0):
return s1
s0 = s1 | [
"def",
"isimplify",
"(",
"geoids",
")",
":",
"s0",
"=",
"list",
"(",
"geoids",
")",
"for",
"i",
"in",
"range",
"(",
"10",
")",
":",
"s1",
"=",
"simplify",
"(",
"s0",
")",
"if",
"len",
"(",
"s1",
")",
"==",
"len",
"(",
"s0",
")",
":",
"return"... | Iteratively simplify until the set stops getting smaller. | [
"Iteratively",
"simplify",
"until",
"the",
"set",
"stops",
"getting",
"smaller",
"."
] | 4b7769406b00e59376fb6046b42a2f8ed706b33b | https://github.com/Metatab/geoid/blob/4b7769406b00e59376fb6046b42a2f8ed706b33b/geoid/util.py#L40-L51 | train | Iteratively simplify until the set stops getting smaller. |
gtaylor/django-athumb | athumb/management/commands/athumb_regen_field.py | Command.parse_input | def parse_input(self):
"""
Go through the user input, get/validate some important values.
"""
app_split = self.args[0].split('.')
app = app_split[0]
model_name = app_split[1].lower()
self.model = get_model(app, model_name)
# String field name to ... | python | def parse_input(self):
"""
Go through the user input, get/validate some important values.
"""
app_split = self.args[0].split('.')
app = app_split[0]
model_name = app_split[1].lower()
self.model = get_model(app, model_name)
# String field name to ... | [
"def",
"parse_input",
"(",
"self",
")",
":",
"app_split",
"=",
"self",
".",
"args",
"[",
"0",
"]",
".",
"split",
"(",
"'.'",
")",
"app",
"=",
"app_split",
"[",
"0",
"]",
"model_name",
"=",
"app_split",
"[",
"1",
"]",
".",
"lower",
"(",
")",
"self... | Go through the user input, get/validate some important values. | [
"Go",
"through",
"the",
"user",
"input",
"get",
"/",
"validate",
"some",
"important",
"values",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/management/commands/athumb_regen_field.py#L30-L41 | train | Go through the user input and get some important values. |
gtaylor/django-athumb | athumb/management/commands/athumb_regen_field.py | Command.regenerate_thumbs | def regenerate_thumbs(self):
"""
Handle re-generating the thumbnails. All this involves is reading the
original file, then saving the same exact thing. Kind of annoying, but
it's simple.
"""
Model = self.model
instances = Model.objects.all()
num_instances ... | python | def regenerate_thumbs(self):
"""
Handle re-generating the thumbnails. All this involves is reading the
original file, then saving the same exact thing. Kind of annoying, but
it's simple.
"""
Model = self.model
instances = Model.objects.all()
num_instances ... | [
"def",
"regenerate_thumbs",
"(",
"self",
")",
":",
"Model",
"=",
"self",
".",
"model",
"instances",
"=",
"Model",
".",
"objects",
".",
"all",
"(",
")",
"num_instances",
"=",
"instances",
".",
"count",
"(",
")",
"# Filenames are keys in here, to help avoid re-gen... | Handle re-generating the thumbnails. All this involves is reading the
original file, then saving the same exact thing. Kind of annoying, but
it's simple. | [
"Handle",
"re",
"-",
"generating",
"the",
"thumbnails",
".",
"All",
"this",
"involves",
"is",
"reading",
"the",
"original",
"file",
"then",
"saving",
"the",
"same",
"exact",
"thing",
".",
"Kind",
"of",
"annoying",
"but",
"it",
"s",
"simple",
"."
] | 69261ace0dff81e33156a54440874456a7b38dfb | https://github.com/gtaylor/django-athumb/blob/69261ace0dff81e33156a54440874456a7b38dfb/athumb/management/commands/athumb_regen_field.py#L43-L119 | train | Handles re - generating the thumbnails for the current language of the object. |
kaustavdm/pyAvroPhonetic | pyavrophonetic/utils/count.py | count_vowels | def count_vowels(text):
"""Count number of occurrences of vowels in a given string"""
count = 0
for i in text:
if i.lower() in config.AVRO_VOWELS:
count += 1
return count | python | def count_vowels(text):
"""Count number of occurrences of vowels in a given string"""
count = 0
for i in text:
if i.lower() in config.AVRO_VOWELS:
count += 1
return count | [
"def",
"count_vowels",
"(",
"text",
")",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"text",
":",
"if",
"i",
".",
"lower",
"(",
")",
"in",
"config",
".",
"AVRO_VOWELS",
":",
"count",
"+=",
"1",
"return",
"count"
] | Count number of occurrences of vowels in a given string | [
"Count",
"number",
"of",
"occurrences",
"of",
"vowels",
"in",
"a",
"given",
"string"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/utils/count.py#L31-L37 | train | Count the number of occurrences of vowels in a given string. |
kaustavdm/pyAvroPhonetic | pyavrophonetic/utils/count.py | count_consonants | def count_consonants(text):
"""Count number of occurrences of consonants in a given string"""
count = 0
for i in text:
if i.lower() in config.AVRO_CONSONANTS:
count += 1
return count | python | def count_consonants(text):
"""Count number of occurrences of consonants in a given string"""
count = 0
for i in text:
if i.lower() in config.AVRO_CONSONANTS:
count += 1
return count | [
"def",
"count_consonants",
"(",
"text",
")",
":",
"count",
"=",
"0",
"for",
"i",
"in",
"text",
":",
"if",
"i",
".",
"lower",
"(",
")",
"in",
"config",
".",
"AVRO_CONSONANTS",
":",
"count",
"+=",
"1",
"return",
"count"
] | Count number of occurrences of consonants in a given string | [
"Count",
"number",
"of",
"occurrences",
"of",
"consonants",
"in",
"a",
"given",
"string"
] | 26b7d567d8db025f2cac4de817e716390d7ac337 | https://github.com/kaustavdm/pyAvroPhonetic/blob/26b7d567d8db025f2cac4de817e716390d7ac337/pyavrophonetic/utils/count.py#L39-L45 | train | Count the number of occurrences of consonants in a given string |
geophysics-ubonn/reda | lib/reda/plotters/plots2d.py | _pseudodepths_wenner | def _pseudodepths_wenner(configs, spacing=1, grid=None):
"""Given distances between electrodes, compute Wenner pseudo
depths for the provided configuration
The pseudodepth is computed after Roy & Apparao, 1971, as 0.11 times
the distance between the two outermost electrodes. It's not really
clear w... | python | def _pseudodepths_wenner(configs, spacing=1, grid=None):
"""Given distances between electrodes, compute Wenner pseudo
depths for the provided configuration
The pseudodepth is computed after Roy & Apparao, 1971, as 0.11 times
the distance between the two outermost electrodes. It's not really
clear w... | [
"def",
"_pseudodepths_wenner",
"(",
"configs",
",",
"spacing",
"=",
"1",
",",
"grid",
"=",
"None",
")",
":",
"if",
"grid",
"is",
"None",
":",
"xpositions",
"=",
"(",
"configs",
"-",
"1",
")",
"*",
"spacing",
"else",
":",
"xpositions",
"=",
"grid",
".... | Given distances between electrodes, compute Wenner pseudo
depths for the provided configuration
The pseudodepth is computed after Roy & Apparao, 1971, as 0.11 times
the distance between the two outermost electrodes. It's not really
clear why the Wenner depths are different from the Dipole-Dipole
de... | [
"Given",
"distances",
"between",
"electrodes",
"compute",
"Wenner",
"pseudo",
"depths",
"for",
"the",
"provided",
"configuration"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/plots2d.py#L13-L31 | train | Compute the pseudodepths for the Wenner electrodes. |
geophysics-ubonn/reda | lib/reda/plotters/plots2d.py | plot_pseudodepths | def plot_pseudodepths(configs, nr_electrodes, spacing=1, grid=None,
ctypes=None, dd_merge=False, **kwargs):
"""Plot pseudodepths for the measurements. If grid is given, then the
actual electrode positions are used, and the parameter 'spacing' is
ignored'
Parameters
----------
... | python | def plot_pseudodepths(configs, nr_electrodes, spacing=1, grid=None,
ctypes=None, dd_merge=False, **kwargs):
"""Plot pseudodepths for the measurements. If grid is given, then the
actual electrode positions are used, and the parameter 'spacing' is
ignored'
Parameters
----------
... | [
"def",
"plot_pseudodepths",
"(",
"configs",
",",
"nr_electrodes",
",",
"spacing",
"=",
"1",
",",
"grid",
"=",
"None",
",",
"ctypes",
"=",
"None",
",",
"dd_merge",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"# for each configuration type we have different... | Plot pseudodepths for the measurements. If grid is given, then the
actual electrode positions are used, and the parameter 'spacing' is
ignored'
Parameters
----------
configs: :class:`numpy.ndarray`
Nx4 array containing the quadrupoles for different measurements
nr_electrodes: int
... | [
"Plot",
"pseudodepths",
"for",
"the",
"measurements",
".",
"If",
"grid",
"is",
"given",
"then",
"the",
"actual",
"electrode",
"positions",
"are",
"used",
"and",
"the",
"parameter",
"spacing",
"is",
"ignored"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/plots2d.py#L72-L227 | train | Plot pseudodepths for the measurements. |
geophysics-ubonn/reda | lib/reda/plotters/plots2d.py | plot_pseudosection | def plot_pseudosection(df, plot_key, spacing=1, ctypes=None, dd_merge=False,
cb=False, **kwargs):
"""Create a pseudosection plot for a given measurement
Parameters
----------
df: dataframe
measurement dataframe, one measurement frame (i.e., only one frequency
etc)... | python | def plot_pseudosection(df, plot_key, spacing=1, ctypes=None, dd_merge=False,
cb=False, **kwargs):
"""Create a pseudosection plot for a given measurement
Parameters
----------
df: dataframe
measurement dataframe, one measurement frame (i.e., only one frequency
etc)... | [
"def",
"plot_pseudosection",
"(",
"df",
",",
"plot_key",
",",
"spacing",
"=",
"1",
",",
"ctypes",
"=",
"None",
",",
"dd_merge",
"=",
"False",
",",
"cb",
"=",
"False",
",",
"*",
"*",
"kwargs",
")",
":",
"grid",
"=",
"None",
"pseudo_d_functions",
"=",
... | Create a pseudosection plot for a given measurement
Parameters
----------
df: dataframe
measurement dataframe, one measurement frame (i.e., only one frequency
etc)
key:
which key to colorcode
spacing: float, optional
assumed electrode spacing
ctypes: list of stri... | [
"Create",
"a",
"pseudosection",
"plot",
"for",
"a",
"given",
"measurement"
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/plots2d.py#L230-L414 | train | Create a pseudosection plot for a given measurement. |
geophysics-ubonn/reda | lib/reda/plotters/plots2d.py | matplot | def matplot(x, y, z, ax=None, colorbar=True, **kwargs):
""" Plot x, y, z as expected with correct axis labels.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from reda.plotters import matplot
>>> a = np.arange(4)
>>> b = np.arange(3) + 3
>>> def sum... | python | def matplot(x, y, z, ax=None, colorbar=True, **kwargs):
""" Plot x, y, z as expected with correct axis labels.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from reda.plotters import matplot
>>> a = np.arange(4)
>>> b = np.arange(3) + 3
>>> def sum... | [
"def",
"matplot",
"(",
"x",
",",
"y",
",",
"z",
",",
"ax",
"=",
"None",
",",
"colorbar",
"=",
"True",
",",
"*",
"*",
"kwargs",
")",
":",
"xmin",
"=",
"x",
".",
"min",
"(",
")",
"xmax",
"=",
"x",
".",
"max",
"(",
")",
"dx",
"=",
"np",
".",... | Plot x, y, z as expected with correct axis labels.
Examples
--------
>>> import matplotlib.pyplot as plt
>>> import numpy as np
>>> from reda.plotters import matplot
>>> a = np.arange(4)
>>> b = np.arange(3) + 3
>>> def sum(a, b):
... return a + b
>>> x, y = np.meshgrid(a, b)... | [
"Plot",
"x",
"y",
"z",
"as",
"expected",
"with",
"correct",
"axis",
"labels",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/plots2d.py#L417-L470 | train | Plot x y z as expected with correct axis labels. |
evolbioinfo/pastml | pastml/models/f81_like.py | get_f81_pij | def get_f81_pij(t, frequencies, mu):
"""
Calculate the probability of substitution i->j over time t, given the mutation rate mu:
For F81 (and JC which is a simpler version of it)
Pij(t) = \pi_j (1 - exp(-mu t)) + exp(-mu t), if i == j, \pi_j (1 - exp(-mu t)), otherwise
[Gascuel "Mathematics of Evolu... | python | def get_f81_pij(t, frequencies, mu):
"""
Calculate the probability of substitution i->j over time t, given the mutation rate mu:
For F81 (and JC which is a simpler version of it)
Pij(t) = \pi_j (1 - exp(-mu t)) + exp(-mu t), if i == j, \pi_j (1 - exp(-mu t)), otherwise
[Gascuel "Mathematics of Evolu... | [
"def",
"get_f81_pij",
"(",
"t",
",",
"frequencies",
",",
"mu",
")",
":",
"# if mu == inf (e.g. just one state) and t == 0, we should prioritise mu",
"exp_mu_t",
"=",
"0.",
"if",
"(",
"mu",
"==",
"np",
".",
"inf",
")",
"else",
"np",
".",
"exp",
"(",
"-",
"mu",
... | Calculate the probability of substitution i->j over time t, given the mutation rate mu:
For F81 (and JC which is a simpler version of it)
Pij(t) = \pi_j (1 - exp(-mu t)) + exp(-mu t), if i == j, \pi_j (1 - exp(-mu t)), otherwise
[Gascuel "Mathematics of Evolution and Phylogeny" 2005].
:param frequencie... | [
"Calculate",
"the",
"probability",
"of",
"substitution",
"i",
"-",
">",
"j",
"over",
"time",
"t",
"given",
"the",
"mutation",
"rate",
"mu",
":",
"For",
"F81",
"(",
"and",
"JC",
"which",
"is",
"a",
"simpler",
"version",
"of",
"it",
")",
"Pij",
"(",
"t... | df8a375841525738383e59548eed3441b07dbd3e | https://github.com/evolbioinfo/pastml/blob/df8a375841525738383e59548eed3441b07dbd3e/pastml/models/f81_like.py#L31-L52 | train | Calculates the probability of substitution i - > j over time t given the mutation rate mu. |
frasertweedale/ledgertools | ltlib/xn.py | Xn.ledger | def ledger(self):
"""Convert to a Ledger transaction (no trailing blank line)"""
self.balance() # make sure the transaction balances
s = "{0}/{1:02}/{2:02} {3}\n".format(
self.date.year,
self.date.month,
self.date.day,
self.desc.replace('\n', ' ... | python | def ledger(self):
"""Convert to a Ledger transaction (no trailing blank line)"""
self.balance() # make sure the transaction balances
s = "{0}/{1:02}/{2:02} {3}\n".format(
self.date.year,
self.date.month,
self.date.day,
self.desc.replace('\n', ' ... | [
"def",
"ledger",
"(",
"self",
")",
":",
"self",
".",
"balance",
"(",
")",
"# make sure the transaction balances",
"s",
"=",
"\"{0}/{1:02}/{2:02} {3}\\n\"",
".",
"format",
"(",
"self",
".",
"date",
".",
"year",
",",
"self",
".",
"date",
".",
"month",
",",
... | Convert to a Ledger transaction (no trailing blank line) | [
"Convert",
"to",
"a",
"Ledger",
"transaction",
"(",
"no",
"trailing",
"blank",
"line",
")"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L72-L86 | train | Convert to a Ledger transaction |
frasertweedale/ledgertools | ltlib/xn.py | Xn.summary | def summary(self):
"""Return a string summary of transaction"""
return "\n".join([
"Transaction:",
" When: " + self.date.strftime("%a %d %b %Y"),
" Description: " + self.desc.replace('\n', ' '),
" For amount: {}".format(self.amount),
... | python | def summary(self):
"""Return a string summary of transaction"""
return "\n".join([
"Transaction:",
" When: " + self.date.strftime("%a %d %b %Y"),
" Description: " + self.desc.replace('\n', ' '),
" For amount: {}".format(self.amount),
... | [
"def",
"summary",
"(",
"self",
")",
":",
"return",
"\"\\n\"",
".",
"join",
"(",
"[",
"\"Transaction:\"",
",",
"\" When: \"",
"+",
"self",
".",
"date",
".",
"strftime",
"(",
"\"%a %d %b %Y\"",
")",
",",
"\" Description: \"",
"+",
"self",
".",
"desc",... | Return a string summary of transaction | [
"Return",
"a",
"string",
"summary",
"of",
"transaction"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L88-L104 | train | Return a string summary of the current state of the current object |
frasertweedale/ledgertools | ltlib/xn.py | Xn.check | def check(self):
"""Check this transaction for completeness"""
if not self.date:
raise XnDataError("Missing date")
if not self.desc:
raise XnDataError("Missing description")
if not self.dst:
raise XnDataError("No destination accounts")
if not s... | python | def check(self):
"""Check this transaction for completeness"""
if not self.date:
raise XnDataError("Missing date")
if not self.desc:
raise XnDataError("Missing description")
if not self.dst:
raise XnDataError("No destination accounts")
if not s... | [
"def",
"check",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"date",
":",
"raise",
"XnDataError",
"(",
"\"Missing date\"",
")",
"if",
"not",
"self",
".",
"desc",
":",
"raise",
"XnDataError",
"(",
"\"Missing description\"",
")",
"if",
"not",
"self",
"... | Check this transaction for completeness | [
"Check",
"this",
"transaction",
"for",
"completeness"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L106-L117 | train | Check this transaction for completeness |
frasertweedale/ledgertools | ltlib/xn.py | Xn.balance | def balance(self):
"""Check this transaction for correctness"""
self.check()
if not sum(map(lambda x: x.amount, self.src)) == -self.amount:
raise XnBalanceError("Sum of source amounts "
"not equal to transaction amount")
if not sum(map(lambda ... | python | def balance(self):
"""Check this transaction for correctness"""
self.check()
if not sum(map(lambda x: x.amount, self.src)) == -self.amount:
raise XnBalanceError("Sum of source amounts "
"not equal to transaction amount")
if not sum(map(lambda ... | [
"def",
"balance",
"(",
"self",
")",
":",
"self",
".",
"check",
"(",
")",
"if",
"not",
"sum",
"(",
"map",
"(",
"lambda",
"x",
":",
"x",
".",
"amount",
",",
"self",
".",
"src",
")",
")",
"==",
"-",
"self",
".",
"amount",
":",
"raise",
"XnBalanceE... | Check this transaction for correctness | [
"Check",
"this",
"transaction",
"for",
"correctness"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L119-L128 | train | Check this transaction for correctness |
frasertweedale/ledgertools | ltlib/xn.py | Xn.match_rules | def match_rules(self, rules):
"""Process this transaction against the given ruleset
Returns a dict of fields with ScoreSet values, which may be empty.
Notably, the rule processing will be shortcircuited if the Xn is
already complete - in this case, None is returned.
"""
... | python | def match_rules(self, rules):
"""Process this transaction against the given ruleset
Returns a dict of fields with ScoreSet values, which may be empty.
Notably, the rule processing will be shortcircuited if the Xn is
already complete - in this case, None is returned.
"""
... | [
"def",
"match_rules",
"(",
"self",
",",
"rules",
")",
":",
"try",
":",
"self",
".",
"check",
"(",
")",
"return",
"None",
"except",
"XnDataError",
":",
"pass",
"scores",
"=",
"{",
"}",
"for",
"r",
"in",
"rules",
":",
"outcomes",
"=",
"r",
".",
"matc... | Process this transaction against the given ruleset
Returns a dict of fields with ScoreSet values, which may be empty.
Notably, the rule processing will be shortcircuited if the Xn is
already complete - in this case, None is returned. | [
"Process",
"this",
"transaction",
"against",
"the",
"given",
"ruleset"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L130-L166 | train | Process this transaction against the given ruleset returning a dictionary of fields with ScoreSet values which may be empty. |
frasertweedale/ledgertools | ltlib/xn.py | Xn.apply_outcomes | def apply_outcomes(self, outcomes, uio, dropped=False, prevxn=None):
"""Apply the given outcomes to this rule.
If user intervention is required, outcomes are not applied
unless a ui.UI is supplied.
"""
if self.dropped and not dropped:
# do nothing for dropped xn, unl... | python | def apply_outcomes(self, outcomes, uio, dropped=False, prevxn=None):
"""Apply the given outcomes to this rule.
If user intervention is required, outcomes are not applied
unless a ui.UI is supplied.
"""
if self.dropped and not dropped:
# do nothing for dropped xn, unl... | [
"def",
"apply_outcomes",
"(",
"self",
",",
"outcomes",
",",
"uio",
",",
"dropped",
"=",
"False",
",",
"prevxn",
"=",
"None",
")",
":",
"if",
"self",
".",
"dropped",
"and",
"not",
"dropped",
":",
"# do nothing for dropped xn, unless specifically told to",
"return... | Apply the given outcomes to this rule.
If user intervention is required, outcomes are not applied
unless a ui.UI is supplied. | [
"Apply",
"the",
"given",
"outcomes",
"to",
"this",
"rule",
"."
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L168-L308 | train | Apply the given outcomes to this rule. |
frasertweedale/ledgertools | ltlib/xn.py | Xn.complete | def complete(self, uio, dropped=False):
"""Query for all missing information in the transaction"""
if self.dropped and not dropped:
# do nothing for dropped xn, unless specifically told to
return
for end in ['src', 'dst']:
if getattr(self, end):
... | python | def complete(self, uio, dropped=False):
"""Query for all missing information in the transaction"""
if self.dropped and not dropped:
# do nothing for dropped xn, unless specifically told to
return
for end in ['src', 'dst']:
if getattr(self, end):
... | [
"def",
"complete",
"(",
"self",
",",
"uio",
",",
"dropped",
"=",
"False",
")",
":",
"if",
"self",
".",
"dropped",
"and",
"not",
"dropped",
":",
"# do nothing for dropped xn, unless specifically told to",
"return",
"for",
"end",
"in",
"[",
"'src'",
",",
"'dst'"... | Query for all missing information in the transaction | [
"Query",
"for",
"all",
"missing",
"information",
"in",
"the",
"transaction"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L312-L351 | train | Query for all missing information in the transaction |
frasertweedale/ledgertools | ltlib/xn.py | Xn.process | def process(self, rules, uio, prevxn=None):
"""Matches rules and applies outcomes"""
self.apply_outcomes(self.match_rules(rules), uio, prevxn=prevxn) | python | def process(self, rules, uio, prevxn=None):
"""Matches rules and applies outcomes"""
self.apply_outcomes(self.match_rules(rules), uio, prevxn=prevxn) | [
"def",
"process",
"(",
"self",
",",
"rules",
",",
"uio",
",",
"prevxn",
"=",
"None",
")",
":",
"self",
".",
"apply_outcomes",
"(",
"self",
".",
"match_rules",
"(",
"rules",
")",
",",
"uio",
",",
"prevxn",
"=",
"prevxn",
")"
] | Matches rules and applies outcomes | [
"Matches",
"rules",
"and",
"applies",
"outcomes"
] | a695f8667d72253e5448693c12f0282d09902aaa | https://github.com/frasertweedale/ledgertools/blob/a695f8667d72253e5448693c12f0282d09902aaa/ltlib/xn.py#L353-L355 | train | Matches rules and applies outcomes |
GearPlug/payu-python | payu/payments.py | Payment.make_payment | def make_payment(self, *, reference_code, description, tx_value, tx_tax, tx_tax_return_base, currency, buyer,
payer, credit_card, payment_method, payment_country, device_session_id, ip_address, cookie,
user_agent, language=None, shipping_address=None, extra_parameters=None, not... | python | def make_payment(self, *, reference_code, description, tx_value, tx_tax, tx_tax_return_base, currency, buyer,
payer, credit_card, payment_method, payment_country, device_session_id, ip_address, cookie,
user_agent, language=None, shipping_address=None, extra_parameters=None, not... | [
"def",
"make_payment",
"(",
"self",
",",
"*",
",",
"reference_code",
",",
"description",
",",
"tx_value",
",",
"tx_tax",
",",
"tx_tax_return_base",
",",
"currency",
",",
"buyer",
",",
"payer",
",",
"credit_card",
",",
"payment_method",
",",
"payment_country",
... | Authorization: used to verify if a credit card is active, if it has funds, etc.
The transaction is not complete until a transaction capture is sent (only available for accounts in Argentina,
Brazil, Peru).
Capture: terminates a previously authorized transaction.
This is when the account... | [
"Authorization",
":",
"used",
"to",
"verify",
"if",
"a",
"credit",
"card",
"is",
"active",
"if",
"it",
"has",
"funds",
"etc",
".",
"The",
"transaction",
"is",
"not",
"complete",
"until",
"a",
"transaction",
"capture",
"is",
"sent",
"(",
"only",
"available"... | 47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e | https://github.com/GearPlug/payu-python/blob/47ec5c9fc89f1f89a53ec0a68c84f358bbe3394e/payu/payments.py#L36-L233 | train | This function is used to make a payment for an order. |
geophysics-ubonn/reda | lib/reda/plotters/time_series.py | plot_quadpole_evolution | def plot_quadpole_evolution(dataobj, quadpole, cols, threshold=5,
rolling=False, ax=None):
"""Visualize time-lapse evolution of a single quadropole.
Parameters
----------
dataobj : :py:class:`pandas.DataFrame`
DataFrame containing the data. Please refer to the docume... | python | def plot_quadpole_evolution(dataobj, quadpole, cols, threshold=5,
rolling=False, ax=None):
"""Visualize time-lapse evolution of a single quadropole.
Parameters
----------
dataobj : :py:class:`pandas.DataFrame`
DataFrame containing the data. Please refer to the docume... | [
"def",
"plot_quadpole_evolution",
"(",
"dataobj",
",",
"quadpole",
",",
"cols",
",",
"threshold",
"=",
"5",
",",
"rolling",
"=",
"False",
",",
"ax",
"=",
"None",
")",
":",
"if",
"isinstance",
"(",
"dataobj",
",",
"pd",
".",
"DataFrame",
")",
":",
"df",... | Visualize time-lapse evolution of a single quadropole.
Parameters
----------
dataobj : :py:class:`pandas.DataFrame`
DataFrame containing the data. Please refer to the documentation for
required columns.
quadpole : list of integers
Electrode numbers of the the quadropole.
col... | [
"Visualize",
"time",
"-",
"lapse",
"evolution",
"of",
"a",
"single",
"quadropole",
"."
] | 46a939729e40c7c4723315c03679c40761152e9e | https://github.com/geophysics-ubonn/reda/blob/46a939729e40c7c4723315c03679c40761152e9e/lib/reda/plotters/time_series.py#L9-L93 | train | Visualize time -lapse evolution of a single quadropole. |
fuzeman/PyUPnP | pyupnp/logr.py | Logr.configure | def configure(level=logging.WARNING, handler=None, formatter=None):
"""Configure Logr
@param handler: Logger message handler
@type handler: logging.Handler or None
@param formatter: Logger message Formatter
@type formatter: logging.Formatter or None
"""
if forma... | python | def configure(level=logging.WARNING, handler=None, formatter=None):
"""Configure Logr
@param handler: Logger message handler
@type handler: logging.Handler or None
@param formatter: Logger message Formatter
@type formatter: logging.Formatter or None
"""
if forma... | [
"def",
"configure",
"(",
"level",
"=",
"logging",
".",
"WARNING",
",",
"handler",
"=",
"None",
",",
"formatter",
"=",
"None",
")",
":",
"if",
"formatter",
"is",
"None",
":",
"formatter",
"=",
"LogrFormatter",
"(",
")",
"if",
"handler",
"is",
"None",
":... | Configure Logr
@param handler: Logger message handler
@type handler: logging.Handler or None
@param formatter: Logger message Formatter
@type formatter: logging.Formatter or None | [
"Configure",
"Logr"
] | 6dea64be299952346a14300ab6cc7dac42736433 | https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/logr.py#L31-L48 | train | Configure Logr with the given level and handler and formatter. |
fuzeman/PyUPnP | pyupnp/logr.py | Logr.get_logger | def get_logger():
"""Get or create logger (if it does not exist)
@rtype: RootLogger
"""
name = Logr.get_logger_name()
if name not in Logr.loggers:
Logr.configure_check()
Logr.loggers[name] = logging.Logger(name)
Logr.loggers[name].addHandler(L... | python | def get_logger():
"""Get or create logger (if it does not exist)
@rtype: RootLogger
"""
name = Logr.get_logger_name()
if name not in Logr.loggers:
Logr.configure_check()
Logr.loggers[name] = logging.Logger(name)
Logr.loggers[name].addHandler(L... | [
"def",
"get_logger",
"(",
")",
":",
"name",
"=",
"Logr",
".",
"get_logger_name",
"(",
")",
"if",
"name",
"not",
"in",
"Logr",
".",
"loggers",
":",
"Logr",
".",
"configure_check",
"(",
")",
"Logr",
".",
"loggers",
"[",
"name",
"]",
"=",
"logging",
"."... | Get or create logger (if it does not exist)
@rtype: RootLogger | [
"Get",
"or",
"create",
"logger",
"(",
"if",
"it",
"does",
"not",
"exist",
")"
] | 6dea64be299952346a14300ab6cc7dac42736433 | https://github.com/fuzeman/PyUPnP/blob/6dea64be299952346a14300ab6cc7dac42736433/pyupnp/logr.py#L102-L112 | train | Get or create a logger. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitMultiElementOneOf | def visitMultiElementOneOf(self, ctx: ShExDocParser.MultiElementOneOfContext):
""" multiElementOneOf: groupShape ('|' groupShape)+ """
self.expression = OneOf(expressions=[])
for gs in ctx.groupShape():
parser = ShexOneOfShapeParser(self.context)
parser.visit(gs)
... | python | def visitMultiElementOneOf(self, ctx: ShExDocParser.MultiElementOneOfContext):
""" multiElementOneOf: groupShape ('|' groupShape)+ """
self.expression = OneOf(expressions=[])
for gs in ctx.groupShape():
parser = ShexOneOfShapeParser(self.context)
parser.visit(gs)
... | [
"def",
"visitMultiElementOneOf",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"MultiElementOneOfContext",
")",
":",
"self",
".",
"expression",
"=",
"OneOf",
"(",
"expressions",
"=",
"[",
"]",
")",
"for",
"gs",
"in",
"ctx",
".",
"groupShape",
"(",
")... | multiElementOneOf: groupShape ('|' groupShape)+ | [
"multiElementOneOf",
":",
"groupShape",
"(",
"|",
"groupShape",
")",
"+"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L43-L49 | train | MultiElementOneOf is an expression that is a one of the items in the table. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitMultiElementGroup | def visitMultiElementGroup(self, ctx: ShExDocParser.MultiElementGroupContext):
""" multiElementGroup: unaryShape (';' unaryShape)+ ';'? """
self.expression = EachOf(expressions=[])
for us in ctx.unaryShape():
parser = ShexOneOfShapeParser(self.context)
parser.visit(us)
... | python | def visitMultiElementGroup(self, ctx: ShExDocParser.MultiElementGroupContext):
""" multiElementGroup: unaryShape (';' unaryShape)+ ';'? """
self.expression = EachOf(expressions=[])
for us in ctx.unaryShape():
parser = ShexOneOfShapeParser(self.context)
parser.visit(us)
... | [
"def",
"visitMultiElementGroup",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"MultiElementGroupContext",
")",
":",
"self",
".",
"expression",
"=",
"EachOf",
"(",
"expressions",
"=",
"[",
"]",
")",
"for",
"us",
"in",
"ctx",
".",
"unaryShape",
"(",
"... | multiElementGroup: unaryShape (';' unaryShape)+ ';'? | [
"multiElementGroup",
":",
"unaryShape",
"(",
";",
"unaryShape",
")",
"+",
";",
"?"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L51-L57 | train | MultiElementGroup is a single element group. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitUnaryShape | def visitUnaryShape(self, ctx: ShExDocParser.UnaryShapeContext):
""" unaryShape: ('$' tripleExprLabel)? (tripleConstraint | encapsulatedShape) | include """
if ctx.include():
self.expression = self.context.tripleexprlabel_to_iriref(ctx.include().tripleExprLabel())
else:
l... | python | def visitUnaryShape(self, ctx: ShExDocParser.UnaryShapeContext):
""" unaryShape: ('$' tripleExprLabel)? (tripleConstraint | encapsulatedShape) | include """
if ctx.include():
self.expression = self.context.tripleexprlabel_to_iriref(ctx.include().tripleExprLabel())
else:
l... | [
"def",
"visitUnaryShape",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"UnaryShapeContext",
")",
":",
"if",
"ctx",
".",
"include",
"(",
")",
":",
"self",
".",
"expression",
"=",
"self",
".",
"context",
".",
"tripleexprlabel_to_iriref",
"(",
"ctx",
"... | unaryShape: ('$' tripleExprLabel)? (tripleConstraint | encapsulatedShape) | include | [
"unaryShape",
":",
"(",
"$",
"tripleExprLabel",
")",
"?",
"(",
"tripleConstraint",
"|",
"encapsulatedShape",
")",
"|",
"include"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L59-L70 | train | visit unaryShape returns unaryShape |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitEncapsulatedShape | def visitEncapsulatedShape(self, ctx: ShExDocParser.EncapsulatedShapeContext):
""" encapsulatedShape: '(' innerShape ')' cardinality? annotation* semanticActions """
enc_shape = ShexOneOfShapeParser(self.context)
enc_shape.visit(ctx.innerShape())
self.expression = enc_shape.expression
... | python | def visitEncapsulatedShape(self, ctx: ShExDocParser.EncapsulatedShapeContext):
""" encapsulatedShape: '(' innerShape ')' cardinality? annotation* semanticActions """
enc_shape = ShexOneOfShapeParser(self.context)
enc_shape.visit(ctx.innerShape())
self.expression = enc_shape.expression
... | [
"def",
"visitEncapsulatedShape",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"EncapsulatedShapeContext",
")",
":",
"enc_shape",
"=",
"ShexOneOfShapeParser",
"(",
"self",
".",
"context",
")",
"enc_shape",
".",
"visit",
"(",
"ctx",
".",
"innerShape",
"(",
... | encapsulatedShape: '(' innerShape ')' cardinality? annotation* semanticActions | [
"encapsulatedShape",
":",
"(",
"innerShape",
")",
"cardinality?",
"annotation",
"*",
"semanticActions"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L72-L77 | train | EncapsulatedShape is an encapsulated shape expression. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitStarCardinality | def visitStarCardinality(self, ctx: ShExDocParser.StarCardinalityContext):
""" '*' """
self.expression.min = 0
self.expression.max = -1 | python | def visitStarCardinality(self, ctx: ShExDocParser.StarCardinalityContext):
""" '*' """
self.expression.min = 0
self.expression.max = -1 | [
"def",
"visitStarCardinality",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"StarCardinalityContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"0",
"self",
".",
"expression",
".",
"max",
"=",
"-",
"1"
] | '*' | [
"*"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L89-L92 | train | Set min and max to 0. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitPlusCardinality | def visitPlusCardinality(self, ctx: ShExDocParser.PlusCardinalityContext):
""" '+' """
self.expression.min = 1
self.expression.max = -1 | python | def visitPlusCardinality(self, ctx: ShExDocParser.PlusCardinalityContext):
""" '+' """
self.expression.min = 1
self.expression.max = -1 | [
"def",
"visitPlusCardinality",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"PlusCardinalityContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"1",
"self",
".",
"expression",
".",
"max",
"=",
"-",
"1"
] | '+' | [
"+"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L94-L97 | train | Set the minimum and maximum of the cardinality of the current entry. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitOptionalCardinality | def visitOptionalCardinality(self, ctx: ShExDocParser.OptionalCardinalityContext):
""" '?' """
self.expression.min = 0
self.expression.max = 1 | python | def visitOptionalCardinality(self, ctx: ShExDocParser.OptionalCardinalityContext):
""" '?' """
self.expression.min = 0
self.expression.max = 1 | [
"def",
"visitOptionalCardinality",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"OptionalCardinalityContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"0",
"self",
".",
"expression",
".",
"max",
"=",
"1"
] | '?' | [
"?"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L99-L102 | train | Set min and max to 0 if cardinality is not defined |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitExactRange | def visitExactRange(self, ctx: ShExDocParser.ExactRangeContext):
""" repeatRange: '{' INTEGER '}' #exactRange """
self.expression.min = int(ctx.INTEGER().getText())
self.expression.max = self.expression.min | python | def visitExactRange(self, ctx: ShExDocParser.ExactRangeContext):
""" repeatRange: '{' INTEGER '}' #exactRange """
self.expression.min = int(ctx.INTEGER().getText())
self.expression.max = self.expression.min | [
"def",
"visitExactRange",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"ExactRangeContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"int",
"(",
"ctx",
".",
"INTEGER",
"(",
")",
".",
"getText",
"(",
")",
")",
"self",
".",
"expressio... | repeatRange: '{' INTEGER '}' #exactRange | [
"repeatRange",
":",
"{",
"INTEGER",
"}",
"#exactRange"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L104-L107 | train | visitExactRange : set min and max |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitMinMaxRange | def visitMinMaxRange(self, ctx: ShExDocParser.MinMaxRangeContext):
""" repeatRange: '{' INTEGER (',' (INTEGER | UNBOUNDED)? '}' """
self.expression.min = int(ctx.INTEGER(0).getText())
self.expression.max = int(ctx.INTEGER(1).getText()) if len(ctx.INTEGER()) > 1 else -1 | python | def visitMinMaxRange(self, ctx: ShExDocParser.MinMaxRangeContext):
""" repeatRange: '{' INTEGER (',' (INTEGER | UNBOUNDED)? '}' """
self.expression.min = int(ctx.INTEGER(0).getText())
self.expression.max = int(ctx.INTEGER(1).getText()) if len(ctx.INTEGER()) > 1 else -1 | [
"def",
"visitMinMaxRange",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"MinMaxRangeContext",
")",
":",
"self",
".",
"expression",
".",
"min",
"=",
"int",
"(",
"ctx",
".",
"INTEGER",
"(",
"0",
")",
".",
"getText",
"(",
")",
")",
"self",
".",
"... | repeatRange: '{' INTEGER (',' (INTEGER | UNBOUNDED)? '}' | [
"repeatRange",
":",
"{",
"INTEGER",
"(",
"(",
"INTEGER",
"|",
"UNBOUNDED",
")",
"?",
"}"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L109-L112 | train | visitMinMaxRange returns repeatRange |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitSenseFlags | def visitSenseFlags(self, ctx: ShExDocParser.SenseFlagsContext):
""" '!' '^'? | '^' '!'? """
if '!' in ctx.getText():
self.expression.negated = True
if '^' in ctx.getText():
self.expression.inverse = True | python | def visitSenseFlags(self, ctx: ShExDocParser.SenseFlagsContext):
""" '!' '^'? | '^' '!'? """
if '!' in ctx.getText():
self.expression.negated = True
if '^' in ctx.getText():
self.expression.inverse = True | [
"def",
"visitSenseFlags",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"SenseFlagsContext",
")",
":",
"if",
"'!'",
"in",
"ctx",
".",
"getText",
"(",
")",
":",
"self",
".",
"expression",
".",
"negated",
"=",
"True",
"if",
"'^'",
"in",
"ctx",
".",... | '!' '^'? | '^' '!'? | [
"!",
"^",
"?",
"|",
"^",
"!",
"?"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L114-L119 | train | Set expression negated and inverse to True. |
shexSpec/grammar | parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py | ShexOneOfShapeParser.visitPredicate | def visitPredicate(self, ctx: ShExDocParser.PredicateContext):
""" predicate: iri | rdfType """
self.expression.predicate = self.context.predicate_to_IRI(ctx) | python | def visitPredicate(self, ctx: ShExDocParser.PredicateContext):
""" predicate: iri | rdfType """
self.expression.predicate = self.context.predicate_to_IRI(ctx) | [
"def",
"visitPredicate",
"(",
"self",
",",
"ctx",
":",
"ShExDocParser",
".",
"PredicateContext",
")",
":",
"self",
".",
"expression",
".",
"predicate",
"=",
"self",
".",
"context",
".",
"predicate_to_IRI",
"(",
"ctx",
")"
] | predicate: iri | rdfType | [
"predicate",
":",
"iri",
"|",
"rdfType"
] | 4497cd1f73fa6703bca6e2cb53ba9c120f22e48c | https://github.com/shexSpec/grammar/blob/4497cd1f73fa6703bca6e2cb53ba9c120f22e48c/parsers/python/pyshexc/parser_impl/shex_oneofshape_parser.py#L121-L123 | train | Set the predicate of the taxonomy. |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.