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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.getRankingBruteForce | def getRankingBruteForce(self, profile):
"""
Returns a list that orders all candidates from best to worst when we use brute force to
compute Bayesian utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child Mechanism... | python | def getRankingBruteForce(self, profile):
"""
Returns a list that orders all candidates from best to worst when we use brute force to
compute Bayesian utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child Mechanism... | [
"def",
"getRankingBruteForce",
"(",
"self",
",",
"profile",
")",
":",
"# We generate a map that associates each score with the candidates that have that score.",
"candScoresMapBruteForce",
"=",
"self",
".",
"getCandScoresMapBruteForce",
"(",
"profile",
")",
"reverseCandScoresMap",
... | Returns a list that orders all candidates from best to worst when we use brute force to
compute Bayesian utilities for an election profile. This function assumes that
getCandScoresMapBruteForce(profile) is implemented for the child Mechanism class. Note that
the returned list gives no indicati... | [
"Returns",
"a",
"list",
"that",
"orders",
"all",
"candidates",
"from",
"best",
"to",
"worst",
"when",
"we",
"use",
"brute",
"force",
"to",
"compute",
"Bayesian",
"utilities",
"for",
"an",
"election",
"profile",
".",
"This",
"function",
"assumes",
"that",
"ge... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L140-L171 | train | Returns a list that orders all candidates from best to worst when we use brute force to maintain order. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmc.printMcmcSamplesToFile | def printMcmcSamplesToFile(self, profile, numSamples, outFileName):
"""
Generate samples to a file.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar int numSamples: The number of samples to be generated.
:ivar str outFileName: The name of the fi... | python | def printMcmcSamplesToFile(self, profile, numSamples, outFileName):
"""
Generate samples to a file.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar int numSamples: The number of samples to be generated.
:ivar str outFileName: The name of the fi... | [
"def",
"printMcmcSamplesToFile",
"(",
"self",
",",
"profile",
",",
"numSamples",
",",
"outFileName",
")",
":",
"wmg",
"=",
"profile",
".",
"getWmg",
"(",
"True",
")",
"V",
"=",
"self",
".",
"getInitialSample",
"(",
"wmg",
")",
"# Print the number of candidates... | Generate samples to a file.
:ivar Profile profile: A Profile object that represents an election profile.
:ivar int numSamples: The number of samples to be generated.
:ivar str outFileName: The name of the file to be output. | [
"Generate",
"samples",
"to",
"a",
"file",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L214-L235 | train | Print the number of samples to a file. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcMallows.kendallTau | def kendallTau(self, orderVector, wmgMap):
"""
Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau
distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the
election. Currently, we expect the vote to be a st... | python | def kendallTau(self, orderVector, wmgMap):
"""
Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau
distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the
election. Currently, we expect the vote to be a st... | [
"def",
"kendallTau",
"(",
"self",
",",
"orderVector",
",",
"wmgMap",
")",
":",
"discordantPairs",
"=",
"0.0",
"for",
"i",
"in",
"itertools",
".",
"combinations",
"(",
"orderVector",
",",
"2",
")",
":",
"discordantPairs",
"=",
"discordantPairs",
"+",
"max",
... | Given a ranking for a single vote and a wmg for the entire election, calculate the kendall-tau
distance. a.k.a the number of discordant pairs between the wmg for the vote and the wmg for the
election. Currently, we expect the vote to be a strict complete ordering over the candidates.
:ivar list... | [
"Given",
"a",
"ranking",
"for",
"a",
"single",
"vote",
"and",
"a",
"wmg",
"for",
"the",
"entire",
"election",
"calculate",
"the",
"kendall",
"-",
"tau",
"distance",
".",
"a",
".",
"k",
".",
"a",
"the",
"number",
"of",
"discordant",
"pairs",
"between",
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L253-L270 | train | Calculates the kendall - tau distance between a single vote and a wmg for the entire election. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcMallows.getInitialSample | def getInitialSample(self, wmg):
"""
Generate an initial sample for the Markov chain. This function will return a list
containing integer representations of each candidate in order of their rank in the current
vote, from first to last. The list will be a complete strict ordering over t... | python | def getInitialSample(self, wmg):
"""
Generate an initial sample for the Markov chain. This function will return a list
containing integer representations of each candidate in order of their rank in the current
vote, from first to last. The list will be a complete strict ordering over t... | [
"def",
"getInitialSample",
"(",
"self",
",",
"wmg",
")",
":",
"V",
"=",
"copy",
".",
"deepcopy",
"(",
"wmg",
".",
"keys",
"(",
")",
")",
"random",
".",
"shuffle",
"(",
"V",
")",
"return",
"V"
] | Generate an initial sample for the Markov chain. This function will return a list
containing integer representations of each candidate in order of their rank in the current
vote, from first to last. The list will be a complete strict ordering over the candidates.
Initially, we rank the candida... | [
"Generate",
"an",
"initial",
"sample",
"for",
"the",
"Markov",
"chain",
".",
"This",
"function",
"will",
"return",
"a",
"list",
"containing",
"integer",
"representations",
"of",
"each",
"candidate",
"in",
"order",
"of",
"their",
"rank",
"in",
"the",
"current",... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L272-L287 | train | Generates an initial sample for the Markov chain. This function is called by MarkovChain. generateRandomSample. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcMallows.getCandScoresMapBruteForce | def getCandScoresMapBruteForce(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile.
"""
... | python | def getCandScoresMapBruteForce(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile.
"""
... | [
"def",
"getCandScoresMapBruteForce",
"(",
"self",
",",
"profile",
")",
":",
"wmg",
"=",
"profile",
".",
"getWmg",
"(",
"True",
")",
"losses",
"=",
"dict",
"(",
")",
"for",
"cand",
"in",
"wmg",
".",
"keys",
"(",
")",
":",
"losses",
"[",
"cand",
"]",
... | Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictonary",
"that",
"associates",
"the",
"integer",
"representation",
"of",
"each",
"candidate",
"with",
"the",
"bayesian",
"losses",
"that",
"we",
"calculate",
"using",
"brute",
"force",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L289-L311 | train | Returns a dictonary that associates the integer representation of each candidate with the integer representation of each candidate with the bayesian losses that we calculate using brute force. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcCondorcet.createBinaryRelation | def createBinaryRelation(self, m):
"""
Initialize a two-dimensional array of size m by m.
:ivar int m: A value for m.
"""
binaryRelation = []
for i in range(m):
binaryRelation.append(range(m))
binaryRelation[i][i] = 0
return binaryRel... | python | def createBinaryRelation(self, m):
"""
Initialize a two-dimensional array of size m by m.
:ivar int m: A value for m.
"""
binaryRelation = []
for i in range(m):
binaryRelation.append(range(m))
binaryRelation[i][i] = 0
return binaryRel... | [
"def",
"createBinaryRelation",
"(",
"self",
",",
"m",
")",
":",
"binaryRelation",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"m",
")",
":",
"binaryRelation",
".",
"append",
"(",
"range",
"(",
"m",
")",
")",
"binaryRelation",
"[",
"i",
"]",
"[",
... | Initialize a two-dimensional array of size m by m.
:ivar int m: A value for m. | [
"Initialize",
"a",
"two",
"-",
"dimensional",
"array",
"of",
"size",
"m",
"by",
"m",
".",
":",
"ivar",
"int",
"m",
":",
"A",
"value",
"for",
"m",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L328-L339 | train | Create a two - dimensional array of size m by m. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcCondorcet.getInitialSample | def getInitialSample(self, wmg):
"""
Generate an initial sample for the Markov chain. This function will return a
two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2,
the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise.
... | python | def getInitialSample(self, wmg):
"""
Generate an initial sample for the Markov chain. This function will return a
two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2,
the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise.
... | [
"def",
"getInitialSample",
"(",
"self",
",",
"wmg",
")",
":",
"cands",
"=",
"range",
"(",
"len",
"(",
"wmg",
")",
")",
"allPairs",
"=",
"itertools",
".",
"combinations",
"(",
"cands",
",",
"2",
")",
"V",
"=",
"self",
".",
"createBinaryRelation",
"(",
... | Generate an initial sample for the Markov chain. This function will return a
two-dimensional array of integers, such that for each pair of candidates, cand1 and cand2,
the array contains 1 if more votes rank cand1 above cand2 and 0 otherwise.
ivar: dict<int,<dict,<int,int>>> wmg: A two-dimensi... | [
"Generate",
"an",
"initial",
"sample",
"for",
"the",
"Markov",
"chain",
".",
"This",
"function",
"will",
"return",
"a",
"two",
"-",
"dimensional",
"array",
"of",
"integers",
"such",
"that",
"for",
"each",
"pair",
"of",
"candidates",
"cand1",
"and",
"cand2",
... | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L341-L363 | train | This function generates an initial sample for the Markov chain. This function returns a two - dimensional array of integers such that for each pair of candidates cand1 and cand2 cand1 and cand2 and 0 if more votes rank cand1 and cand2 and 1 if more votes rank cand1 and cand2 and 0 otherwise. |
PrefPy/prefpy | prefpy/mechanismMcmc.py | MechanismMcmcCondorcet.getCandScoresMapBruteForce | def getCandScoresMapBruteForce(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile.
"""
... | python | def getCandScoresMapBruteForce(self, profile):
"""
Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile.
"""
... | [
"def",
"getCandScoresMapBruteForce",
"(",
"self",
",",
"profile",
")",
":",
"wmg",
"=",
"profile",
".",
"getWmg",
"(",
"True",
")",
"m",
"=",
"len",
"(",
"wmg",
".",
"keys",
"(",
")",
")",
"cands",
"=",
"range",
"(",
"m",
")",
"V",
"=",
"self",
"... | Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force.
:ivar Profile profile: A Profile object that represents an election profile. | [
"Returns",
"a",
"dictonary",
"that",
"associates",
"the",
"integer",
"representation",
"of",
"each",
"candidate",
"with",
"the",
"bayesian",
"losses",
"that",
"we",
"calculate",
"using",
"brute",
"force",
"."
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/mechanismMcmc.py#L365-L396 | train | Returns a dictonary that associates the integer representation of each candidate with the
bayesian losses that we calculate using brute force. |
tamasgal/km3pipe | pipeinspector/app.py | filter_input | def filter_input(keys, raw):
"""Adds fancy mouse wheel functionality and VI navigation to ListBox"""
if len(keys) == 1:
if keys[0] in UI.keys['up']:
keys[0] = 'up'
elif keys[0] in UI.keys['down']:
keys[0] = 'down'
elif len(keys[0]) == 4 and keys[0][0] == 'mouse pr... | python | def filter_input(keys, raw):
"""Adds fancy mouse wheel functionality and VI navigation to ListBox"""
if len(keys) == 1:
if keys[0] in UI.keys['up']:
keys[0] = 'up'
elif keys[0] in UI.keys['down']:
keys[0] = 'down'
elif len(keys[0]) == 4 and keys[0][0] == 'mouse pr... | [
"def",
"filter_input",
"(",
"keys",
",",
"raw",
")",
":",
"if",
"len",
"(",
"keys",
")",
"==",
"1",
":",
"if",
"keys",
"[",
"0",
"]",
"in",
"UI",
".",
"keys",
"[",
"'up'",
"]",
":",
"keys",
"[",
"0",
"]",
"=",
"'up'",
"elif",
"keys",
"[",
"... | Adds fancy mouse wheel functionality and VI navigation to ListBox | [
"Adds",
"fancy",
"mouse",
"wheel",
"functionality",
"and",
"VI",
"navigation",
"to",
"ListBox"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/pipeinspector/app.py#L39-L51 | train | Filter out the input keys that are not in the listbox. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | wordlist2cognates | def wordlist2cognates(wordlist, source, expert='expert', ref='cogid'):
"""Turn a wordlist into a cognate set list, using the cldf parameters."""
for k in wordlist:
yield dict(
Form_ID=wordlist[k, 'lid'],
ID=k,
Form=wordlist[k, 'ipa'],
Cognateset_ID='{0}-{1... | python | def wordlist2cognates(wordlist, source, expert='expert', ref='cogid'):
"""Turn a wordlist into a cognate set list, using the cldf parameters."""
for k in wordlist:
yield dict(
Form_ID=wordlist[k, 'lid'],
ID=k,
Form=wordlist[k, 'ipa'],
Cognateset_ID='{0}-{1... | [
"def",
"wordlist2cognates",
"(",
"wordlist",
",",
"source",
",",
"expert",
"=",
"'expert'",
",",
"ref",
"=",
"'cogid'",
")",
":",
"for",
"k",
"in",
"wordlist",
":",
"yield",
"dict",
"(",
"Form_ID",
"=",
"wordlist",
"[",
"k",
",",
"'lid'",
"]",
",",
"... | Turn a wordlist into a cognate set list, using the cldf parameters. | [
"Turn",
"a",
"wordlist",
"into",
"a",
"cognate",
"set",
"list",
"using",
"the",
"cldf",
"parameters",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L9-L19 | train | Turn a wordlist into a cognate set list using the cldf parameters. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | _cldf2wld | def _cldf2wld(dataset):
"""Make lingpy-compatible dictinary out of cldf main data."""
header = [f for f in dataset.dataset.lexeme_class.fieldnames() if f != 'ID']
D = {0: ['lid'] + [h.lower() for h in header]}
for idx, row in enumerate(dataset.objects['FormTable']):
row = deepcopy(row)
r... | python | def _cldf2wld(dataset):
"""Make lingpy-compatible dictinary out of cldf main data."""
header = [f for f in dataset.dataset.lexeme_class.fieldnames() if f != 'ID']
D = {0: ['lid'] + [h.lower() for h in header]}
for idx, row in enumerate(dataset.objects['FormTable']):
row = deepcopy(row)
r... | [
"def",
"_cldf2wld",
"(",
"dataset",
")",
":",
"header",
"=",
"[",
"f",
"for",
"f",
"in",
"dataset",
".",
"dataset",
".",
"lexeme_class",
".",
"fieldnames",
"(",
")",
"if",
"f",
"!=",
"'ID'",
"]",
"D",
"=",
"{",
"0",
":",
"[",
"'lid'",
"]",
"+",
... | Make lingpy-compatible dictinary out of cldf main data. | [
"Make",
"lingpy",
"-",
"compatible",
"dictinary",
"out",
"of",
"cldf",
"main",
"data",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L22-L30 | train | Make lingpy - compatible dictinary out of cldf main data. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | _cldf2lexstat | def _cldf2lexstat(
dataset,
segments='segments',
transcription='value',
row='parameter_id',
col='language_id'):
"""Read LexStat object from cldf dataset."""
D = _cldf2wld(dataset)
return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=co... | python | def _cldf2lexstat(
dataset,
segments='segments',
transcription='value',
row='parameter_id',
col='language_id'):
"""Read LexStat object from cldf dataset."""
D = _cldf2wld(dataset)
return lingpy.LexStat(D, segments=segments, transcription=transcription, row=row, col=co... | [
"def",
"_cldf2lexstat",
"(",
"dataset",
",",
"segments",
"=",
"'segments'",
",",
"transcription",
"=",
"'value'",
",",
"row",
"=",
"'parameter_id'",
",",
"col",
"=",
"'language_id'",
")",
":",
"D",
"=",
"_cldf2wld",
"(",
"dataset",
")",
"return",
"lingpy",
... | Read LexStat object from cldf dataset. | [
"Read",
"LexStat",
"object",
"from",
"cldf",
"dataset",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L33-L41 | train | Read LexStat object from cldf dataset. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | _cldf2wordlist | def _cldf2wordlist(dataset, row='parameter_id', col='language_id'):
"""Read worldist object from cldf dataset."""
return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col) | python | def _cldf2wordlist(dataset, row='parameter_id', col='language_id'):
"""Read worldist object from cldf dataset."""
return lingpy.Wordlist(_cldf2wld(dataset), row=row, col=col) | [
"def",
"_cldf2wordlist",
"(",
"dataset",
",",
"row",
"=",
"'parameter_id'",
",",
"col",
"=",
"'language_id'",
")",
":",
"return",
"lingpy",
".",
"Wordlist",
"(",
"_cldf2wld",
"(",
"dataset",
")",
",",
"row",
"=",
"row",
",",
"col",
"=",
"col",
")"
] | Read worldist object from cldf dataset. | [
"Read",
"worldist",
"object",
"from",
"cldf",
"dataset",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L44-L46 | train | Read worldist object from cldf dataset. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | iter_cognates | def iter_cognates(dataset, column='Segments', method='turchin', threshold=0.5, **kw):
"""
Compute cognates automatically for a given dataset.
"""
if method == 'turchin':
for row in dataset.objects['FormTable']:
sounds = ''.join(lingpy.tokens2class(row[column], 'dolgo'))
i... | python | def iter_cognates(dataset, column='Segments', method='turchin', threshold=0.5, **kw):
"""
Compute cognates automatically for a given dataset.
"""
if method == 'turchin':
for row in dataset.objects['FormTable']:
sounds = ''.join(lingpy.tokens2class(row[column], 'dolgo'))
i... | [
"def",
"iter_cognates",
"(",
"dataset",
",",
"column",
"=",
"'Segments'",
",",
"method",
"=",
"'turchin'",
",",
"threshold",
"=",
"0.5",
",",
"*",
"*",
"kw",
")",
":",
"if",
"method",
"==",
"'turchin'",
":",
"for",
"row",
"in",
"dataset",
".",
"objects... | Compute cognates automatically for a given dataset. | [
"Compute",
"cognates",
"automatically",
"for",
"a",
"given",
"dataset",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L49-L77 | train | Iterate over all cognates in a given dataset. |
lexibank/pylexibank | src/pylexibank/lingpy_util.py | iter_alignments | def iter_alignments(dataset, cognate_sets, column='Segments', method='library'):
"""
Function computes automatic alignments and writes them to file.
"""
if not isinstance(dataset, lingpy.basic.parser.QLCParser):
wordlist = _cldf2wordlist(dataset)
cognates = {r['Form_ID']: r for r in cogn... | python | def iter_alignments(dataset, cognate_sets, column='Segments', method='library'):
"""
Function computes automatic alignments and writes them to file.
"""
if not isinstance(dataset, lingpy.basic.parser.QLCParser):
wordlist = _cldf2wordlist(dataset)
cognates = {r['Form_ID']: r for r in cogn... | [
"def",
"iter_alignments",
"(",
"dataset",
",",
"cognate_sets",
",",
"column",
"=",
"'Segments'",
",",
"method",
"=",
"'library'",
")",
":",
"if",
"not",
"isinstance",
"(",
"dataset",
",",
"lingpy",
".",
"basic",
".",
"parser",
".",
"QLCParser",
")",
":",
... | Function computes automatic alignments and writes them to file. | [
"Function",
"computes",
"automatic",
"alignments",
"and",
"writes",
"them",
"to",
"file",
"."
] | c28e7f122f20de1232623dd7003cb5b01535e581 | https://github.com/lexibank/pylexibank/blob/c28e7f122f20de1232623dd7003cb5b01535e581/src/pylexibank/lingpy_util.py#L80-L110 | train | Function computes automatic alignments and writes them to file. |
tamasgal/km3pipe | km3pipe/utils/tohdf5.py | tohdf5 | def tohdf5(input_files, output_file, n_events, conv_times_to_jte, **kwargs):
"""Convert Any file to HDF5 file"""
if len(input_files) > 1:
cprint(
"Preparing to convert {} files to HDF5.".format(len(input_files))
)
from km3pipe import Pipeline # noqa
from km3pipe.io import... | python | def tohdf5(input_files, output_file, n_events, conv_times_to_jte, **kwargs):
"""Convert Any file to HDF5 file"""
if len(input_files) > 1:
cprint(
"Preparing to convert {} files to HDF5.".format(len(input_files))
)
from km3pipe import Pipeline # noqa
from km3pipe.io import... | [
"def",
"tohdf5",
"(",
"input_files",
",",
"output_file",
",",
"n_events",
",",
"conv_times_to_jte",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"len",
"(",
"input_files",
")",
">",
"1",
":",
"cprint",
"(",
"\"Preparing to convert {} files to HDF5.\"",
".",
"forma... | Convert Any file to HDF5 file | [
"Convert",
"Any",
"file",
"to",
"HDF5",
"file"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/tohdf5.py#L46-L73 | train | Convert Any file to HDF5 file |
IRC-SPHERE/HyperStream | hyperstream/channels/channel_manager.py | ChannelManager.update_channels | def update_channels(self):
"""
Pulls out all of the stream definitions from the database, and populates the channels with stream references
"""
logging.info("Updating channels")
with switch_db(StreamDefinitionModel, 'hyperstream'):
for s in StreamDefinitionModel.objec... | python | def update_channels(self):
"""
Pulls out all of the stream definitions from the database, and populates the channels with stream references
"""
logging.info("Updating channels")
with switch_db(StreamDefinitionModel, 'hyperstream'):
for s in StreamDefinitionModel.objec... | [
"def",
"update_channels",
"(",
"self",
")",
":",
"logging",
".",
"info",
"(",
"\"Updating channels\"",
")",
"with",
"switch_db",
"(",
"StreamDefinitionModel",
",",
"'hyperstream'",
")",
":",
"for",
"s",
"in",
"StreamDefinitionModel",
".",
"objects",
"(",
")",
... | Pulls out all of the stream definitions from the database, and populates the channels with stream references | [
"Pulls",
"out",
"all",
"of",
"the",
"stream",
"definitions",
"from",
"the",
"database",
"and",
"populates",
"the",
"channels",
"with",
"stream",
"references"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/channel_manager.py#L97-L146 | train | Updates the channels with the stream references from the database. |
IRC-SPHERE/HyperStream | hyperstream/channels/channel_manager.py | ChannelManager.get_tool_class | def get_tool_class(self, tool):
"""
Gets the actual class which can then be instantiated with its parameters
:param tool: The tool name or id
:type tool: str | unicode | StreamId
:rtype: Tool | MultiOutputTool
:return: The tool class
"""
if isinstance(too... | python | def get_tool_class(self, tool):
"""
Gets the actual class which can then be instantiated with its parameters
:param tool: The tool name or id
:type tool: str | unicode | StreamId
:rtype: Tool | MultiOutputTool
:return: The tool class
"""
if isinstance(too... | [
"def",
"get_tool_class",
"(",
"self",
",",
"tool",
")",
":",
"if",
"isinstance",
"(",
"tool",
",",
"string_types",
")",
":",
"tool_id",
"=",
"StreamId",
"(",
"tool",
")",
"elif",
"isinstance",
"(",
"tool",
",",
"StreamId",
")",
":",
"tool_id",
"=",
"to... | Gets the actual class which can then be instantiated with its parameters
:param tool: The tool name or id
:type tool: str | unicode | StreamId
:rtype: Tool | MultiOutputTool
:return: The tool class | [
"Gets",
"the",
"actual",
"class",
"which",
"can",
"then",
"be",
"instantiated",
"with",
"its",
"parameters"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/channel_manager.py#L148-L186 | train | Gets the actual class which can then be instantiated with its parameters
|
IRC-SPHERE/HyperStream | hyperstream/channels/channel_manager.py | ChannelManager.get_tool | def get_tool(self, name, parameters, version=None):
"""
Gets the tool object from the tool channel(s), and instantiates it using the tool parameters
:param name: The name or stream id for the tool in the tool channel
:param parameters: The parameters for the tool
:param version:... | python | def get_tool(self, name, parameters, version=None):
"""
Gets the tool object from the tool channel(s), and instantiates it using the tool parameters
:param name: The name or stream id for the tool in the tool channel
:param parameters: The parameters for the tool
:param version:... | [
"def",
"get_tool",
"(",
"self",
",",
"name",
",",
"parameters",
",",
"version",
"=",
"None",
")",
":",
"# TODO: use the version",
"if",
"version",
"is",
"not",
"None",
":",
"logging",
".",
"warn",
"(",
"\"Tool versions not yet supported\"",
")",
"tool_class",
... | Gets the tool object from the tool channel(s), and instantiates it using the tool parameters
:param name: The name or stream id for the tool in the tool channel
:param parameters: The parameters for the tool
:param version: The string representation of the version
:return: The instantia... | [
"Gets",
"the",
"tool",
"object",
"from",
"the",
"tool",
"channel",
"(",
"s",
")",
"and",
"instantiates",
"it",
"using",
"the",
"tool",
"parameters"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/channel_manager.py#L188-L227 | train | Gets the tool object from the tool channel and instantiates it using the parameters. |
IRC-SPHERE/HyperStream | hyperstream/plate/plate.py | Plate._get_ancestors | def _get_ancestors(self, current=None):
"""
Gets the ancestors of this node
:param current: The current ancestor list
:return: The ancestor list
:type current: list[Plate] | list[str] | list[unicode] | None
:rtype: list[Plate] | list[str] | list[unicode]
"""
... | python | def _get_ancestors(self, current=None):
"""
Gets the ancestors of this node
:param current: The current ancestor list
:return: The ancestor list
:type current: list[Plate] | list[str] | list[unicode] | None
:rtype: list[Plate] | list[str] | list[unicode]
"""
... | [
"def",
"_get_ancestors",
"(",
"self",
",",
"current",
"=",
"None",
")",
":",
"if",
"not",
"current",
":",
"current",
"=",
"[",
"]",
"current",
".",
"insert",
"(",
"0",
",",
"self",
")",
"if",
"self",
".",
"is_root",
":",
"if",
"current",
":",
"retu... | Gets the ancestors of this node
:param current: The current ancestor list
:return: The ancestor list
:type current: list[Plate] | list[str] | list[unicode] | None
:rtype: list[Plate] | list[str] | list[unicode] | [
"Gets",
"the",
"ancestors",
"of",
"this",
"node",
":",
"param",
"current",
":",
"The",
"current",
"ancestor",
"list",
":",
"return",
":",
"The",
"ancestor",
"list",
":",
"type",
"current",
":",
"list",
"[",
"Plate",
"]",
"|",
"list",
"[",
"str",
"]",
... | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/plate/plate.py#L85-L100 | train | Gets the ancestors of this node |
IRC-SPHERE/HyperStream | hyperstream/plate/plate.py | Plate.combine_values | def combine_values(parent_plate_value, plate_value):
"""
Combine the plate value(s) with the parent plate value(s)
:param parent_plate_value: The parent plate value(s)
:param plate_value: The plate value(s)
:return: The combined plate values
"""
if parent_plate_va... | python | def combine_values(parent_plate_value, plate_value):
"""
Combine the plate value(s) with the parent plate value(s)
:param parent_plate_value: The parent plate value(s)
:param plate_value: The plate value(s)
:return: The combined plate values
"""
if parent_plate_va... | [
"def",
"combine_values",
"(",
"parent_plate_value",
",",
"plate_value",
")",
":",
"if",
"parent_plate_value",
":",
"if",
"isinstance",
"(",
"plate_value",
"[",
"0",
"]",
",",
"string_types",
")",
":",
"combined_plate_value",
"=",
"parent_plate_value",
"+",
"(",
... | Combine the plate value(s) with the parent plate value(s)
:param parent_plate_value: The parent plate value(s)
:param plate_value: The plate value(s)
:return: The combined plate values | [
"Combine",
"the",
"plate",
"value",
"(",
"s",
")",
"with",
"the",
"parent",
"plate",
"value",
"(",
"s",
")",
":",
"param",
"parent_plate_value",
":",
"The",
"parent",
"plate",
"value",
"(",
"s",
")",
":",
"param",
"plate_value",
":",
"The",
"plate",
"v... | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/plate/plate.py#L196-L213 | train | Combine the plate value with the parent plate value. |
IRC-SPHERE/HyperStream | hyperstream/plate/plate.py | Plate.get_overlapping_values | def get_overlapping_values(plates):
"""
Need to find where in the tree the two plates intersect, e.g.
We are given as input plates D, E, whose positions in the tree are:
root -> A -> B -> C -> D
root -> A -> B -> E
The results should then be the cartesian product betwe... | python | def get_overlapping_values(plates):
"""
Need to find where in the tree the two plates intersect, e.g.
We are given as input plates D, E, whose positions in the tree are:
root -> A -> B -> C -> D
root -> A -> B -> E
The results should then be the cartesian product betwe... | [
"def",
"get_overlapping_values",
"(",
"plates",
")",
":",
"if",
"not",
"plates",
":",
"return",
"None",
"if",
"len",
"(",
"plates",
")",
"==",
"1",
":",
"return",
"plates",
"[",
"0",
"]",
".",
"values",
"if",
"len",
"(",
"plates",
")",
">",
"2",
":... | Need to find where in the tree the two plates intersect, e.g.
We are given as input plates D, E, whose positions in the tree are:
root -> A -> B -> C -> D
root -> A -> B -> E
The results should then be the cartesian product between C, D, E looped over A and B
If there's a sha... | [
"Need",
"to",
"find",
"where",
"in",
"the",
"tree",
"the",
"two",
"plates",
"intersect",
"e",
".",
"g",
"."
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/plate/plate.py#L216-L315 | train | This function returns the values of the overlapping meta data for the given plates. |
NaPs/Kolekto | kolekto/commands/list.py | List._config | def _config(self, args, config):
""" Get configuration for the current used listing.
"""
listings = dict((x.args, x) for x in config.subsections('listing'))
listing = listings.get(args.listing)
if listing is None:
if args.listing == u'default':
return ... | python | def _config(self, args, config):
""" Get configuration for the current used listing.
"""
listings = dict((x.args, x) for x in config.subsections('listing'))
listing = listings.get(args.listing)
if listing is None:
if args.listing == u'default':
return ... | [
"def",
"_config",
"(",
"self",
",",
"args",
",",
"config",
")",
":",
"listings",
"=",
"dict",
"(",
"(",
"x",
".",
"args",
",",
"x",
")",
"for",
"x",
"in",
"config",
".",
"subsections",
"(",
"'listing'",
")",
")",
"listing",
"=",
"listings",
".",
... | Get configuration for the current used listing. | [
"Get",
"configuration",
"for",
"the",
"current",
"used",
"listing",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/list.py#L45-L58 | train | Get the configuration for the current used listing. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries.py | TimeSeries._merge_points | def _merge_points(self, pc1, pc2):
"""
Merges points based on time/location.
@TODO: move to paegan, SO SLOW
"""
res = pc1[:]
for p in pc2:
for sp in res:
if sp.time == p.time and (
sp.location is None or (sp.location.equal... | python | def _merge_points(self, pc1, pc2):
"""
Merges points based on time/location.
@TODO: move to paegan, SO SLOW
"""
res = pc1[:]
for p in pc2:
for sp in res:
if sp.time == p.time and (
sp.location is None or (sp.location.equal... | [
"def",
"_merge_points",
"(",
"self",
",",
"pc1",
",",
"pc2",
")",
":",
"res",
"=",
"pc1",
"[",
":",
"]",
"for",
"p",
"in",
"pc2",
":",
"for",
"sp",
"in",
"res",
":",
"if",
"sp",
".",
"time",
"==",
"p",
".",
"time",
"and",
"(",
"sp",
".",
"l... | Merges points based on time/location.
@TODO: move to paegan, SO SLOW | [
"Merges",
"points",
"based",
"on",
"time",
"/",
"location",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries.py#L232-L250 | train | Merge two sets of points based on time and location. |
thebigmunch/google-music-utils | src/google_music_utils/utils.py | normalize_value | def normalize_value(value):
"""Normalize metadata value to improve match accuracy."""
value = str(value)
value = value.casefold()
value = re.sub(r'\/\s*\d+', '', value) # Remove "/<totaltracks>" from track number.
value = re.sub(r'^0+([0-9]+)', r'\1', value) # Remove leading zero(s) from track number.
value =... | python | def normalize_value(value):
"""Normalize metadata value to improve match accuracy."""
value = str(value)
value = value.casefold()
value = re.sub(r'\/\s*\d+', '', value) # Remove "/<totaltracks>" from track number.
value = re.sub(r'^0+([0-9]+)', r'\1', value) # Remove leading zero(s) from track number.
value =... | [
"def",
"normalize_value",
"(",
"value",
")",
":",
"value",
"=",
"str",
"(",
"value",
")",
"value",
"=",
"value",
".",
"casefold",
"(",
")",
"value",
"=",
"re",
".",
"sub",
"(",
"r'\\/\\s*\\d+'",
",",
"''",
",",
"value",
")",
"# Remove \"/<totaltracks>\" ... | Normalize metadata value to improve match accuracy. | [
"Normalize",
"metadata",
"value",
"to",
"improve",
"match",
"accuracy",
"."
] | 2e8873defe7d5aab7321b9d5ec8a80d72687578e | https://github.com/thebigmunch/google-music-utils/blob/2e8873defe7d5aab7321b9d5ec8a80d72687578e/src/google_music_utils/utils.py#L53-L68 | train | Normalize metadata value to improve match accuracy. |
ioos/pyoos | pyoos/utils/dataorg.py | flatten_element | def flatten_element(p):
"""
Convenience function to return record-style time series representation
from elements ('p') members in station element.
member['standard'] is a standard_name parameter name, typically CF based.
Ideally, member['value'] should already be floating point value,
so it's re... | python | def flatten_element(p):
"""
Convenience function to return record-style time series representation
from elements ('p') members in station element.
member['standard'] is a standard_name parameter name, typically CF based.
Ideally, member['value'] should already be floating point value,
so it's re... | [
"def",
"flatten_element",
"(",
"p",
")",
":",
"rd",
"=",
"{",
"\"time\"",
":",
"p",
".",
"time",
"}",
"for",
"member",
"in",
"p",
".",
"members",
":",
"rd",
"[",
"member",
"[",
"\"standard\"",
"]",
"]",
"=",
"member",
"[",
"\"value\"",
"]",
"return... | Convenience function to return record-style time series representation
from elements ('p') members in station element.
member['standard'] is a standard_name parameter name, typically CF based.
Ideally, member['value'] should already be floating point value,
so it's ready to use.
Useful with most pyo... | [
"Convenience",
"function",
"to",
"return",
"record",
"-",
"style",
"time",
"series",
"representation",
"from",
"elements",
"(",
"p",
")",
"members",
"in",
"station",
"element",
".",
"member",
"[",
"standard",
"]",
"is",
"a",
"standard_name",
"parameter",
"name... | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/utils/dataorg.py#L4-L16 | train | Convenience function to flatten a station element into a record - style time series representation. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector._init_from_file | def _init_from_file(self, filename):
"""Create detector from detx file."""
if not filename.endswith("detx"):
raise NotImplementedError('Only the detx format is supported.')
self._open_file(filename)
self._extract_comments()
self._parse_header()
self._parse_dom... | python | def _init_from_file(self, filename):
"""Create detector from detx file."""
if not filename.endswith("detx"):
raise NotImplementedError('Only the detx format is supported.')
self._open_file(filename)
self._extract_comments()
self._parse_header()
self._parse_dom... | [
"def",
"_init_from_file",
"(",
"self",
",",
"filename",
")",
":",
"if",
"not",
"filename",
".",
"endswith",
"(",
"\"detx\"",
")",
":",
"raise",
"NotImplementedError",
"(",
"'Only the detx format is supported.'",
")",
"self",
".",
"_open_file",
"(",
"filename",
"... | Create detector from detx file. | [
"Create",
"detector",
"from",
"detx",
"file",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L92-L100 | train | Create detector from detx file. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector._readline | def _readline(self, ignore_comments=True):
"""The next line of the DETX file, optionally ignores comments"""
while True:
line = self._det_file.readline()
if line == '':
return line # To conform the EOF behaviour of .readline()
line = line.strip()
... | python | def _readline(self, ignore_comments=True):
"""The next line of the DETX file, optionally ignores comments"""
while True:
line = self._det_file.readline()
if line == '':
return line # To conform the EOF behaviour of .readline()
line = line.strip()
... | [
"def",
"_readline",
"(",
"self",
",",
"ignore_comments",
"=",
"True",
")",
":",
"while",
"True",
":",
"line",
"=",
"self",
".",
"_det_file",
".",
"readline",
"(",
")",
"if",
"line",
"==",
"''",
":",
"return",
"line",
"# To conform the EOF behaviour of .readl... | The next line of the DETX file, optionally ignores comments | [
"The",
"next",
"line",
"of",
"the",
"DETX",
"file",
"optionally",
"ignores",
"comments"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L106-L119 | train | Returns the next line of the DETX file. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector._extract_comments | def _extract_comments(self):
"""Retrieve all comments from the file"""
self._det_file.seek(0, 0)
for line in self._det_file.readlines():
line = line.strip()
if line.startswith('#'):
self.add_comment(line[1:]) | python | def _extract_comments(self):
"""Retrieve all comments from the file"""
self._det_file.seek(0, 0)
for line in self._det_file.readlines():
line = line.strip()
if line.startswith('#'):
self.add_comment(line[1:]) | [
"def",
"_extract_comments",
"(",
"self",
")",
":",
"self",
".",
"_det_file",
".",
"seek",
"(",
"0",
",",
"0",
")",
"for",
"line",
"in",
"self",
".",
"_det_file",
".",
"readlines",
"(",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"if",
... | Retrieve all comments from the file | [
"Retrieve",
"all",
"comments",
"from",
"the",
"file"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L121-L127 | train | Retrieve all comments from the file and add them to the object |
tamasgal/km3pipe | km3pipe/hardware.py | Detector._parse_header | def _parse_header(self):
"""Extract information from the header of the detector file"""
self.print("Parsing the DETX header")
self._det_file.seek(0, 0)
first_line = self._readline()
try:
self.det_id, self.n_doms = split(first_line, int)
self.version = 'v1'... | python | def _parse_header(self):
"""Extract information from the header of the detector file"""
self.print("Parsing the DETX header")
self._det_file.seek(0, 0)
first_line = self._readline()
try:
self.det_id, self.n_doms = split(first_line, int)
self.version = 'v1'... | [
"def",
"_parse_header",
"(",
"self",
")",
":",
"self",
".",
"print",
"(",
"\"Parsing the DETX header\"",
")",
"self",
".",
"_det_file",
".",
"seek",
"(",
"0",
",",
"0",
")",
"first_line",
"=",
"self",
".",
"_readline",
"(",
")",
"try",
":",
"self",
"."... | Extract information from the header of the detector file | [
"Extract",
"information",
"from",
"the",
"header",
"of",
"the",
"detector",
"file"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L129-L148 | train | Parse the header of the detector file and set the attributes. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector._parse_doms | def _parse_doms(self):
"""Extract dom information from detector file"""
self.print("Reading PMT information...")
self._det_file.seek(0, 0)
self._readline()
pmts = defaultdict(list)
pmt_index = 0
while True:
line = self._readline()
if line ... | python | def _parse_doms(self):
"""Extract dom information from detector file"""
self.print("Reading PMT information...")
self._det_file.seek(0, 0)
self._readline()
pmts = defaultdict(list)
pmt_index = 0
while True:
line = self._readline()
if line ... | [
"def",
"_parse_doms",
"(",
"self",
")",
":",
"self",
".",
"print",
"(",
"\"Reading PMT information...\"",
")",
"self",
".",
"_det_file",
".",
"seek",
"(",
"0",
",",
"0",
")",
"self",
".",
"_readline",
"(",
")",
"pmts",
"=",
"defaultdict",
"(",
"list",
... | Extract dom information from detector file | [
"Extract",
"dom",
"information",
"from",
"detector",
"file"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L151-L227 | train | Parses the DOMs from the detector file. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.dom_positions | def dom_positions(self):
"""The positions of the DOMs, calculated from PMT directions."""
if not self._dom_positions:
for dom_id in self.dom_ids:
mask = self.pmts.dom_id == dom_id
pmt_pos = self.pmts[mask].pos
pmt_dir = self.pmts[mask].dir
... | python | def dom_positions(self):
"""The positions of the DOMs, calculated from PMT directions."""
if not self._dom_positions:
for dom_id in self.dom_ids:
mask = self.pmts.dom_id == dom_id
pmt_pos = self.pmts[mask].pos
pmt_dir = self.pmts[mask].dir
... | [
"def",
"dom_positions",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"_dom_positions",
":",
"for",
"dom_id",
"in",
"self",
".",
"dom_ids",
":",
"mask",
"=",
"self",
".",
"pmts",
".",
"dom_id",
"==",
"dom_id",
"pmt_pos",
"=",
"self",
".",
"pmts",
... | The positions of the DOMs, calculated from PMT directions. | [
"The",
"positions",
"of",
"the",
"DOMs",
"calculated",
"from",
"PMT",
"directions",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L252-L261 | train | The positions of the DOMs calculated from PMT directions. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.dom_table | def dom_table(self):
"""A `Table` containing DOM attributes"""
if self._dom_table is None:
data = defaultdict(list)
for dom_id, (du, floor, _) in self.doms.items():
data['dom_id'].append(dom_id)
data['du'].append(du)
data['floor'].a... | python | def dom_table(self):
"""A `Table` containing DOM attributes"""
if self._dom_table is None:
data = defaultdict(list)
for dom_id, (du, floor, _) in self.doms.items():
data['dom_id'].append(dom_id)
data['du'].append(du)
data['floor'].a... | [
"def",
"dom_table",
"(",
"self",
")",
":",
"if",
"self",
".",
"_dom_table",
"is",
"None",
":",
"data",
"=",
"defaultdict",
"(",
"list",
")",
"for",
"dom_id",
",",
"(",
"du",
",",
"floor",
",",
"_",
")",
"in",
"self",
".",
"doms",
".",
"items",
"(... | A `Table` containing DOM attributes | [
"A",
"Table",
"containing",
"DOM",
"attributes"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L264-L277 | train | A Table containing DOM attributes |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.com | def com(self):
"""Center of mass, calculated from the mean of the PMT positions"""
if self._com is None:
self._com = np.mean(self.pmts.pos, axis=0)
return self._com | python | def com(self):
"""Center of mass, calculated from the mean of the PMT positions"""
if self._com is None:
self._com = np.mean(self.pmts.pos, axis=0)
return self._com | [
"def",
"com",
"(",
"self",
")",
":",
"if",
"self",
".",
"_com",
"is",
"None",
":",
"self",
".",
"_com",
"=",
"np",
".",
"mean",
"(",
"self",
".",
"pmts",
".",
"pos",
",",
"axis",
"=",
"0",
")",
"return",
"self",
".",
"_com"
] | Center of mass, calculated from the mean of the PMT positions | [
"Center",
"of",
"mass",
"calculated",
"from",
"the",
"mean",
"of",
"the",
"PMT",
"positions"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L280-L284 | train | Center of mass calculated from the mean of the PMT positions |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.xy_positions | def xy_positions(self):
"""XY positions of the DUs, given by the DOMs on floor 1."""
if self._xy_positions is None or len(self._xy_positions) == 0:
xy_pos = []
for dom_id, pos in self.dom_positions.items():
if self.domid2floor(dom_id) == 1:
xy_... | python | def xy_positions(self):
"""XY positions of the DUs, given by the DOMs on floor 1."""
if self._xy_positions is None or len(self._xy_positions) == 0:
xy_pos = []
for dom_id, pos in self.dom_positions.items():
if self.domid2floor(dom_id) == 1:
xy_... | [
"def",
"xy_positions",
"(",
"self",
")",
":",
"if",
"self",
".",
"_xy_positions",
"is",
"None",
"or",
"len",
"(",
"self",
".",
"_xy_positions",
")",
"==",
"0",
":",
"xy_pos",
"=",
"[",
"]",
"for",
"dom_id",
",",
"pos",
"in",
"self",
".",
"dom_positio... | XY positions of the DUs, given by the DOMs on floor 1. | [
"XY",
"positions",
"of",
"the",
"DUs",
"given",
"by",
"the",
"DOMs",
"on",
"floor",
"1",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L287-L295 | train | XY positions of the DUs given by the DOMs on floor 1. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.translate_detector | def translate_detector(self, vector):
"""Translate the detector by a given vector"""
vector = np.array(vector, dtype=float)
self.pmts.pos_x += vector[0]
self.pmts.pos_y += vector[1]
self.pmts.pos_z += vector[2]
self.reset_caches() | python | def translate_detector(self, vector):
"""Translate the detector by a given vector"""
vector = np.array(vector, dtype=float)
self.pmts.pos_x += vector[0]
self.pmts.pos_y += vector[1]
self.pmts.pos_z += vector[2]
self.reset_caches() | [
"def",
"translate_detector",
"(",
"self",
",",
"vector",
")",
":",
"vector",
"=",
"np",
".",
"array",
"(",
"vector",
",",
"dtype",
"=",
"float",
")",
"self",
".",
"pmts",
".",
"pos_x",
"+=",
"vector",
"[",
"0",
"]",
"self",
".",
"pmts",
".",
"pos_y... | Translate the detector by a given vector | [
"Translate",
"the",
"detector",
"by",
"a",
"given",
"vector"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L297-L303 | train | Translate the detector by a given vector |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.rotate_dom_by_yaw | def rotate_dom_by_yaw(self, dom_id, heading, centre_point=None):
"""Rotate a DOM by a given (yaw) heading."""
pmts = self.pmts[self.pmts.dom_id == dom_id]
if centre_point is None:
centre_point = self.dom_positions[dom_id]
for pmt in pmts:
pmt_pos = np.array([pmt.... | python | def rotate_dom_by_yaw(self, dom_id, heading, centre_point=None):
"""Rotate a DOM by a given (yaw) heading."""
pmts = self.pmts[self.pmts.dom_id == dom_id]
if centre_point is None:
centre_point = self.dom_positions[dom_id]
for pmt in pmts:
pmt_pos = np.array([pmt.... | [
"def",
"rotate_dom_by_yaw",
"(",
"self",
",",
"dom_id",
",",
"heading",
",",
"centre_point",
"=",
"None",
")",
":",
"pmts",
"=",
"self",
".",
"pmts",
"[",
"self",
".",
"pmts",
".",
"dom_id",
"==",
"dom_id",
"]",
"if",
"centre_point",
"is",
"None",
":",... | Rotate a DOM by a given (yaw) heading. | [
"Rotate",
"a",
"DOM",
"by",
"a",
"given",
"(",
"yaw",
")",
"heading",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L305-L327 | train | Rotate a DOM by a given yaw heading. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.rotate_du_by_yaw | def rotate_du_by_yaw(self, du, heading):
"""Rotate all DOMs on DU by a given (yaw) heading."""
mask = (self.pmts.du == du)
dom_ids = np.unique(self.pmts.dom_id[mask])
for dom_id in dom_ids:
self.rotate_dom_by_yaw(dom_id, heading)
self.reset_caches() | python | def rotate_du_by_yaw(self, du, heading):
"""Rotate all DOMs on DU by a given (yaw) heading."""
mask = (self.pmts.du == du)
dom_ids = np.unique(self.pmts.dom_id[mask])
for dom_id in dom_ids:
self.rotate_dom_by_yaw(dom_id, heading)
self.reset_caches() | [
"def",
"rotate_du_by_yaw",
"(",
"self",
",",
"du",
",",
"heading",
")",
":",
"mask",
"=",
"(",
"self",
".",
"pmts",
".",
"du",
"==",
"du",
")",
"dom_ids",
"=",
"np",
".",
"unique",
"(",
"self",
".",
"pmts",
".",
"dom_id",
"[",
"mask",
"]",
")",
... | Rotate all DOMs on DU by a given (yaw) heading. | [
"Rotate",
"all",
"DOMs",
"on",
"DU",
"by",
"a",
"given",
"(",
"yaw",
")",
"heading",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L329-L335 | train | Rotate all DOMs on a given DU by a given yaw heading. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.rescale | def rescale(self, factor, origin=(0, 0, 0)):
"""Stretch or shrink detector (DOM positions) by a given factor."""
pmts = self.pmts
for dom_id in self.dom_ids:
mask = pmts.dom_id == dom_id
pos_x = pmts[mask].pos_x
pos_y = pmts[mask].pos_y
pos_z = pmt... | python | def rescale(self, factor, origin=(0, 0, 0)):
"""Stretch or shrink detector (DOM positions) by a given factor."""
pmts = self.pmts
for dom_id in self.dom_ids:
mask = pmts.dom_id == dom_id
pos_x = pmts[mask].pos_x
pos_y = pmts[mask].pos_y
pos_z = pmt... | [
"def",
"rescale",
"(",
"self",
",",
"factor",
",",
"origin",
"=",
"(",
"0",
",",
"0",
",",
"0",
")",
")",
":",
"pmts",
"=",
"self",
".",
"pmts",
"for",
"dom_id",
"in",
"self",
".",
"dom_ids",
":",
"mask",
"=",
"pmts",
".",
"dom_id",
"==",
"dom_... | Stretch or shrink detector (DOM positions) by a given factor. | [
"Stretch",
"or",
"shrink",
"detector",
"(",
"DOM",
"positions",
")",
"by",
"a",
"given",
"factor",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L337-L348 | train | Rescale detector positions by a given factor. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.pmt_angles | def pmt_angles(self):
"""A list of PMT directions sorted by PMT channel, on DU-1, floor-1"""
if self._pmt_angles == []:
mask = (self.pmts.du == 1) & (self.pmts.floor == 1)
self._pmt_angles = self.pmts.dir[mask]
return self._pmt_angles | python | def pmt_angles(self):
"""A list of PMT directions sorted by PMT channel, on DU-1, floor-1"""
if self._pmt_angles == []:
mask = (self.pmts.du == 1) & (self.pmts.floor == 1)
self._pmt_angles = self.pmts.dir[mask]
return self._pmt_angles | [
"def",
"pmt_angles",
"(",
"self",
")",
":",
"if",
"self",
".",
"_pmt_angles",
"==",
"[",
"]",
":",
"mask",
"=",
"(",
"self",
".",
"pmts",
".",
"du",
"==",
"1",
")",
"&",
"(",
"self",
".",
"pmts",
".",
"floor",
"==",
"1",
")",
"self",
".",
"_p... | A list of PMT directions sorted by PMT channel, on DU-1, floor-1 | [
"A",
"list",
"of",
"PMT",
"directions",
"sorted",
"by",
"PMT",
"channel",
"on",
"DU",
"-",
"1",
"floor",
"-",
"1"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L351-L356 | train | A list of PMT angles sorted by PMT channel on DU - 1 floor - 1 |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.ascii | def ascii(self):
"""The ascii representation of the detector"""
comments = ''
if self.version == 'v3':
for comment in self.comments:
if not comment.startswith(' '):
comment = ' ' + comment
comments += "#" + comment + "\n"
i... | python | def ascii(self):
"""The ascii representation of the detector"""
comments = ''
if self.version == 'v3':
for comment in self.comments:
if not comment.startswith(' '):
comment = ' ' + comment
comments += "#" + comment + "\n"
i... | [
"def",
"ascii",
"(",
"self",
")",
":",
"comments",
"=",
"''",
"if",
"self",
".",
"version",
"==",
"'v3'",
":",
"for",
"comment",
"in",
"self",
".",
"comments",
":",
"if",
"not",
"comment",
".",
"startswith",
"(",
"' '",
")",
":",
"comment",
"=",
"'... | The ascii representation of the detector | [
"The",
"ascii",
"representation",
"of",
"the",
"detector"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L359-L389 | train | The ascii representation of the detector. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.write | def write(self, filename):
"""Save detx file."""
with open(filename, 'w') as f:
f.write(self.ascii)
self.print("Detector file saved as '{0}'".format(filename)) | python | def write(self, filename):
"""Save detx file."""
with open(filename, 'w') as f:
f.write(self.ascii)
self.print("Detector file saved as '{0}'".format(filename)) | [
"def",
"write",
"(",
"self",
",",
"filename",
")",
":",
"with",
"open",
"(",
"filename",
",",
"'w'",
")",
"as",
"f",
":",
"f",
".",
"write",
"(",
"self",
".",
"ascii",
")",
"self",
".",
"print",
"(",
"\"Detector file saved as '{0}'\"",
".",
"format",
... | Save detx file. | [
"Save",
"detx",
"file",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L391-L395 | train | Save detector file. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.pmt_with_id | def pmt_with_id(self, pmt_id):
"""Get PMT with global pmt_id"""
try:
return self.pmts[self._pmt_index_by_pmt_id[pmt_id]]
except KeyError:
raise KeyError("No PMT found for ID: {0}".format(pmt_id)) | python | def pmt_with_id(self, pmt_id):
"""Get PMT with global pmt_id"""
try:
return self.pmts[self._pmt_index_by_pmt_id[pmt_id]]
except KeyError:
raise KeyError("No PMT found for ID: {0}".format(pmt_id)) | [
"def",
"pmt_with_id",
"(",
"self",
",",
"pmt_id",
")",
":",
"try",
":",
"return",
"self",
".",
"pmts",
"[",
"self",
".",
"_pmt_index_by_pmt_id",
"[",
"pmt_id",
"]",
"]",
"except",
"KeyError",
":",
"raise",
"KeyError",
"(",
"\"No PMT found for ID: {0}\"",
"."... | Get PMT with global pmt_id | [
"Get",
"PMT",
"with",
"global",
"pmt_id"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L397-L402 | train | Get PMT with global pmt_id. |
tamasgal/km3pipe | km3pipe/hardware.py | Detector.get_pmt | def get_pmt(self, dom_id, channel_id):
"""Return PMT with DOM ID and DAQ channel ID"""
du, floor, _ = self.doms[dom_id]
pmt = self.pmts[self._pmt_index_by_omkey[(du, floor, channel_id)]]
return pmt | python | def get_pmt(self, dom_id, channel_id):
"""Return PMT with DOM ID and DAQ channel ID"""
du, floor, _ = self.doms[dom_id]
pmt = self.pmts[self._pmt_index_by_omkey[(du, floor, channel_id)]]
return pmt | [
"def",
"get_pmt",
"(",
"self",
",",
"dom_id",
",",
"channel_id",
")",
":",
"du",
",",
"floor",
",",
"_",
"=",
"self",
".",
"doms",
"[",
"dom_id",
"]",
"pmt",
"=",
"self",
".",
"pmts",
"[",
"self",
".",
"_pmt_index_by_omkey",
"[",
"(",
"du",
",",
... | Return PMT with DOM ID and DAQ channel ID | [
"Return",
"PMT",
"with",
"DOM",
"ID",
"and",
"DAQ",
"channel",
"ID"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/hardware.py#L404-L408 | train | Return the PMT with the given DOM ID and DAQ channel ID. |
NaPs/Kolekto | kolekto/commands/webexport.py | WebExport._config | def _config(self, args, config):
""" Get configuration for the current used listing.
"""
webexports = dict((x.args, x) for x in config.subsections('webexport'))
webexport = webexports.get(args.webexport)
if webexport is None:
if args.webexport == u'default':
... | python | def _config(self, args, config):
""" Get configuration for the current used listing.
"""
webexports = dict((x.args, x) for x in config.subsections('webexport'))
webexport = webexports.get(args.webexport)
if webexport is None:
if args.webexport == u'default':
... | [
"def",
"_config",
"(",
"self",
",",
"args",
",",
"config",
")",
":",
"webexports",
"=",
"dict",
"(",
"(",
"x",
".",
"args",
",",
"x",
")",
"for",
"x",
"in",
"config",
".",
"subsections",
"(",
"'webexport'",
")",
")",
"webexport",
"=",
"webexports",
... | Get configuration for the current used listing. | [
"Get",
"configuration",
"for",
"the",
"current",
"used",
"listing",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/webexport.py#L109-L122 | train | Get configuration for the current used listing. |
tamasgal/km3pipe | km3modules/mc.py | convert_mc_times_to_jte_times | def convert_mc_times_to_jte_times(times_mc, evt_timestamp_in_ns, evt_mc_time):
"""
Function that converts MC times to JTE times.
Parameters
----------
times_mc : np.ndarray
Time array with MC times.
evt_timestamp_in_ns : int
Total timestamp of the event in nanoseconds.
evt_m... | python | def convert_mc_times_to_jte_times(times_mc, evt_timestamp_in_ns, evt_mc_time):
"""
Function that converts MC times to JTE times.
Parameters
----------
times_mc : np.ndarray
Time array with MC times.
evt_timestamp_in_ns : int
Total timestamp of the event in nanoseconds.
evt_m... | [
"def",
"convert_mc_times_to_jte_times",
"(",
"times_mc",
",",
"evt_timestamp_in_ns",
",",
"evt_mc_time",
")",
":",
"# needs to be cast to normal ndarray (not recarray), or else we",
"# would get invalid type promotion",
"times_mc",
"=",
"np",
".",
"array",
"(",
"times_mc",
")",... | Function that converts MC times to JTE times.
Parameters
----------
times_mc : np.ndarray
Time array with MC times.
evt_timestamp_in_ns : int
Total timestamp of the event in nanoseconds.
evt_mc_time : int
Mc time of the event in nanoseconds.
Returns
-------
ndar... | [
"Function",
"that",
"converts",
"MC",
"times",
"to",
"JTE",
"times",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3modules/mc.py#L86-L108 | train | Function that converts MC times to JTE times. |
IRC-SPHERE/HyperStream | hyperstream/tool/multi_output_tool.py | MultiOutputTool.execute | def execute(self, source, splitting_stream, sinks, interval, meta_data_id, output_plate_values):
"""
Execute the tool over the given time interval.
:param source: The source stream
:param splitting_stream: The stream over which to split
:param sinks: The sink streams
:pa... | python | def execute(self, source, splitting_stream, sinks, interval, meta_data_id, output_plate_values):
"""
Execute the tool over the given time interval.
:param source: The source stream
:param splitting_stream: The stream over which to split
:param sinks: The sink streams
:pa... | [
"def",
"execute",
"(",
"self",
",",
"source",
",",
"splitting_stream",
",",
"sinks",
",",
"interval",
",",
"meta_data_id",
",",
"output_plate_values",
")",
":",
"if",
"not",
"isinstance",
"(",
"interval",
",",
"TimeInterval",
")",
":",
"raise",
"TypeError",
... | Execute the tool over the given time interval.
:param source: The source stream
:param splitting_stream: The stream over which to split
:param sinks: The sink streams
:param interval: The time interval
:param meta_data_id: The meta data id of the output plate
:param outp... | [
"Execute",
"the",
"tool",
"over",
"the",
"given",
"time",
"interval",
"."
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/tool/multi_output_tool.py#L53-L127 | train | Execute the tool over the given time interval. |
tamasgal/km3pipe | km3pipe/tools.py | ifiles | def ifiles(irods_path):
"""Return a list of filenames for given iRODS path (recursively)"""
raw_output = subprocess.check_output(
"ils -r --bundle {0}"
" | grep 'Bundle file:'"
" | awk '{{print $3}}'".format(irods_path),
shell=True
)
filenames = raw_output.decode('a... | python | def ifiles(irods_path):
"""Return a list of filenames for given iRODS path (recursively)"""
raw_output = subprocess.check_output(
"ils -r --bundle {0}"
" | grep 'Bundle file:'"
" | awk '{{print $3}}'".format(irods_path),
shell=True
)
filenames = raw_output.decode('a... | [
"def",
"ifiles",
"(",
"irods_path",
")",
":",
"raw_output",
"=",
"subprocess",
".",
"check_output",
"(",
"\"ils -r --bundle {0}\"",
"\" | grep 'Bundle file:'\"",
"\" | awk '{{print $3}}'\"",
".",
"format",
"(",
"irods_path",
")",
",",
"shell",
"=",
"True",
")",
... | Return a list of filenames for given iRODS path (recursively) | [
"Return",
"a",
"list",
"of",
"filenames",
"for",
"given",
"iRODS",
"path",
"(",
"recursively",
")"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L30-L39 | train | Return a list of filenames for given iRODS path ( recursively |
tamasgal/km3pipe | km3pipe/tools.py | iexists | def iexists(irods_path):
"""Returns True of iRODS path exists, otherwise False"""
try:
subprocess.check_output(
'ils {}'.format(irods_path),
shell=True,
stderr=subprocess.PIPE,
)
return True
except subprocess.CalledProcessError:
return Fals... | python | def iexists(irods_path):
"""Returns True of iRODS path exists, otherwise False"""
try:
subprocess.check_output(
'ils {}'.format(irods_path),
shell=True,
stderr=subprocess.PIPE,
)
return True
except subprocess.CalledProcessError:
return Fals... | [
"def",
"iexists",
"(",
"irods_path",
")",
":",
"try",
":",
"subprocess",
".",
"check_output",
"(",
"'ils {}'",
".",
"format",
"(",
"irods_path",
")",
",",
"shell",
"=",
"True",
",",
"stderr",
"=",
"subprocess",
".",
"PIPE",
",",
")",
"return",
"True",
... | Returns True of iRODS path exists, otherwise False | [
"Returns",
"True",
"of",
"iRODS",
"path",
"exists",
"otherwise",
"False"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L42-L52 | train | Returns True of iRODS path exists otherwise False |
tamasgal/km3pipe | km3pipe/tools.py | token_urlsafe | def token_urlsafe(nbytes=32):
"""Return a random URL-safe text string, in Base64 encoding.
This is taken and slightly modified from the Python 3.6 stdlib.
The string has *nbytes* random bytes. If *nbytes* is ``None``
or not supplied, a reasonable default is used.
>>> token_urlsafe(16) #doctest:... | python | def token_urlsafe(nbytes=32):
"""Return a random URL-safe text string, in Base64 encoding.
This is taken and slightly modified from the Python 3.6 stdlib.
The string has *nbytes* random bytes. If *nbytes* is ``None``
or not supplied, a reasonable default is used.
>>> token_urlsafe(16) #doctest:... | [
"def",
"token_urlsafe",
"(",
"nbytes",
"=",
"32",
")",
":",
"tok",
"=",
"os",
".",
"urandom",
"(",
"nbytes",
")",
"return",
"base64",
".",
"urlsafe_b64encode",
"(",
"tok",
")",
".",
"rstrip",
"(",
"b'='",
")",
".",
"decode",
"(",
"'ascii'",
")"
] | Return a random URL-safe text string, in Base64 encoding.
This is taken and slightly modified from the Python 3.6 stdlib.
The string has *nbytes* random bytes. If *nbytes* is ``None``
or not supplied, a reasonable default is used.
>>> token_urlsafe(16) #doctest:+SKIP
'Drmhze6EPcv0fN_81Bj-nA' | [
"Return",
"a",
"random",
"URL",
"-",
"safe",
"text",
"string",
"in",
"Base64",
"encoding",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L55-L68 | train | Return a random URL - safe text string in Base64 encoding. |
tamasgal/km3pipe | km3pipe/tools.py | prettyln | def prettyln(text, fill='-', align='^', prefix='[ ', suffix=' ]', length=69):
"""Wrap `text` in a pretty line with maximum length."""
text = '{prefix}{0}{suffix}'.format(text, prefix=prefix, suffix=suffix)
print(
"{0:{fill}{align}{length}}".format(
text, fill=fill, align=align, length=le... | python | def prettyln(text, fill='-', align='^', prefix='[ ', suffix=' ]', length=69):
"""Wrap `text` in a pretty line with maximum length."""
text = '{prefix}{0}{suffix}'.format(text, prefix=prefix, suffix=suffix)
print(
"{0:{fill}{align}{length}}".format(
text, fill=fill, align=align, length=le... | [
"def",
"prettyln",
"(",
"text",
",",
"fill",
"=",
"'-'",
",",
"align",
"=",
"'^'",
",",
"prefix",
"=",
"'[ '",
",",
"suffix",
"=",
"' ]'",
",",
"length",
"=",
"69",
")",
":",
"text",
"=",
"'{prefix}{0}{suffix}'",
".",
"format",
"(",
"text",
",",
"p... | Wrap `text` in a pretty line with maximum length. | [
"Wrap",
"text",
"in",
"a",
"pretty",
"line",
"with",
"maximum",
"length",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L77-L84 | train | Wrap text in a pretty line with maximum length. |
tamasgal/km3pipe | km3pipe/tools.py | irods_filepath | def irods_filepath(det_id, run_id):
"""Generate the iRODS filepath for given detector (O)ID and run ID"""
data_path = "/in2p3/km3net/data/raw/sea"
from km3pipe.db import DBManager
if not isinstance(det_id, int):
dts = DBManager().detectors
det_id = int(dts[dts.OID == det_id].SERIALNUMBER... | python | def irods_filepath(det_id, run_id):
"""Generate the iRODS filepath for given detector (O)ID and run ID"""
data_path = "/in2p3/km3net/data/raw/sea"
from km3pipe.db import DBManager
if not isinstance(det_id, int):
dts = DBManager().detectors
det_id = int(dts[dts.OID == det_id].SERIALNUMBER... | [
"def",
"irods_filepath",
"(",
"det_id",
",",
"run_id",
")",
":",
"data_path",
"=",
"\"/in2p3/km3net/data/raw/sea\"",
"from",
"km3pipe",
".",
"db",
"import",
"DBManager",
"if",
"not",
"isinstance",
"(",
"det_id",
",",
"int",
")",
":",
"dts",
"=",
"DBManager",
... | Generate the iRODS filepath for given detector (O)ID and run ID | [
"Generate",
"the",
"iRODS",
"filepath",
"for",
"given",
"detector",
"(",
"O",
")",
"ID",
"and",
"run",
"ID"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L87-L95 | train | Generate the iRODS filepath for given detector ID and run ID |
tamasgal/km3pipe | km3pipe/tools.py | unpack_nfirst | def unpack_nfirst(seq, nfirst):
"""Unpack the nfrist items from the list and return the rest.
>>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3)
>>> a, b, c
(1, 2, 3)
>>> rest
(4, 5)
"""
iterator = iter(seq)
for _ in range(nfirst):
yield next(iterator, None)
yield tu... | python | def unpack_nfirst(seq, nfirst):
"""Unpack the nfrist items from the list and return the rest.
>>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3)
>>> a, b, c
(1, 2, 3)
>>> rest
(4, 5)
"""
iterator = iter(seq)
for _ in range(nfirst):
yield next(iterator, None)
yield tu... | [
"def",
"unpack_nfirst",
"(",
"seq",
",",
"nfirst",
")",
":",
"iterator",
"=",
"iter",
"(",
"seq",
")",
"for",
"_",
"in",
"range",
"(",
"nfirst",
")",
":",
"yield",
"next",
"(",
"iterator",
",",
"None",
")",
"yield",
"tuple",
"(",
"iterator",
")"
] | Unpack the nfrist items from the list and return the rest.
>>> a, b, c, rest = unpack_nfirst((1, 2, 3, 4, 5), 3)
>>> a, b, c
(1, 2, 3)
>>> rest
(4, 5) | [
"Unpack",
"the",
"nfrist",
"items",
"from",
"the",
"list",
"and",
"return",
"the",
"rest",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L98-L111 | train | Unpack the nfrist items from the list and return the rest. |
tamasgal/km3pipe | km3pipe/tools.py | split | def split(string, callback=None, sep=None):
"""Split the string and execute the callback function on each part.
>>> string = "1 2 3 4"
>>> parts = split(string, int)
>>> parts
[1, 2, 3, 4]
"""
if callback is not None:
return [callback(i) for i in string.split(sep)]
else:
... | python | def split(string, callback=None, sep=None):
"""Split the string and execute the callback function on each part.
>>> string = "1 2 3 4"
>>> parts = split(string, int)
>>> parts
[1, 2, 3, 4]
"""
if callback is not None:
return [callback(i) for i in string.split(sep)]
else:
... | [
"def",
"split",
"(",
"string",
",",
"callback",
"=",
"None",
",",
"sep",
"=",
"None",
")",
":",
"if",
"callback",
"is",
"not",
"None",
":",
"return",
"[",
"callback",
"(",
"i",
")",
"for",
"i",
"in",
"string",
".",
"split",
"(",
"sep",
")",
"]",
... | Split the string and execute the callback function on each part.
>>> string = "1 2 3 4"
>>> parts = split(string, int)
>>> parts
[1, 2, 3, 4] | [
"Split",
"the",
"string",
"and",
"execute",
"the",
"callback",
"function",
"on",
"each",
"part",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L114-L126 | train | Split the string and execute the callback function on each part. |
tamasgal/km3pipe | km3pipe/tools.py | namedtuple_with_defaults | def namedtuple_with_defaults(typename, field_names, default_values=[]):
"""Create a namedtuple with default values
>>> Node = namedtuple_with_defaults('Node', 'val left right')
>>> Node()
Node(val=None, left=None, right=None)
>>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3])
... | python | def namedtuple_with_defaults(typename, field_names, default_values=[]):
"""Create a namedtuple with default values
>>> Node = namedtuple_with_defaults('Node', 'val left right')
>>> Node()
Node(val=None, left=None, right=None)
>>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3])
... | [
"def",
"namedtuple_with_defaults",
"(",
"typename",
",",
"field_names",
",",
"default_values",
"=",
"[",
"]",
")",
":",
"the_tuple",
"=",
"collections",
".",
"namedtuple",
"(",
"typename",
",",
"field_names",
")",
"the_tuple",
".",
"__new__",
".",
"__defaults__"... | Create a namedtuple with default values
>>> Node = namedtuple_with_defaults('Node', 'val left right')
>>> Node()
Node(val=None, left=None, right=None)
>>> Node = namedtuple_with_defaults('Node', 'val left right', [1, 2, 3])
>>> Node()
Node(val=1, left=2, right=3)
>>> Node = namedtuple_with_... | [
"Create",
"a",
"namedtuple",
"with",
"default",
"values"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L129-L151 | train | Create a namedtuple with default values |
tamasgal/km3pipe | km3pipe/tools.py | remain_file_pointer | def remain_file_pointer(function):
"""Remain the file pointer position after calling the decorated function
This decorator assumes that the last argument is the file handler.
"""
def wrapper(*args, **kwargs):
"""Wrap the function and remain its parameters and return values"""
file_obj... | python | def remain_file_pointer(function):
"""Remain the file pointer position after calling the decorated function
This decorator assumes that the last argument is the file handler.
"""
def wrapper(*args, **kwargs):
"""Wrap the function and remain its parameters and return values"""
file_obj... | [
"def",
"remain_file_pointer",
"(",
"function",
")",
":",
"def",
"wrapper",
"(",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"\"\"\"Wrap the function and remain its parameters and return values\"\"\"",
"file_obj",
"=",
"args",
"[",
"-",
"1",
"]",
"old_position",
... | Remain the file pointer position after calling the decorated function
This decorator assumes that the last argument is the file handler. | [
"Remain",
"the",
"file",
"pointer",
"position",
"after",
"calling",
"the",
"decorated",
"function"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L154-L169 | train | Decorator that remains the file pointer position after calling the decorated function |
tamasgal/km3pipe | km3pipe/tools.py | decamelise | def decamelise(text):
"""Convert CamelCase to lower_and_underscore."""
s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower() | python | def decamelise(text):
"""Convert CamelCase to lower_and_underscore."""
s = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', text)
return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s).lower() | [
"def",
"decamelise",
"(",
"text",
")",
":",
"s",
"=",
"re",
".",
"sub",
"(",
"'(.)([A-Z][a-z]+)'",
",",
"r'\\1_\\2'",
",",
"text",
")",
"return",
"re",
".",
"sub",
"(",
"'([a-z0-9])([A-Z])'",
",",
"r'\\1_\\2'",
",",
"s",
")",
".",
"lower",
"(",
")"
] | Convert CamelCase to lower_and_underscore. | [
"Convert",
"CamelCase",
"to",
"lower_and_underscore",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L180-L183 | train | Convert CamelCase to lower_and_underscore. |
tamasgal/km3pipe | km3pipe/tools.py | camelise | def camelise(text, capital_first=True):
"""Convert lower_underscore to CamelCase."""
def camelcase():
if not capital_first:
yield str.lower
while True:
yield str.capitalize
if istype(text, 'unicode'):
text = text.encode('utf8')
c = camelcase()
return... | python | def camelise(text, capital_first=True):
"""Convert lower_underscore to CamelCase."""
def camelcase():
if not capital_first:
yield str.lower
while True:
yield str.capitalize
if istype(text, 'unicode'):
text = text.encode('utf8')
c = camelcase()
return... | [
"def",
"camelise",
"(",
"text",
",",
"capital_first",
"=",
"True",
")",
":",
"def",
"camelcase",
"(",
")",
":",
"if",
"not",
"capital_first",
":",
"yield",
"str",
".",
"lower",
"while",
"True",
":",
"yield",
"str",
".",
"capitalize",
"if",
"istype",
"(... | Convert lower_underscore to CamelCase. | [
"Convert",
"lower_underscore",
"to",
"CamelCase",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L186-L198 | train | Convert lower_underscore to CamelCase. |
tamasgal/km3pipe | km3pipe/tools.py | colored | def colored(text, color=None, on_color=None, attrs=None, ansi_code=None):
"""Colorize text, while stripping nested ANSI color sequences.
Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highli... | python | def colored(text, color=None, on_color=None, attrs=None, ansi_code=None):
"""Colorize text, while stripping nested ANSI color sequences.
Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highli... | [
"def",
"colored",
"(",
"text",
",",
"color",
"=",
"None",
",",
"on_color",
"=",
"None",
",",
"attrs",
"=",
"None",
",",
"ansi_code",
"=",
"None",
")",
":",
"if",
"os",
".",
"getenv",
"(",
"'ANSI_COLORS_DISABLED'",
")",
"is",
"None",
":",
"if",
"ansi_... | Colorize text, while stripping nested ANSI color sequences.
Author: Konstantin Lepa <konstantin.lepa@gmail.com> / termcolor
Available text colors:
red, green, yellow, blue, magenta, cyan, white.
Available text highlights:
on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white... | [
"Colorize",
"text",
"while",
"stripping",
"nested",
"ANSI",
"color",
"sequences",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L247-L278 | train | Colorize text while stripping nested ANSI color sequences. |
tamasgal/km3pipe | km3pipe/tools.py | zero_pad | def zero_pad(m, n=1):
"""Pad a matrix with zeros, on all sides."""
return np.pad(m, (n, n), mode='constant', constant_values=[0]) | python | def zero_pad(m, n=1):
"""Pad a matrix with zeros, on all sides."""
return np.pad(m, (n, n), mode='constant', constant_values=[0]) | [
"def",
"zero_pad",
"(",
"m",
",",
"n",
"=",
"1",
")",
":",
"return",
"np",
".",
"pad",
"(",
"m",
",",
"(",
"n",
",",
"n",
")",
",",
"mode",
"=",
"'constant'",
",",
"constant_values",
"=",
"[",
"0",
"]",
")"
] | Pad a matrix with zeros, on all sides. | [
"Pad",
"a",
"matrix",
"with",
"zeros",
"on",
"all",
"sides",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L332-L334 | train | Pad a matrix with zeros on all sides. |
tamasgal/km3pipe | km3pipe/tools.py | supports_color | def supports_color():
"""Checks if the terminal supports color."""
if isnotebook():
return True
supported_platform = sys.platform != 'win32' or 'ANSICON' in os.environ
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
if not supported_platform or not is_a_tty:
return ... | python | def supports_color():
"""Checks if the terminal supports color."""
if isnotebook():
return True
supported_platform = sys.platform != 'win32' or 'ANSICON' in os.environ
is_a_tty = hasattr(sys.stdout, 'isatty') and sys.stdout.isatty()
if not supported_platform or not is_a_tty:
return ... | [
"def",
"supports_color",
"(",
")",
":",
"if",
"isnotebook",
"(",
")",
":",
"return",
"True",
"supported_platform",
"=",
"sys",
".",
"platform",
"!=",
"'win32'",
"or",
"'ANSICON'",
"in",
"os",
".",
"environ",
"is_a_tty",
"=",
"hasattr",
"(",
"sys",
".",
"... | Checks if the terminal supports color. | [
"Checks",
"if",
"the",
"terminal",
"supports",
"color",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L356-L366 | train | Checks if the terminal supports color. |
tamasgal/km3pipe | km3pipe/tools.py | get_jpp_revision | def get_jpp_revision(via_command='JPrint'):
"""Retrieves the Jpp revision number"""
try:
output = subprocess.check_output([via_command, '-v'],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if e.returncode == 1:
outpu... | python | def get_jpp_revision(via_command='JPrint'):
"""Retrieves the Jpp revision number"""
try:
output = subprocess.check_output([via_command, '-v'],
stderr=subprocess.STDOUT)
except subprocess.CalledProcessError as e:
if e.returncode == 1:
outpu... | [
"def",
"get_jpp_revision",
"(",
"via_command",
"=",
"'JPrint'",
")",
":",
"try",
":",
"output",
"=",
"subprocess",
".",
"check_output",
"(",
"[",
"via_command",
",",
"'-v'",
"]",
",",
"stderr",
"=",
"subprocess",
".",
"STDOUT",
")",
"except",
"subprocess",
... | Retrieves the Jpp revision number | [
"Retrieves",
"the",
"Jpp",
"revision",
"number"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L369-L382 | train | Retrieves the Jpp revision number |
tamasgal/km3pipe | km3pipe/tools.py | timed_cache | def timed_cache(**timed_cache_kwargs):
"""LRU cache decorator with timeout.
Parameters
----------
days: int
seconds: int
microseconds: int
milliseconds: int
minutes: int
hours: int
weeks: int
maxsise: int [default: 128]
typed: bool [default: False]
"""
def _wrap... | python | def timed_cache(**timed_cache_kwargs):
"""LRU cache decorator with timeout.
Parameters
----------
days: int
seconds: int
microseconds: int
milliseconds: int
minutes: int
hours: int
weeks: int
maxsise: int [default: 128]
typed: bool [default: False]
"""
def _wrap... | [
"def",
"timed_cache",
"(",
"*",
"*",
"timed_cache_kwargs",
")",
":",
"def",
"_wrapper",
"(",
"f",
")",
":",
"maxsize",
"=",
"timed_cache_kwargs",
".",
"pop",
"(",
"'maxsize'",
",",
"128",
")",
"typed",
"=",
"timed_cache_kwargs",
".",
"pop",
"(",
"'typed'",... | LRU cache decorator with timeout.
Parameters
----------
days: int
seconds: int
microseconds: int
milliseconds: int
minutes: int
hours: int
weeks: int
maxsise: int [default: 128]
typed: bool [default: False] | [
"LRU",
"cache",
"decorator",
"with",
"timeout",
"."
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/tools.py#L385-L430 | train | Decorator to cache the return value of a function with a timeout. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries_profile.py | ProfileCache._get_point | def _get_point(self, profile, point):
"""
Finds the given point in the profile, or adds it in sorted z order.
"""
cur_points_z = [p.location.z for p in profile.elements]
try:
cur_idx = cur_points_z.index(point.z)
return profile.elements[cur_idx]
ex... | python | def _get_point(self, profile, point):
"""
Finds the given point in the profile, or adds it in sorted z order.
"""
cur_points_z = [p.location.z for p in profile.elements]
try:
cur_idx = cur_points_z.index(point.z)
return profile.elements[cur_idx]
ex... | [
"def",
"_get_point",
"(",
"self",
",",
"profile",
",",
"point",
")",
":",
"cur_points_z",
"=",
"[",
"p",
".",
"location",
".",
"z",
"for",
"p",
"in",
"profile",
".",
"elements",
"]",
"try",
":",
"cur_idx",
"=",
"cur_points_z",
".",
"index",
"(",
"poi... | Finds the given point in the profile, or adds it in sorted z order. | [
"Finds",
"the",
"given",
"point",
"in",
"the",
"profile",
"or",
"adds",
"it",
"in",
"sorted",
"z",
"order",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L74-L88 | train | Returns the given point in the given profile or adds it in sorted z order. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries_profile.py | TimeSeriesProfile._parse_data_array | def _parse_data_array(self, data_array):
"""
Parses a general DataArray.
"""
# decimalSeparator = data_array.encoding.decimalSeparator
tokenSeparator = data_array.encoding.tokenSeparator
blockSeparator = data_array.encoding.blockSeparator
# collapseWhiteSpaces = d... | python | def _parse_data_array(self, data_array):
"""
Parses a general DataArray.
"""
# decimalSeparator = data_array.encoding.decimalSeparator
tokenSeparator = data_array.encoding.tokenSeparator
blockSeparator = data_array.encoding.blockSeparator
# collapseWhiteSpaces = d... | [
"def",
"_parse_data_array",
"(",
"self",
",",
"data_array",
")",
":",
"# decimalSeparator = data_array.encoding.decimalSeparator",
"tokenSeparator",
"=",
"data_array",
".",
"encoding",
".",
"tokenSeparator",
"blockSeparator",
"=",
"data_array",
".",
"encoding",
".",
"bloc... | Parses a general DataArray. | [
"Parses",
"a",
"general",
"DataArray",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L280-L306 | train | Parses a general DataArray. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries_profile.py | TimeSeriesProfile._parse_sensor_data | def _parse_sensor_data(self, obs_el, sensor_info):
"""
Returns ProfileCollection
"""
data_array = obs_el.content
# get column defs
data_record = data_array.elementType.content
columns = []
for f in data_record.field:
columns.append(f)
... | python | def _parse_sensor_data(self, obs_el, sensor_info):
"""
Returns ProfileCollection
"""
data_array = obs_el.content
# get column defs
data_record = data_array.elementType.content
columns = []
for f in data_record.field:
columns.append(f)
... | [
"def",
"_parse_sensor_data",
"(",
"self",
",",
"obs_el",
",",
"sensor_info",
")",
":",
"data_array",
"=",
"obs_el",
".",
"content",
"# get column defs",
"data_record",
"=",
"data_array",
".",
"elementType",
".",
"content",
"columns",
"=",
"[",
"]",
"for",
"f",... | Returns ProfileCollection | [
"Returns",
"ProfileCollection"
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L308-L391 | train | Parse the sensor data from an OGC observation element. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries_profile.py | TimeSeriesProfile._parse_sensor_record | def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values):
"""
Parses values via sensor data record passed in.
Returns parsed values AND how many items it consumed out of rem_values.
"""
val_idx = 0
# @TODO seems there is only a single field in each of the... | python | def _parse_sensor_record(self, sensor_data_rec, sensor_info, rem_values):
"""
Parses values via sensor data record passed in.
Returns parsed values AND how many items it consumed out of rem_values.
"""
val_idx = 0
# @TODO seems there is only a single field in each of the... | [
"def",
"_parse_sensor_record",
"(",
"self",
",",
"sensor_data_rec",
",",
"sensor_info",
",",
"rem_values",
")",
":",
"val_idx",
"=",
"0",
"# @TODO seems there is only a single field in each of these",
"assert",
"len",
"(",
"sensor_data_rec",
".",
"field",
")",
"==",
"... | Parses values via sensor data record passed in.
Returns parsed values AND how many items it consumed out of rem_values. | [
"Parses",
"values",
"via",
"sensor",
"data",
"record",
"passed",
"in",
".",
"Returns",
"parsed",
"values",
"AND",
"how",
"many",
"items",
"it",
"consumed",
"out",
"of",
"rem_values",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L393-L446 | train | Parses sensor data record and returns parsed values and how many items it consumed out of rem_values. |
ioos/pyoos | pyoos/parsers/ioos/one/timeseries_profile.py | TimeSeriesProfile._build_obs_point | def _build_obs_point(self, sensor_info, obs_recs):
"""
Pulls bin/profile height info out and calcs a z.
TODO: currently extremely naive
Returns a 2-tuple: point, remaining obs_recs
"""
cur_point = sensor_info["location"]["point"]
keys = [m["name"] for m in obs_... | python | def _build_obs_point(self, sensor_info, obs_recs):
"""
Pulls bin/profile height info out and calcs a z.
TODO: currently extremely naive
Returns a 2-tuple: point, remaining obs_recs
"""
cur_point = sensor_info["location"]["point"]
keys = [m["name"] for m in obs_... | [
"def",
"_build_obs_point",
"(",
"self",
",",
"sensor_info",
",",
"obs_recs",
")",
":",
"cur_point",
"=",
"sensor_info",
"[",
"\"location\"",
"]",
"[",
"\"point\"",
"]",
"keys",
"=",
"[",
"m",
"[",
"\"name\"",
"]",
"for",
"m",
"in",
"obs_recs",
"]",
"if",... | Pulls bin/profile height info out and calcs a z.
TODO: currently extremely naive
Returns a 2-tuple: point, remaining obs_recs | [
"Pulls",
"bin",
"/",
"profile",
"height",
"info",
"out",
"and",
"calcs",
"a",
"z",
"."
] | 908660385029ecd8eccda8ab3a6b20b47b915c77 | https://github.com/ioos/pyoos/blob/908660385029ecd8eccda8ab3a6b20b47b915c77/pyoos/parsers/ioos/one/timeseries_profile.py#L448-L483 | train | Builds a 2 - tuple of sPoint and a list of obs_rec objects. |
htm-community/menorah | menorah/menorah.py | Menorah.populateCsv | def populateCsv(self):
"""
Writes data from streams into CSV in working directory.
:return:
"""
workingDirPath = createDir(self._workingDir)
csvPath = os.path.join(workingDirPath, "data.csv")
self.writeCsv(csvPath)
return csvPath, workingDirPath | python | def populateCsv(self):
"""
Writes data from streams into CSV in working directory.
:return:
"""
workingDirPath = createDir(self._workingDir)
csvPath = os.path.join(workingDirPath, "data.csv")
self.writeCsv(csvPath)
return csvPath, workingDirPath | [
"def",
"populateCsv",
"(",
"self",
")",
":",
"workingDirPath",
"=",
"createDir",
"(",
"self",
".",
"_workingDir",
")",
"csvPath",
"=",
"os",
".",
"path",
".",
"join",
"(",
"workingDirPath",
",",
"\"data.csv\"",
")",
"self",
".",
"writeCsv",
"(",
"csvPath",... | Writes data from streams into CSV in working directory.
:return: | [
"Writes",
"data",
"from",
"streams",
"into",
"CSV",
"in",
"working",
"directory",
".",
":",
"return",
":"
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L113-L121 | train | Writes data from streams into CSV in working directory. |
htm-community/menorah | menorah/menorah.py | Menorah.writeCsv | def writeCsv(self, path):
"""
Writes data one or many streams into one CSV file.
:param path: absolute or relative file path
"""
self._createConfluence()
with open(path, "w") as outputFile:
writer = csv.writer(outputFile)
headers = self.getStreamIds()
fieldNames = ["timestamp"]... | python | def writeCsv(self, path):
"""
Writes data one or many streams into one CSV file.
:param path: absolute or relative file path
"""
self._createConfluence()
with open(path, "w") as outputFile:
writer = csv.writer(outputFile)
headers = self.getStreamIds()
fieldNames = ["timestamp"]... | [
"def",
"writeCsv",
"(",
"self",
",",
"path",
")",
":",
"self",
".",
"_createConfluence",
"(",
")",
"with",
"open",
"(",
"path",
",",
"\"w\"",
")",
"as",
"outputFile",
":",
"writer",
"=",
"csv",
".",
"writer",
"(",
"outputFile",
")",
"headers",
"=",
"... | Writes data one or many streams into one CSV file.
:param path: absolute or relative file path | [
"Writes",
"data",
"one",
"or",
"many",
"streams",
"into",
"one",
"CSV",
"file",
".",
":",
"param",
"path",
":",
"absolute",
"or",
"relative",
"file",
"path"
] | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L124-L141 | train | Writes data into one or many CSV files. |
htm-community/menorah | menorah/menorah.py | Menorah.writeSwarmDescription | def writeSwarmDescription(self, csvPath, outPath,
predictedField=None, swarmParams=None):
"""
Writes swarm description file (JSON).
:param csvPath: path to CSV data
:param outPath: absolute or relative file path to write swarm JSON file
:param predictedField: (string)
:para... | python | def writeSwarmDescription(self, csvPath, outPath,
predictedField=None, swarmParams=None):
"""
Writes swarm description file (JSON).
:param csvPath: path to CSV data
:param outPath: absolute or relative file path to write swarm JSON file
:param predictedField: (string)
:para... | [
"def",
"writeSwarmDescription",
"(",
"self",
",",
"csvPath",
",",
"outPath",
",",
"predictedField",
"=",
"None",
",",
"swarmParams",
"=",
"None",
")",
":",
"if",
"self",
".",
"_confluence",
"is",
"None",
":",
"raise",
"Exception",
"(",
"\"Missing Confluence! C... | Writes swarm description file (JSON).
:param csvPath: path to CSV data
:param outPath: absolute or relative file path to write swarm JSON file
:param predictedField: (string)
:param swarmParams: (dict) overrides any swarm params | [
"Writes",
"swarm",
"description",
"file",
"(",
"JSON",
")",
".",
":",
"param",
"csvPath",
":",
"path",
"to",
"CSV",
"data",
":",
"param",
"outPath",
":",
"absolute",
"or",
"relative",
"file",
"path",
"to",
"write",
"swarm",
"JSON",
"file",
":",
"param",
... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L144-L163 | train | Writes swarm description file. |
htm-community/menorah | menorah/menorah.py | Menorah.prepareSwarm | def prepareSwarm(self, predictedField=None, swarmParams=None):
"""
Gathers data from streams into local CSV file, then creates a swarm
description for it.
:param predictedField: (string)
:param swarmParams: (dict) overrides any swarm params
"""
csvPath, workingDirPath = self.populateCsv()
... | python | def prepareSwarm(self, predictedField=None, swarmParams=None):
"""
Gathers data from streams into local CSV file, then creates a swarm
description for it.
:param predictedField: (string)
:param swarmParams: (dict) overrides any swarm params
"""
csvPath, workingDirPath = self.populateCsv()
... | [
"def",
"prepareSwarm",
"(",
"self",
",",
"predictedField",
"=",
"None",
",",
"swarmParams",
"=",
"None",
")",
":",
"csvPath",
",",
"workingDirPath",
"=",
"self",
".",
"populateCsv",
"(",
")",
"swarmDescriptionPath",
"=",
"os",
".",
"path",
".",
"join",
"("... | Gathers data from streams into local CSV file, then creates a swarm
description for it.
:param predictedField: (string)
:param swarmParams: (dict) overrides any swarm params | [
"Gathers",
"data",
"from",
"streams",
"into",
"local",
"CSV",
"file",
"then",
"creates",
"a",
"swarm",
"description",
"for",
"it",
".",
":",
"param",
"predictedField",
":",
"(",
"string",
")",
":",
"param",
"swarmParams",
":",
"(",
"dict",
")",
"overrides"... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L166-L180 | train | Populates the CSV file and creates a swarm_description. json file for it. |
htm-community/menorah | menorah/menorah.py | Menorah.runSwarm | def runSwarm(self, workingDirPath):
"""
Runs a swarm with data within a working directory. This assumes that the
user has already run prepareSwarm().
:param workingDirPath: absolute or relative path to working directory
"""
if not os.path.exists(workingDirPath):
raise Exception("Working d... | python | def runSwarm(self, workingDirPath):
"""
Runs a swarm with data within a working directory. This assumes that the
user has already run prepareSwarm().
:param workingDirPath: absolute or relative path to working directory
"""
if not os.path.exists(workingDirPath):
raise Exception("Working d... | [
"def",
"runSwarm",
"(",
"self",
",",
"workingDirPath",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"workingDirPath",
")",
":",
"raise",
"Exception",
"(",
"\"Working directory %s does not exist!\"",
"%",
"workingDirPath",
")",
"banner",
"(",
"... | Runs a swarm with data within a working directory. This assumes that the
user has already run prepareSwarm().
:param workingDirPath: absolute or relative path to working directory | [
"Runs",
"a",
"swarm",
"with",
"data",
"within",
"a",
"working",
"directory",
".",
"This",
"assumes",
"that",
"the",
"user",
"has",
"already",
"run",
"prepareSwarm",
"()",
".",
":",
"param",
"workingDirPath",
":",
"absolute",
"or",
"relative",
"path",
"to",
... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L183-L192 | train | Runs a swarm with data within a working directory. |
htm-community/menorah | menorah/menorah.py | Menorah.swarm | def swarm(self, predictedField=None, swarmParams=None):
"""
Runs a swarm on data and swarm description found within the given working
directory.
If no predictedField is provided, it is assumed that the first stream listed
in the streamIds provided to the Menorah constructor is the predicted fi... | python | def swarm(self, predictedField=None, swarmParams=None):
"""
Runs a swarm on data and swarm description found within the given working
directory.
If no predictedField is provided, it is assumed that the first stream listed
in the streamIds provided to the Menorah constructor is the predicted fi... | [
"def",
"swarm",
"(",
"self",
",",
"predictedField",
"=",
"None",
",",
"swarmParams",
"=",
"None",
")",
":",
"self",
".",
"prepareSwarm",
"(",
"predictedField",
"=",
"predictedField",
",",
"swarmParams",
"=",
"swarmParams",
")",
"self",
".",
"runSwarm",
"(",
... | Runs a swarm on data and swarm description found within the given working
directory.
If no predictedField is provided, it is assumed that the first stream listed
in the streamIds provided to the Menorah constructor is the predicted field.
:param predictedField: (string)
:param swarmParams... | [
"Runs",
"a",
"swarm",
"on",
"data",
"and",
"swarm",
"description",
"found",
"within",
"the",
"given",
"working",
"directory",
".",
"If",
"no",
"predictedField",
"is",
"provided",
"it",
"is",
"assumed",
"that",
"the",
"first",
"stream",
"listed",
"in",
"the",... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L195-L210 | train | Runs a swarm on the data and swarm description found within the given working directory. |
htm-community/menorah | menorah/menorah.py | Menorah.stream | def stream(self, handler, whenDone=None):
"""
Fetches data from river streams and feeds them into the given function.
:param handler: (function) passed headers [list] and row [list] of the data
for one time step, for every row of data
"""
self._createConfluence()
headers = ["... | python | def stream(self, handler, whenDone=None):
"""
Fetches data from river streams and feeds them into the given function.
:param handler: (function) passed headers [list] and row [list] of the data
for one time step, for every row of data
"""
self._createConfluence()
headers = ["... | [
"def",
"stream",
"(",
"self",
",",
"handler",
",",
"whenDone",
"=",
"None",
")",
":",
"self",
".",
"_createConfluence",
"(",
")",
"headers",
"=",
"[",
"\"timestamp\"",
"]",
"+",
"self",
".",
"getStreamIds",
"(",
")",
"for",
"row",
"in",
"self",
".",
... | Fetches data from river streams and feeds them into the given function.
:param handler: (function) passed headers [list] and row [list] of the data
for one time step, for every row of data | [
"Fetches",
"data",
"from",
"river",
"streams",
"and",
"feeds",
"them",
"into",
"the",
"given",
"function",
".",
":",
"param",
"handler",
":",
"(",
"function",
")",
"passed",
"headers",
"[",
"list",
"]",
"and",
"row",
"[",
"list",
"]",
"of",
"the",
"dat... | 1991b01eda3f6361b22ed165b4a688ae3fb2deaf | https://github.com/htm-community/menorah/blob/1991b01eda3f6361b22ed165b4a688ae3fb2deaf/menorah/menorah.py#L225-L237 | train | Fetches data from river streams and feeds them into the given function. |
IRC-SPHERE/HyperStream | hyperstream/online_engine.py | OnlineEngine.execute | def execute(self, debug=False):
"""
Execute the engine - currently simple executes all workflows.
"""
if debug:
# Set some default times for execution (debugging)
start_time = datetime(year=2016, month=10, day=19, hour=12, minute=28, tzinfo=UTC)
durat... | python | def execute(self, debug=False):
"""
Execute the engine - currently simple executes all workflows.
"""
if debug:
# Set some default times for execution (debugging)
start_time = datetime(year=2016, month=10, day=19, hour=12, minute=28, tzinfo=UTC)
durat... | [
"def",
"execute",
"(",
"self",
",",
"debug",
"=",
"False",
")",
":",
"if",
"debug",
":",
"# Set some default times for execution (debugging)",
"start_time",
"=",
"datetime",
"(",
"year",
"=",
"2016",
",",
"month",
"=",
"10",
",",
"day",
"=",
"19",
",",
"ho... | Execute the engine - currently simple executes all workflows. | [
"Execute",
"the",
"engine",
"-",
"currently",
"simple",
"executes",
"all",
"workflows",
"."
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/online_engine.py#L47-L85 | train | Execute the online engine. |
tamasgal/km3pipe | km3pipe/utils/nb2sphx.py | convert_ipynb_to_gallery | def convert_ipynb_to_gallery(file_name):
"""
Blatantly stolen + adapted from
https://gist.github.com/wuhuikai/4a7ceb8bc52454e17a4eb8327d538d85
"""
python_file = ""
nb_dict = json.load(open(file_name))
cells = nb_dict['cells']
for i, cell in enumerate(cells):
if i == 0:
... | python | def convert_ipynb_to_gallery(file_name):
"""
Blatantly stolen + adapted from
https://gist.github.com/wuhuikai/4a7ceb8bc52454e17a4eb8327d538d85
"""
python_file = ""
nb_dict = json.load(open(file_name))
cells = nb_dict['cells']
for i, cell in enumerate(cells):
if i == 0:
... | [
"def",
"convert_ipynb_to_gallery",
"(",
"file_name",
")",
":",
"python_file",
"=",
"\"\"",
"nb_dict",
"=",
"json",
".",
"load",
"(",
"open",
"(",
"file_name",
")",
")",
"cells",
"=",
"nb_dict",
"[",
"'cells'",
"]",
"for",
"i",
",",
"cell",
"in",
"enumera... | Blatantly stolen + adapted from
https://gist.github.com/wuhuikai/4a7ceb8bc52454e17a4eb8327d538d85 | [
"Blatantly",
"stolen",
"+",
"adapted",
"from",
"https",
":",
"//",
"gist",
".",
"github",
".",
"com",
"/",
"wuhuikai",
"/",
"4a7ceb8bc52454e17a4eb8327d538d85"
] | 7a9b59ac899a28775b5bdc5d391d9a5340d08040 | https://github.com/tamasgal/km3pipe/blob/7a9b59ac899a28775b5bdc5d391d9a5340d08040/km3pipe/utils/nb2sphx.py#L17-L49 | train | Convert the ipynb file to a gallery file. |
PrefPy/prefpy | prefpy/util.py | get_index_nested | def get_index_nested(x, i):
"""
Description:
Returns the first index of the array (vector) x containing the value i.
Parameters:
x: one-dimensional array
i: search value
"""
for ind in range(len(x)):
if i == x[ind]:
return ind
return -1 | python | def get_index_nested(x, i):
"""
Description:
Returns the first index of the array (vector) x containing the value i.
Parameters:
x: one-dimensional array
i: search value
"""
for ind in range(len(x)):
if i == x[ind]:
return ind
return -1 | [
"def",
"get_index_nested",
"(",
"x",
",",
"i",
")",
":",
"for",
"ind",
"in",
"range",
"(",
"len",
"(",
"x",
")",
")",
":",
"if",
"i",
"==",
"x",
"[",
"ind",
"]",
":",
"return",
"ind",
"return",
"-",
"1"
] | Description:
Returns the first index of the array (vector) x containing the value i.
Parameters:
x: one-dimensional array
i: search value | [
"Description",
":",
"Returns",
"the",
"first",
"index",
"of",
"the",
"array",
"(",
"vector",
")",
"x",
"containing",
"the",
"value",
"i",
".",
"Parameters",
":",
"x",
":",
"one",
"-",
"dimensional",
"array",
"i",
":",
"search",
"value"
] | f395ba3782f05684fa5de0cece387a6da9391d02 | https://github.com/PrefPy/prefpy/blob/f395ba3782f05684fa5de0cece387a6da9391d02/prefpy/util.py#L6-L17 | train | Returns the index of the first element in x containing the value i. |
NaPs/Kolekto | kolekto/commands/show.py | show | def show(movie):
""" Show the movie metadata.
"""
for key, value in sorted(movie.iteritems(), cmp=metadata_sorter, key=lambda x: x[0]):
if isinstance(value, list):
if not value:
continue
other = value[1:]
value = value[0]
else:
... | python | def show(movie):
""" Show the movie metadata.
"""
for key, value in sorted(movie.iteritems(), cmp=metadata_sorter, key=lambda x: x[0]):
if isinstance(value, list):
if not value:
continue
other = value[1:]
value = value[0]
else:
... | [
"def",
"show",
"(",
"movie",
")",
":",
"for",
"key",
",",
"value",
"in",
"sorted",
"(",
"movie",
".",
"iteritems",
"(",
")",
",",
"cmp",
"=",
"metadata_sorter",
",",
"key",
"=",
"lambda",
"x",
":",
"x",
"[",
"0",
"]",
")",
":",
"if",
"isinstance"... | Show the movie metadata. | [
"Show",
"the",
"movie",
"metadata",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/show.py#L11-L24 | train | Show the movie metadata. |
NaPs/Kolekto | kolekto/commands/show.py | metadata_sorter | def metadata_sorter(x, y):
""" Sort metadata keys by priority.
"""
if x == y:
return 0
if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST:
return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1
elif x in METADATA_SORTER_FIRST:
return -1
... | python | def metadata_sorter(x, y):
""" Sort metadata keys by priority.
"""
if x == y:
return 0
if x in METADATA_SORTER_FIRST and y in METADATA_SORTER_FIRST:
return -1 if METADATA_SORTER_FIRST.index(x) < METADATA_SORTER_FIRST.index(y) else 1
elif x in METADATA_SORTER_FIRST:
return -1
... | [
"def",
"metadata_sorter",
"(",
"x",
",",
"y",
")",
":",
"if",
"x",
"==",
"y",
":",
"return",
"0",
"if",
"x",
"in",
"METADATA_SORTER_FIRST",
"and",
"y",
"in",
"METADATA_SORTER_FIRST",
":",
"return",
"-",
"1",
"if",
"METADATA_SORTER_FIRST",
".",
"index",
"... | Sort metadata keys by priority. | [
"Sort",
"metadata",
"keys",
"by",
"priority",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/show.py#L27-L46 | train | Sort metadata keys by priority. |
wtsi-hgi/consul-lock | consullock/_helpers.py | create_consul_client | def create_consul_client(consul_configuration: ConsulConfiguration) -> Consul:
"""
Creates a Consul client using the given configuration.
:param consul_configuration: the configuration to use to create the client
:return: the created client
"""
consul_client = Consul(
host=consul_configu... | python | def create_consul_client(consul_configuration: ConsulConfiguration) -> Consul:
"""
Creates a Consul client using the given configuration.
:param consul_configuration: the configuration to use to create the client
:return: the created client
"""
consul_client = Consul(
host=consul_configu... | [
"def",
"create_consul_client",
"(",
"consul_configuration",
":",
"ConsulConfiguration",
")",
"->",
"Consul",
":",
"consul_client",
"=",
"Consul",
"(",
"host",
"=",
"consul_configuration",
".",
"host",
",",
"port",
"=",
"consul_configuration",
".",
"port",
",",
"to... | Creates a Consul client using the given configuration.
:param consul_configuration: the configuration to use to create the client
:return: the created client | [
"Creates",
"a",
"Consul",
"client",
"using",
"the",
"given",
"configuration",
".",
":",
"param",
"consul_configuration",
":",
"the",
"configuration",
"to",
"use",
"to",
"create",
"the",
"client",
":",
"return",
":",
"the",
"created",
"client"
] | deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2 | https://github.com/wtsi-hgi/consul-lock/blob/deb07ab41dabbb49f4d0bbc062bc3b4b6e5d71b2/consullock/_helpers.py#L6-L24 | train | Creates a Consul client using the given configuration. |
finklabs/korg | korg/korg.py | parse_lines | def parse_lines(log_parsers, fileinp):
"""parse lines from the fileinput and send them to the log_parsers"""
while 1:
logentry = fileinp.readline()
if not logentry:
break
elif not logentry.rstrip():
continue # skip newlines
processed = False
for ... | python | def parse_lines(log_parsers, fileinp):
"""parse lines from the fileinput and send them to the log_parsers"""
while 1:
logentry = fileinp.readline()
if not logentry:
break
elif not logentry.rstrip():
continue # skip newlines
processed = False
for ... | [
"def",
"parse_lines",
"(",
"log_parsers",
",",
"fileinp",
")",
":",
"while",
"1",
":",
"logentry",
"=",
"fileinp",
".",
"readline",
"(",
")",
"if",
"not",
"logentry",
":",
"break",
"elif",
"not",
"logentry",
".",
"rstrip",
"(",
")",
":",
"continue",
"#... | parse lines from the fileinput and send them to the log_parsers | [
"parse",
"lines",
"from",
"the",
"fileinput",
"and",
"send",
"them",
"to",
"the",
"log_parsers"
] | e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f | https://github.com/finklabs/korg/blob/e931a673ce4bc79cdf26cb4f697fa23fa8a72e4f/korg/korg.py#L24-L44 | train | parse lines from the fileinput and send them to the log_parsers |
NaPs/Kolekto | kolekto/profiles/__init__.py | Profile.load_commands | def load_commands(self, parser):
""" Load commands of this profile.
:param parser: argparse parser on which to add commands
"""
entrypoints = self._get_entrypoints()
already_loaded = set()
for entrypoint in entrypoints:
if entrypoint.name not in already_loa... | python | def load_commands(self, parser):
""" Load commands of this profile.
:param parser: argparse parser on which to add commands
"""
entrypoints = self._get_entrypoints()
already_loaded = set()
for entrypoint in entrypoints:
if entrypoint.name not in already_loa... | [
"def",
"load_commands",
"(",
"self",
",",
"parser",
")",
":",
"entrypoints",
"=",
"self",
".",
"_get_entrypoints",
"(",
")",
"already_loaded",
"=",
"set",
"(",
")",
"for",
"entrypoint",
"in",
"entrypoints",
":",
"if",
"entrypoint",
".",
"name",
"not",
"in"... | Load commands of this profile.
:param parser: argparse parser on which to add commands | [
"Load",
"commands",
"of",
"this",
"profile",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/profiles/__init__.py#L19-L32 | train | Load commands of this profile. |
NaPs/Kolekto | kolekto/commands/importer.py | copy | def copy(tree, source_filename):
""" Copy file in tree, show a progress bar during operations,
and return the sha1 sum of copied file.
"""
#_, ext = os.path.splitext(source_filename)
filehash = sha1()
with printer.progress(os.path.getsize(source_filename)) as update:
with open(source... | python | def copy(tree, source_filename):
""" Copy file in tree, show a progress bar during operations,
and return the sha1 sum of copied file.
"""
#_, ext = os.path.splitext(source_filename)
filehash = sha1()
with printer.progress(os.path.getsize(source_filename)) as update:
with open(source... | [
"def",
"copy",
"(",
"tree",
",",
"source_filename",
")",
":",
"#_, ext = os.path.splitext(source_filename)",
"filehash",
"=",
"sha1",
"(",
")",
"with",
"printer",
".",
"progress",
"(",
"os",
".",
"path",
".",
"getsize",
"(",
"source_filename",
")",
")",
"as",
... | Copy file in tree, show a progress bar during operations,
and return the sha1 sum of copied file. | [
"Copy",
"file",
"in",
"tree",
"show",
"a",
"progress",
"bar",
"during",
"operations",
"and",
"return",
"the",
"sha1",
"sum",
"of",
"copied",
"file",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L36-L60 | train | Copy a file in tree to a new file in tree. |
NaPs/Kolekto | kolekto/commands/importer.py | list_attachments | def list_attachments(fullname):
""" List attachment for the specified fullname.
"""
parent, filename = os.path.split(fullname)
filename_without_ext, ext = os.path.splitext(filename)
attachments = []
for found_filename in os.listdir(parent):
found_filename_without_ext, _ = os.path.splitex... | python | def list_attachments(fullname):
""" List attachment for the specified fullname.
"""
parent, filename = os.path.split(fullname)
filename_without_ext, ext = os.path.splitext(filename)
attachments = []
for found_filename in os.listdir(parent):
found_filename_without_ext, _ = os.path.splitex... | [
"def",
"list_attachments",
"(",
"fullname",
")",
":",
"parent",
",",
"filename",
"=",
"os",
".",
"path",
".",
"split",
"(",
"fullname",
")",
"filename_without_ext",
",",
"ext",
"=",
"os",
".",
"path",
".",
"splitext",
"(",
"filename",
")",
"attachments",
... | List attachment for the specified fullname. | [
"List",
"attachment",
"for",
"the",
"specified",
"fullname",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L88-L98 | train | List all attachments for the specified fullname. |
NaPs/Kolekto | kolekto/commands/importer.py | ImportMovies._search | def _search(self, mdb, query, filename, year=None, auto=False):
""" Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found.
"""
choic... | python | def _search(self, mdb, query, filename, year=None, auto=False):
""" Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found.
"""
choic... | [
"def",
"_search",
"(",
"self",
",",
"mdb",
",",
"query",
",",
"filename",
",",
"year",
"=",
"None",
",",
"auto",
"=",
"False",
")",
":",
"choices",
"=",
"[",
"]",
"for",
"datasource",
",",
"movie",
"in",
"mdb",
".",
"search",
"(",
"query",
",",
"... | Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found. | [
"Search",
"the",
"movie",
"using",
"all",
"available",
"datasources",
"and",
"let",
"the",
"user",
"select",
"a",
"result",
".",
"Return",
"the",
"choosen",
"datasource",
"and",
"produced",
"movie",
"dict",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L222-L254 | train | Search the movie using all available datasources and let the user choose a result. |
NaPs/Kolekto | kolekto/commands/importer.py | ImportTvSeries._search | def _search(self, mdb, query, filename, season_num, episode_num, auto=False):
""" Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found.
"""... | python | def _search(self, mdb, query, filename, season_num, episode_num, auto=False):
""" Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found.
"""... | [
"def",
"_search",
"(",
"self",
",",
"mdb",
",",
"query",
",",
"filename",
",",
"season_num",
",",
"episode_num",
",",
"auto",
"=",
"False",
")",
":",
"choices",
"=",
"[",
"]",
"for",
"datasource",
",",
"movie",
"in",
"mdb",
".",
"search",
"(",
"query... | Search the movie using all available datasources and let the user
select a result. Return the choosen datasource and produced movie dict.
If auto is enabled, directly returns the first movie found. | [
"Search",
"the",
"movie",
"using",
"all",
"available",
"datasources",
"and",
"let",
"the",
"user",
"select",
"a",
"result",
".",
"Return",
"the",
"choosen",
"datasource",
"and",
"produced",
"movie",
"dict",
"."
] | 29c5469da8782780a06bf9a76c59414bb6fd8fe3 | https://github.com/NaPs/Kolekto/blob/29c5469da8782780a06bf9a76c59414bb6fd8fe3/kolekto/commands/importer.py#L293-L317 | train | Search the movie using all available datasources and let the user choose a result. |
IRC-SPHERE/HyperStream | hyperstream/channels/assets_channel.py | AssetsChannel.purge_stream | def purge_stream(self, stream_id, remove_definition=False, sandbox=None):
"""
Purge the stream
:param stream_id: The stream identifier
:param remove_definition: Whether to remove the stream definition as well
:param sandbox: The sandbox for this stream
:return: None
... | python | def purge_stream(self, stream_id, remove_definition=False, sandbox=None):
"""
Purge the stream
:param stream_id: The stream identifier
:param remove_definition: Whether to remove the stream definition as well
:param sandbox: The sandbox for this stream
:return: None
... | [
"def",
"purge_stream",
"(",
"self",
",",
"stream_id",
",",
"remove_definition",
"=",
"False",
",",
"sandbox",
"=",
"None",
")",
":",
"super",
"(",
"AssetsChannel",
",",
"self",
")",
".",
"purge_stream",
"(",
"stream_id",
"=",
"stream_id",
",",
"remove_defini... | Purge the stream
:param stream_id: The stream identifier
:param remove_definition: Whether to remove the stream definition as well
:param sandbox: The sandbox for this stream
:return: None | [
"Purge",
"the",
"stream"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/assets_channel.py#L50-L60 | train | Purge the stream with the given identifier. |
IRC-SPHERE/HyperStream | hyperstream/channels/assets_channel.py | AssetsChannel.write_to_stream | def write_to_stream(self, stream_id, data, sandbox=None):
"""
Write to the stream
:param stream_id: The stream identifier
:param data: The stream instances
:param sandbox: The sandbox for this stream
:type stream_id: StreamId
:return: None
:raises: NotImp... | python | def write_to_stream(self, stream_id, data, sandbox=None):
"""
Write to the stream
:param stream_id: The stream identifier
:param data: The stream instances
:param sandbox: The sandbox for this stream
:type stream_id: StreamId
:return: None
:raises: NotImp... | [
"def",
"write_to_stream",
"(",
"self",
",",
"stream_id",
",",
"data",
",",
"sandbox",
"=",
"None",
")",
":",
"if",
"sandbox",
"is",
"not",
"None",
":",
"raise",
"NotImplementedError",
"if",
"stream_id",
"not",
"in",
"self",
".",
"streams",
":",
"raise",
... | Write to the stream
:param stream_id: The stream identifier
:param data: The stream instances
:param sandbox: The sandbox for this stream
:type stream_id: StreamId
:return: None
:raises: NotImplementedError | [
"Write",
"to",
"the",
"stream"
] | 98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780 | https://github.com/IRC-SPHERE/HyperStream/blob/98478f4d31ed938f4aa7c958ed0d4c3ffcb2e780/hyperstream/channels/assets_channel.py#L82-L107 | train | Writes the data to the specified stream. |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startXTVDNode | def _startXTVDNode(self, name, attrs):
"""Process the start of the top-level xtvd node"""
schemaVersion = attrs.get('schemaVersion')
validFrom = self._parseDateTime(attrs.get('from'))
validTo = self._parseDateTime(attrs.get('to'))
self._progress.printMsg('Parsing version %s data... | python | def _startXTVDNode(self, name, attrs):
"""Process the start of the top-level xtvd node"""
schemaVersion = attrs.get('schemaVersion')
validFrom = self._parseDateTime(attrs.get('from'))
validTo = self._parseDateTime(attrs.get('to'))
self._progress.printMsg('Parsing version %s data... | [
"def",
"_startXTVDNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"schemaVersion",
"=",
"attrs",
".",
"get",
"(",
"'schemaVersion'",
")",
"validFrom",
"=",
"self",
".",
"_parseDateTime",
"(",
"attrs",
".",
"get",
"(",
"'from'",
")",
")",
"validT... | Process the start of the top-level xtvd node | [
"Process",
"the",
"start",
"of",
"the",
"top",
"-",
"level",
"xtvd",
"node"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L68-L77 | train | Process the start of the top - level xtvd node |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startStationsNode | def _startStationsNode(self, name, attrs):
"""Process the start of a node under xtvd/stations"""
if name == 'station':
self._stationId = attrs.get('id')
self._callSign = None
self._stationName = None
self._affiliate = None
self._fccChannelNumb... | python | def _startStationsNode(self, name, attrs):
"""Process the start of a node under xtvd/stations"""
if name == 'station':
self._stationId = attrs.get('id')
self._callSign = None
self._stationName = None
self._affiliate = None
self._fccChannelNumb... | [
"def",
"_startStationsNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"if",
"name",
"==",
"'station'",
":",
"self",
".",
"_stationId",
"=",
"attrs",
".",
"get",
"(",
"'id'",
")",
"self",
".",
"_callSign",
"=",
"None",
"self",
".",
"_stationNam... | Process the start of a node under xtvd/stations | [
"Process",
"the",
"start",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"stations"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L79-L87 | train | Process the start of a stations node under xtvd / stations |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._endStationsNode | def _endStationsNode(self, name, content):
"""Process the end of a node under xtvd/stations"""
if name == 'callSign':
self._callSign = content
elif name == 'name':
self._stationName = content
elif name == 'affiliate':
self._affiliate = content
... | python | def _endStationsNode(self, name, content):
"""Process the end of a node under xtvd/stations"""
if name == 'callSign':
self._callSign = content
elif name == 'name':
self._stationName = content
elif name == 'affiliate':
self._affiliate = content
... | [
"def",
"_endStationsNode",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"if",
"name",
"==",
"'callSign'",
":",
"self",
".",
"_callSign",
"=",
"content",
"elif",
"name",
"==",
"'name'",
":",
"self",
".",
"_stationName",
"=",
"content",
"elif",
"nam... | Process the end of a node under xtvd/stations | [
"Process",
"the",
"end",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"stations"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L89-L104 | train | Process the end of a stations node under xtvd / stations |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startLineupsNode | def _startLineupsNode(self, name, attrs):
"""Process the start of a node under xtvd/lineups"""
if name == 'lineup':
self._lineupName = attrs.get('name')
self._location = attrs.get('location')
self._device = attrs.get('device')
self._lineupType = attrs.get... | python | def _startLineupsNode(self, name, attrs):
"""Process the start of a node under xtvd/lineups"""
if name == 'lineup':
self._lineupName = attrs.get('name')
self._location = attrs.get('location')
self._device = attrs.get('device')
self._lineupType = attrs.get... | [
"def",
"_startLineupsNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"if",
"name",
"==",
"'lineup'",
":",
"self",
".",
"_lineupName",
"=",
"attrs",
".",
"get",
"(",
"'name'",
")",
"self",
".",
"_location",
"=",
"attrs",
".",
"get",
"(",
"'lo... | Process the start of a node under xtvd/lineups | [
"Process",
"the",
"start",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"lineups"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L106-L131 | train | Process the start of a lineup node under xtvd / lineups |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._endLineupsNode | def _endLineupsNode(self, name, content):
"""Process the end of a node under xtvd/lineups"""
if name == 'map':
if not self._error:
self._importer.new_mapping(self._lineupId, self._stationId,
self._channel, self._channelMinor,
... | python | def _endLineupsNode(self, name, content):
"""Process the end of a node under xtvd/lineups"""
if name == 'map':
if not self._error:
self._importer.new_mapping(self._lineupId, self._stationId,
self._channel, self._channelMinor,
... | [
"def",
"_endLineupsNode",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"if",
"name",
"==",
"'map'",
":",
"if",
"not",
"self",
".",
"_error",
":",
"self",
".",
"_importer",
".",
"new_mapping",
"(",
"self",
".",
"_lineupId",
",",
"self",
".",
"_... | Process the end of a node under xtvd/lineups | [
"Process",
"the",
"end",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"lineups"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L133-L141 | train | Process the end of a lineup node under xtvd / lineups |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startSchedulesNode | def _startSchedulesNode(self, name, attrs):
"""Process the start of a node under xtvd/schedules"""
if name == 'schedule':
self._programId = attrs.get('program')
self._stationId = attrs.get('station')
self._time = self._parseDateTime(attrs.get('time'))
sel... | python | def _startSchedulesNode(self, name, attrs):
"""Process the start of a node under xtvd/schedules"""
if name == 'schedule':
self._programId = attrs.get('program')
self._stationId = attrs.get('station')
self._time = self._parseDateTime(attrs.get('time'))
sel... | [
"def",
"_startSchedulesNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"if",
"name",
"==",
"'schedule'",
":",
"self",
".",
"_programId",
"=",
"attrs",
".",
"get",
"(",
"'program'",
")",
"self",
".",
"_stationId",
"=",
"attrs",
".",
"get",
"(",... | Process the start of a node under xtvd/schedules | [
"Process",
"the",
"start",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"schedules"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L143-L163 | train | Process the start of a node under xtvd / schedules |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._endSchedulesNode | def _endSchedulesNode(self, name, content):
"""Process the end of a node under xtvd/schedules"""
if name == 'schedule':
if not self._error:
self._importer.new_schedule(self._programId, self._stationId,
self._time, self._duration,
... | python | def _endSchedulesNode(self, name, content):
"""Process the end of a node under xtvd/schedules"""
if name == 'schedule':
if not self._error:
self._importer.new_schedule(self._programId, self._stationId,
self._time, self._duration,
... | [
"def",
"_endSchedulesNode",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"if",
"name",
"==",
"'schedule'",
":",
"if",
"not",
"self",
".",
"_error",
":",
"self",
".",
"_importer",
".",
"new_schedule",
"(",
"self",
".",
"_programId",
",",
"self",
... | Process the end of a node under xtvd/schedules | [
"Process",
"the",
"end",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"schedules"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L165-L176 | train | Process the end of a schedule node under xtvd / schedules |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startProgramsNode | def _startProgramsNode(self, name, attrs):
"""Process the start of a node under xtvd/programs"""
if name == 'program':
self._programId = attrs.get('id')
self._series = None
self._title = None
self._subtitle = None
self._description = None
... | python | def _startProgramsNode(self, name, attrs):
"""Process the start of a node under xtvd/programs"""
if name == 'program':
self._programId = attrs.get('id')
self._series = None
self._title = None
self._subtitle = None
self._description = None
... | [
"def",
"_startProgramsNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"if",
"name",
"==",
"'program'",
":",
"self",
".",
"_programId",
"=",
"attrs",
".",
"get",
"(",
"'id'",
")",
"self",
".",
"_series",
"=",
"None",
"self",
".",
"_title",
"=... | Process the start of a node under xtvd/programs | [
"Process",
"the",
"start",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"programs"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L178-L195 | train | Process the start of a program node under xtvd / programs |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._endProgramsNode | def _endProgramsNode(self, name, content):
"""Process the end of a node under xtvd/programs"""
if name == 'series':
self._series = content
elif name == 'title':
self._title = content
elif name == 'subtitle':
self._subtitle = content
elif name ... | python | def _endProgramsNode(self, name, content):
"""Process the end of a node under xtvd/programs"""
if name == 'series':
self._series = content
elif name == 'title':
self._title = content
elif name == 'subtitle':
self._subtitle = content
elif name ... | [
"def",
"_endProgramsNode",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"if",
"name",
"==",
"'series'",
":",
"self",
".",
"_series",
"=",
"content",
"elif",
"name",
"==",
"'title'",
":",
"self",
".",
"_title",
"=",
"content",
"elif",
"name",
"==... | Process the end of a node under xtvd/programs | [
"Process",
"the",
"end",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"programs"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L197-L236 | train | Process the end of a program node under xtvd / programs |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._startProductionCrewNode | def _startProductionCrewNode(self, name, attrs):
"""Process the start of a node under xtvd/productionCrew"""
if name == 'crew':
self._programId = attrs.get('program')
elif name == 'member':
self._role = None
self._givenname = None
self._surname = ... | python | def _startProductionCrewNode(self, name, attrs):
"""Process the start of a node under xtvd/productionCrew"""
if name == 'crew':
self._programId = attrs.get('program')
elif name == 'member':
self._role = None
self._givenname = None
self._surname = ... | [
"def",
"_startProductionCrewNode",
"(",
"self",
",",
"name",
",",
"attrs",
")",
":",
"if",
"name",
"==",
"'crew'",
":",
"self",
".",
"_programId",
"=",
"attrs",
".",
"get",
"(",
"'program'",
")",
"elif",
"name",
"==",
"'member'",
":",
"self",
".",
"_ro... | Process the start of a node under xtvd/productionCrew | [
"Process",
"the",
"start",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"productionCrew"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L238-L246 | train | Process the start of a production crew node under xtvd / productionCrew |
dsoprea/PySchedules | pyschedules/xml_callbacks.py | XmlCallbacks._endProductionCrewNode | def _endProductionCrewNode(self, name, content):
"""Process the end of a node under xtvd/productionCrew"""
if name == 'role':
self._role = content
elif name == 'givenname':
self._givenname = content
elif name == 'surname':
self._surname = content
... | python | def _endProductionCrewNode(self, name, content):
"""Process the end of a node under xtvd/productionCrew"""
if name == 'role':
self._role = content
elif name == 'givenname':
self._givenname = content
elif name == 'surname':
self._surname = content
... | [
"def",
"_endProductionCrewNode",
"(",
"self",
",",
"name",
",",
"content",
")",
":",
"if",
"name",
"==",
"'role'",
":",
"self",
".",
"_role",
"=",
"content",
"elif",
"name",
"==",
"'givenname'",
":",
"self",
".",
"_givenname",
"=",
"content",
"elif",
"na... | Process the end of a node under xtvd/productionCrew | [
"Process",
"the",
"end",
"of",
"a",
"node",
"under",
"xtvd",
"/",
"productionCrew"
] | e5aae988fad90217f72db45f93bf69839f4d75e7 | https://github.com/dsoprea/PySchedules/blob/e5aae988fad90217f72db45f93bf69839f4d75e7/pyschedules/xml_callbacks.py#L248-L266 | train | Process the end of a production crew node under xtvd / productionCrew |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.