hexsha stringlengths 40 40 | repo stringlengths 7 114 | path stringlengths 4 124 | license listlengths 1 9 | language stringclasses 1
value | identifier stringlengths 1 71 | return_type stringlengths 1 749 ⌀ | original_string stringlengths 76 22.7k | original_docstring stringlengths 16 7.61k | docstring stringlengths 16 2.47k | docstring_tokens listlengths 6 477 | code stringlengths 14 10.2k | code_tokens listlengths 6 996 | short_docstring stringlengths 2 644 | short_docstring_tokens listlengths 1 116 | comment listlengths 1 89 | parameters listlengths 0 64 | docstring_params dict |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | authenticate | <not_specific> | def authenticate(lexicon, action='read'):
"""
Authentication check. Used when but data is sent to the user, but Karp is
not involved (Karp takes care of this otherwise).
Args:
lexicon (str): the lexicon name
action (str, optional): defines which permission to verify.
Possible... |
Authentication check. Used when but data is sent to the user, but Karp is
not involved (Karp takes care of this otherwise).
Args:
lexicon (str): the lexicon name
action (str, optional): defines which permission to verify.
Possible values: read, write.
Raises:
MflExce... | Authentication check. Used when but data is sent to the user, but Karp is
not involved (Karp takes care of this otherwise). | [
"Authentication",
"check",
".",
"Used",
"when",
"but",
"data",
"is",
"sent",
"to",
"the",
"user",
"but",
"Karp",
"is",
"not",
"involved",
"(",
"Karp",
"takes",
"care",
"of",
"this",
"otherwise",
")",
"."
] | def authenticate(lexicon, action='read'):
if action == 'checkopen':
auth = None
else:
auth = request.authorization
postdata = {"include_open_resources": "true"}
if auth is not None:
user, pw = auth.username, auth.password
server = C.config['AUTH_SERVER']
mdcode = ... | [
"def",
"authenticate",
"(",
"lexicon",
",",
"action",
"=",
"'read'",
")",
":",
"if",
"action",
"==",
"'checkopen'",
":",
"auth",
"=",
"None",
"else",
":",
"auth",
"=",
"request",
".",
"authorization",
"postdata",
"=",
"{",
"\"include_open_resources\"",
":",
... | Authentication check. | [
"Authentication",
"check",
"."
] | [
"\"\"\"\n Authentication check. Used when but data is sent to the user, but Karp is\n not involved (Karp takes care of this otherwise).\n Args:\n lexicon (str): the lexicon name\n action (str, optional): defines which permission to verify.\n Possible values: read, write.\n Raise... | [
{
"param": "lexicon",
"type": null
},
{
"param": "action",
"type": null
}
] | {
"returns": [],
"raises": [
{
"docstring": "if the user is not granted the action in the lexicon",
"docstring_tokens": [
"if",
"the",
"user",
"is",
"not",
"granted",
"the",
"action",
"in",
"the",
"lexicon"
... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | karp_wftableize | <not_specific> | def karp_wftableize(lexicon, paradigm, table, classes=None, baseform='',
identifier='', pos='', resource=''):
""" Format a word table into a Karp friendly json object """
def default(paradigm, table, classes, baseform, identifier, pos, resource):
# TODO implement something more gener... | Format a word table into a Karp friendly json object | Format a word table into a Karp friendly json object | [
"Format",
"a",
"word",
"table",
"into",
"a",
"Karp",
"friendly",
"json",
"object"
] | def karp_wftableize(lexicon, paradigm, table, classes=None, baseform='',
identifier='', pos='', resource=''):
def default(paradigm, table, classes, baseform, identifier, pos, resource):
table = table.split(',')
obj = {'lexiconName': resource}
wfs = []
for l in tab... | [
"def",
"karp_wftableize",
"(",
"lexicon",
",",
"paradigm",
",",
"table",
",",
"classes",
"=",
"None",
",",
"baseform",
"=",
"''",
",",
"identifier",
"=",
"''",
",",
"pos",
"=",
"''",
",",
"resource",
"=",
"''",
")",
":",
"def",
"default",
"(",
"parad... | Format a word table into a Karp friendly json object | [
"Format",
"a",
"word",
"table",
"into",
"a",
"Karp",
"friendly",
"json",
"object"
] | [
"\"\"\" Format a word table into a Karp friendly json object \"\"\"",
"# TODO implement something more generic?"
] | [
{
"param": "lexicon",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "classes",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "paradigm",
"type": null,
"docstring": null,
"docstring_tok... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | karp_tableize | <not_specific> | def karp_tableize(lexicon, table, paradigm=None, pos='', identifier='', score=0):
" Format a generated inflection table into a Karp friendly json object "
table = table.split(',')
obj = {'score': score, 'paradigm': '', 'new': True}
if paradigm is not None:
obj['variables'] = dict([var for var in... | Format a generated inflection table into a Karp friendly json object | Format a generated inflection table into a Karp friendly json object | [
"Format",
"a",
"generated",
"inflection",
"table",
"into",
"a",
"Karp",
"friendly",
"json",
"object"
] | def karp_tableize(lexicon, table, paradigm=None, pos='', identifier='', score=0):
table = table.split(',')
obj = {'score': score, 'paradigm': '', 'new': True}
if paradigm is not None:
obj['variables'] = dict([var for var in paradigm.var_insts[0][1:]])
obj['paradigm'] = paradigm.name
... | [
"def",
"karp_tableize",
"(",
"lexicon",
",",
"table",
",",
"paradigm",
"=",
"None",
",",
"pos",
"=",
"''",
",",
"identifier",
"=",
"''",
",",
"score",
"=",
"0",
")",
":",
"table",
"=",
"table",
".",
"split",
"(",
"','",
")",
"obj",
"=",
"{",
"'sc... | Format a generated inflection table into a Karp friendly json object | [
"Format",
"a",
"generated",
"inflection",
"table",
"into",
"a",
"Karp",
"friendly",
"json",
"object"
] | [
"\" Format a generated inflection table into a Karp friendly json object \""
] | [
{
"param": "lexicon",
"type": null
},
{
"param": "table",
"type": null
},
{
"param": "paradigm",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "identifier",
"type": null
},
{
"param": "score",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_tokens... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | make_identifier | <not_specific> | def make_identifier(lexicon, baseform, pos, field='', default=False):
""" Suggest an identifier for an entry
Args:
lexicon (str): the name of the lexicon in which the identifier
should be used
baseform (str): the entry's baseform
pos (str): the entry's word class
fiel... | Suggest an identifier for an entry
Args:
lexicon (str): the name of the lexicon in which the identifier
should be used
baseform (str): the entry's baseform
pos (str): the entry's word class
field (str, optional): the identier's field name.
Defaults to the lex... | Suggest an identifier for an entry | [
"Suggest",
"an",
"identifier",
"for",
"an",
"entry"
] | def make_identifier(lexicon, baseform, pos, field='', default=False):
lexconf = lexconfig.get_lexiconconf(lexicon)
func = extra_src(lexicon, 'yield_identifier', None)
if default or func is None:
return str(uuid.uuid1())
field = field or lexconf['identifier']
mode = lexconf['lexiconMode']
... | [
"def",
"make_identifier",
"(",
"lexicon",
",",
"baseform",
",",
"pos",
",",
"field",
"=",
"''",
",",
"default",
"=",
"False",
")",
":",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"func",
"=",
"extra_src",
"(",
"lexicon",
",... | Suggest an identifier for an entry | [
"Suggest",
"an",
"identifier",
"for",
"an",
"entry"
] | [
"\"\"\" Suggest an identifier for an entry\n Args:\n lexicon (str): the name of the lexicon in which the identifier\n should be used\n baseform (str): the entry's baseform\n pos (str): the entry's word class\n field (str, optional): the identier's field name.\n D... | [
{
"param": "lexicon",
"type": null
},
{
"param": "baseform",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "field",
"type": null
},
{
"param": "default",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": "the name of the lexicon in which the identifier\nshould be used",
"docstring_tokens": [
"the",
"name",
"of",
"the",
"lexicon",
"in",
... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | read_pos | <not_specific> | def read_pos(lexconf):
" Return a list of pos tags, either from the parameters or the config "
pos = request.args.get('pos', '')
partofspeech = request.args.get('partOfSpeech', lexconf['defaultpos'])
pos = pos or partofspeech
return pos.split(',') | Return a list of pos tags, either from the parameters or the config | Return a list of pos tags, either from the parameters or the config | [
"Return",
"a",
"list",
"of",
"pos",
"tags",
"either",
"from",
"the",
"parameters",
"or",
"the",
"config"
] | def read_pos(lexconf):
pos = request.args.get('pos', '')
partofspeech = request.args.get('partOfSpeech', lexconf['defaultpos'])
pos = pos or partofspeech
return pos.split(',') | [
"def",
"read_pos",
"(",
"lexconf",
")",
":",
"pos",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'pos'",
",",
"''",
")",
"partofspeech",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'partOfSpeech'",
",",
"lexconf",
"[",
"'defaultpos'",
"]",
")",
... | Return a list of pos tags, either from the parameters or the config | [
"Return",
"a",
"list",
"of",
"pos",
"tags",
"either",
"from",
"the",
"parameters",
"or",
"the",
"config"
] | [
"\" Return a list of pos tags, either from the parameters or the config \""
] | [
{
"param": "lexconf",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexconf",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | read_restriction | <not_specific> | def read_restriction(lexconf):
""" Check whether restrict_to_baseform is true,
either from the parameters or the config """
restrict = request.args.get('restrict_to_baseform')
if restrict is None:
return lexconf['restrict_to_baseform']
return restrict in ['True', 'true', True] | Check whether restrict_to_baseform is true,
either from the parameters or the config | Check whether restrict_to_baseform is true,
either from the parameters or the config | [
"Check",
"whether",
"restrict_to_baseform",
"is",
"true",
"either",
"from",
"the",
"parameters",
"or",
"the",
"config"
] | def read_restriction(lexconf):
restrict = request.args.get('restrict_to_baseform')
if restrict is None:
return lexconf['restrict_to_baseform']
return restrict in ['True', 'true', True] | [
"def",
"read_restriction",
"(",
"lexconf",
")",
":",
"restrict",
"=",
"request",
".",
"args",
".",
"get",
"(",
"'restrict_to_baseform'",
")",
"if",
"restrict",
"is",
"None",
":",
"return",
"lexconf",
"[",
"'restrict_to_baseform'",
"]",
"return",
"restrict",
"i... | Check whether restrict_to_baseform is true,
either from the parameters or the config | [
"Check",
"whether",
"restrict_to_baseform",
"is",
"true",
"either",
"from",
"the",
"parameters",
"or",
"the",
"config"
] | [
"\"\"\" Check whether restrict_to_baseform is true,\n either from the parameters or the config \"\"\""
] | [
{
"param": "lexconf",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexconf",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | identifier2pos | <not_specific> | def identifier2pos(lexicon, lemgram):
" Try to find the pos tag by looking at the identfier "
func = extra_src(lexicon, 'get_pos',
lambda x: re.search('.*\.\.(.*?)\..*', x))
return func(lemgram) | Try to find the pos tag by looking at the identfier | Try to find the pos tag by looking at the identfier | [
"Try",
"to",
"find",
"the",
"pos",
"tag",
"by",
"looking",
"at",
"the",
"identfier"
] | def identifier2pos(lexicon, lemgram):
func = extra_src(lexicon, 'get_pos',
lambda x: re.search('.*\.\.(.*?)\..*', x))
return func(lemgram) | [
"def",
"identifier2pos",
"(",
"lexicon",
",",
"lemgram",
")",
":",
"func",
"=",
"extra_src",
"(",
"lexicon",
",",
"'get_pos'",
",",
"lambda",
"x",
":",
"re",
".",
"search",
"(",
"'.*\\.\\.(.*?)\\..*'",
",",
"x",
")",
")",
"return",
"func",
"(",
"lemgram"... | Try to find the pos tag by looking at the identfier | [
"Try",
"to",
"find",
"the",
"pos",
"tag",
"by",
"looking",
"at",
"the",
"identfier"
] | [
"\" Try to find the pos tag by looking at the identfier \""
] | [
{
"param": "lexicon",
"type": null
},
{
"param": "lemgram",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lemgram",
"type": null,
"docstring": null,
"docstring_toke... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | extra_src | <not_specific> | def extra_src(lexicon, funcname, default):
" Return a lexicon specific function if there is any "
import importlib
# If importing fails, try with a different path.
logging.debug('look for %s', funcname)
lexconf = lexconfig.get_lexiconconf(lexicon)
try:
logging.debug('file: %s', lexconf['... | Return a lexicon specific function if there is any | Return a lexicon specific function if there is any | [
"Return",
"a",
"lexicon",
"specific",
"function",
"if",
"there",
"is",
"any"
] | def extra_src(lexicon, funcname, default):
import importlib
logging.debug('look for %s', funcname)
lexconf = lexconfig.get_lexiconconf(lexicon)
try:
logging.debug('file: %s', lexconf['src'])
classmodule = importlib.import_module(lexconf['src'])
logging.debug('\n\ngo look in %s\n\... | [
"def",
"extra_src",
"(",
"lexicon",
",",
"funcname",
",",
"default",
")",
":",
"import",
"importlib",
"logging",
".",
"debug",
"(",
"'look for %s'",
",",
"funcname",
")",
"lexconf",
"=",
"lexconfig",
".",
"get_lexiconconf",
"(",
"lexicon",
")",
"try",
":",
... | Return a lexicon specific function if there is any | [
"Return",
"a",
"lexicon",
"specific",
"function",
"if",
"there",
"is",
"any"
] | [
"\" Return a lexicon specific function if there is any \"",
"# If importing fails, try with a different path."
] | [
{
"param": "lexicon",
"type": null
},
{
"param": "funcname",
"type": null
},
{
"param": "default",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "lexicon",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "funcname",
"type": null,
"docstring": null,
"docstring_tok... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | relevant_paradigms | <not_specific> | def relevant_paradigms(paradigmdict, lexicon, pos, possible_p=[]):
""" Returns a subset of the paradigms.
Args:
paradigmdict (dict): a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
lexicon (str): the lexicon name
pos (str): the tables word class
pos... | Returns a subset of the paradigms.
Args:
paradigmdict (dict): a dictionary with all paradigms
'{"lexname": {"nn": [], "vb": []}'
lexicon (str): the lexicon name
pos (str): the tables word class
possible_p (list, optional): a list of all acceptable paradigm id:s.
... | Returns a subset of the paradigms. | [
"Returns",
"a",
"subset",
"of",
"the",
"paradigms",
"."
] | def relevant_paradigms(paradigmdict, lexicon, pos, possible_p=[]):
try:
all_paras, numex, lms, alpha = paradigmdict[lexicon].get(pos, ({}, 0, None, ''))
if possible_p:
all_paras = [all_paras[p] for p in possible_p if p in all_paras]
else:
all_paras = list(all_paras.va... | [
"def",
"relevant_paradigms",
"(",
"paradigmdict",
",",
"lexicon",
",",
"pos",
",",
"possible_p",
"=",
"[",
"]",
")",
":",
"try",
":",
"all_paras",
",",
"numex",
",",
"lms",
",",
"alpha",
"=",
"paradigmdict",
"[",
"lexicon",
"]",
".",
"get",
"(",
"pos",... | Returns a subset of the paradigms. | [
"Returns",
"a",
"subset",
"of",
"the",
"paradigms",
"."
] | [
"\"\"\" Returns a subset of the paradigms.\n Args:\n paradigmdict (dict): a dictionary with all paradigms\n '{\"lexname\": {\"nn\": [], \"vb\": []}'\n lexicon (str): the lexicon name\n pos (str): the tables word class\n possible_p (list, optional): a list of all acceptable ... | [
{
"param": "paradigmdict",
"type": null
},
{
"param": "lexicon",
"type": null
},
{
"param": "pos",
"type": null
},
{
"param": "possible_p",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "paradigmdict",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lexicon",
"type": null,
"docstring": null,
"docstring... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | compile_list | <not_specific> | def compile_list(query, searchfield, querystr, lexicon, show,
size, start, mode, isfilter=False):
" Ask karp about entries matching the given query "
query = search_q(query, searchfield, querystr, lexicon, isfilter=isfilter)
res = karp_query('minientry',
{'q': query, 's... | Ask karp about entries matching the given query | Ask karp about entries matching the given query | [
"Ask",
"karp",
"about",
"entries",
"matching",
"the",
"given",
"query"
] | def compile_list(query, searchfield, querystr, lexicon, show,
size, start, mode, isfilter=False):
query = search_q(query, searchfield, querystr, lexicon, isfilter=isfilter)
res = karp_query('minientry',
{'q': query, 'show': show, 'size': size,
'start':... | [
"def",
"compile_list",
"(",
"query",
",",
"searchfield",
",",
"querystr",
",",
"lexicon",
",",
"show",
",",
"size",
",",
"start",
",",
"mode",
",",
"isfilter",
"=",
"False",
")",
":",
"query",
"=",
"search_q",
"(",
"query",
",",
"searchfield",
",",
"qu... | Ask karp about entries matching the given query | [
"Ask",
"karp",
"about",
"entries",
"matching",
"the",
"given",
"query"
] | [
"\" Ask karp about entries matching the given query \""
] | [
{
"param": "query",
"type": null
},
{
"param": "searchfield",
"type": null
},
{
"param": "querystr",
"type": null
},
{
"param": "lexicon",
"type": null
},
{
"param": "show",
"type": null
},
{
"param": "size",
"type": null
},
{
"param": "sta... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "query",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "searchfield",
"type": null,
"docstring": null,
"docstring_to... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | check_identifier | <not_specific> | def check_identifier(_id, field, resource, mode, unique=True, fail=True):
" Check whether an identifier has been used before "
q = {'size': 0, 'q': 'extended||and|%s.search|equals|%s' % (field, _id)}
res = karp_query('query', q, mode=mode, resource=resource)
used = es_total(res) > 0
ok = (used and n... | Check whether an identifier has been used before | Check whether an identifier has been used before | [
"Check",
"whether",
"an",
"identifier",
"has",
"been",
"used",
"before"
] | def check_identifier(_id, field, resource, mode, unique=True, fail=True):
q = {'size': 0, 'q': 'extended||and|%s.search|equals|%s' % (field, _id)}
res = karp_query('query', q, mode=mode, resource=resource)
used = es_total(res) > 0
ok = (used and not unique) or (not used and unique)
if not ok and fai... | [
"def",
"check_identifier",
"(",
"_id",
",",
"field",
",",
"resource",
",",
"mode",
",",
"unique",
"=",
"True",
",",
"fail",
"=",
"True",
")",
":",
"q",
"=",
"{",
"'size'",
":",
"0",
",",
"'q'",
":",
"'extended||and|%s.search|equals|%s'",
"%",
"(",
"fie... | Check whether an identifier has been used before | [
"Check",
"whether",
"an",
"identifier",
"has",
"been",
"used",
"before"
] | [
"\" Check whether an identifier has been used before \""
] | [
{
"param": "_id",
"type": null
},
{
"param": "field",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "mode",
"type": null
},
{
"param": "unique",
"type": null
},
{
"param": "fail",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "_id",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "field",
"type": null,
"docstring": null,
"docstring_tokens": [... |
76578b14619d11b40e693cbf46944e8db78e6656 | spraakbanken/karp-mfl | mflbackend/src/helpers.py | [
"MIT"
] | Python | give_info | <not_specific> | def give_info(identifier, id_field, mode, resource, show=[]):
" Give information for the word/paradigm infobox "
q = 'extended||and|%s.search|equals|%s' %\
(id_field, identifier)
body = {'q': q}
action = 'query'
if show:
body['show'] = ','.join(show)
action = 'minientry'
... | Give information for the word/paradigm infobox | Give information for the word/paradigm infobox | [
"Give",
"information",
"for",
"the",
"word",
"/",
"paradigm",
"infobox"
] | def give_info(identifier, id_field, mode, resource, show=[]):
q = 'extended||and|%s.search|equals|%s' %\
(id_field, identifier)
body = {'q': q}
action = 'query'
if show:
body['show'] = ','.join(show)
action = 'minientry'
res = karp_query(action, body, mode=mode, resource=reso... | [
"def",
"give_info",
"(",
"identifier",
",",
"id_field",
",",
"mode",
",",
"resource",
",",
"show",
"=",
"[",
"]",
")",
":",
"q",
"=",
"'extended||and|%s.search|equals|%s'",
"%",
"(",
"id_field",
",",
"identifier",
")",
"body",
"=",
"{",
"'q'",
":",
"q",
... | Give information for the word/paradigm infobox | [
"Give",
"information",
"for",
"the",
"word",
"/",
"paradigm",
"infobox"
] | [
"\" Give information for the word/paradigm infobox \""
] | [
{
"param": "identifier",
"type": null
},
{
"param": "id_field",
"type": null
},
{
"param": "mode",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "show",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "identifier",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "id_field",
"type": null,
"docstring": null,
"docstring_... |
116c5e3f153f0cd7af5fd302cd07860b98ffd0f2 | kevinjp2000/wificoin | test/functional/test_framework/test_node.py | [
"MIT"
] | Python | wait_for_rpc_connection | <not_specific> | def wait_for_rpc_connection(self):
"""Sets up an RPC connection to the wificoind process. Returns False if unable to connect."""
# Poll at a rate of four times per second
poll_per_s = 4
for _ in range(poll_per_s * self.rpc_timeout):
assert self.process.poll() is None, "wifico... | Sets up an RPC connection to the wificoind process. Returns False if unable to connect. | Sets up an RPC connection to the wificoind process. Returns False if unable to connect. | [
"Sets",
"up",
"an",
"RPC",
"connection",
"to",
"the",
"wificoind",
"process",
".",
"Returns",
"False",
"if",
"unable",
"to",
"connect",
"."
] | def wait_for_rpc_connection(self):
poll_per_s = 4
for _ in range(poll_per_s * self.rpc_timeout):
assert self.process.poll() is None, "wificoind exited with status %i during initialization" % self.process.returncode
try:
self.rpc = get_rpc_proxy(rpc_url(self.datadi... | [
"def",
"wait_for_rpc_connection",
"(",
"self",
")",
":",
"poll_per_s",
"=",
"4",
"for",
"_",
"in",
"range",
"(",
"poll_per_s",
"*",
"self",
".",
"rpc_timeout",
")",
":",
"assert",
"self",
".",
"process",
".",
"poll",
"(",
")",
"is",
"None",
",",
"\"wif... | Sets up an RPC connection to the wificoind process. | [
"Sets",
"up",
"an",
"RPC",
"connection",
"to",
"the",
"wificoind",
"process",
"."
] | [
"\"\"\"Sets up an RPC connection to the wificoind process. Returns False if unable to connect.\"\"\"",
"# Poll at a rate of four times per second",
"# If the call to getblockcount() succeeds then the RPC connection is up",
"# Port not yet open?",
"# unknown IO error",
"# Initialization phase",
"# RPC in... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
116c5e3f153f0cd7af5fd302cd07860b98ffd0f2 | kevinjp2000/wificoin | test/functional/test_framework/test_node.py | [
"MIT"
] | Python | send_cli | <not_specific> | def send_cli(self, command, *args, **kwargs):
"""Run wificoin-cli command. Deserializes returned string as python object."""
pos_args = [str(arg) for arg in args]
named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()]
assert not (pos_args and named_args), "Cannot ... | Run wificoin-cli command. Deserializes returned string as python object. | Run wificoin-cli command. Deserializes returned string as python object. | [
"Run",
"wificoin",
"-",
"cli",
"command",
".",
"Deserializes",
"returned",
"string",
"as",
"python",
"object",
"."
] | def send_cli(self, command, *args, **kwargs):
pos_args = [str(arg) for arg in args]
named_args = [str(key) + "=" + str(value) for (key, value) in kwargs.items()]
assert not (pos_args and named_args), "Cannot use positional arguments and named arguments in the same wificoin-cli call"
p_ar... | [
"def",
"send_cli",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"pos_args",
"=",
"[",
"str",
"(",
"arg",
")",
"for",
"arg",
"in",
"args",
"]",
"named_args",
"=",
"[",
"str",
"(",
"key",
")",
"+",
"\"=\"",
"+",
"... | Run wificoin-cli command. | [
"Run",
"wificoin",
"-",
"cli",
"command",
"."
] | [
"\"\"\"Run wificoin-cli command. Deserializes returned string as python object.\"\"\"",
"# Ignore cli_stdout, raise with cli_stderr"
] | [
{
"param": "self",
"type": null
},
{
"param": "command",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "command",
"type": null,
"docstring": null,
"docstring_tokens"... |
c7ce035564b5eb6ca7529376434c4fcbfa89e46f | whiteking64/lang-seg | additional_utils/models.py | [
"MIT"
] | Python | parallel_forward | <not_specific> | def parallel_forward(self, inputs, label_set='', **kwargs):
"""Multi-GPU Mult-size Evaluation
Args:
inputs: list of Tensors
"""
if len(label_set) < 10:
print('** MultiEvalModule parallel_forward phase: {} **'.format(label_set))
self.nclass = len(label_set... | Multi-GPU Mult-size Evaluation
Args:
inputs: list of Tensors
| Multi-GPU Mult-size Evaluation | [
"Multi",
"-",
"GPU",
"Mult",
"-",
"size",
"Evaluation"
] | def parallel_forward(self, inputs, label_set='', **kwargs):
if len(label_set) < 10:
print('** MultiEvalModule parallel_forward phase: {} **'.format(label_set))
self.nclass = len(label_set)
inputs = [(input.unsqueeze(0).cuda(device),)
for input, device in zip(inputs,... | [
"def",
"parallel_forward",
"(",
"self",
",",
"inputs",
",",
"label_set",
"=",
"''",
",",
"**",
"kwargs",
")",
":",
"if",
"len",
"(",
"label_set",
")",
"<",
"10",
":",
"print",
"(",
"'** MultiEvalModule parallel_forward phase: {} **'",
".",
"format",
"(",
"la... | Multi-GPU Mult-size Evaluation | [
"Multi",
"-",
"GPU",
"Mult",
"-",
"size",
"Evaluation"
] | [
"\"\"\"Multi-GPU Mult-size Evaluation\n\n Args:\n inputs: list of Tensors\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "inputs",
"type": null
},
{
"param": "label_set",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inputs",
"type": null,
"docstring": "list of Tensors",
"docst... |
8d30ed0f72def0f29eb433d2dbb8ac2312d5e210 | PyFunceble/docker | pyfunceble_docker/base.py | [
"MIT"
] | Python | log_response | null | def log_response(cls, response: dict):
"""
Given a response from the Docker client.
We log it.
"""
if "stream" in response:
for line in response["stream"].splitlines():
if line:
logging.info(line)
if "progressDetail" in re... |
Given a response from the Docker client.
We log it.
| Given a response from the Docker client.
We log it. | [
"Given",
"a",
"response",
"from",
"the",
"Docker",
"client",
".",
"We",
"log",
"it",
"."
] | def log_response(cls, response: dict):
if "stream" in response:
for line in response["stream"].splitlines():
if line:
logging.info(line)
if "progressDetail" in response and "status" in response:
if "id" in response and response["progressDetail"... | [
"def",
"log_response",
"(",
"cls",
",",
"response",
":",
"dict",
")",
":",
"if",
"\"stream\"",
"in",
"response",
":",
"for",
"line",
"in",
"response",
"[",
"\"stream\"",
"]",
".",
"splitlines",
"(",
")",
":",
"if",
"line",
":",
"logging",
".",
"info",
... | Given a response from the Docker client. | [
"Given",
"a",
"response",
"from",
"the",
"Docker",
"client",
"."
] | [
"\"\"\"\n Given a response from the Docker client.\n We log it.\n \"\"\""
] | [
{
"param": "cls",
"type": null
},
{
"param": "response",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "cls",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "response",
"type": "dict",
"docstring": null,
"docstring_token... |
8d30ed0f72def0f29eb433d2dbb8ac2312d5e210 | PyFunceble/docker | pyfunceble_docker/base.py | [
"MIT"
] | Python | is_already_pushed | <not_specific> | def is_already_pushed(self, tag: str):
"""
Checks if the given tag was already pushed.
"""
url = f"https://registry.hub.docker.com/v2/repositories/{self.docker_repository}/tags/"
tag_published = False
while True:
req = requests.get(url)
req.rais... |
Checks if the given tag was already pushed.
| Checks if the given tag was already pushed. | [
"Checks",
"if",
"the",
"given",
"tag",
"was",
"already",
"pushed",
"."
] | def is_already_pushed(self, tag: str):
url = f"https://registry.hub.docker.com/v2/repositories/{self.docker_repository}/tags/"
tag_published = False
while True:
req = requests.get(url)
req.raise_for_status()
data = req.json()
tag_published = any([x... | [
"def",
"is_already_pushed",
"(",
"self",
",",
"tag",
":",
"str",
")",
":",
"url",
"=",
"f\"https://registry.hub.docker.com/v2/repositories/{self.docker_repository}/tags/\"",
"tag_published",
"=",
"False",
"while",
"True",
":",
"req",
"=",
"requests",
".",
"get",
"(",
... | Checks if the given tag was already pushed. | [
"Checks",
"if",
"the",
"given",
"tag",
"was",
"already",
"pushed",
"."
] | [
"\"\"\"\n Checks if the given tag was already pushed.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "tag",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "tag",
"type": "str",
"docstring": null,
"docstring_tokens": [... |
dbe776914e162bd6b48ef4a4d805539afd94e736 | PyFunceble/docker | pyfunceble_docker/publish.py | [
"MIT"
] | Python | are_we_authorized_to_push | bool | def are_we_authorized_to_push(self, images: dict) -> bool:
"""
Checks if we are authorized to push.
"""
if "RepoTags" not in images or not images["RepoTags"]:
return False
for repo_tag in images["RepoTags"]:
tag = repo_tag.split(":")[-1]
if ... |
Checks if we are authorized to push.
| Checks if we are authorized to push. | [
"Checks",
"if",
"we",
"are",
"authorized",
"to",
"push",
"."
] | def are_we_authorized_to_push(self, images: dict) -> bool:
if "RepoTags" not in images or not images["RepoTags"]:
return False
for repo_tag in images["RepoTags"]:
tag = repo_tag.split(":")[-1]
if tag == "latest":
continue
if self.is_already... | [
"def",
"are_we_authorized_to_push",
"(",
"self",
",",
"images",
":",
"dict",
")",
"->",
"bool",
":",
"if",
"\"RepoTags\"",
"not",
"in",
"images",
"or",
"not",
"images",
"[",
"\"RepoTags\"",
"]",
":",
"return",
"False",
"for",
"repo_tag",
"in",
"images",
"[... | Checks if we are authorized to push. | [
"Checks",
"if",
"we",
"are",
"authorized",
"to",
"push",
"."
] | [
"\"\"\"\n Checks if we are authorized to push.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "images",
"type": "dict"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "images",
"type": "dict",
"docstring": null,
"docstring_tokens... |
3759b86a1269044ce3a9dc45463a6b17dc100294 | PyFunceble/docker | pyfunceble_docker/cli.py | [
"MIT"
] | Python | add_common_commands | <not_specific> | def add_common_commands(parser):
"""
Adds some common commands to the given parser.
"""
parser.add_argument(
"-v",
"--version",
help="Show the version and exit.",
action="version",
version=f"%(prog)s {VERSION}",
)
parser.add_argument(
"-d",
... |
Adds some common commands to the given parser.
| Adds some common commands to the given parser. | [
"Adds",
"some",
"common",
"commands",
"to",
"the",
"given",
"parser",
"."
] | def add_common_commands(parser):
parser.add_argument(
"-v",
"--version",
help="Show the version and exit.",
action="version",
version=f"%(prog)s {VERSION}",
)
parser.add_argument(
"-d",
"--debug",
help="Activated the debug mode.",
actio... | [
"def",
"add_common_commands",
"(",
"parser",
")",
":",
"parser",
".",
"add_argument",
"(",
"\"-v\"",
",",
"\"--version\"",
",",
"help",
"=",
"\"Show the version and exit.\"",
",",
"action",
"=",
"\"version\"",
",",
"version",
"=",
"f\"%(prog)s {VERSION}\"",
",",
"... | Adds some common commands to the given parser. | [
"Adds",
"some",
"common",
"commands",
"to",
"the",
"given",
"parser",
"."
] | [
"\"\"\"\n Adds some common commands to the given parser.\n \"\"\""
] | [
{
"param": "parser",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "parser",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8d429d14e9a90874cea930fa21709a7459fd73bc | mburtless/opal | opal_common/sources/api_policy_source.py | [
"Apache-2.0"
] | Python | fetch_policy_bundle_from_api_source | Tuple[Path, BundleHash, BundleHash] | async def fetch_policy_bundle_from_api_source(
self,
url: str,
token: Optional[str]
) -> Tuple[Path, BundleHash, BundleHash]:
"""
Fetches the bundle. May throw, in which case we retry again.
Checks that the bundle file isn't the same with Etag, if server
doesn... |
Fetches the bundle. May throw, in which case we retry again.
Checks that the bundle file isn't the same with Etag, if server
doesn't have Etag it checks it with hash on the bundle file
Read more on Etag here:
https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag
... | Fetches the bundle. May throw, in which case we retry again.
Checks that the bundle file isn't the same with Etag, if server
doesn't have Etag it checks it with hash on the bundle file
| [
"Fetches",
"the",
"bundle",
".",
"May",
"throw",
"in",
"which",
"case",
"we",
"retry",
"again",
".",
"Checks",
"that",
"the",
"bundle",
"file",
"isn",
"'",
"t",
"the",
"same",
"with",
"Etag",
"if",
"server",
"doesn",
"'",
"t",
"have",
"Etag",
"it",
"... | async def fetch_policy_bundle_from_api_source(
self,
url: str,
token: Optional[str]
) -> Tuple[Path, BundleHash, BundleHash]:
auth_headers = tuple_to_dict(
get_authorization_header(token)) if token else {}
etag_headers = {'ETag': self.etag,
... | [
"async",
"def",
"fetch_policy_bundle_from_api_source",
"(",
"self",
",",
"url",
":",
"str",
",",
"token",
":",
"Optional",
"[",
"str",
"]",
")",
"->",
"Tuple",
"[",
"Path",
",",
"BundleHash",
",",
"BundleHash",
"]",
":",
"auth_headers",
"=",
"tuple_to_dict",... | Fetches the bundle. | [
"Fetches",
"the",
"bundle",
"."
] | [
"\"\"\"\n Fetches the bundle. May throw, in which case we retry again.\n Checks that the bundle file isn't the same with Etag, if server\n doesn't have Etag it checks it with hash on the bundle file\n\n Read more on Etag here:\n https://developer.mozilla.org/en-US/docs/Web/HTTP/He... | [
{
"param": "self",
"type": null
},
{
"param": "url",
"type": "str"
},
{
"param": "token",
"type": "Optional[str]"
}
] | {
"returns": [
{
"docstring": "path to the bundle file that we just downloaded from the remote API source\nBundleHash: previous bundle hash on None if this is the initial bundle file\nBundleHash: current bundle hash",
"docstring_tokens": [
"path",
"to",
"the",
"bundle",... |
8d429d14e9a90874cea930fa21709a7459fd73bc | mburtless/opal | opal_common/sources/api_policy_source.py | [
"Apache-2.0"
] | Python | check_for_changes | null | async def check_for_changes(self):
"""
Calling this method will trigger an api check to the remote.
If after the request the watcher detects new bundle, it will call the
callbacks registered with _on_new_policy().
"""
logger.info(
"Fetching changes from remote... |
Calling this method will trigger an api check to the remote.
If after the request the watcher detects new bundle, it will call the
callbacks registered with _on_new_policy().
| Calling this method will trigger an api check to the remote.
If after the request the watcher detects new bundle, it will call the
callbacks registered with _on_new_policy(). | [
"Calling",
"this",
"method",
"will",
"trigger",
"an",
"api",
"check",
"to",
"the",
"remote",
".",
"If",
"after",
"the",
"request",
"the",
"watcher",
"detects",
"new",
"bundle",
"it",
"will",
"call",
"the",
"callbacks",
"registered",
"with",
"_on_new_policy",
... | async def check_for_changes(self):
logger.info(
"Fetching changes from remote: '{remote}'", remote=self.remote_source_url)
has_changes, prev, latest, prev_commit, new_commit = await self.api_update_policy()
if not has_changes:
logger.info(
"No new version:... | [
"async",
"def",
"check_for_changes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Fetching changes from remote: '{remote}'\"",
",",
"remote",
"=",
"self",
".",
"remote_source_url",
")",
"has_changes",
",",
"prev",
",",
"latest",
",",
"prev_commit",
",",
... | Calling this method will trigger an api check to the remote. | [
"Calling",
"this",
"method",
"will",
"trigger",
"an",
"api",
"check",
"to",
"the",
"remote",
"."
] | [
"\"\"\"\n Calling this method will trigger an api check to the remote.\n If after the request the watcher detects new bundle, it will call the\n callbacks registered with _on_new_policy().\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9b559d2db2124099f99b815d9f3c9f1cc8ae52fc | mburtless/opal | opal_server/policy/watcher/factory.py | [
"Apache-2.0"
] | Python | trigger_repo_watcher_pull | null | async def trigger_repo_watcher_pull(watcher: PolicyWatcherTask, topic: Topic, data: Any):
"""
triggers the policy watcher check for changes.
will trigger a task on the watcher's thread.
"""
logger.info("webhook listener triggered")
watcher.trigger() |
triggers the policy watcher check for changes.
will trigger a task on the watcher's thread.
| triggers the policy watcher check for changes.
will trigger a task on the watcher's thread. | [
"triggers",
"the",
"policy",
"watcher",
"check",
"for",
"changes",
".",
"will",
"trigger",
"a",
"task",
"on",
"the",
"watcher",
"'",
"s",
"thread",
"."
] | async def trigger_repo_watcher_pull(watcher: PolicyWatcherTask, topic: Topic, data: Any):
logger.info("webhook listener triggered")
watcher.trigger() | [
"async",
"def",
"trigger_repo_watcher_pull",
"(",
"watcher",
":",
"PolicyWatcherTask",
",",
"topic",
":",
"Topic",
",",
"data",
":",
"Any",
")",
":",
"logger",
".",
"info",
"(",
"\"webhook listener triggered\"",
")",
"watcher",
".",
"trigger",
"(",
")"
] | triggers the policy watcher check for changes. | [
"triggers",
"the",
"policy",
"watcher",
"check",
"for",
"changes",
"."
] | [
"\"\"\"\n triggers the policy watcher check for changes.\n will trigger a task on the watcher's thread.\n \"\"\""
] | [
{
"param": "watcher",
"type": "PolicyWatcherTask"
},
{
"param": "topic",
"type": "Topic"
},
{
"param": "data",
"type": "Any"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "watcher",
"type": "PolicyWatcherTask",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "topic",
"type": "Topic",
"docstring": null,
... |
0c6ce63fa3796bbd252c35c4cbc1508f3c01fc12 | mburtless/opal | opal_common/git/branch_tracker.py | [
"Apache-2.0"
] | Python | pull | Tuple[bool, Commit, Commit] | def pull(self) -> Tuple[bool, Commit, Commit]:
"""
git pulls from tracked remote.
Returns:
pull_result (bool, Commit, Commit): a tuple consisting of:
has_changes (bool): whether the remote had new commits on our tracked branch
prev (Commit): the previ... |
git pulls from tracked remote.
Returns:
pull_result (bool, Commit, Commit): a tuple consisting of:
has_changes (bool): whether the remote had new commits on our tracked branch
prev (Commit): the previous (before the pull) top-most commit on the tracked branc... | git pulls from tracked remote. | [
"git",
"pulls",
"from",
"tracked",
"remote",
"."
] | def pull(self) -> Tuple[bool, Commit, Commit]:
self._pull()
if (self.prev_commit.hexsha == self.latest_commit.hexsha):
return False, self.prev_commit, self.prev_commit
else:
prev = self._prev_commit
self._save_latest_commit_as_prev_commit()
return ... | [
"def",
"pull",
"(",
"self",
")",
"->",
"Tuple",
"[",
"bool",
",",
"Commit",
",",
"Commit",
"]",
":",
"self",
".",
"_pull",
"(",
")",
"if",
"(",
"self",
".",
"prev_commit",
".",
"hexsha",
"==",
"self",
".",
"latest_commit",
".",
"hexsha",
")",
":",
... | git pulls from tracked remote. | [
"git",
"pulls",
"from",
"tracked",
"remote",
"."
] | [
"\"\"\"\n git pulls from tracked remote.\n\n Returns:\n pull_result (bool, Commit, Commit): a tuple consisting of:\n has_changes (bool): whether the remote had new commits on our tracked branch\n prev (Commit): the previous (before the pull) top-most commit on ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "pull_result (bool, Commit, Commit): a tuple consisting of:\nhas_changes (bool): whether the remote had new commits on our tracked branch\nprev (Commit): the previous (before the pull) top-most commit on the tracked branch\nlatest (Commit): the new top-most (latest) commit on t... |
0c6ce63fa3796bbd252c35c4cbc1508f3c01fc12 | mburtless/opal | opal_common/git/branch_tracker.py | [
"Apache-2.0"
] | Python | _pull | <not_specific> | def _pull(self):
"""
runs git pull with retries.
"""
attempt_pull = retry(**self._retry_config)(self.tracked_remote.pull)
return attempt_pull() |
runs git pull with retries.
| runs git pull with retries. | [
"runs",
"git",
"pull",
"with",
"retries",
"."
] | def _pull(self):
attempt_pull = retry(**self._retry_config)(self.tracked_remote.pull)
return attempt_pull() | [
"def",
"_pull",
"(",
"self",
")",
":",
"attempt_pull",
"=",
"retry",
"(",
"**",
"self",
".",
"_retry_config",
")",
"(",
"self",
".",
"tracked_remote",
".",
"pull",
")",
"return",
"attempt_pull",
"(",
")"
] | runs git pull with retries. | [
"runs",
"git",
"pull",
"with",
"retries",
"."
] | [
"\"\"\"\n runs git pull with retries.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0c6ce63fa3796bbd252c35c4cbc1508f3c01fc12 | mburtless/opal | opal_common/git/branch_tracker.py | [
"Apache-2.0"
] | Python | prev_commit | Commit | def prev_commit(self) -> Commit:
"""
the last previously known HEAD of the tracked branch
"""
return self._prev_commit |
the last previously known HEAD of the tracked branch
| the last previously known HEAD of the tracked branch | [
"the",
"last",
"previously",
"known",
"HEAD",
"of",
"the",
"tracked",
"branch"
] | def prev_commit(self) -> Commit:
return self._prev_commit | [
"def",
"prev_commit",
"(",
"self",
")",
"->",
"Commit",
":",
"return",
"self",
".",
"_prev_commit"
] | the last previously known HEAD of the tracked branch | [
"the",
"last",
"previously",
"known",
"HEAD",
"of",
"the",
"tracked",
"branch"
] | [
"\"\"\"\n the last previously known HEAD of the tracked branch\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0c6ce63fa3796bbd252c35c4cbc1508f3c01fc12 | mburtless/opal | opal_common/git/branch_tracker.py | [
"Apache-2.0"
] | Python | tracked_branch | Head | def tracked_branch(self) -> Head:
"""
returns the tracked branch object (of type git.HEAD)
or throws if such branch does not exist on the repo
"""
try:
return getattr(self._repo.heads, self._branch_name)
except AttributeError as e:
branches = [{'na... |
returns the tracked branch object (of type git.HEAD)
or throws if such branch does not exist on the repo
| returns the tracked branch object (of type git.HEAD)
or throws if such branch does not exist on the repo | [
"returns",
"the",
"tracked",
"branch",
"object",
"(",
"of",
"type",
"git",
".",
"HEAD",
")",
"or",
"throws",
"if",
"such",
"branch",
"does",
"not",
"exist",
"on",
"the",
"repo"
] | def tracked_branch(self) -> Head:
try:
return getattr(self._repo.heads, self._branch_name)
except AttributeError as e:
branches = [{'name': head.name, 'path': head.path} for head in self._repo.heads]
logger.exception("did not find main branch: {error}, instead found: ... | [
"def",
"tracked_branch",
"(",
"self",
")",
"->",
"Head",
":",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"_repo",
".",
"heads",
",",
"self",
".",
"_branch_name",
")",
"except",
"AttributeError",
"as",
"e",
":",
"branches",
"=",
"[",
"{",
"'name... | returns the tracked branch object (of type git.HEAD)
or throws if such branch does not exist on the repo | [
"returns",
"the",
"tracked",
"branch",
"object",
"(",
"of",
"type",
"git",
".",
"HEAD",
")",
"or",
"throws",
"if",
"such",
"branch",
"does",
"not",
"exist",
"on",
"the",
"repo"
] | [
"\"\"\"\n returns the tracked branch object (of type git.HEAD)\n or throws if such branch does not exist on the repo\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0c6ce63fa3796bbd252c35c4cbc1508f3c01fc12 | mburtless/opal | opal_common/git/branch_tracker.py | [
"Apache-2.0"
] | Python | tracked_remote | Remote | def tracked_remote(self) -> Remote:
"""
returns the tracked remote object (of type git.Remote)
or throws if such remote does not exist on the repo
"""
try:
return getattr(self._repo.remotes, self._remote_name)
except AttributeError as e:
remotes = ... |
returns the tracked remote object (of type git.Remote)
or throws if such remote does not exist on the repo
| returns the tracked remote object (of type git.Remote)
or throws if such remote does not exist on the repo | [
"returns",
"the",
"tracked",
"remote",
"object",
"(",
"of",
"type",
"git",
".",
"Remote",
")",
"or",
"throws",
"if",
"such",
"remote",
"does",
"not",
"exist",
"on",
"the",
"repo"
] | def tracked_remote(self) -> Remote:
try:
return getattr(self._repo.remotes, self._remote_name)
except AttributeError as e:
remotes = [remote.name for remote in self._repo.remotes]
logger.exception("did not find main branch: {error}, instead found: {remotes_found}", er... | [
"def",
"tracked_remote",
"(",
"self",
")",
"->",
"Remote",
":",
"try",
":",
"return",
"getattr",
"(",
"self",
".",
"_repo",
".",
"remotes",
",",
"self",
".",
"_remote_name",
")",
"except",
"AttributeError",
"as",
"e",
":",
"remotes",
"=",
"[",
"remote",
... | returns the tracked remote object (of type git.Remote)
or throws if such remote does not exist on the repo | [
"returns",
"the",
"tracked",
"remote",
"object",
"(",
"of",
"type",
"git",
".",
"Remote",
")",
"or",
"throws",
"if",
"such",
"remote",
"does",
"not",
"exist",
"on",
"the",
"repo"
] | [
"\"\"\"\n returns the tracked remote object (of type git.Remote)\n or throws if such remote does not exist on the repo\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b1d22a1de091f1d2de9bacfddce740fc6481f67 | mburtless/opal | opal_common/git/repo_cloner.py | [
"Apache-2.0"
] | Python | is_ssh_repo_url | <not_specific> | def is_ssh_repo_url(repo_url: str):
"""
return True if the repo url uses SSH authentication.
(see: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
"""
return repo_url.startswith(SSH_PREFIX) or repo_url.startswith(GIT_SSH_USER_PREFIX) |
return True if the repo url uses SSH authentication.
(see: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)
| return True if the repo url uses SSH authentication. | [
"return",
"True",
"if",
"the",
"repo",
"url",
"uses",
"SSH",
"authentication",
"."
] | def is_ssh_repo_url(repo_url: str):
return repo_url.startswith(SSH_PREFIX) or repo_url.startswith(GIT_SSH_USER_PREFIX) | [
"def",
"is_ssh_repo_url",
"(",
"repo_url",
":",
"str",
")",
":",
"return",
"repo_url",
".",
"startswith",
"(",
"SSH_PREFIX",
")",
"or",
"repo_url",
".",
"startswith",
"(",
"GIT_SSH_USER_PREFIX",
")"
] | return True if the repo url uses SSH authentication. | [
"return",
"True",
"if",
"the",
"repo",
"url",
"uses",
"SSH",
"authentication",
"."
] | [
"\"\"\"\n return True if the repo url uses SSH authentication.\n (see: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh)\n \"\"\""
] | [
{
"param": "repo_url",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "repo_url",
"type": "str",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b1d22a1de091f1d2de9bacfddce740fc6481f67 | mburtless/opal | opal_common/git/repo_cloner.py | [
"Apache-2.0"
] | Python | clone | CloneResult | async def clone(self) -> CloneResult:
"""
initializes a git.Repo and returns the clone result.
it either:
- does not found a cloned repo locally and clones from remote url
- finds a cloned repo locally and does not clone from remote.
"""
logger.info("Cloni... |
initializes a git.Repo and returns the clone result.
it either:
- does not found a cloned repo locally and clones from remote url
- finds a cloned repo locally and does not clone from remote.
| initializes a git.Repo and returns the clone result.
it either:
does not found a cloned repo locally and clones from remote url
finds a cloned repo locally and does not clone from remote. | [
"initializes",
"a",
"git",
".",
"Repo",
"and",
"returns",
"the",
"clone",
"result",
".",
"it",
"either",
":",
"does",
"not",
"found",
"a",
"cloned",
"repo",
"locally",
"and",
"clones",
"from",
"remote",
"url",
"finds",
"a",
"cloned",
"repo",
"locally",
"... | async def clone(self) -> CloneResult:
logger.info("Cloning repo from '{url}' to '{to_path}' (branch: '{branch}')", url=self.url, to_path=self.path, branch=self.branch_name)
loop = asyncio.get_running_loop()
return await loop.run_in_executor(None, self._attempt_clone_from_url) | [
"async",
"def",
"clone",
"(",
"self",
")",
"->",
"CloneResult",
":",
"logger",
".",
"info",
"(",
"\"Cloning repo from '{url}' to '{to_path}' (branch: '{branch}')\"",
",",
"url",
"=",
"self",
".",
"url",
",",
"to_path",
"=",
"self",
".",
"path",
",",
"branch",
... | initializes a git.Repo and returns the clone result. | [
"initializes",
"a",
"git",
".",
"Repo",
"and",
"returns",
"the",
"clone",
"result",
"."
] | [
"\"\"\"\n initializes a git.Repo and returns the clone result.\n it either:\n - does not found a cloned repo locally and clones from remote url\n - finds a cloned repo locally and does not clone from remote.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b1d22a1de091f1d2de9bacfddce740fc6481f67 | mburtless/opal | opal_common/git/repo_cloner.py | [
"Apache-2.0"
] | Python | _attempt_clone_from_url | CloneResult | def _attempt_clone_from_url(self) -> CloneResult:
"""
clones the repo from url or throws GitFailed
"""
env = self._provide_git_ssh_environment()
_clone_func = partial(self._clone, env=env)
_clone_with_retries = retry(**self._retry_config)(_clone_func)
try:
... |
clones the repo from url or throws GitFailed
| clones the repo from url or throws GitFailed | [
"clones",
"the",
"repo",
"from",
"url",
"or",
"throws",
"GitFailed"
] | def _attempt_clone_from_url(self) -> CloneResult:
env = self._provide_git_ssh_environment()
_clone_func = partial(self._clone, env=env)
_clone_with_retries = retry(**self._retry_config)(_clone_func)
try:
repo: Repo = _clone_with_retries()
except (GitError, GitCommandE... | [
"def",
"_attempt_clone_from_url",
"(",
"self",
")",
"->",
"CloneResult",
":",
"env",
"=",
"self",
".",
"_provide_git_ssh_environment",
"(",
")",
"_clone_func",
"=",
"partial",
"(",
"self",
".",
"_clone",
",",
"env",
"=",
"env",
")",
"_clone_with_retries",
"=",... | clones the repo from url or throws GitFailed | [
"clones",
"the",
"repo",
"from",
"url",
"or",
"throws",
"GitFailed"
] | [
"\"\"\"\n clones the repo from url or throws GitFailed\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
5b1d22a1de091f1d2de9bacfddce740fc6481f67 | mburtless/opal | opal_common/git/repo_cloner.py | [
"Apache-2.0"
] | Python | _provide_git_ssh_environment | <not_specific> | def _provide_git_ssh_environment(self):
"""
provides git SSH configuration via GIT_SSH_COMMAND.
the git ssh config will be provided only if the following conditions are met:
- the repo url is a git ssh url
- an ssh private key is provided in Repo Cloner __init__
"""
... |
provides git SSH configuration via GIT_SSH_COMMAND.
the git ssh config will be provided only if the following conditions are met:
- the repo url is a git ssh url
- an ssh private key is provided in Repo Cloner __init__
| provides git SSH configuration via GIT_SSH_COMMAND.
the git ssh config will be provided only if the following conditions are met:
the repo url is a git ssh url
an ssh private key is provided in Repo Cloner __init | [
"provides",
"git",
"SSH",
"configuration",
"via",
"GIT_SSH_COMMAND",
".",
"the",
"git",
"ssh",
"config",
"will",
"be",
"provided",
"only",
"if",
"the",
"following",
"conditions",
"are",
"met",
":",
"the",
"repo",
"url",
"is",
"a",
"git",
"ssh",
"url",
"an"... | def _provide_git_ssh_environment(self):
if not is_ssh_repo_url(self.url) or self._ssh_key is None:
return None
git_ssh_identity_file = self._save_ssh_key_to_pem_file(self._ssh_key)
return {
"GIT_SSH_COMMAND": f"ssh -o StrictHostKeyChecking=no -o IdentitiesOnly=yes -i {gi... | [
"def",
"_provide_git_ssh_environment",
"(",
"self",
")",
":",
"if",
"not",
"is_ssh_repo_url",
"(",
"self",
".",
"url",
")",
"or",
"self",
".",
"_ssh_key",
"is",
"None",
":",
"return",
"None",
"git_ssh_identity_file",
"=",
"self",
".",
"_save_ssh_key_to_pem_file"... | provides git SSH configuration via GIT_SSH_COMMAND. | [
"provides",
"git",
"SSH",
"configuration",
"via",
"GIT_SSH_COMMAND",
"."
] | [
"\"\"\"\n provides git SSH configuration via GIT_SSH_COMMAND.\n\n the git ssh config will be provided only if the following conditions are met:\n - the repo url is a git ssh url\n - an ssh private key is provided in Repo Cloner __init__\n \"\"\"",
"# no ssh config"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
2fedacbbf7cf0fe96e6a661116198686c58400fc | mburtless/opal | opal_common/sources/git_policy_source.py | [
"Apache-2.0"
] | Python | check_for_changes | null | async def check_for_changes(self):
"""
Calling this method will trigger a git pull from the tracked remote.
If after the pull the watcher detects new commits, it will call the
callbacks registered with _on_new_policy().
"""
logger.info("Pulling changes from remote: '{remo... |
Calling this method will trigger a git pull from the tracked remote.
If after the pull the watcher detects new commits, it will call the
callbacks registered with _on_new_policy().
| Calling this method will trigger a git pull from the tracked remote.
If after the pull the watcher detects new commits, it will call the
callbacks registered with _on_new_policy(). | [
"Calling",
"this",
"method",
"will",
"trigger",
"a",
"git",
"pull",
"from",
"the",
"tracked",
"remote",
".",
"If",
"after",
"the",
"pull",
"the",
"watcher",
"detects",
"new",
"commits",
"it",
"will",
"call",
"the",
"callbacks",
"registered",
"with",
"_on_new... | async def check_for_changes(self):
logger.info("Pulling changes from remote: '{remote}'", remote=self._tracker.tracked_remote.name)
has_changes, prev, latest = self._tracker.pull()
if not has_changes:
logger.info("No new commits: HEAD is at '{head}'", head=latest.hexsha)
else... | [
"async",
"def",
"check_for_changes",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"\"Pulling changes from remote: '{remote}'\"",
",",
"remote",
"=",
"self",
".",
"_tracker",
".",
"tracked_remote",
".",
"name",
")",
"has_changes",
",",
"prev",
",",
"latest"... | Calling this method will trigger a git pull from the tracked remote. | [
"Calling",
"this",
"method",
"will",
"trigger",
"a",
"git",
"pull",
"from",
"the",
"tracked",
"remote",
"."
] | [
"\"\"\"\n Calling this method will trigger a git pull from the tracked remote.\n If after the pull the watcher detects new commits, it will call the\n callbacks registered with _on_new_policy().\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
33bf7db44db21fea5cea3abdcacf3747ac25890b | mburtless/opal | opal_server/server.py | [
"Apache-2.0"
] | Python | _configure_api_routes | <not_specific> | def _configure_api_routes(self, app: FastAPI):
"""
mounts the api routes on the app object
"""
authenticator = JWTAuthenticator(self.signer)
data_update_publisher: Optional[DataUpdatePublisher] = None
if self.publisher is not None:
data_update_publisher = Dat... |
mounts the api routes on the app object
| mounts the api routes on the app object | [
"mounts",
"the",
"api",
"routes",
"on",
"the",
"app",
"object"
] | def _configure_api_routes(self, app: FastAPI):
authenticator = JWTAuthenticator(self.signer)
data_update_publisher: Optional[DataUpdatePublisher] = None
if self.publisher is not None:
data_update_publisher = DataUpdatePublisher(self.publisher)
data_updates_router = init_data_... | [
"def",
"_configure_api_routes",
"(",
"self",
",",
"app",
":",
"FastAPI",
")",
":",
"authenticator",
"=",
"JWTAuthenticator",
"(",
"self",
".",
"signer",
")",
"data_update_publisher",
":",
"Optional",
"[",
"DataUpdatePublisher",
"]",
"=",
"None",
"if",
"self",
... | mounts the api routes on the app object | [
"mounts",
"the",
"api",
"routes",
"on",
"the",
"app",
"object"
] | [
"\"\"\"\n mounts the api routes on the app object\n \"\"\"",
"# Init api routers with required dependencies",
"# mount the api routes on the app object",
"# mount jwts (static) route",
"# top level routes (i.e: healthchecks)"
] | [
{
"param": "self",
"type": null
},
{
"param": "app",
"type": "FastAPI"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "app",
"type": "FastAPI",
"docstring": null,
"docstring_tokens... |
33bf7db44db21fea5cea3abdcacf3747ac25890b | mburtless/opal | opal_server/server.py | [
"Apache-2.0"
] | Python | start_server_background_tasks | null | async def start_server_background_tasks(self):
"""
starts the background processes (as asyncio tasks) if such are configured.
all workers will start these tasks:
- publisher: a client that is used to publish updates to the client.
only the leader worker (first to obtain leaders... |
starts the background processes (as asyncio tasks) if such are configured.
all workers will start these tasks:
- publisher: a client that is used to publish updates to the client.
only the leader worker (first to obtain leadership lock) will start these tasks:
- (repo) watcher... | starts the background processes (as asyncio tasks) if such are configured.
all workers will start these tasks:
publisher: a client that is used to publish updates to the client.
only the leader worker (first to obtain leadership lock) will start these tasks:
(repo) watcher: monitors the policy git repository for chang... | [
"starts",
"the",
"background",
"processes",
"(",
"as",
"asyncio",
"tasks",
")",
"if",
"such",
"are",
"configured",
".",
"all",
"workers",
"will",
"start",
"these",
"tasks",
":",
"publisher",
":",
"a",
"client",
"that",
"is",
"used",
"to",
"publish",
"updat... | async def start_server_background_tasks(self):
if self.publisher is not None:
async with self.publisher:
if self._init_policy_watcher:
self.leadership_lock = NamedLock(opal_server_config.LEADER_LOCK_FILE_PATH)
async with self.leadership_lock:
... | [
"async",
"def",
"start_server_background_tasks",
"(",
"self",
")",
":",
"if",
"self",
".",
"publisher",
"is",
"not",
"None",
":",
"async",
"with",
"self",
".",
"publisher",
":",
"if",
"self",
".",
"_init_policy_watcher",
":",
"self",
".",
"leadership_lock",
... | starts the background processes (as asyncio tasks) if such are configured. | [
"starts",
"the",
"background",
"processes",
"(",
"as",
"asyncio",
"tasks",
")",
"if",
"such",
"are",
"configured",
"."
] | [
"\"\"\"\n starts the background processes (as asyncio tasks) if such are configured.\n\n all workers will start these tasks:\n - publisher: a client that is used to publish updates to the client.\n\n only the leader worker (first to obtain leadership lock) will start these tasks:\n ... | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ccc965eff9628527b39585e341a7e5816bc08dc3 | mburtless/opal | opal_client/policy/fetcher.py | [
"Apache-2.0"
] | Python | _fetch_policy_bundle | Optional[PolicyBundle] | async def _fetch_policy_bundle(
self,
directories: List[str] = ['.'],
base_hash: Optional[str] = None
) -> Optional[PolicyBundle]:
"""
Fetches the bundle. May throw, in which case we retry again.
"""
params = {"path": directories}
if base_hash is not N... |
Fetches the bundle. May throw, in which case we retry again.
| Fetches the bundle. May throw, in which case we retry again. | [
"Fetches",
"the",
"bundle",
".",
"May",
"throw",
"in",
"which",
"case",
"we",
"retry",
"again",
"."
] | async def _fetch_policy_bundle(
self,
directories: List[str] = ['.'],
base_hash: Optional[str] = None
) -> Optional[PolicyBundle]:
params = {"path": directories}
if base_hash is not None:
params["base_hash"] = base_hash
async with aiohttp.ClientSession() a... | [
"async",
"def",
"_fetch_policy_bundle",
"(",
"self",
",",
"directories",
":",
"List",
"[",
"str",
"]",
"=",
"[",
"'.'",
"]",
",",
"base_hash",
":",
"Optional",
"[",
"str",
"]",
"=",
"None",
")",
"->",
"Optional",
"[",
"PolicyBundle",
"]",
":",
"params"... | Fetches the bundle. | [
"Fetches",
"the",
"bundle",
"."
] | [
"\"\"\"\n Fetches the bundle. May throw, in which case we retry again.\n \"\"\"",
"# may throw ValueError",
"# may throw Validation Error"
] | [
{
"param": "self",
"type": null
},
{
"param": "directories",
"type": "List[str]"
},
{
"param": "base_hash",
"type": "Optional[str]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "directories",
"type": "List[str]",
"docstring": null,
"docstr... |
fd75ecce24b333f42f926e73bf7ba4be0a0e180b | chelnak/vRAAPIClient | vraapiclient/catalog.py | [
"MIT"
] | Python | requestResource | <not_specific> | def requestResource(self, payload):
"""
Function that will submit a request based on payload.
payload = json body (example in request.json)
Parameters:
payload = JSON request body.
"""
host = self.host
token = self.token
url = 'https://{host}/catalog-service/api/consumer/req... |
Function that will submit a request based on payload.
payload = json body (example in request.json)
Parameters:
payload = JSON request body.
| Function that will submit a request based on payload.
payload = json body (example in request.json)
Parameters:
payload = JSON request body. | [
"Function",
"that",
"will",
"submit",
"a",
"request",
"based",
"on",
"payload",
".",
"payload",
"=",
"json",
"body",
"(",
"example",
"in",
"request",
".",
"json",
")",
"Parameters",
":",
"payload",
"=",
"JSON",
"request",
"body",
"."
] | def requestResource(self, payload):
host = self.host
token = self.token
url = 'https://{host}/catalog-service/api/consumer/requests'.format(host=host)
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json',
'Authorization': token
... | [
"def",
"requestResource",
"(",
"self",
",",
"payload",
")",
":",
"host",
"=",
"self",
".",
"host",
"token",
"=",
"self",
".",
"token",
"url",
"=",
"'https://{host}/catalog-service/api/consumer/requests'",
".",
"format",
"(",
"host",
"=",
"host",
")",
"headers"... | Function that will submit a request based on payload. | [
"Function",
"that",
"will",
"submit",
"a",
"request",
"based",
"on",
"payload",
"."
] | [
"\"\"\"\n\t\tFunction that will submit a request based on payload.\n\t\tpayload = json body (example in request.json)\n\t\tParameters:\n\t\t\tpayload = JSON request body.\n\t\t\"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "payload",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "payload",
"type": null,
"docstring": null,
"docstring_tokens"... |
6d50f946e40013abbcafc07ec78af4cd88c985f1 | chelnak/vRAAPIClient | vraapiclient/helpers.py | [
"MIT"
] | Python | checkResponse | null | def checkResponse(r):
"""
Quick logic to check the http response code.
Parameters:
r = http response object.
"""
acceptedResponses = [200, 201, 203, 204]
if not r.status_code in acceptedResponses:
print "STATUS: {status} ".format(status=r.status_code)
print "ERROR: " + r.text
... |
Quick logic to check the http response code.
Parameters:
r = http response object.
| Quick logic to check the http response code.
Parameters:
r = http response object. | [
"Quick",
"logic",
"to",
"check",
"the",
"http",
"response",
"code",
".",
"Parameters",
":",
"r",
"=",
"http",
"response",
"object",
"."
] | def checkResponse(r):
acceptedResponses = [200, 201, 203, 204]
if not r.status_code in acceptedResponses:
print "STATUS: {status} ".format(status=r.status_code)
print "ERROR: " + r.text
sys.exit(r.status_code) | [
"def",
"checkResponse",
"(",
"r",
")",
":",
"acceptedResponses",
"=",
"[",
"200",
",",
"201",
",",
"203",
",",
"204",
"]",
"if",
"not",
"r",
".",
"status_code",
"in",
"acceptedResponses",
":",
"print",
"\"STATUS: {status} \"",
".",
"format",
"(",
"status",... | Quick logic to check the http response code. | [
"Quick",
"logic",
"to",
"check",
"the",
"http",
"response",
"code",
"."
] | [
"\"\"\"\n\tQuick logic to check the http response code.\n\n\tParameters:\n\t\tr = http response object.\n\t\"\"\""
] | [
{
"param": "r",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "r",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6d50f946e40013abbcafc07ec78af4cd88c985f1 | chelnak/vRAAPIClient | vraapiclient/helpers.py | [
"MIT"
] | Python | authenticate | <not_specific> | def authenticate(host, user, password, tenant):
"""
Function that will authenticate a user and build.
Parameters:
host = vRA Appliance fqdn.
user = user account with access to the vRA portal.
passowrd = valid password for above user.
tenant = tenant for the user.
"""
headers = {
'Content-Ty... |
Function that will authenticate a user and build.
Parameters:
host = vRA Appliance fqdn.
user = user account with access to the vRA portal.
passowrd = valid password for above user.
tenant = tenant for the user.
| Function that will authenticate a user and build.
Parameters:
host = vRA Appliance fqdn.
user = user account with access to the vRA portal.
passowrd = valid password for above user.
tenant = tenant for the user. | [
"Function",
"that",
"will",
"authenticate",
"a",
"user",
"and",
"build",
".",
"Parameters",
":",
"host",
"=",
"vRA",
"Appliance",
"fqdn",
".",
"user",
"=",
"user",
"account",
"with",
"access",
"to",
"the",
"vRA",
"portal",
".",
"passowrd",
"=",
"valid",
... | def authenticate(host, user, password, tenant):
headers = {
'Content-Type': 'application/json',
'Accept': 'application/json'
}
payload = {"username": user, "password": password, "tenant": tenant}
url = 'https://' + host + '/identity/api/tokens'
r = requests.post(url=url,
... | [
"def",
"authenticate",
"(",
"host",
",",
"user",
",",
"password",
",",
"tenant",
")",
":",
"headers",
"=",
"{",
"'Content-Type'",
":",
"'application/json'",
",",
"'Accept'",
":",
"'application/json'",
"}",
"payload",
"=",
"{",
"\"username\"",
":",
"user",
",... | Function that will authenticate a user and build. | [
"Function",
"that",
"will",
"authenticate",
"a",
"user",
"and",
"build",
"."
] | [
"\"\"\"\n\tFunction that will authenticate a user and build.\n\n\tParameters:\n\t\thost = vRA Appliance fqdn.\n\t\tuser = user account with access to the vRA portal.\n\t\tpassowrd = valid password for above user.\n\t\ttenant = tenant for the user.\n\t\"\"\""
] | [
{
"param": "host",
"type": null
},
{
"param": "user",
"type": null
},
{
"param": "password",
"type": null
},
{
"param": "tenant",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "host",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "user",
"type": null,
"docstring": null,
"docstring_tokens": [... |
89e54cba1a9d5d2c741379fe3fb869542a296615 | BenbqZhang/ground-recognition | ground_recognition/batchtrainer.py | [
"MIT"
] | Python | save_batch | <not_specific> | def save_batch(batch):
"""
make batch directory and save batch info.
"""
batch_name = batch["batch_name"]
batch_dir = result_base_dir / batch_name
batch_dir.mkdir()
# save batch information
info_file = batch_dir / "batch_info.txt"
with open(info_file, "w") as info_f:
info_f.... |
make batch directory and save batch info.
| make batch directory and save batch info. | [
"make",
"batch",
"directory",
"and",
"save",
"batch",
"info",
"."
] | def save_batch(batch):
batch_name = batch["batch_name"]
batch_dir = result_base_dir / batch_name
batch_dir.mkdir()
info_file = batch_dir / "batch_info.txt"
with open(info_file, "w") as info_f:
info_f.write(f"batch_name: {batch_name}\n")
info_f.write(f"batch_time: {batchs['time']}\n")... | [
"def",
"save_batch",
"(",
"batch",
")",
":",
"batch_name",
"=",
"batch",
"[",
"\"batch_name\"",
"]",
"batch_dir",
"=",
"result_base_dir",
"/",
"batch_name",
"batch_dir",
".",
"mkdir",
"(",
")",
"info_file",
"=",
"batch_dir",
"/",
"\"batch_info.txt\"",
"with",
... | make batch directory and save batch info. | [
"make",
"batch",
"directory",
"and",
"save",
"batch",
"info",
"."
] | [
"\"\"\"\n make batch directory and save batch info.\n \"\"\"",
"# save batch information",
"# save batch config snapshot to file",
"# save snapshot to json format too"
] | [
{
"param": "batch",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "batch",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
89e54cba1a9d5d2c741379fe3fb869542a296615 | BenbqZhang/ground-recognition | ground_recognition/batchtrainer.py | [
"MIT"
] | Python | save_group | <not_specific> | def save_group(batch_dir, group):
"""
make group directory and save group info.
"""
group_name = group["group_name"]
group_dir = batch_dir / group_name
group_dir.mkdir()
# save group information
info_file = group_dir / "group_info.txt"
with open(info_file, "w") as info_f:
in... |
make group directory and save group info.
| make group directory and save group info. | [
"make",
"group",
"directory",
"and",
"save",
"group",
"info",
"."
] | def save_group(batch_dir, group):
group_name = group["group_name"]
group_dir = batch_dir / group_name
group_dir.mkdir()
info_file = group_dir / "group_info.txt"
with open(info_file, "w") as info_f:
info_f.write(f"group_name: {group_name}\n")
info_f.write(f"group_info: {group['group_i... | [
"def",
"save_group",
"(",
"batch_dir",
",",
"group",
")",
":",
"group_name",
"=",
"group",
"[",
"\"group_name\"",
"]",
"group_dir",
"=",
"batch_dir",
"/",
"group_name",
"group_dir",
".",
"mkdir",
"(",
")",
"info_file",
"=",
"group_dir",
"/",
"\"group_info.txt\... | make group directory and save group info. | [
"make",
"group",
"directory",
"and",
"save",
"group",
"info",
"."
] | [
"\"\"\"\n make group directory and save group info.\n \"\"\"",
"# save group information"
] | [
{
"param": "batch_dir",
"type": null
},
{
"param": "group",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "batch_dir",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "group",
"type": null,
"docstring": null,
"docstring_toke... |
6adfaeb159e4b5e0b85cf2217f1aec9d807a6bed | byfaith/pb_chime5 | toolbox/nt/database/iterator.py | [
"MIT"
] | Python | filter | <not_specific> | def filter(self, filter_fn, lazy=True):
"""
The filter_fn consumes an example. If the filter_fn returns True, we
keep the example. If it is False, we drop the example.
Filtering examples. If using lazy=False this method should be called
before applying expensive map functions.
... |
The filter_fn consumes an example. If the filter_fn returns True, we
keep the example. If it is False, we drop the example.
Filtering examples. If using lazy=False this method should be called
before applying expensive map functions.
Syntax is inspired by:
https://docs... | The filter_fn consumes an example. If the filter_fn returns True, we
keep the example. If it is False, we drop the example.
Filtering examples. If using lazy=False this method should be called
before applying expensive map functions.
| [
"The",
"filter_fn",
"consumes",
"an",
"example",
".",
"If",
"the",
"filter_fn",
"returns",
"True",
"we",
"keep",
"the",
"example",
".",
"If",
"it",
"is",
"False",
"we",
"drop",
"the",
"example",
".",
"Filtering",
"examples",
".",
"If",
"using",
"lazy",
"... | def filter(self, filter_fn, lazy=True):
if lazy:
return FilterIterator(filter_fn, self)
else:
try:
_ = self.keys()
except Exception:
raise RuntimeError(
'You can only use lazy=False if the incoming iterator is '
... | [
"def",
"filter",
"(",
"self",
",",
"filter_fn",
",",
"lazy",
"=",
"True",
")",
":",
"if",
"lazy",
":",
"return",
"FilterIterator",
"(",
"filter_fn",
",",
"self",
")",
"else",
":",
"try",
":",
"_",
"=",
"self",
".",
"keys",
"(",
")",
"except",
"Exce... | The filter_fn consumes an example. | [
"The",
"filter_fn",
"consumes",
"an",
"example",
"."
] | [
"\"\"\"\n The filter_fn consumes an example. If the filter_fn returns True, we\n keep the example. If it is False, we drop the example.\n\n Filtering examples. If using lazy=False this method should be called\n before applying expensive map functions.\n\n Syntax is inspired by:\n ... | [
{
"param": "self",
"type": null
},
{
"param": "filter_fn",
"type": null
},
{
"param": "lazy",
"type": null
}
] | {
"returns": [
{
"docstring": "FilterIterator iterating over filtered examples.",
"docstring_tokens": [
"FilterIterator",
"iterating",
"over",
"filtered",
"examples",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"i... |
6adfaeb159e4b5e0b85cf2217f1aec9d807a6bed | byfaith/pb_chime5 | toolbox/nt/database/iterator.py | [
"MIT"
] | Python | concatenate | <not_specific> | def concatenate(self, *others):
"""
Concatenate this iterator with others. keys need to be unambiguous.
:param others: list of other iterators to be concatenated
:return: ExamplesIterator iterating over all examples.
"""
if len(others) == 0:
return self
... |
Concatenate this iterator with others. keys need to be unambiguous.
:param others: list of other iterators to be concatenated
:return: ExamplesIterator iterating over all examples.
| Concatenate this iterator with others. keys need to be unambiguous. | [
"Concatenate",
"this",
"iterator",
"with",
"others",
".",
"keys",
"need",
"to",
"be",
"unambiguous",
"."
] | def concatenate(self, *others):
if len(others) == 0:
return self
return ConcatenateIterator(self, *others) | [
"def",
"concatenate",
"(",
"self",
",",
"*",
"others",
")",
":",
"if",
"len",
"(",
"others",
")",
"==",
"0",
":",
"return",
"self",
"return",
"ConcatenateIterator",
"(",
"self",
",",
"*",
"others",
")"
] | Concatenate this iterator with others. | [
"Concatenate",
"this",
"iterator",
"with",
"others",
"."
] | [
"\"\"\"\n Concatenate this iterator with others. keys need to be unambiguous.\n :param others: list of other iterators to be concatenated\n :return: ExamplesIterator iterating over all examples.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "ExamplesIterator iterating over all examples.",
"docstring_tokens": [
"ExamplesIterator",
"iterating",
"over",
"all",
"examples",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identif... |
6adfaeb159e4b5e0b85cf2217f1aec9d807a6bed | byfaith/pb_chime5 | toolbox/nt/database/iterator.py | [
"MIT"
] | Python | zip | <not_specific> | def zip(self, *others):
"""
Creates a `Dataset` by zipping together the given datasets.
This method has two major differences to the built-in `zip()` function
in Python. First the zipping happen based on the keys of the
first dataset (i.e. The first defines the order).
... |
Creates a `Dataset` by zipping together the given datasets.
This method has two major differences to the built-in `zip()` function
in Python. First the zipping happen based on the keys of the
first dataset (i.e. The first defines the order).
Second it is assumes that all datas... | Creates a `Dataset` by zipping together the given datasets.
This method has two major differences to the built-in `zip()` function
in Python. First the zipping happen based on the keys of the
first dataset .
Second it is assumes that all datasets have the same length and keys.
(Could be removed, when someone needs it.... | [
"Creates",
"a",
"`",
"Dataset",
"`",
"by",
"zipping",
"together",
"the",
"given",
"datasets",
".",
"This",
"method",
"has",
"two",
"major",
"differences",
"to",
"the",
"built",
"-",
"in",
"`",
"zip",
"()",
"`",
"function",
"in",
"Python",
".",
"First",
... | def zip(self, *others):
return ZipIterator(self, *others) | [
"def",
"zip",
"(",
"self",
",",
"*",
"others",
")",
":",
"return",
"ZipIterator",
"(",
"self",
",",
"*",
"others",
")"
] | Creates a `Dataset` by zipping together the given datasets. | [
"Creates",
"a",
"`",
"Dataset",
"`",
"by",
"zipping",
"together",
"the",
"given",
"datasets",
"."
] | [
"\"\"\"\n Creates a `Dataset` by zipping together the given datasets.\n\n This method has two major differences to the built-in `zip()` function\n in Python. First the zipping happen based on the keys of the\n first dataset (i.e. The first defines the order).\n\n Second it is assu... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6adfaeb159e4b5e0b85cf2217f1aec9d807a6bed | byfaith/pb_chime5 | toolbox/nt/database/iterator.py | [
"MIT"
] | Python | apply | <not_specific> | def apply(self, apply_fn: callable):
"""Allows to apply functions to the complete iterator, not to the
examples itself.
Args:
apply_fn: For now, it is a single function, e.g.
`lambda it: it.shard(num_shards, shard_index)` but can
potentially be a list... | Allows to apply functions to the complete iterator, not to the
examples itself.
Args:
apply_fn: For now, it is a single function, e.g.
`lambda it: it.shard(num_shards, shard_index)` but can
potentially be a list in future implementations.
Returns:
... | Allows to apply functions to the complete iterator, not to the
examples itself. | [
"Allows",
"to",
"apply",
"functions",
"to",
"the",
"complete",
"iterator",
"not",
"to",
"the",
"examples",
"itself",
"."
] | def apply(self, apply_fn: callable):
if apply_fn is None:
return self
elif isinstance(apply_fn, list):
raise NotImplementedError
else:
return apply_fn(self) | [
"def",
"apply",
"(",
"self",
",",
"apply_fn",
":",
"callable",
")",
":",
"if",
"apply_fn",
"is",
"None",
":",
"return",
"self",
"elif",
"isinstance",
"(",
"apply_fn",
",",
"list",
")",
":",
"raise",
"NotImplementedError",
"else",
":",
"return",
"apply_fn",... | Allows to apply functions to the complete iterator, not to the
examples itself. | [
"Allows",
"to",
"apply",
"functions",
"to",
"the",
"complete",
"iterator",
"not",
"to",
"the",
"examples",
"itself",
"."
] | [
"\"\"\"Allows to apply functions to the complete iterator, not to the\n examples itself.\n\n Args:\n apply_fn: For now, it is a single function, e.g.\n `lambda it: it.shard(num_shards, shard_index)` but can\n potentially be a list in future implementations.\n\n... | [
{
"param": "self",
"type": null
},
{
"param": "apply_fn",
"type": "callable"
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
... |
6adfaeb159e4b5e0b85cf2217f1aec9d807a6bed | byfaith/pb_chime5 | toolbox/nt/database/iterator.py | [
"MIT"
] | Python | recursive_transform | <not_specific> | def recursive_transform(func, dict_list_val, list2array=False):
"""
Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. This function can e.g. be used to recursively apply a
transformatio... |
Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. This function can e.g. be used to recursively apply a
transformation (e.g. audioread) to all audio paths in an example dict
(see top o... | Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. | [
"Applies",
"a",
"function",
"func",
"to",
"all",
"leaf",
"values",
"in",
"a",
"dict",
"or",
"list",
"or",
"directly",
"to",
"a",
"value",
".",
"The",
"hierarchy",
"of",
"dict_list_val",
"is",
"inherited",
".",
"Lists",
"are",
"stacked",
"to",
"numpy",
"a... | def recursive_transform(func, dict_list_val, list2array=False):
if isinstance(dict_list_val, dict):
return {key: recursive_transform(func, val, list2array)
for key, val in dict_list_val.items()}
if isinstance(dict_list_val, (list, tuple)):
l = type(dict_list_val)(
[re... | [
"def",
"recursive_transform",
"(",
"func",
",",
"dict_list_val",
",",
"list2array",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"dict_list_val",
",",
"dict",
")",
":",
"return",
"{",
"key",
":",
"recursive_transform",
"(",
"func",
",",
"val",
",",
"li... | Applies a function func to all leaf values in a dict or list or directly to
a value. | [
"Applies",
"a",
"function",
"func",
"to",
"all",
"leaf",
"values",
"in",
"a",
"dict",
"or",
"list",
"or",
"directly",
"to",
"a",
"value",
"."
] | [
"\"\"\"\n Applies a function func to all leaf values in a dict or list or directly to\n a value. The hierarchy of dict_list_val is inherited. Lists are stacked\n to numpy arrays. This function can e.g. be used to recursively apply a\n transformation (e.g. audioread) to all audio paths in an example dict... | [
{
"param": "func",
"type": null
},
{
"param": "dict_list_val",
"type": null
},
{
"param": "list2array",
"type": null
}
] | {
"returns": [
{
"docstring": "dict, list or value with transformed elements",
"docstring_tokens": [
"dict",
"list",
"or",
"value",
"with",
"transformed",
"elements"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
45af14cd10e3eaba4e58d4bb764a21f8df33f608 | byfaith/pb_chime5 | toolbox/nt/io/audiowrite.py | [
"MIT"
] | Python | dump_audio | <not_specific> | def dump_audio(
obj,
path,
*,
sample_rate=16000,
dtype=np.int16,
start=None,
normalize=True,
):
"""
If normalize is False and the dytpe is float, the values of obj should be in
the range [-1, 1).
Params:
obj: Shape (channels, samples) or (... |
If normalize is False and the dytpe is float, the values of obj should be in
the range [-1, 1).
Params:
obj: Shape (channels, samples) or (samples,)
path:
sample_rate:
dtype:
start:
normalize:
>>> from nt.utils.process_caller import run_process
>>> ... | If normalize is False and the dytpe is float, the values of obj should be in
the range [-1, 1). | [
"If",
"normalize",
"is",
"False",
"and",
"the",
"dytpe",
"is",
"float",
"the",
"values",
"of",
"obj",
"should",
"be",
"in",
"the",
"range",
"[",
"-",
"1",
"1",
")",
"."
] | def dump_audio(
obj,
path,
*,
sample_rate=16000,
dtype=np.int16,
start=None,
normalize=True,
):
assert isinstance(path, (str, Path)), path
if isinstance(path, Path):
path = str(path)
if normalize:
if not obj.dtype.kind in ['f', 'i']:
... | [
"def",
"dump_audio",
"(",
"obj",
",",
"path",
",",
"*",
",",
"sample_rate",
"=",
"16000",
",",
"dtype",
"=",
"np",
".",
"int16",
",",
"start",
"=",
"None",
",",
"normalize",
"=",
"True",
",",
")",
":",
"assert",
"isinstance",
"(",
"path",
",",
"(",... | If normalize is False and the dytpe is float, the values of obj should be in
the range [-1, 1). | [
"If",
"normalize",
"is",
"False",
"and",
"the",
"dytpe",
"is",
"float",
"the",
"values",
"of",
"obj",
"should",
"be",
"in",
"the",
"range",
"[",
"-",
"1",
"1",
")",
"."
] | [
"\"\"\"\n If normalize is False and the dytpe is float, the values of obj should be in\n the range [-1, 1).\n\n Params:\n obj: Shape (channels, samples) or (samples,)\n path:\n sample_rate:\n dtype:\n start:\n normalize:\n\n >>> from nt.utils.process_caller impo... | [
{
"param": "obj",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "sample_rate",
"type": null
},
{
"param": "dtype",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "normalize",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "obj",
"type": null,
"docstring": "Shape (channels, samples) or (samples,)",
"docstring_tokens": [
"Shape",
"(",
"channels",
"samples",
")",
"or",
"(",
"samples",
... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | stft | np.array | def stft(
time_signal,
size: int=1024,
shift: int=256,
*,
axis=-1,
window: typing.Callable=signal.blackman,
window_length: int=None,
fading: bool=True,
pad: bool=True,
symmetric_window: bool=False,
) -> np.array:
"""
ToDo: Open poin... |
ToDo: Open points:
- sym_window need literature
- fading why it is better?
- should pad have more degrees of freedom?
Calculates the short time Fourier transformation of a multi channel multi
speaker time signal. It is able to add additional zeros for fade-in and
fade out and should yie... | Open points:
sym_window need literature
fading why it is better.
Calculates the short time Fourier transformation of a multi channel multi
speaker time signal. It is able to add additional zeros for fade-in and
fade out and should yield an STFT signal which allows perfect
reconstruction. | [
"Open",
"points",
":",
"sym_window",
"need",
"literature",
"fading",
"why",
"it",
"is",
"better",
".",
"Calculates",
"the",
"short",
"time",
"Fourier",
"transformation",
"of",
"a",
"multi",
"channel",
"multi",
"speaker",
"time",
"signal",
".",
"It",
"is",
"a... | def stft(
time_signal,
size: int=1024,
shift: int=256,
*,
axis=-1,
window: typing.Callable=signal.blackman,
window_length: int=None,
fading: bool=True,
pad: bool=True,
symmetric_window: bool=False,
) -> np.array:
time_signal = np.array(... | [
"def",
"stft",
"(",
"time_signal",
",",
"size",
":",
"int",
"=",
"1024",
",",
"shift",
":",
"int",
"=",
"256",
",",
"*",
",",
"axis",
"=",
"-",
"1",
",",
"window",
":",
"typing",
".",
"Callable",
"=",
"signal",
".",
"blackman",
",",
"window_length"... | ToDo: Open points:
sym_window need literature
fading why it is better? | [
"ToDo",
":",
"Open",
"points",
":",
"sym_window",
"need",
"literature",
"fading",
"why",
"it",
"is",
"better?"
] | [
"\"\"\"\n ToDo: Open points:\n - sym_window need literature\n - fading why it is better?\n - should pad have more degrees of freedom?\n\n Calculates the short time Fourier transformation of a multi channel multi\n speaker time signal. It is able to add additional zeros for fade-in and\n fade... | [
{
"param": "time_signal",
"type": null
},
{
"param": "size",
"type": "int"
},
{
"param": "shift",
"type": "int"
},
{
"param": "axis",
"type": null
},
{
"param": "window",
"type": "typing.Callable"
},
{
"param": "window_length",
"type": "int"
},
... | {
"returns": [
{
"docstring": "Single channel complex STFT signal with dimensions\nAA x ... x AZ x T' times size/2+1 times BA x ... x BZ.",
"docstring_tokens": [
"Single",
"channel",
"complex",
"STFT",
"signal",
"with",
"dimensions",
"AA"... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | stft_with_kaldi_dimensions | <not_specific> | def stft_with_kaldi_dimensions(
time_signal,
size: int = 512,
shift: int = 160,
*,
axis=-1,
window=signal.blackman,
window_length=400,
symmetric_window: bool = False
):
"""
The Kaldi implementation uses another non standard window.
See:
- ... |
The Kaldi implementation uses another non standard window.
See:
- https://github.com/kaldi-asr/kaldi/blob/master/src/feat/feature-window.h#L48
- https://github.com/kaldi-asr/kaldi/blob/81b7a1947fb8df501a2bbb680b65ce18ce606cff/src/feat/feature-window.h#L48
..note::
Kaldi uses symmetric_win... | The Kaldi implementation uses another non standard window.
| [
"The",
"Kaldi",
"implementation",
"uses",
"another",
"non",
"standard",
"window",
"."
] | def stft_with_kaldi_dimensions(
time_signal,
size: int = 512,
shift: int = 160,
*,
axis=-1,
window=signal.blackman,
window_length=400,
symmetric_window: bool = False
):
return stft(
time_signal,
size=size,
shift=shift,
a... | [
"def",
"stft_with_kaldi_dimensions",
"(",
"time_signal",
",",
"size",
":",
"int",
"=",
"512",
",",
"shift",
":",
"int",
"=",
"160",
",",
"*",
",",
"axis",
"=",
"-",
"1",
",",
"window",
"=",
"signal",
".",
"blackman",
",",
"window_length",
"=",
"400",
... | The Kaldi implementation uses another non standard window. | [
"The",
"Kaldi",
"implementation",
"uses",
"another",
"non",
"standard",
"window",
"."
] | [
"\"\"\"\n The Kaldi implementation uses another non standard window.\n See:\n - https://github.com/kaldi-asr/kaldi/blob/master/src/feat/feature-window.h#L48\n - https://github.com/kaldi-asr/kaldi/blob/81b7a1947fb8df501a2bbb680b65ce18ce606cff/src/feat/feature-window.h#L48\n\n ..note::\n Kaldi ... | [
{
"param": "time_signal",
"type": null
},
{
"param": "size",
"type": "int"
},
{
"param": "shift",
"type": "int"
},
{
"param": "axis",
"type": null
},
{
"param": "window",
"type": null
},
{
"param": "window_length",
"type": null
},
{
"param"... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "time_signal",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "size",
"type": "int",
"docstring": null,
"docstring_to... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | _samples_to_stft_frames | <not_specific> | def _samples_to_stft_frames(
samples,
size,
shift,
*,
fading=False,
):
"""
Calculates STFT frames from samples in time domain.
:param samples: Number of samples in time domain.
:param size: window_length often equal to FFT size.
The name size shou... |
Calculates STFT frames from samples in time domain.
:param samples: Number of samples in time domain.
:param size: window_length often equal to FFT size.
The name size should be marked as deprecated and replaced with
window_length.
:param shift: Hop in samples.
:pa... | Calculates STFT frames from samples in time domain. | [
"Calculates",
"STFT",
"frames",
"from",
"samples",
"in",
"time",
"domain",
"."
] | def _samples_to_stft_frames(
samples,
size,
shift,
*,
fading=False,
):
if fading:
samples = samples + 2 * (size - shift)
return ceil((samples - size + shift) / shift) | [
"def",
"_samples_to_stft_frames",
"(",
"samples",
",",
"size",
",",
"shift",
",",
"*",
",",
"fading",
"=",
"False",
",",
")",
":",
"if",
"fading",
":",
"samples",
"=",
"samples",
"+",
"2",
"*",
"(",
"size",
"-",
"shift",
")",
"return",
"ceil",
"(",
... | Calculates STFT frames from samples in time domain. | [
"Calculates",
"STFT",
"frames",
"from",
"samples",
"in",
"time",
"domain",
"."
] | [
"\"\"\"\n Calculates STFT frames from samples in time domain.\n :param samples: Number of samples in time domain.\n :param size: window_length often equal to FFT size.\n The name size should be marked as deprecated and replaced with\n window_length.\n :param shift: Hop in... | [
{
"param": "samples",
"type": null
},
{
"param": "size",
"type": null
},
{
"param": "shift",
"type": null
},
{
"param": "fading",
"type": null
}
] | {
"returns": [
{
"docstring": "Number of STFT frames.\n\n\n\n\n\n\n\n",
"docstring_tokens": [
"Number",
"of",
"STFT",
"frames",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "samples",
"type": null,
... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | _stft_frames_to_samples | <not_specific> | def _stft_frames_to_samples(frames, size, shift, fading=False):
"""
Calculates samples in time domain from STFT frames
:param frames: Number of STFT frames.
:param size: FFT size.
:param shift: Hop in samples.
:return: Number of samples in time domain.
>>> _stft_frames_to_samples(2, 16, 4)
... |
Calculates samples in time domain from STFT frames
:param frames: Number of STFT frames.
:param size: FFT size.
:param shift: Hop in samples.
:return: Number of samples in time domain.
>>> _stft_frames_to_samples(2, 16, 4)
20
| Calculates samples in time domain from STFT frames | [
"Calculates",
"samples",
"in",
"time",
"domain",
"from",
"STFT",
"frames"
] | def _stft_frames_to_samples(frames, size, shift, fading=False):
if fading:
assert 'Not implemented'
return frames * shift + size - shift | [
"def",
"_stft_frames_to_samples",
"(",
"frames",
",",
"size",
",",
"shift",
",",
"fading",
"=",
"False",
")",
":",
"if",
"fading",
":",
"assert",
"'Not implemented'",
"return",
"frames",
"*",
"shift",
"+",
"size",
"-",
"shift"
] | Calculates samples in time domain from STFT frames | [
"Calculates",
"samples",
"in",
"time",
"domain",
"from",
"STFT",
"frames"
] | [
"\"\"\"\n Calculates samples in time domain from STFT frames\n :param frames: Number of STFT frames.\n :param size: FFT size.\n :param shift: Hop in samples.\n :return: Number of samples in time domain.\n\n >>> _stft_frames_to_samples(2, 16, 4)\n 20\n \"\"\""
] | [
{
"param": "frames",
"type": null
},
{
"param": "size",
"type": null
},
{
"param": "shift",
"type": null
},
{
"param": "fading",
"type": null
}
] | {
"returns": [
{
"docstring": "Number of samples in time domain.",
"docstring_tokens": [
"Number",
"of",
"samples",
"in",
"time",
"domain",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "frames... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | sample_id_to_stft_frame_id | <not_specific> | def sample_id_to_stft_frame_id(sample, window_length, shift, fading=True):
"""
Calculates the best frame index for a given sample index
:param sample: Sample index in time domain.
:param size: FFT size.
:param shift: Hop in samples.
:return: Best STFT frame index.
## ## ## ##
## ## ... |
Calculates the best frame index for a given sample index
:param sample: Sample index in time domain.
:param size: FFT size.
:param shift: Hop in samples.
:return: Best STFT frame index.
## ## ## ##
## ## ## ##
## ## ## ##
## ## ## ##
00 00 01 12 23 34 45
... | Calculates the best frame index for a given sample index | [
"Calculates",
"the",
"best",
"frame",
"index",
"for",
"a",
"given",
"sample",
"index"
] | def sample_id_to_stft_frame_id(sample, window_length, shift, fading=True):
if (window_length + 1) // 2 > sample:
frame = 0
else:
frame = (sample - (window_length + 1) // 2) // shift + 1
if fading:
frame = frame + ceil((window_length - shift) / shift)
return frame | [
"def",
"sample_id_to_stft_frame_id",
"(",
"sample",
",",
"window_length",
",",
"shift",
",",
"fading",
"=",
"True",
")",
":",
"if",
"(",
"window_length",
"+",
"1",
")",
"//",
"2",
">",
"sample",
":",
"frame",
"=",
"0",
"else",
":",
"frame",
"=",
"(",
... | Calculates the best frame index for a given sample index | [
"Calculates",
"the",
"best",
"frame",
"index",
"for",
"a",
"given",
"sample",
"index"
] | [
"\"\"\"\n Calculates the best frame index for a given sample index\n :param sample: Sample index in time domain.\n :param size: FFT size.\n :param shift: Hop in samples.\n :return: Best STFT frame index.\n\n\n ## ## ## ##\n ## ## ## ##\n ## ## ## ##\n ## ## ## ##\n 00... | [
{
"param": "sample",
"type": null
},
{
"param": "window_length",
"type": null
},
{
"param": "shift",
"type": null
},
{
"param": "fading",
"type": null
}
] | {
"returns": [
{
"docstring": "Best STFT frame index.\n\n\n\n\n\n\n\n\n\n",
"docstring_tokens": [
"Best",
"STFT",
"frame",
"index",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "sample",
"type": null,
... |
1bf8f41c1e9b7cf2e6801da679657578b5d57c76 | byfaith/pb_chime5 | toolbox/nt/transform/module_stft.py | [
"MIT"
] | Python | istft | <not_specific> | def istft(
stft_signal,
size: int=1024,
shift: int=256,
*,
window: typing.Callable=signal.blackman,
fading: bool=True,
window_length: int=None,
symmetric_window: bool=False,
):
"""
Calculated the inverse short time Fourier transform to exactly reco... |
Calculated the inverse short time Fourier transform to exactly reconstruct
the time signal.
..note::
Be careful if you make modifications in the frequency domain (e.g.
beamforming) because the synthesis window is calculated according to
the unmodified! analysis window.
:param ... | Calculated the inverse short time Fourier transform to exactly reconstruct
the time signal.
:
Be careful if you make modifications in the frequency domain because the synthesis window is calculated according to
the unmodified. analysis window. | [
"Calculated",
"the",
"inverse",
"short",
"time",
"Fourier",
"transform",
"to",
"exactly",
"reconstruct",
"the",
"time",
"signal",
".",
":",
"Be",
"careful",
"if",
"you",
"make",
"modifications",
"in",
"the",
"frequency",
"domain",
"because",
"the",
"synthesis",
... | def istft(
stft_signal,
size: int=1024,
shift: int=256,
*,
window: typing.Callable=signal.blackman,
fading: bool=True,
window_length: int=None,
symmetric_window: bool=False,
):
stft_signal = np.array(stft_signal)
assert stft_signal.shape[-1] == siz... | [
"def",
"istft",
"(",
"stft_signal",
",",
"size",
":",
"int",
"=",
"1024",
",",
"shift",
":",
"int",
"=",
"256",
",",
"*",
",",
"window",
":",
"typing",
".",
"Callable",
"=",
"signal",
".",
"blackman",
",",
"fading",
":",
"bool",
"=",
"True",
",",
... | Calculated the inverse short time Fourier transform to exactly reconstruct
the time signal. | [
"Calculated",
"the",
"inverse",
"short",
"time",
"Fourier",
"transform",
"to",
"exactly",
"reconstruct",
"the",
"time",
"signal",
"."
] | [
"\"\"\"\n Calculated the inverse short time Fourier transform to exactly reconstruct\n the time signal.\n\n ..note::\n Be careful if you make modifications in the frequency domain (e.g.\n beamforming) because the synthesis window is calculated according to\n the unmodified! analysis wi... | [
{
"param": "stft_signal",
"type": null
},
{
"param": "size",
"type": "int"
},
{
"param": "shift",
"type": "int"
},
{
"param": "window",
"type": "typing.Callable"
},
{
"param": "fading",
"type": "bool"
},
{
"param": "window_length",
"type": "int"
... | {
"returns": [
{
"docstring": "Single channel complex STFT signal",
"docstring_tokens": [
"Single",
"channel",
"complex",
"STFT",
"signal"
],
"type": null
},
{
"docstring": "Single channel time signal.",
"docstring_tokens": [
... |
402450efd066ada3a13d893ccea9d53bd3623299 | byfaith/pb_chime5 | toolbox/nt/database/chime5/__init__.py | [
"MIT"
] | Python | word2id | <not_specific> | def word2id(self, word):
"""Returns the integer ID for a given word.
If the word is not found, it returns the ID for `<UNK>`.
"""
try:
return self._word2id_dict[word]
except KeyError:
return self._word2id_dict['<eps>'] | Returns the integer ID for a given word.
If the word is not found, it returns the ID for `<UNK>`.
| Returns the integer ID for a given word.
If the word is not found, it returns the ID for ``. | [
"Returns",
"the",
"integer",
"ID",
"for",
"a",
"given",
"word",
".",
"If",
"the",
"word",
"is",
"not",
"found",
"it",
"returns",
"the",
"ID",
"for",
"`",
"`",
"."
] | def word2id(self, word):
try:
return self._word2id_dict[word]
except KeyError:
return self._word2id_dict['<eps>'] | [
"def",
"word2id",
"(",
"self",
",",
"word",
")",
":",
"try",
":",
"return",
"self",
".",
"_word2id_dict",
"[",
"word",
"]",
"except",
"KeyError",
":",
"return",
"self",
".",
"_word2id_dict",
"[",
"'<eps>'",
"]"
] | Returns the integer ID for a given word. | [
"Returns",
"the",
"integer",
"ID",
"for",
"a",
"given",
"word",
"."
] | [
"\"\"\"Returns the integer ID for a given word.\n\n If the word is not found, it returns the ID for `<UNK>`.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "word",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "word",
"type": null,
"docstring": null,
"docstring_tokens": [... |
402450efd066ada3a13d893ccea9d53bd3623299 | byfaith/pb_chime5 | toolbox/nt/database/chime5/__init__.py | [
"MIT"
] | Python | recursive_transform | <not_specific> | def recursive_transform(func, dict_list_val, start, end, list2array=False):
"""
Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. This function can e.g. be used to recursively apply a
t... |
Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. This function can e.g. be used to recursively apply a
transformation (e.g. audioread) to all audio paths in an example dict
(see top o... | Applies a function func to all leaf values in a dict or list or directly to
a value. The hierarchy of dict_list_val is inherited. Lists are stacked
to numpy arrays. | [
"Applies",
"a",
"function",
"func",
"to",
"all",
"leaf",
"values",
"in",
"a",
"dict",
"or",
"list",
"or",
"directly",
"to",
"a",
"value",
".",
"The",
"hierarchy",
"of",
"dict_list_val",
"is",
"inherited",
".",
"Lists",
"are",
"stacked",
"to",
"numpy",
"a... | def recursive_transform(func, dict_list_val, start, end, list2array=False):
if isinstance(dict_list_val, dict):
return {
key: recursive_transform(
func,
val,
start=start[key],
end=end[key],
list2array=list2array,
... | [
"def",
"recursive_transform",
"(",
"func",
",",
"dict_list_val",
",",
"start",
",",
"end",
",",
"list2array",
"=",
"False",
")",
":",
"if",
"isinstance",
"(",
"dict_list_val",
",",
"dict",
")",
":",
"return",
"{",
"key",
":",
"recursive_transform",
"(",
"f... | Applies a function func to all leaf values in a dict or list or directly to
a value. | [
"Applies",
"a",
"function",
"func",
"to",
"all",
"leaf",
"values",
"in",
"a",
"dict",
"or",
"list",
"or",
"directly",
"to",
"a",
"value",
"."
] | [
"\"\"\"\n Applies a function func to all leaf values in a dict or list or directly to\n a value. The hierarchy of dict_list_val is inherited. Lists are stacked\n to numpy arrays. This function can e.g. be used to recursively apply a\n transformation (e.g. audioread) to all audio paths in an example dict... | [
{
"param": "func",
"type": null
},
{
"param": "dict_list_val",
"type": null
},
{
"param": "start",
"type": null
},
{
"param": "end",
"type": null
},
{
"param": "list2array",
"type": null
}
] | {
"returns": [
{
"docstring": "dict, list or value with transformed elements",
"docstring_tokens": [
"dict",
"list",
"or",
"value",
"with",
"transformed",
"elements"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
34a7c7c8bbfbbadedd342a4ae9a01b7241119d45 | byfaith/pb_chime5 | toolbox/nt/database/__init__.py | [
"MIT"
] | Python | to_list | <not_specific> | def to_list(x, item_type=None):
"""
Note:
It is recommended to use item_type, when the type of the list is known
to catch as much cases as possible.
The problem is that many python functions return a type that does not
inherit from tuple and/or list.
e.g. dict keys, dict ... |
Note:
It is recommended to use item_type, when the type of the list is known
to catch as much cases as possible.
The problem is that many python functions return a type that does not
inherit from tuple and/or list.
e.g. dict keys, dict values, map, sorted, ...
The i... | It is recommended to use item_type, when the type of the list is known
to catch as much cases as possible.
The problem is that many python functions return a type that does not
inherit from tuple and/or list.
The instance check with collections.Sequence could produce problem with
str. (isinstance('any str', collection... | [
"It",
"is",
"recommended",
"to",
"use",
"item_type",
"when",
"the",
"type",
"of",
"the",
"list",
"is",
"known",
"to",
"catch",
"as",
"much",
"cases",
"as",
"possible",
".",
"The",
"problem",
"is",
"that",
"many",
"python",
"functions",
"return",
"a",
"ty... | def to_list(x, item_type=None):
if item_type is None:
if isinstance(x, (list, tuple)):
return x
return [x]
else:
if isinstance(x, item_type):
return [x]
return list(x) | [
"def",
"to_list",
"(",
"x",
",",
"item_type",
"=",
"None",
")",
":",
"if",
"item_type",
"is",
"None",
":",
"if",
"isinstance",
"(",
"x",
",",
"(",
"list",
",",
"tuple",
")",
")",
":",
"return",
"x",
"return",
"[",
"x",
"]",
"else",
":",
"if",
"... | Note:
It is recommended to use item_type, when the type of the list is known
to catch as much cases as possible. | [
"Note",
":",
"It",
"is",
"recommended",
"to",
"use",
"item_type",
"when",
"the",
"type",
"of",
"the",
"list",
"is",
"known",
"to",
"catch",
"as",
"much",
"cases",
"as",
"possible",
"."
] | [
"\"\"\"\n Note:\n It is recommended to use item_type, when the type of the list is known\n to catch as much cases as possible.\n The problem is that many python functions return a type that does not\n inherit from tuple and/or list.\n e.g. dict keys, dict values, map, sorted, .... | [
{
"param": "x",
"type": null
},
{
"param": "item_type",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "item_type",
"type": null,
"docstring": null,
"docstring_tokens":... |
34a7c7c8bbfbbadedd342a4ae9a01b7241119d45 | byfaith/pb_chime5 | toolbox/nt/database/__init__.py | [
"MIT"
] | Python | ali_path_train | <not_specific> | def ali_path_train(self):
"""Path containing the kaldi alignments for train data."""
if self.lfr:
return self.ali_path_train_lfr
else:
return self.ali_path_train_ffr | Path containing the kaldi alignments for train data. | Path containing the kaldi alignments for train data. | [
"Path",
"containing",
"the",
"kaldi",
"alignments",
"for",
"train",
"data",
"."
] | def ali_path_train(self):
if self.lfr:
return self.ali_path_train_lfr
else:
return self.ali_path_train_ffr | [
"def",
"ali_path_train",
"(",
"self",
")",
":",
"if",
"self",
".",
"lfr",
":",
"return",
"self",
".",
"ali_path_train_lfr",
"else",
":",
"return",
"self",
".",
"ali_path_train_ffr"
] | Path containing the kaldi alignments for train data. | [
"Path",
"containing",
"the",
"kaldi",
"alignments",
"for",
"train",
"data",
"."
] | [
"\"\"\"Path containing the kaldi alignments for train data.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
34a7c7c8bbfbbadedd342a4ae9a01b7241119d45 | byfaith/pb_chime5 | toolbox/nt/database/__init__.py | [
"MIT"
] | Python | hclg_path | <not_specific> | def hclg_path(self):
"""Path to HCLG directory created by Kaldi."""
if self.lfr:
return self.hclg_path_lfr
else:
return self.hclg_path_ffr | Path to HCLG directory created by Kaldi. | Path to HCLG directory created by Kaldi. | [
"Path",
"to",
"HCLG",
"directory",
"created",
"by",
"Kaldi",
"."
] | def hclg_path(self):
if self.lfr:
return self.hclg_path_lfr
else:
return self.hclg_path_ffr | [
"def",
"hclg_path",
"(",
"self",
")",
":",
"if",
"self",
".",
"lfr",
":",
"return",
"self",
".",
"hclg_path_lfr",
"else",
":",
"return",
"self",
".",
"hclg_path_ffr"
] | Path to HCLG directory created by Kaldi. | [
"Path",
"to",
"HCLG",
"directory",
"created",
"by",
"Kaldi",
"."
] | [
"\"\"\"Path to HCLG directory created by Kaldi.\"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
34a7c7c8bbfbbadedd342a4ae9a01b7241119d45 | byfaith/pb_chime5 | toolbox/nt/database/__init__.py | [
"MIT"
] | Python | word2id | <not_specific> | def word2id(self, word):
"""Returns the integer ID for a given word.
If the word is not found, it returns the ID for `<UNK>`.
"""
try:
return self._word2id_dict[word]
except KeyError:
return self._word2id_dict['<UNK>'] | Returns the integer ID for a given word.
If the word is not found, it returns the ID for `<UNK>`.
| Returns the integer ID for a given word.
If the word is not found, it returns the ID for ``. | [
"Returns",
"the",
"integer",
"ID",
"for",
"a",
"given",
"word",
".",
"If",
"the",
"word",
"is",
"not",
"found",
"it",
"returns",
"the",
"ID",
"for",
"`",
"`",
"."
] | def word2id(self, word):
try:
return self._word2id_dict[word]
except KeyError:
return self._word2id_dict['<UNK>'] | [
"def",
"word2id",
"(",
"self",
",",
"word",
")",
":",
"try",
":",
"return",
"self",
".",
"_word2id_dict",
"[",
"word",
"]",
"except",
"KeyError",
":",
"return",
"self",
".",
"_word2id_dict",
"[",
"'<UNK>'",
"]"
] | Returns the integer ID for a given word. | [
"Returns",
"the",
"integer",
"ID",
"for",
"a",
"given",
"word",
"."
] | [
"\"\"\"Returns the integer ID for a given word.\n\n If the word is not found, it returns the ID for `<UNK>`.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "word",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "word",
"type": null,
"docstring": null,
"docstring_tokens": [... |
bff2146aaea27d8f670b2a02577fadda7ba9c2de | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_examples/scripts/gripper_joystick.py | [
"Apache-2.0"
] | Python | map_joystick | <not_specific> | def map_joystick(joystick, limb):
"""
maps joystick input to gripper commands
@param joystick: an instance of a Joystick
"""
print("Getting robot state... ")
rs = intera_interface.RobotEnable(intera_interface.CHECK_VERSION)
init_state = rs.state()
try:
gripper = intera_interface... |
maps joystick input to gripper commands
@param joystick: an instance of a Joystick
| maps joystick input to gripper commands | [
"maps",
"joystick",
"input",
"to",
"gripper",
"commands"
] | def map_joystick(joystick, limb):
print("Getting robot state... ")
rs = intera_interface.RobotEnable(intera_interface.CHECK_VERSION)
init_state = rs.state()
try:
gripper = intera_interface.Gripper(limb)
except ValueError:
rospy.logerr("Could not detect a gripper attached to the robot... | [
"def",
"map_joystick",
"(",
"joystick",
",",
"limb",
")",
":",
"print",
"(",
"\"Getting robot state... \"",
")",
"rs",
"=",
"intera_interface",
".",
"RobotEnable",
"(",
"intera_interface",
".",
"CHECK_VERSION",
")",
"init_state",
"=",
"rs",
".",
"state",
"(",
... | maps joystick input to gripper commands | [
"maps",
"joystick",
"input",
"to",
"gripper",
"commands"
] | [
"\"\"\"\n maps joystick input to gripper commands\n\n @param joystick: an instance of a Joystick\n \"\"\"",
"# decrease position dead_zone",
"# abbreviations",
"#(test, command, description)",
"# test each joystick condition and call binding cmd if true"
] | [
{
"param": "joystick",
"type": null
},
{
"param": "limb",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "joystick",
"type": null,
"docstring": "an instance of a Joystick",
"docstring_tokens": [
"an",
"instance",
"of",
"a",
"Joystick"
],
"default": null,
"is_optional": fals... |
0c3fcaec256f7fa2c5e6991653f97e6ef171ddc9 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_examples/scripts/gripper_keyboard.py | [
"Apache-2.0"
] | Python | main | <not_specific> | def main():
"""RSDK Gripper Example: Keyboard Control
Use your dev machine's keyboard to control and configure grippers.
Run this example to command various gripper movements while
adjusting gripper parameters, including calibration, velocity,
and force. Uses the intera_interface.Gripper class and... | RSDK Gripper Example: Keyboard Control
Use your dev machine's keyboard to control and configure grippers.
Run this example to command various gripper movements while
adjusting gripper parameters, including calibration, velocity,
and force. Uses the intera_interface.Gripper class and the
helper fun... | RSDK Gripper Example: Keyboard Control
Use your dev machine's keyboard to control and configure grippers.
Run this example to command various gripper movements while
adjusting gripper parameters, including calibration, velocity,
and force. | [
"RSDK",
"Gripper",
"Example",
":",
"Keyboard",
"Control",
"Use",
"your",
"dev",
"machine",
"'",
"s",
"keyboard",
"to",
"control",
"and",
"configure",
"grippers",
".",
"Run",
"this",
"example",
"to",
"command",
"various",
"gripper",
"movements",
"while",
"adjus... | def main():
epilog = """
See help inside the example with the '?' key for key bindings.
"""
rp = intera_interface.RobotParams()
valid_limbs = rp.get_limb_names()
if not valid_limbs:
rp.log_message(("Cannot detect any limb parameters on this robot. "
"Exiting."), "ERRO... | [
"def",
"main",
"(",
")",
":",
"epilog",
"=",
"\"\"\"\nSee help inside the example with the '?' key for key bindings.\n \"\"\"",
"rp",
"=",
"intera_interface",
".",
"RobotParams",
"(",
")",
"valid_limbs",
"=",
"rp",
".",
"get_limb_names",
"(",
")",
"if",
"not",
"val... | RSDK Gripper Example: Keyboard Control
Use your dev machine's keyboard to control and configure grippers. | [
"RSDK",
"Gripper",
"Example",
":",
"Keyboard",
"Control",
"Use",
"your",
"dev",
"machine",
"'",
"s",
"keyboard",
"to",
"control",
"and",
"configure",
"grippers",
"."
] | [
"\"\"\"RSDK Gripper Example: Keyboard Control\n\n Use your dev machine's keyboard to control and configure grippers.\n\n Run this example to command various gripper movements while\n adjusting gripper parameters, including calibration, velocity,\n and force. Uses the intera_interface.Gripper class and t... | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
dacac992daacbb7d787f5b1561bcd81b8a5bd22a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_examples/scripts/ar10_hand_pressurecontrol.py | [
"Apache-2.0"
] | Python | response | null | def response(data): # main that is called when a message from commands is recieved
'''
Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings.
'''
hand = ar10() #creating instance of ar10 hand
#hand.open_hand() # opens the hand
rospy.loginfo(... |
Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings.
| Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings. | [
"Reads",
"in",
"data",
"from",
"tactile",
"sensors",
".",
"either",
"keeps",
"continue",
"grabbing",
"motion",
"or",
"stop",
"based",
"on",
"the",
"readings",
"."
] | def response(data):
hand = ar10()
rospy.loginfo(rospy.get_caller_id() + '\nI heard %s', data.data)
message = data.data
global target,targetstep
if message == "q":
print("object grabbed!!!!")
sub.unregister()
print("Finished Grabbing.")
print('target value:{}'.... | [
"def",
"response",
"(",
"data",
")",
":",
"hand",
"=",
"ar10",
"(",
")",
"rospy",
".",
"loginfo",
"(",
"rospy",
".",
"get_caller_id",
"(",
")",
"+",
"'\\nI heard %s'",
",",
"data",
".",
"data",
")",
"message",
"=",
"data",
".",
"data",
"global",
"tar... | Reads in data from tactile sensors. | [
"Reads",
"in",
"data",
"from",
"tactile",
"sensors",
"."
] | [
"# main that is called when a message from commands is recieved",
"'''\n Reads in data from tactile sensors.\n either keeps continue grabbing motion or stop based on the readings. \n '''",
"#creating instance of ar10 hand",
"#hand.open_hand() # opens the hand",
"# logs messages recieved from comman... | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | _camera_streaming_status | <not_specific> | def _camera_streaming_status(self, camera_name):
"""
Private function to check if the camera is currently in streaming mode.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the camera is streaming, False otherwise
"""
... |
Private function to check if the camera is currently in streaming mode.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the camera is streaming, False otherwise
| Private function to check if the camera is currently in streaming mode. | [
"Private",
"function",
"to",
"check",
"if",
"the",
"camera",
"is",
"currently",
"in",
"streaming",
"mode",
"."
] | def _camera_streaming_status(self, camera_name):
return self.cameras_io[camera_name]['interface'].get_signal_value(
"camera_streaming") | [
"def",
"_camera_streaming_status",
"(",
"self",
",",
"camera_name",
")",
":",
"return",
"self",
".",
"cameras_io",
"[",
"camera_name",
"]",
"[",
"'interface'",
"]",
".",
"get_signal_value",
"(",
"\"camera_streaming\"",
")"
] | Private function to check if the camera is currently in streaming mode. | [
"Private",
"function",
"to",
"check",
"if",
"the",
"camera",
"is",
"currently",
"in",
"streaming",
"mode",
"."
] | [
"\"\"\"\n Private function to check if the camera is currently in streaming mode.\n\n @type camera_name: str\n @param camera_name: camera name\n\n @rtype: bool\n @return: True if the camera is streaming, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "camera_name",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the camera is streaming, False otherwise",
"docstring_tokens": [
"True",
"if",
"the",
"camera",
"is",
"streaming",
"False",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"par... |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | list_cameras | <not_specific> | def list_cameras(self):
"""
Return the list of all camera names on current robot.
@rtype: [str]
@return: ordered list of camera names
"""
return self.cameras_io.keys() |
Return the list of all camera names on current robot.
@rtype: [str]
@return: ordered list of camera names
| Return the list of all camera names on current robot. | [
"Return",
"the",
"list",
"of",
"all",
"camera",
"names",
"on",
"current",
"robot",
"."
] | def list_cameras(self):
return self.cameras_io.keys() | [
"def",
"list_cameras",
"(",
"self",
")",
":",
"return",
"self",
".",
"cameras_io",
".",
"keys",
"(",
")"
] | Return the list of all camera names on current robot. | [
"Return",
"the",
"list",
"of",
"all",
"camera",
"names",
"on",
"current",
"robot",
"."
] | [
"\"\"\"\n Return the list of all camera names on current robot.\n\n @rtype: [str]\n @return: ordered list of camera names\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "ordered list of camera names",
"docstring_tokens": [
"ordered",
"list",
"of",
"camera",
"names"
],
"type": "[str]"
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"do... |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | verify_camera_exists | <not_specific> | def verify_camera_exists(self, camera_name):
"""
Verify if the given camera name is in the list of camera names or not.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the name exists in camera name list, False otherwise.
"""... |
Verify if the given camera name is in the list of camera names or not.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the name exists in camera name list, False otherwise.
| Verify if the given camera name is in the list of camera names or not. | [
"Verify",
"if",
"the",
"given",
"camera",
"name",
"is",
"in",
"the",
"list",
"of",
"camera",
"names",
"or",
"not",
"."
] | def verify_camera_exists(self, camera_name):
if camera_name not in self.list_cameras():
rospy.logerr(' '.join([camera_name, "not in the list of cameras"
" detected on this robot:", ' , '.join(self.list_cameras())]))
return False
return True | [
"def",
"verify_camera_exists",
"(",
"self",
",",
"camera_name",
")",
":",
"if",
"camera_name",
"not",
"in",
"self",
".",
"list_cameras",
"(",
")",
":",
"rospy",
".",
"logerr",
"(",
"' '",
".",
"join",
"(",
"[",
"camera_name",
",",
"\"not in the list of camer... | Verify if the given camera name is in the list of camera names or not. | [
"Verify",
"if",
"the",
"given",
"camera",
"name",
"is",
"in",
"the",
"list",
"of",
"camera",
"names",
"or",
"not",
"."
] | [
"\"\"\"\n Verify if the given camera name is in the list of camera names or not.\n\n @type camera_name: str\n @param camera_name: camera name\n\n @rtype: bool\n @return: True if the name exists in camera name list, False otherwise.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "camera_name",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the name exists in camera name list, False otherwise.",
"docstring_tokens": [
"True",
"if",
"the",
"name",
"exists",
"in",
"camera",
"name",
"list",
"False",
"otherwise",
... |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | is_camera_streaming | <not_specific> | def is_camera_streaming(self, camera_name):
"""
Check the given camera name is streaming or not.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the camera is streaming, False camera is not
streaming, False with log ... |
Check the given camera name is streaming or not.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: True if the camera is streaming, False camera is not
streaming, False with log error means camera name not exists
in ... | Check the given camera name is streaming or not. | [
"Check",
"the",
"given",
"camera",
"name",
"is",
"streaming",
"or",
"not",
"."
] | def is_camera_streaming(self, camera_name):
if self.verify_camera_exists(camera_name):
return self._camera_streaming_status(camera_name)
return False | [
"def",
"is_camera_streaming",
"(",
"self",
",",
"camera_name",
")",
":",
"if",
"self",
".",
"verify_camera_exists",
"(",
"camera_name",
")",
":",
"return",
"self",
".",
"_camera_streaming_status",
"(",
"camera_name",
")",
"return",
"False"
] | Check the given camera name is streaming or not. | [
"Check",
"the",
"given",
"camera",
"name",
"is",
"streaming",
"or",
"not",
"."
] | [
"\"\"\"\n Check the given camera name is streaming or not.\n\n @type camera_name: str\n @param camera_name: camera name\n\n @rtype: bool\n @return: True if the camera is streaming, False camera is not\n streaming, False with log error means camera name not exists\n... | [
{
"param": "self",
"type": null
},
{
"param": "camera_name",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the camera is streaming, False camera is not\nstreaming, False with log error means camera name not exists\nin camera name list",
"docstring_tokens": [
"True",
"if",
"the",
"camera",
"is",
"streaming",
"Fals... |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | start_streaming | <not_specific> | def start_streaming(self, camera_name):
"""
Start camera streaming for the given camera name, This only allows
one camera open at one time and forces closed any other open cameras
before open the wanted one.
@type camera_name: str
@param camera_name: camera name
... |
Start camera streaming for the given camera name, This only allows
one camera open at one time and forces closed any other open cameras
before open the wanted one.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: False if camera not ... | Start camera streaming for the given camera name, This only allows
one camera open at one time and forces closed any other open cameras
before open the wanted one. | [
"Start",
"camera",
"streaming",
"for",
"the",
"given",
"camera",
"name",
"This",
"only",
"allows",
"one",
"camera",
"open",
"at",
"one",
"time",
"and",
"forces",
"closed",
"any",
"other",
"open",
"cameras",
"before",
"open",
"the",
"wanted",
"one",
"."
] | def start_streaming(self, camera_name):
if not self.verify_camera_exists(camera_name):
return False
elif not self._camera_streaming_status(camera_name):
other_cameras_list = list(set(self.list_cameras())-set([
camera_name]))
for other_camera in other_c... | [
"def",
"start_streaming",
"(",
"self",
",",
"camera_name",
")",
":",
"if",
"not",
"self",
".",
"verify_camera_exists",
"(",
"camera_name",
")",
":",
"return",
"False",
"elif",
"not",
"self",
".",
"_camera_streaming_status",
"(",
"camera_name",
")",
":",
"other... | Start camera streaming for the given camera name, This only allows
one camera open at one time and forces closed any other open cameras
before open the wanted one. | [
"Start",
"camera",
"streaming",
"for",
"the",
"given",
"camera",
"name",
"This",
"only",
"allows",
"one",
"camera",
"open",
"at",
"one",
"time",
"and",
"forces",
"closed",
"any",
"other",
"open",
"cameras",
"before",
"open",
"the",
"wanted",
"one",
"."
] | [
"\"\"\"\n Start camera streaming for the given camera name, This only allows\n one camera open at one time and forces closed any other open cameras\n before open the wanted one.\n\n @type camera_name: str\n @param camera_name: camera name\n\n @rtype: bool\n @return: ... | [
{
"param": "self",
"type": null
},
{
"param": "camera_name",
"type": null
}
] | {
"returns": [
{
"docstring": "False if camera not exists in camera_name_list or the\ninterface is not able to stop streaming other camera.\nAdditionally, returns False if the interface is not able\nto start streaming the desired camera. Returns True if the\ncamera already streaming or the camera successful... |
838da429cb810b320a5e36462c2bebd0e3264401 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/camera.py | [
"Apache-2.0"
] | Python | stop_streaming | <not_specific> | def stop_streaming(self, camera_name):
"""
Stop camera streaming by given the camera name.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: False if camera not exists in camera name list or not able
to stop streaming camera. ... |
Stop camera streaming by given the camera name.
@type camera_name: str
@param camera_name: camera name
@rtype: bool
@return: False if camera not exists in camera name list or not able
to stop streaming camera. True if the camera not is streaming
... | Stop camera streaming by given the camera name. | [
"Stop",
"camera",
"streaming",
"by",
"given",
"the",
"camera",
"name",
"."
] | def stop_streaming(self, camera_name):
if not self.verify_camera_exists(camera_name):
return False
elif self._camera_streaming_status(camera_name):
self.cameras_io[camera_name]['interface'].set_signal_value(
"camera_streaming", False)
if self._camera_s... | [
"def",
"stop_streaming",
"(",
"self",
",",
"camera_name",
")",
":",
"if",
"not",
"self",
".",
"verify_camera_exists",
"(",
"camera_name",
")",
":",
"return",
"False",
"elif",
"self",
".",
"_camera_streaming_status",
"(",
"camera_name",
")",
":",
"self",
".",
... | Stop camera streaming by given the camera name. | [
"Stop",
"camera",
"streaming",
"by",
"given",
"the",
"camera",
"name",
"."
] | [
"\"\"\"\n Stop camera streaming by given the camera name.\n\n @type camera_name: str\n @param camera_name: camera name\n\n @rtype: bool\n @return: False if camera not exists in camera name list or not able\n to stop streaming camera. True if the camera not is strea... | [
{
"param": "self",
"type": null
},
{
"param": "camera_name",
"type": null
}
] | {
"returns": [
{
"docstring": "False if camera not exists in camera name list or not able\nto stop streaming camera. True if the camera not is streaming\nmode or the camera successfully stop streaming.",
"docstring_tokens": [
"False",
"if",
"camera",
"not",
"exi... |
047f9e5cf280deaa6a3bf73cdb11e47a123784ad | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_examples/scripts/manageArmTrajectory.py | [
"Apache-2.0"
] | Python | response | null | def response(data): # main that is called when a message from commands is recieved
'''
Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings.
'''
rospy.loginfo(rospy.get_caller_id() + '\nI heard %s', data.data) # logs messages recieved from commands... |
Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings.
| Reads in data from tactile sensors.
either keeps continue grabbing motion or stop based on the readings. | [
"Reads",
"in",
"data",
"from",
"tactile",
"sensors",
".",
"either",
"keeps",
"continue",
"grabbing",
"motion",
"or",
"stop",
"based",
"on",
"the",
"readings",
"."
] | def response(data):
rospy.loginfo(rospy.get_caller_id() + '\nI heard %s', data.data)
message = data.data
global target,targetstep
if message == "q":
print("object grabbed!!!!")
sub.unregister()
print("Finished Grabbing.")
os.system(r"rosrun intera_examples head_dis... | [
"def",
"response",
"(",
"data",
")",
":",
"rospy",
".",
"loginfo",
"(",
"rospy",
".",
"get_caller_id",
"(",
")",
"+",
"'\\nI heard %s'",
",",
"data",
".",
"data",
")",
"message",
"=",
"data",
".",
"data",
"global",
"target",
",",
"targetstep",
"if",
"m... | Reads in data from tactile sensors. | [
"Reads",
"in",
"data",
"from",
"tactile",
"sensors",
"."
] | [
"# main that is called when a message from commands is recieved",
"'''\n Reads in data from tactile sensors.\n either keeps continue grabbing motion or stop based on the readings. \n '''",
"# logs messages recieved from commands to /rosout",
"#os.system(r\"rosrun intera_examples head_display_image.py... | [
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
24e65b07affb37ff3dad1baf1d93658fa2ada001 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/limb.py | [
"Apache-2.0"
] | Python | has_collided | <not_specific> | def has_collided(self):
"""
Return True if the specified limb has experienced a collision.
@rtype: bool
@return: True if the arm is in collision, False otherwise.
"""
return self._collision_state |
Return True if the specified limb has experienced a collision.
@rtype: bool
@return: True if the arm is in collision, False otherwise.
| Return True if the specified limb has experienced a collision. | [
"Return",
"True",
"if",
"the",
"specified",
"limb",
"has",
"experienced",
"a",
"collision",
"."
] | def has_collided(self):
return self._collision_state | [
"def",
"has_collided",
"(",
"self",
")",
":",
"return",
"self",
".",
"_collision_state"
] | Return True if the specified limb has experienced a collision. | [
"Return",
"True",
"if",
"the",
"specified",
"limb",
"has",
"experienced",
"a",
"collision",
"."
] | [
"\"\"\"\n Return True if the specified limb has experienced a collision.\n\n @rtype: bool\n @return: True if the arm is in collision, False otherwise.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the arm is in collision, False otherwise.",
"docstring_tokens": [
"True",
"if",
"the",
"arm",
"is",
"in",
"collision",
"False",
"otherwise",
"."
],
"type": "bool"
}
... |
24e65b07affb37ff3dad1baf1d93658fa2ada001 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/limb.py | [
"Apache-2.0"
] | Python | move_to_neutral | <not_specific> | def move_to_neutral(self, timeout=15.0, speed=0.3):
"""
Command the Limb joints to a predefined set of "neutral" joint angles.
From rosparam named_poses/<limb>/poses/neutral.
@type timeout: float
@param timeout: seconds to wait for move to finish [15]
@type speed: float
... |
Command the Limb joints to a predefined set of "neutral" joint angles.
From rosparam named_poses/<limb>/poses/neutral.
@type timeout: float
@param timeout: seconds to wait for move to finish [15]
@type speed: float
@param speed: ratio of maximum joint speed for executio... | Command the Limb joints to a predefined set of "neutral" joint angles. | [
"Command",
"the",
"Limb",
"joints",
"to",
"a",
"predefined",
"set",
"of",
"\"",
"neutral",
"\"",
"joint",
"angles",
"."
] | def move_to_neutral(self, timeout=15.0, speed=0.3):
try:
neutral_pose = rospy.get_param("named_poses/{0}/poses/neutral".format(self.name))
except KeyError:
rospy.logerr(("Get neutral pose failed, arm: \"{0}\".").format(self.name))
return
angles = dict(zip(self... | [
"def",
"move_to_neutral",
"(",
"self",
",",
"timeout",
"=",
"15.0",
",",
"speed",
"=",
"0.3",
")",
":",
"try",
":",
"neutral_pose",
"=",
"rospy",
".",
"get_param",
"(",
"\"named_poses/{0}/poses/neutral\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",... | Command the Limb joints to a predefined set of "neutral" joint angles. | [
"Command",
"the",
"Limb",
"joints",
"to",
"a",
"predefined",
"set",
"of",
"\"",
"neutral",
"\"",
"joint",
"angles",
"."
] | [
"\"\"\"\n Command the Limb joints to a predefined set of \"neutral\" joint angles.\n From rosparam named_poses/<limb>/poses/neutral.\n\n @type timeout: float\n @param timeout: seconds to wait for move to finish [15]\n @type speed: float\n @param speed: ratio of maximum join... | [
{
"param": "self",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "speed",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "timeout",
"type": null,
"docstring": "seconds to wait for move to f... |
24e65b07affb37ff3dad1baf1d93658fa2ada001 | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/limb.py | [
"Apache-2.0"
] | Python | move_to_joint_positions | <not_specific> | def move_to_joint_positions(self, positions, timeout=15.0,
threshold=settings.JOINT_ANGLE_TOLERANCE,
test=None):
"""
(Blocking) Commands the limb to the provided positions.
Waits until the reported joint state matches that specifie... |
(Blocking) Commands the limb to the provided positions.
Waits until the reported joint state matches that specified.
This function uses a low-pass filter to smooth the movement.
@type positions: dict({str:float})
@param positions: joint_name:angle command
@type timeou... | (Blocking) Commands the limb to the provided positions.
Waits until the reported joint state matches that specified.
This function uses a low-pass filter to smooth the movement. | [
"(",
"Blocking",
")",
"Commands",
"the",
"limb",
"to",
"the",
"provided",
"positions",
".",
"Waits",
"until",
"the",
"reported",
"joint",
"state",
"matches",
"that",
"specified",
".",
"This",
"function",
"uses",
"a",
"low",
"-",
"pass",
"filter",
"to",
"sm... | def move_to_joint_positions(self, positions, timeout=15.0,
threshold=settings.JOINT_ANGLE_TOLERANCE,
test=None):
cmd = self.joint_angles()
def genf(joint, angle):
def joint_diff():
return abs(angle - self._joint_... | [
"def",
"move_to_joint_positions",
"(",
"self",
",",
"positions",
",",
"timeout",
"=",
"15.0",
",",
"threshold",
"=",
"settings",
".",
"JOINT_ANGLE_TOLERANCE",
",",
"test",
"=",
"None",
")",
":",
"cmd",
"=",
"self",
".",
"joint_angles",
"(",
")",
"def",
"ge... | (Blocking) Commands the limb to the provided positions. | [
"(",
"Blocking",
")",
"Commands",
"the",
"limb",
"to",
"the",
"provided",
"positions",
"."
] | [
"\"\"\"\n (Blocking) Commands the limb to the provided positions.\n\n Waits until the reported joint state matches that specified.\n\n This function uses a low-pass filter to smooth the movement.\n\n @type positions: dict({str:float})\n @param positions: joint_name:angle command\n... | [
{
"param": "self",
"type": null
},
{
"param": "positions",
"type": null
},
{
"param": "timeout",
"type": null
},
{
"param": "threshold",
"type": null
},
{
"param": "test",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "positions",
"type": null,
"docstring": null,
"docstring_token... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | reboot | <not_specific> | def reboot(self):
"""
Power cycle the gripper, removing calibration information.
Basic call to the gripper reboot command. Waits for gripper to return
ready state but does not clear errors that could occur during boot.
@rtype: bool
@return: True if successfully Rebooted... |
Power cycle the gripper, removing calibration information.
Basic call to the gripper reboot command. Waits for gripper to return
ready state but does not clear errors that could occur during boot.
@rtype: bool
@return: True if successfully Rebooted, False otherwise
| Power cycle the gripper, removing calibration information.
Basic call to the gripper reboot command. Waits for gripper to return
ready state but does not clear errors that could occur during boot. | [
"Power",
"cycle",
"the",
"gripper",
"removing",
"calibration",
"information",
".",
"Basic",
"call",
"to",
"the",
"gripper",
"reboot",
"command",
".",
"Waits",
"for",
"gripper",
"to",
"return",
"ready",
"state",
"but",
"does",
"not",
"clear",
"errors",
"that",
... | def reboot(self):
return self.gripper_io.set_signal_value("reboot", True) | [
"def",
"reboot",
"(",
"self",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"reboot\"",
",",
"True",
")"
] | Power cycle the gripper, removing calibration information. | [
"Power",
"cycle",
"the",
"gripper",
"removing",
"calibration",
"information",
"."
] | [
"\"\"\"\n Power cycle the gripper, removing calibration information.\n\n Basic call to the gripper reboot command. Waits for gripper to return\n ready state but does not clear errors that could occur during boot.\n\n @rtype: bool\n @return: True if successfully Rebooted, False oth... | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if successfully Rebooted, False otherwise",
"docstring_tokens": [
"True",
"if",
"successfully",
"Rebooted",
"False",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"ident... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | stop | <not_specific> | def stop(self):
"""
Set the gripper to stop executing command at the current
position, apply holding force.
@rtype: bool
@return: True if successfully Stopped, False otherwise
"""
return self.gripper_io.set_signal_value("go", False) |
Set the gripper to stop executing command at the current
position, apply holding force.
@rtype: bool
@return: True if successfully Stopped, False otherwise
| Set the gripper to stop executing command at the current
position, apply holding force. | [
"Set",
"the",
"gripper",
"to",
"stop",
"executing",
"command",
"at",
"the",
"current",
"position",
"apply",
"holding",
"force",
"."
] | def stop(self):
return self.gripper_io.set_signal_value("go", False) | [
"def",
"stop",
"(",
"self",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"go\"",
",",
"False",
")"
] | Set the gripper to stop executing command at the current
position, apply holding force. | [
"Set",
"the",
"gripper",
"to",
"stop",
"executing",
"command",
"at",
"the",
"current",
"position",
"apply",
"holding",
"force",
"."
] | [
"\"\"\"\n Set the gripper to stop executing command at the current\n position, apply holding force.\n\n @rtype: bool\n @return: True if successfully Stopped, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if successfully Stopped, False otherwise",
"docstring_tokens": [
"True",
"if",
"successfully",
"Stopped",
"False",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identif... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | start | <not_specific> | def start(self):
"""
Set the gripper to start executing command at the current
position, apply holding force.
@rtype: bool
@return: True if successfully Started, False otherwise
"""
return self.gripper_io.set_signal_value("go", True) |
Set the gripper to start executing command at the current
position, apply holding force.
@rtype: bool
@return: True if successfully Started, False otherwise
| Set the gripper to start executing command at the current
position, apply holding force. | [
"Set",
"the",
"gripper",
"to",
"start",
"executing",
"command",
"at",
"the",
"current",
"position",
"apply",
"holding",
"force",
"."
] | def start(self):
return self.gripper_io.set_signal_value("go", True) | [
"def",
"start",
"(",
"self",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"go\"",
",",
"True",
")"
] | Set the gripper to start executing command at the current
position, apply holding force. | [
"Set",
"the",
"gripper",
"to",
"start",
"executing",
"command",
"at",
"the",
"current",
"position",
"apply",
"holding",
"force",
"."
] | [
"\"\"\"\n Set the gripper to start executing command at the current\n position, apply holding force.\n\n @rtype: bool\n @return: True if successfully Started, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if successfully Started, False otherwise",
"docstring_tokens": [
"True",
"if",
"successfully",
"Started",
"False",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
"identif... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | open | <not_specific> | def open(self, position=MAX_POSITION):
"""
Set the gripper position to open by providing opening position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise
"""
return self.gripp... |
Set the gripper position to open by providing opening position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise
| Set the gripper position to open by providing opening position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise | [
"Set",
"the",
"gripper",
"position",
"to",
"open",
"by",
"providing",
"opening",
"position",
".",
"@type",
":",
"float",
"@param",
":",
"the",
"postion",
"of",
"gripper",
"in",
"meters",
"@rtype",
":",
"bool",
"@return",
":",
"True",
"if",
"successfully",
... | def open(self, position=MAX_POSITION):
return self.gripper_io.set_signal_value("position_m", position) | [
"def",
"open",
"(",
"self",
",",
"position",
"=",
"MAX_POSITION",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"position_m\"",
",",
"position",
")"
] | Set the gripper position to open by providing opening position. | [
"Set",
"the",
"gripper",
"position",
"to",
"open",
"by",
"providing",
"opening",
"position",
"."
] | [
"\"\"\"\n Set the gripper position to open by providing opening position.\n @type: float\n @param: the postion of gripper in meters\n\n @rtype: bool\n @return: True if successfully set Position, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "position",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "position",
"type": null,
"docstring": null,
"docstring_tokens... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | close | <not_specific> | def close(self, position=MIN_POSITION):
"""
Set the gripper position to close by providing closing position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise
"""
return self.gri... |
Set the gripper position to close by providing closing position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise
| Set the gripper position to close by providing closing position.
@type: float
@param: the postion of gripper in meters
@rtype: bool
@return: True if successfully set Position, False otherwise | [
"Set",
"the",
"gripper",
"position",
"to",
"close",
"by",
"providing",
"closing",
"position",
".",
"@type",
":",
"float",
"@param",
":",
"the",
"postion",
"of",
"gripper",
"in",
"meters",
"@rtype",
":",
"bool",
"@return",
":",
"True",
"if",
"successfully",
... | def close(self, position=MIN_POSITION):
return self.gripper_io.set_signal_value("position_m", position) | [
"def",
"close",
"(",
"self",
",",
"position",
"=",
"MIN_POSITION",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"position_m\"",
",",
"position",
")"
] | Set the gripper position to close by providing closing position. | [
"Set",
"the",
"gripper",
"position",
"to",
"close",
"by",
"providing",
"closing",
"position",
"."
] | [
"\"\"\"\n Set the gripper position to close by providing closing position.\n @type: float\n @param: the postion of gripper in meters\n\n @rtype: bool\n @return: True if successfully set Position, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "position",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "position",
"type": null,
"docstring": null,
"docstring_tokens... |
78454e14cc85a0930a2799bddf948b48567d229a | CNCR-NTU/Sawyer-AR10hand-WeissTactile | intera_interface/src/intera_interface/gripper.py | [
"Apache-2.0"
] | Python | calibrate | <not_specific> | def calibrate(self):
"""
Calibrate the gripper in order to set maximum and
minimum travel distance.
@rtype: bool
@return: True if successfully calibrating, False otherwise
"""
return self.gripper_io.set_signal_value("calibrate", True) |
Calibrate the gripper in order to set maximum and
minimum travel distance.
@rtype: bool
@return: True if successfully calibrating, False otherwise
| Calibrate the gripper in order to set maximum and
minimum travel distance. | [
"Calibrate",
"the",
"gripper",
"in",
"order",
"to",
"set",
"maximum",
"and",
"minimum",
"travel",
"distance",
"."
] | def calibrate(self):
return self.gripper_io.set_signal_value("calibrate", True) | [
"def",
"calibrate",
"(",
"self",
")",
":",
"return",
"self",
".",
"gripper_io",
".",
"set_signal_value",
"(",
"\"calibrate\"",
",",
"True",
")"
] | Calibrate the gripper in order to set maximum and
minimum travel distance. | [
"Calibrate",
"the",
"gripper",
"in",
"order",
"to",
"set",
"maximum",
"and",
"minimum",
"travel",
"distance",
"."
] | [
"\"\"\"\n Calibrate the gripper in order to set maximum and\n minimum travel distance.\n\n @rtype: bool\n @return: True if successfully calibrating, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if successfully calibrating, False otherwise",
"docstring_tokens": [
"True",
"if",
"successfully",
"calibrating",
"False",
"otherwise"
],
"type": "bool"
}
],
"raises": [],
"params": [
{
... |
a4c932907311cd366fd079226d4547757cf8bd1b | ArcetriAdaptiveOptics/arte | test/utils/tabular_report_test.py | [
"MIT"
] | Python | testDocstring | null | def testDocstring(self):
'''
doctest's automated tests only check one line at a time,
while we want the entire output, so we make our own
'''
# Run the example
docstring = doctest.script_from_examples(TabularReport.__doc__ )
with capture_output() as (out, err):
... |
doctest's automated tests only check one line at a time,
while we want the entire output, so we make our own
| doctest's automated tests only check one line at a time,
while we want the entire output, so we make our own | [
"doctest",
"'",
"s",
"automated",
"tests",
"only",
"check",
"one",
"line",
"at",
"a",
"time",
"while",
"we",
"want",
"the",
"entire",
"output",
"so",
"we",
"make",
"our",
"own"
] | def testDocstring(self):
docstring = doctest.script_from_examples(TabularReport.__doc__ )
with capture_output() as (out, err):
exec(docstring)
out = ['# '+x for x in out.getvalue().splitlines()]
ref = docstring.splitlines()[-len(out):]
assert( strip_all(out) == strip... | [
"def",
"testDocstring",
"(",
"self",
")",
":",
"docstring",
"=",
"doctest",
".",
"script_from_examples",
"(",
"TabularReport",
".",
"__doc__",
")",
"with",
"capture_output",
"(",
")",
"as",
"(",
"out",
",",
"err",
")",
":",
"exec",
"(",
"docstring",
")",
... | doctest's automated tests only check one line at a time,
while we want the entire output, so we make our own | [
"doctest",
"'",
"s",
"automated",
"tests",
"only",
"check",
"one",
"line",
"at",
"a",
"time",
"while",
"we",
"want",
"the",
"entire",
"output",
"so",
"we",
"make",
"our",
"own"
] | [
"'''\n doctest's automated tests only check one line at a time,\n while we want the entire output, so we make our own\n '''",
"# Run the example",
"# Add '#' like doctest.script_from_examples() does.",
"# The reference lines are the last x lines of the docstring"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
a4cbd14a47884ddc036cdec229bdbc37ab5540a7 | ArcetriAdaptiveOptics/arte | arte/utils/iterators.py | [
"MIT"
] | Python | flatten | null | def flatten(x):
'''
Generator that flatten arbitrarily nested lists.
This generator will flatten a list that may contain
other lists (nested arbitrarily) and simple items
into a flat list.
>>> flat = flatten([[1,[2,3]],4,[5,6]])
>>> list(flat)
[1, 2, 3, 4, 5, 6]
'''
for item in... |
Generator that flatten arbitrarily nested lists.
This generator will flatten a list that may contain
other lists (nested arbitrarily) and simple items
into a flat list.
>>> flat = flatten([[1,[2,3]],4,[5,6]])
>>> list(flat)
[1, 2, 3, 4, 5, 6]
| Generator that flatten arbitrarily nested lists.
This generator will flatten a list that may contain
other lists (nested arbitrarily) and simple items
into a flat list.
| [
"Generator",
"that",
"flatten",
"arbitrarily",
"nested",
"lists",
".",
"This",
"generator",
"will",
"flatten",
"a",
"list",
"that",
"may",
"contain",
"other",
"lists",
"(",
"nested",
"arbitrarily",
")",
"and",
"simple",
"items",
"into",
"a",
"flat",
"list",
... | def flatten(x):
for item in x:
try:
yield from flatten(item)
except TypeError:
yield item | [
"def",
"flatten",
"(",
"x",
")",
":",
"for",
"item",
"in",
"x",
":",
"try",
":",
"yield",
"from",
"flatten",
"(",
"item",
")",
"except",
"TypeError",
":",
"yield",
"item"
] | Generator that flatten arbitrarily nested lists. | [
"Generator",
"that",
"flatten",
"arbitrarily",
"nested",
"lists",
"."
] | [
"'''\n Generator that flatten arbitrarily nested lists.\n\n This generator will flatten a list that may contain\n other lists (nested arbitrarily) and simple items\n into a flat list.\n\n >>> flat = flatten([[1,[2,3]],4,[5,6]])\n >>> list(flat)\n [1, 2, 3, 4, 5, 6]\n '''"
] | [
{
"param": "x",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "x",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
3c3312eb6c1eb450816938133e92c15efd57206a | ArcetriAdaptiveOptics/arte | test/utils/circular_buffer_test.py | [
"MIT"
] | Python | task | null | def task(arr):
'''
A task that polls on a trigger for max 5 seconds,
and when triggered, modifies the input array.
'''
timeout = 5
now = time.time()
while True:
if arr.counter() == 3:
break
... |
A task that polls on a trigger for max 5 seconds,
and when triggered, modifies the input array.
| A task that polls on a trigger for max 5 seconds,
and when triggered, modifies the input array. | [
"A",
"task",
"that",
"polls",
"on",
"a",
"trigger",
"for",
"max",
"5",
"seconds",
"and",
"when",
"triggered",
"modifies",
"the",
"input",
"array",
"."
] | def task(arr):
timeout = 5
now = time.time()
while True:
if arr.counter() == 3:
break
time.sleep(0.01)
if time.time() - now >= timeout:
raise TimeoutError
arr.store(np.ones(2,)) | [
"def",
"task",
"(",
"arr",
")",
":",
"timeout",
"=",
"5",
"now",
"=",
"time",
".",
"time",
"(",
")",
"while",
"True",
":",
"if",
"arr",
".",
"counter",
"(",
")",
"==",
"3",
":",
"break",
"time",
".",
"sleep",
"(",
"0.01",
")",
"if",
"time",
"... | A task that polls on a trigger for max 5 seconds,
and when triggered, modifies the input array. | [
"A",
"task",
"that",
"polls",
"on",
"a",
"trigger",
"for",
"max",
"5",
"seconds",
"and",
"when",
"triggered",
"modifies",
"the",
"input",
"array",
"."
] | [
"'''\n A task that polls on a trigger for max 5 seconds,\n and when triggered, modifies the input array.\n '''"
] | [
{
"param": "arr",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arr",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
1b9322c377072ca8d869b1731e55f6f98da48faf | ArcetriAdaptiveOptics/arte | arte/utils/quadratic_sum.py | [
"MIT"
] | Python | quadraticSum | <not_specific> | def quadraticSum(arrayOfErrorsWithSign):
''' quadraticSum(arrayOfErrorsWithSign)
Sum in quadrature of errors, considering sign
5 = quadraticSum([3, 4])
8 = quadraticSum(10, -6])
'''
total = 0.
for err in arrayOfErrorsWithSign:
if err < 0:
total -= err ** 2
else:... | quadraticSum(arrayOfErrorsWithSign)
Sum in quadrature of errors, considering sign
5 = quadraticSum([3, 4])
8 = quadraticSum(10, -6])
| quadraticSum(arrayOfErrorsWithSign)
Sum in quadrature of errors, considering sign
| [
"quadraticSum",
"(",
"arrayOfErrorsWithSign",
")",
"Sum",
"in",
"quadrature",
"of",
"errors",
"considering",
"sign"
] | def quadraticSum(arrayOfErrorsWithSign):
total = 0.
for err in arrayOfErrorsWithSign:
if err < 0:
total -= err ** 2
else:
total += err ** 2
return np.sqrt(total) | [
"def",
"quadraticSum",
"(",
"arrayOfErrorsWithSign",
")",
":",
"total",
"=",
"0.",
"for",
"err",
"in",
"arrayOfErrorsWithSign",
":",
"if",
"err",
"<",
"0",
":",
"total",
"-=",
"err",
"**",
"2",
"else",
":",
"total",
"+=",
"err",
"**",
"2",
"return",
"n... | quadraticSum(arrayOfErrorsWithSign)
Sum in quadrature of errors, considering sign | [
"quadraticSum",
"(",
"arrayOfErrorsWithSign",
")",
"Sum",
"in",
"quadrature",
"of",
"errors",
"considering",
"sign"
] | [
"''' quadraticSum(arrayOfErrorsWithSign)\n Sum in quadrature of errors, considering sign\n\n 5 = quadraticSum([3, 4])\n 8 = quadraticSum(10, -6])\n\n '''"
] | [
{
"param": "arrayOfErrorsWithSign",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "arrayOfErrorsWithSign",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | add_series | null | def add_series(self, series):
'''
Adds a new series to this MultiTimeSeries instance
Parameters
----------
series: :class:`~arte.time_series.time_series.TimeSeries` or :class:`~arte.time_series.time_series.TimeSeriesWithInterpolation` instance
the series to be... |
Adds a new series to this MultiTimeSeries instance
Parameters
----------
series: :class:`~arte.time_series.time_series.TimeSeries` or :class:`~arte.time_series.time_series.TimeSeriesWithInterpolation` instance
the series to be added
| Adds a new series to this MultiTimeSeries instance
Parameters
| [
"Adds",
"a",
"new",
"series",
"to",
"this",
"MultiTimeSeries",
"instance",
"Parameters"
] | def add_series(self, series):
self._series.append(series) | [
"def",
"add_series",
"(",
"self",
",",
"series",
")",
":",
"self",
".",
"_series",
".",
"append",
"(",
"series",
")"
] | Adds a new series to this MultiTimeSeries instance
Parameters | [
"Adds",
"a",
"new",
"series",
"to",
"this",
"MultiTimeSeries",
"instance",
"Parameters"
] | [
"'''\n Adds a new series to this MultiTimeSeries instance\n \n Parameters\n ----------\n series: :class:`~arte.time_series.time_series.TimeSeries` or :class:`~arte.time_series.time_series.TimeSeriesWithInterpolation` instance\n the series to be added \n '''... | [
{
"param": "self",
"type": null
},
{
"param": "series",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "series",
"type": null,
"docstring": null,
"docstring_tokens":... |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | is_homogeneous | <not_specific> | def is_homogeneous(self, *args, **kwargs):
'''Returns True if all selected series have the same
:py:attr:`~arte.time_series.time_series.TimeSeries.delta_time`
'''
dt = [x.value for x in self.delta_times(*args, **kwargs)]
return len(set(dt)) == 1 | Returns True if all selected series have the same
:py:attr:`~arte.time_series.time_series.TimeSeries.delta_time`
| Returns True if all selected series have the same | [
"Returns",
"True",
"if",
"all",
"selected",
"series",
"have",
"the",
"same"
] | def is_homogeneous(self, *args, **kwargs):
dt = [x.value for x in self.delta_times(*args, **kwargs)]
return len(set(dt)) == 1 | [
"def",
"is_homogeneous",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"dt",
"=",
"[",
"x",
".",
"value",
"for",
"x",
"in",
"self",
".",
"delta_times",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"]",
"return",
"len",
"(",
"set",
... | Returns True if all selected series have the same | [
"Returns",
"True",
"if",
"all",
"selected",
"series",
"have",
"the",
"same"
] | [
"'''Returns True if all selected series have the same\n :py:attr:`~arte.time_series.time_series.TimeSeries.delta_time`\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": [
{
"identifier": "py",
"docstring": null,
"... |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | delta_times | <not_specific> | def delta_times(self, *args, **kwargs):
'''Returns a vector of delta times'''
# Known astropy bug (numpy < 1.17): units are lost when using hstack
# We remove them before stacking, and add them later
dt = np.hstack( \
[np.repeat(x.delta_time.to('s').value, x.ensemble_size... | Returns a vector of delta times | Returns a vector of delta times | [
"Returns",
"a",
"vector",
"of",
"delta",
"times"
] | def delta_times(self, *args, **kwargs):
dt = np.hstack( \
[np.repeat(x.delta_time.to('s').value, x.ensemble_size())
for x in self._series])
dt = dt * u.s
index = self.get_index_of(*args, **kwargs)
if index is not None and len(index)>0:
dt = dt[ind... | [
"def",
"delta_times",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"dt",
"=",
"np",
".",
"hstack",
"(",
"[",
"np",
".",
"repeat",
"(",
"x",
".",
"delta_time",
".",
"to",
"(",
"'s'",
")",
".",
"value",
",",
"x",
".",
"ensemble_s... | Returns a vector of delta times | [
"Returns",
"a",
"vector",
"of",
"delta",
"times"
] | [
"'''Returns a vector of delta times'''",
"# Known astropy bug (numpy < 1.17): units are lost when using hstack ",
"# We remove them before stacking, and add them later"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | ensemble_average | <not_specific> | def ensemble_average(self, times=None, *args, **kwargs):
''' Average across series at each sampling time '''
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_average(times, *args, **kwargs)
else:
rai... | Average across series at each sampling time | Average across series at each sampling time | [
"Average",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | def ensemble_average(self, times=None, *args, **kwargs):
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_average(times, *args, **kwargs)
else:
raise Exception('Data series cannot be combined') | [
"def",
"ensemble_average",
"(",
"self",
",",
"times",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"is_homogeneous",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_impersonateDeltaTime",
"(",
"*",
... | Average across series at each sampling time | [
"Average",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | [
"''' Average across series at each sampling time '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "times",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "times",
"type": null,
"docstring": null,
"docstring_tokens": ... |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | ensemble_std | <not_specific> | def ensemble_std(self, times=None, *args, **kwargs):
''' Standard deviation across series at each sampling time '''
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_std(times, *args, **kwargs)
else:
... | Standard deviation across series at each sampling time | Standard deviation across series at each sampling time | [
"Standard",
"deviation",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | def ensemble_std(self, times=None, *args, **kwargs):
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_std(times, *args, **kwargs)
else:
raise Exception('Data series cannot be combined') | [
"def",
"ensemble_std",
"(",
"self",
",",
"times",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"is_homogeneous",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_impersonateDeltaTime",
"(",
"*",
"arg... | Standard deviation across series at each sampling time | [
"Standard",
"deviation",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | [
"''' Standard deviation across series at each sampling time '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "times",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "times",
"type": null,
"docstring": null,
"docstring_tokens": ... |
136f9ac4ea003d0c16293268aa6237ef61ecc8a4 | ArcetriAdaptiveOptics/arte | arte/time_series/multi_time_series.py | [
"MIT"
] | Python | ensemble_median | <not_specific> | def ensemble_median(self, times=None, *args, **kwargs):
''' Standard deviation across series at each sampling time '''
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_median(times, *args, **kwargs)
else:
... | Standard deviation across series at each sampling time | Standard deviation across series at each sampling time | [
"Standard",
"deviation",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | def ensemble_median(self, times=None, *args, **kwargs):
if self.is_homogeneous(*args, **kwargs):
self._impersonateDeltaTime(*args, **kwargs)
return super().ensemble_median(times, *args, **kwargs)
else:
raise Exception('Data series cannot be combined') | [
"def",
"ensemble_median",
"(",
"self",
",",
"times",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"if",
"self",
".",
"is_homogeneous",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"self",
".",
"_impersonateDeltaTime",
"(",
"*",
"... | Standard deviation across series at each sampling time | [
"Standard",
"deviation",
"across",
"series",
"at",
"each",
"sampling",
"time"
] | [
"''' Standard deviation across series at each sampling time '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "times",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "times",
"type": null,
"docstring": null,
"docstring_tokens": ... |
9e17f2c29f8301325787a297a3f3e525f6ec93c3 | ArcetriAdaptiveOptics/arte | arte/utils/tabular_report.py | [
"MIT"
] | Python | report | <not_specific> | def report(self):
'''
Increment the iteration counter and if, conditions match,
print a header and/or a line of values.
'''
self.counter += 1
if self.counter % self.decimation != 0:
return
if self.hdr_counter % self.hdr_decimation == 0:
se... |
Increment the iteration counter and if, conditions match,
print a header and/or a line of values.
| Increment the iteration counter and if, conditions match,
print a header and/or a line of values. | [
"Increment",
"the",
"iteration",
"counter",
"and",
"if",
"conditions",
"match",
"print",
"a",
"header",
"and",
"/",
"or",
"a",
"line",
"of",
"values",
"."
] | def report(self):
self.counter += 1
if self.counter % self.decimation != 0:
return
if self.hdr_counter % self.hdr_decimation == 0:
self.print_header()
self.hdr_counter += 1
self.print_line() | [
"def",
"report",
"(",
"self",
")",
":",
"self",
".",
"counter",
"+=",
"1",
"if",
"self",
".",
"counter",
"%",
"self",
".",
"decimation",
"!=",
"0",
":",
"return",
"if",
"self",
".",
"hdr_counter",
"%",
"self",
".",
"hdr_decimation",
"==",
"0",
":",
... | Increment the iteration counter and if, conditions match,
print a header and/or a line of values. | [
"Increment",
"the",
"iteration",
"counter",
"and",
"if",
"conditions",
"match",
"print",
"a",
"header",
"and",
"/",
"or",
"a",
"line",
"of",
"values",
"."
] | [
"'''\n Increment the iteration counter and if, conditions match,\n print a header and/or a line of values.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9e17f2c29f8301325787a297a3f3e525f6ec93c3 | ArcetriAdaptiveOptics/arte | arte/utils/tabular_report.py | [
"MIT"
] | Python | print_header | null | def print_header(self):
'''Unconditionally print a line with the header.'''
cols = self.values.keys()
if self.add_iter:
cols = ['iteration'] + list(cols)
fmt = '%%-%ds ' % self.column_width
hdr = ''.join([fmt % col for col in cols])
print()
print(hd... | Unconditionally print a line with the header. | Unconditionally print a line with the header. | [
"Unconditionally",
"print",
"a",
"line",
"with",
"the",
"header",
"."
] | def print_header(self):
cols = self.values.keys()
if self.add_iter:
cols = ['iteration'] + list(cols)
fmt = '%%-%ds ' % self.column_width
hdr = ''.join([fmt % col for col in cols])
print()
print(hdr)
print('-' * len(hdr)) | [
"def",
"print_header",
"(",
"self",
")",
":",
"cols",
"=",
"self",
".",
"values",
".",
"keys",
"(",
")",
"if",
"self",
".",
"add_iter",
":",
"cols",
"=",
"[",
"'iteration'",
"]",
"+",
"list",
"(",
"cols",
")",
"fmt",
"=",
"'%%-%ds '",
"%",
"self",
... | Unconditionally print a line with the header. | [
"Unconditionally",
"print",
"a",
"line",
"with",
"the",
"header",
"."
] | [
"'''Unconditionally print a line with the header.'''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
9e17f2c29f8301325787a297a3f3e525f6ec93c3 | ArcetriAdaptiveOptics/arte | arte/utils/tabular_report.py | [
"MIT"
] | Python | print_line | null | def print_line(self):
'''Unconditionally print a line with all the current values'''
cols = self.values.keys()
formatted_values = [self.fmt[col](self.values[col]) for col in cols]
if self.add_iter:
formatted_values = [str(self.counter)] + formatted_values
fmt = '%%... | Unconditionally print a line with all the current values | Unconditionally print a line with all the current values | [
"Unconditionally",
"print",
"a",
"line",
"with",
"all",
"the",
"current",
"values"
] | def print_line(self):
cols = self.values.keys()
formatted_values = [self.fmt[col](self.values[col]) for col in cols]
if self.add_iter:
formatted_values = [str(self.counter)] + formatted_values
fmt = '%%-%ds ' % self.column_width
line = ''.join([fmt % value for value i... | [
"def",
"print_line",
"(",
"self",
")",
":",
"cols",
"=",
"self",
".",
"values",
".",
"keys",
"(",
")",
"formatted_values",
"=",
"[",
"self",
".",
"fmt",
"[",
"col",
"]",
"(",
"self",
".",
"values",
"[",
"col",
"]",
")",
"for",
"col",
"in",
"cols"... | Unconditionally print a line with all the current values | [
"Unconditionally",
"print",
"a",
"line",
"with",
"all",
"the",
"current",
"values"
] | [
"'''Unconditionally print a line with all the current values'''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0d8958b9229822a8178d208d35f792c292f79b4e | ArcetriAdaptiveOptics/arte | arte/utils/circular_buffer.py | [
"MIT"
] | Python | store | null | def store(self, data, position=None):
'''
Store a record in the circular buffer.
By default, the record is stored following an internal counter,
which is then incremented.
'''
if position is None:
position = self._position[0]
self._buf[position,:] = ... |
Store a record in the circular buffer.
By default, the record is stored following an internal counter,
which is then incremented.
| Store a record in the circular buffer.
By default, the record is stored following an internal counter,
which is then incremented. | [
"Store",
"a",
"record",
"in",
"the",
"circular",
"buffer",
".",
"By",
"default",
"the",
"record",
"is",
"stored",
"following",
"an",
"internal",
"counter",
"which",
"is",
"then",
"incremented",
"."
] | def store(self, data, position=None):
if position is None:
position = self._position[0]
self._buf[position,:] = data
self._counter[0] = self._counter[0] + 1
self._position[0] = self._counter[0] % self._len | [
"def",
"store",
"(",
"self",
",",
"data",
",",
"position",
"=",
"None",
")",
":",
"if",
"position",
"is",
"None",
":",
"position",
"=",
"self",
".",
"_position",
"[",
"0",
"]",
"self",
".",
"_buf",
"[",
"position",
",",
":",
"]",
"=",
"data",
"se... | Store a record in the circular buffer. | [
"Store",
"a",
"record",
"in",
"the",
"circular",
"buffer",
"."
] | [
"'''\n Store a record in the circular buffer.\n\n By default, the record is stored following an internal counter,\n which is then incremented.\n '''"
] | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
},
{
"param": "position",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
9a1dc8b097eff9b240b2162004a1a5b75bbd18ea | ArcetriAdaptiveOptics/arte | arte/utils/compareIDL.py | [
"MIT"
] | Python | compareIDL | <not_specific> | def compareIDL(idlscript, pyscript, vars_to_compare,
precision=1e-5, verbose=0, tmpfile=None):
'''
Compare IDL and Python routines results, to aid in porting.
This function will run an IDL batch script (containing statements
that will be executed as if they were typed on the IDL command ... |
Compare IDL and Python routines results, to aid in porting.
This function will run an IDL batch script (containing statements
that will be executed as if they were typed on the IDL command prompt)
and a Python script. After both scripts have been run, the variables
listed in vars_to_compare are ex... | Compare IDL and Python routines results, to aid in porting.
This function will run an IDL batch script (containing statements
that will be executed as if they were typed on the IDL command prompt)
and a Python script. After both scripts have been run, the variables
listed in vars_to_compare are extracted from both sess... | [
"Compare",
"IDL",
"and",
"Python",
"routines",
"results",
"to",
"aid",
"in",
"porting",
".",
"This",
"function",
"will",
"run",
"an",
"IDL",
"batch",
"script",
"(",
"containing",
"statements",
"that",
"will",
"be",
"executed",
"as",
"if",
"they",
"were",
"... | def compareIDL(idlscript, pyscript, vars_to_compare,
precision=1e-5, verbose=0, tmpfile=None):
if tmpfile is None:
tmpfile = os.path.join(tempfile.gettempdir(), 'idl_compare.sav')
savecmd = ','.join(['\nSAVE',
*vars_to_compare,
'FILENAME="%s"\... | [
"def",
"compareIDL",
"(",
"idlscript",
",",
"pyscript",
",",
"vars_to_compare",
",",
"precision",
"=",
"1e-5",
",",
"verbose",
"=",
"0",
",",
"tmpfile",
"=",
"None",
")",
":",
"if",
"tmpfile",
"is",
"None",
":",
"tmpfile",
"=",
"os",
".",
"path",
".",
... | Compare IDL and Python routines results, to aid in porting. | [
"Compare",
"IDL",
"and",
"Python",
"routines",
"results",
"to",
"aid",
"in",
"porting",
"."
] | [
"'''\n Compare IDL and Python routines results, to aid in porting.\n\n This function will run an IDL batch script (containing statements\n that will be executed as if they were typed on the IDL command prompt)\n and a Python script. After both scripts have been run, the variables\n listed in vars_to_... | [
{
"param": "idlscript",
"type": null
},
{
"param": "pyscript",
"type": null
},
{
"param": "vars_to_compare",
"type": null
},
{
"param": "precision",
"type": null
},
{
"param": "verbose",
"type": null
},
{
"param": "tmpfile",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "idlscript",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "pyscript",
"type": null,
"docstring": null,
"docstring_t... |
6126ec8df66bbae0b55f22f87d224f08b44208a4 | ArcetriAdaptiveOptics/arte | arte/photometry/eso_sky_calc.py | [
"MIT"
] | Python | lam | <not_specific> | def lam(self):
'''
Wavelength array in astropy units of nm
'''
return self._res['lam'] * u.nm |
Wavelength array in astropy units of nm
| Wavelength array in astropy units of nm | [
"Wavelength",
"array",
"in",
"astropy",
"units",
"of",
"nm"
] | def lam(self):
return self._res['lam'] * u.nm | [
"def",
"lam",
"(",
"self",
")",
":",
"return",
"self",
".",
"_res",
"[",
"'lam'",
"]",
"*",
"u",
".",
"nm"
] | Wavelength array in astropy units of nm | [
"Wavelength",
"array",
"in",
"astropy",
"units",
"of",
"nm"
] | [
"'''\n Wavelength array in astropy units of nm\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
c013eeadcf96245479512775019615540190efc8 | ArcetriAdaptiveOptics/arte | arte/time_series/time_series.py | [
"MIT"
] | Python | _apply | <not_specific> | def _apply(self, func, times=None, *args, **kwargs):
'''Extract data and apply the passed function'''
data = self.get_data(*args, **kwargs)
if times is None:
result = func(data)
else:
idxs = np.array(np.arange(times[0], times[1]) / self.__delta_time,
... | Extract data and apply the passed function | Extract data and apply the passed function | [
"Extract",
"data",
"and",
"apply",
"the",
"passed",
"function"
] | def _apply(self, func, times=None, *args, **kwargs):
data = self.get_data(*args, **kwargs)
if times is None:
result = func(data)
else:
idxs = np.array(np.arange(times[0], times[1]) / self.__delta_time,
dtype='int32')
result = func(d... | [
"def",
"_apply",
"(",
"self",
",",
"func",
",",
"times",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"data",
"=",
"self",
".",
"get_data",
"(",
"*",
"args",
",",
"**",
"kwargs",
")",
"if",
"times",
"is",
"None",
":",
"result",
... | Extract data and apply the passed function | [
"Extract",
"data",
"and",
"apply",
"the",
"passed",
"function"
] | [
"'''Extract data and apply the passed function'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "func",
"type": null
},
{
"param": "times",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [... |
c013eeadcf96245479512775019615540190efc8 | ArcetriAdaptiveOptics/arte | arte/time_series/time_series.py | [
"MIT"
] | Python | plot_spectra | <not_specific> | def plot_spectra(self, from_freq=None, to_freq=None,
segment_factor=None,
overplot=False,
label=None,
*args, **kwargs):
'''Plot the PSD across specified series'''
power = self.power(from_freq, to_freq,
... | Plot the PSD across specified series | Plot the PSD across specified series | [
"Plot",
"the",
"PSD",
"across",
"specified",
"series"
] | def plot_spectra(self, from_freq=None, to_freq=None,
segment_factor=None,
overplot=False,
label=None,
*args, **kwargs):
power = self.power(from_freq, to_freq,
segment_factor,
... | [
"def",
"plot_spectra",
"(",
"self",
",",
"from_freq",
"=",
"None",
",",
"to_freq",
"=",
"None",
",",
"segment_factor",
"=",
"None",
",",
"overplot",
"=",
"False",
",",
"label",
"=",
"None",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"power",
"=... | Plot the PSD across specified series | [
"Plot",
"the",
"PSD",
"across",
"specified",
"series"
] | [
"'''Plot the PSD across specified series'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "from_freq",
"type": null
},
{
"param": "to_freq",
"type": null
},
{
"param": "segment_factor",
"type": null
},
{
"param": "overplot",
"type": null
},
{
"param": "label",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "from_freq",
"type": null,
"docstring": null,
"docstring_token... |
c013eeadcf96245479512775019615540190efc8 | ArcetriAdaptiveOptics/arte | arte/time_series/time_series.py | [
"MIT"
] | Python | plot_cumulative_spectra | <not_specific> | def plot_cumulative_spectra(self, from_freq=None, to_freq=None,
segment_factor=None,
overplot=False, *args, **kwargs):
'''Plot the cumulative PSD across specified series'''
power = self.power(from_freq, to_freq,
s... | Plot the cumulative PSD across specified series | Plot the cumulative PSD across specified series | [
"Plot",
"the",
"cumulative",
"PSD",
"across",
"specified",
"series"
] | def plot_cumulative_spectra(self, from_freq=None, to_freq=None,
segment_factor=None,
overplot=False, *args, **kwargs):
power = self.power(from_freq, to_freq,
segment_factor,
*args, **kwargs)
... | [
"def",
"plot_cumulative_spectra",
"(",
"self",
",",
"from_freq",
"=",
"None",
",",
"to_freq",
"=",
"None",
",",
"segment_factor",
"=",
"None",
",",
"overplot",
"=",
"False",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
":",
"power",
"=",
"self",
".",
"p... | Plot the cumulative PSD across specified series | [
"Plot",
"the",
"cumulative",
"PSD",
"across",
"specified",
"series"
] | [
"'''Plot the cumulative PSD across specified series'''"
] | [
{
"param": "self",
"type": null
},
{
"param": "from_freq",
"type": null
},
{
"param": "to_freq",
"type": null
},
{
"param": "segment_factor",
"type": null
},
{
"param": "overplot",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "from_freq",
"type": null,
"docstring": null,
"docstring_token... |
c013eeadcf96245479512775019615540190efc8 | ArcetriAdaptiveOptics/arte | arte/time_series/time_series.py | [
"MIT"
] | Python | interpolate_missing_data | <not_specific> | def interpolate_missing_data(self, data):
'''
Interpolate missing data.
Parameters
----------
data: ndarray
the original data
Returns
-------
ndarray
the interpolated array
Raises
------
ValueError
... |
Interpolate missing data.
Parameters
----------
data: ndarray
the original data
Returns
-------
ndarray
the interpolated array
Raises
------
ValueError
if the frame counter first dimension does not ha... | Interpolate missing data.
Parameters
ndarray
the original data
Returns
ndarray
the interpolated array
Raises
ValueError
if the frame counter first dimension does not have the same length
as the data first dimension. | [
"Interpolate",
"missing",
"data",
".",
"Parameters",
"ndarray",
"the",
"original",
"data",
"Returns",
"ndarray",
"the",
"interpolated",
"array",
"Raises",
"ValueError",
"if",
"the",
"frame",
"counter",
"first",
"dimension",
"does",
"not",
"have",
"the",
"same",
... | def interpolate_missing_data(self, data):
counter = self.get_original_counter()
if isinstance(counter, NotAvailable):
return NotAvailable()
if data.shape[0] != counter.shape[0]:
raise ValueError('Shape mismatch between frame counter and data:'
... | [
"def",
"interpolate_missing_data",
"(",
"self",
",",
"data",
")",
":",
"counter",
"=",
"self",
".",
"get_original_counter",
"(",
")",
"if",
"isinstance",
"(",
"counter",
",",
"NotAvailable",
")",
":",
"return",
"NotAvailable",
"(",
")",
"if",
"data",
".",
... | Interpolate missing data. | [
"Interpolate",
"missing",
"data",
"."
] | [
"'''\n Interpolate missing data.\n\n Parameters\n ----------\n data: ndarray\n the original data\n\n Returns\n -------\n ndarray\n the interpolated array\n\n Raises\n ------\n ValueError\n if the frame counter fir... | [
{
"param": "self",
"type": null
},
{
"param": "data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "data",
"type": null,
"docstring": null,
"docstring_tokens": [... |
31f4de776a33bad63cd59a635d0b983170e982b4 | ArcetriAdaptiveOptics/arte | arte/atmo/von_karman_psd.py | [
"MIT"
] | Python | spatial_psd | <not_specific> | def spatial_psd(self, freqs):
'''
Spatial Power Spectral Density of Von Karman turbulence
Parameters
----------
freqs: :class:`~numpy:numpy.ndarray`
Spatial frequencies vector[m^-1].
Returns
-------
psd: :class:`~numpy:numpy.ndarray`
... |
Spatial Power Spectral Density of Von Karman turbulence
Parameters
----------
freqs: :class:`~numpy:numpy.ndarray`
Spatial frequencies vector[m^-1].
Returns
-------
psd: :class:`~numpy:numpy.ndarray`
power spectral density computed at th... | Spatial Power Spectral Density of Von Karman turbulence
Parameters
Returns
:class:`~numpy:numpy.ndarray`
power spectral density computed at the specified frequencies | [
"Spatial",
"Power",
"Spectral",
"Density",
"of",
"Von",
"Karman",
"turbulence",
"Parameters",
"Returns",
":",
"class",
":",
"`",
"~numpy",
":",
"numpy",
".",
"ndarray",
"`",
"power",
"spectral",
"density",
"computed",
"at",
"the",
"specified",
"frequencies"
] | def spatial_psd(self, freqs):
self._computeVonKarmanPsd(freqs)
return self._psd | [
"def",
"spatial_psd",
"(",
"self",
",",
"freqs",
")",
":",
"self",
".",
"_computeVonKarmanPsd",
"(",
"freqs",
")",
"return",
"self",
".",
"_psd"
] | Spatial Power Spectral Density of Von Karman turbulence
Parameters | [
"Spatial",
"Power",
"Spectral",
"Density",
"of",
"Von",
"Karman",
"turbulence",
"Parameters"
] | [
"'''\n Spatial Power Spectral Density of Von Karman turbulence\n\n Parameters\n ----------\n freqs: :class:`~numpy:numpy.ndarray`\n Spatial frequencies vector[m^-1].\n\n Returns\n -------\n psd: :class:`~numpy:numpy.ndarray`\n power spectral den... | [
{
"param": "self",
"type": null
},
{
"param": "freqs",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "freqs",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0bf300bd7a2a73b4e8790f58766473ae74211404 | ArcetriAdaptiveOptics/arte | arte/photometry/mag_estimator.py | [
"MIT"
] | Python | flux_zero | <not_specific> | def flux_zero(self):
'''Zero point in photons/sec'''
wl, ergs = self._bands[self._bandname]
photons = self._ergs_to_photons(ergs, wl)
return (photons * self._telescope.area() * self._bandwidth).to(u.ph / u.s) | Zero point in photons/sec | Zero point in photons/sec | [
"Zero",
"point",
"in",
"photons",
"/",
"sec"
] | def flux_zero(self):
wl, ergs = self._bands[self._bandname]
photons = self._ergs_to_photons(ergs, wl)
return (photons * self._telescope.area() * self._bandwidth).to(u.ph / u.s) | [
"def",
"flux_zero",
"(",
"self",
")",
":",
"wl",
",",
"ergs",
"=",
"self",
".",
"_bands",
"[",
"self",
".",
"_bandname",
"]",
"photons",
"=",
"self",
".",
"_ergs_to_photons",
"(",
"ergs",
",",
"wl",
")",
"return",
"(",
"photons",
"*",
"self",
".",
... | Zero point in photons/sec | [
"Zero",
"point",
"in",
"photons",
"/",
"sec"
] | [
"'''Zero point in photons/sec'''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
0bf300bd7a2a73b4e8790f58766473ae74211404 | ArcetriAdaptiveOptics/arte | arte/photometry/mag_estimator.py | [
"MIT"
] | Python | photons_per_subap_per_frame | <not_specific> | def photons_per_subap_per_frame(self):
'''Photons/subap/frame detected by sensor'''
gain = self._detector_gain
nsubaps = self._detector_nsubaps
adu_e_ratio = self._detector_adu_e_ratio
qe = self._detector_qe
return self._total_adus * adu_e_ratio / gain / nsubaps / qe | Photons/subap/frame detected by sensor | Photons/subap/frame detected by sensor | [
"Photons",
"/",
"subap",
"/",
"frame",
"detected",
"by",
"sensor"
] | def photons_per_subap_per_frame(self):
gain = self._detector_gain
nsubaps = self._detector_nsubaps
adu_e_ratio = self._detector_adu_e_ratio
qe = self._detector_qe
return self._total_adus * adu_e_ratio / gain / nsubaps / qe | [
"def",
"photons_per_subap_per_frame",
"(",
"self",
")",
":",
"gain",
"=",
"self",
".",
"_detector_gain",
"nsubaps",
"=",
"self",
".",
"_detector_nsubaps",
"adu_e_ratio",
"=",
"self",
".",
"_detector_adu_e_ratio",
"qe",
"=",
"self",
".",
"_detector_qe",
"return",
... | Photons/subap/frame detected by sensor | [
"Photons",
"/",
"subap",
"/",
"frame",
"detected",
"by",
"sensor"
] | [
"'''Photons/subap/frame detected by sensor'''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.