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 |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
28ec9a33bc55560693b0e59dfd4a14ea9a75b5cc | MarcinOrlowski/dhunter | dhunter/core/log.py | [
"MIT"
] | Python | substitute_ansi | <not_specific> | def substitute_ansi(message):
"""Replaces color code placeholder with ANSI values.
Args:
message: message to process
Returns:
message with placeholders replaced with ANSI codes
"""
color_map = {
'reset': Log.ANSI_RESET,
'reverse': Log... | Replaces color code placeholder with ANSI values.
Args:
message: message to process
Returns:
message with placeholders replaced with ANSI codes
| Replaces color code placeholder with ANSI values. | [
"Replaces",
"color",
"code",
"placeholder",
"with",
"ANSI",
"values",
"."
] | def substitute_ansi(message):
color_map = {
'reset': Log.ANSI_RESET,
'reverse': Log.ANSI_REVERSE,
'black': Log.ANSI_BLACK,
'black_bright': Log.ANSI_BLACK_BRIGHT,
'red': Log.ANSI_RED,
'green': Log.ANSI_GREEN,
'green_bright': Log.... | [
"def",
"substitute_ansi",
"(",
"message",
")",
":",
"color_map",
"=",
"{",
"'reset'",
":",
"Log",
".",
"ANSI_RESET",
",",
"'reverse'",
":",
"Log",
".",
"ANSI_REVERSE",
",",
"'black'",
":",
"Log",
".",
"ANSI_BLACK",
",",
"'black_bright'",
":",
"Log",
".",
... | Replaces color code placeholder with ANSI values. | [
"Replaces",
"color",
"code",
"placeholder",
"with",
"ANSI",
"values",
"."
] | [
"\"\"\"Replaces color code placeholder with ANSI values.\n\n Args:\n message: message to process\n\n Returns:\n message with placeholders replaced with ANSI codes\n \"\"\""
] | [
{
"param": "message",
"type": null
}
] | {
"returns": [
{
"docstring": "message with placeholders replaced with ANSI codes",
"docstring_tokens": [
"message",
"with",
"placeholders",
"replaced",
"with",
"ANSI",
"codes"
],
"type": null
}
],
"raises": [],
"params": [
... |
28ec9a33bc55560693b0e59dfd4a14ea9a75b5cc | MarcinOrlowski/dhunter | dhunter/core/log.py | [
"MIT"
] | Python | _format_log_line | <not_specific> | def _format_log_line(message=None, color=None, stacktrace_postfix=None):
"""Formats log message, adding required indentation and stuff.
Args:
message: message to format
color: COLOR_xxx or ANSI_xxx color code to use if line should be colored
stacktrace_postfix:
Re... | Formats log message, adding required indentation and stuff.
Args:
message: message to format
color: COLOR_xxx or ANSI_xxx color code to use if line should be colored
stacktrace_postfix:
Returns:
Formatted log line
| Formats log message, adding required indentation and stuff. | [
"Formats",
"log",
"message",
"adding",
"required",
"indentation",
"and",
"stuff",
"."
] | def _format_log_line(message=None, color=None, stacktrace_postfix=None):
if message is not None:
message = ' ' * (Log.log_level * 2) + Log.substitute_ansi(message)
if Log.is_debug():
message = '%d: %s' % (Log.log_level, message)
if color is not None:
... | [
"def",
"_format_log_line",
"(",
"message",
"=",
"None",
",",
"color",
"=",
"None",
",",
"stacktrace_postfix",
"=",
"None",
")",
":",
"if",
"message",
"is",
"not",
"None",
":",
"message",
"=",
"' '",
"*",
"(",
"Log",
".",
"log_level",
"*",
"2",
")",
"... | Formats log message, adding required indentation and stuff. | [
"Formats",
"log",
"message",
"adding",
"required",
"indentation",
"and",
"stuff",
"."
] | [
"\"\"\"Formats log message, adding required indentation and stuff.\n\n Args:\n message: message to format\n color: COLOR_xxx or ANSI_xxx color code to use if line should be colored\n stacktrace_postfix:\n\n Returns:\n Formatted log line\n \"\"\""
] | [
{
"param": "message",
"type": null
},
{
"param": "color",
"type": null
},
{
"param": "stacktrace_postfix",
"type": null
}
] | {
"returns": [
{
"docstring": "Formatted log line",
"docstring_tokens": [
"Formatted",
"log",
"line"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "message",
"type": null,
"docstring": "message to format",
"docs... |
28ec9a33bc55560693b0e59dfd4a14ea9a75b5cc | MarcinOrlowski/dhunter | dhunter/core/log.py | [
"MIT"
] | Python | _to_list | <not_specific> | def _to_list(data):
"""Converts certain data types (str, unicode) into list.
Args:
data: data to convert
Returns:
list with converted data
"""
# variable types to be converted
# noinspection PyCompatibility
types = [str]
for data_typ... | Converts certain data types (str, unicode) into list.
Args:
data: data to convert
Returns:
list with converted data
| Converts certain data types (str, unicode) into list. | [
"Converts",
"certain",
"data",
"types",
"(",
"str",
"unicode",
")",
"into",
"list",
"."
] | def _to_list(data):
types = [str]
for data_type in types:
if isinstance(data, data_type):
return [data]
return data | [
"def",
"_to_list",
"(",
"data",
")",
":",
"types",
"=",
"[",
"str",
"]",
"for",
"data_type",
"in",
"types",
":",
"if",
"isinstance",
"(",
"data",
",",
"data_type",
")",
":",
"return",
"[",
"data",
"]",
"return",
"data"
] | Converts certain data types (str, unicode) into list. | [
"Converts",
"certain",
"data",
"types",
"(",
"str",
"unicode",
")",
"into",
"list",
"."
] | [
"\"\"\"Converts certain data types (str, unicode) into list.\n\n Args:\n data: data to convert\n\n Returns:\n list with converted data\n \"\"\"",
"# variable types to be converted",
"# noinspection PyCompatibility"
] | [
{
"param": "data",
"type": null
}
] | {
"returns": [
{
"docstring": "list with converted data",
"docstring_tokens": [
"list",
"with",
"converted",
"data"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "data",
"type": null,
"docstring": "data to con... |
28ec9a33bc55560693b0e59dfd4a14ea9a75b5cc | MarcinOrlowski/dhunter | dhunter/core/log.py | [
"MIT"
] | Python | _dict_to_list | <not_specific> | def _dict_to_list(data_to_convert, color=None):
"""Converts dictionary elements into list.
Args:
data_to_convert: dictionary to convert
color: color code (i.e. '%red%' for each row)
Returns:
list with converted data.
"""
if not isinstance(data_to_... | Converts dictionary elements into list.
Args:
data_to_convert: dictionary to convert
color: color code (i.e. '%red%' for each row)
Returns:
list with converted data.
| Converts dictionary elements into list. | [
"Converts",
"dictionary",
"elements",
"into",
"list",
"."
] | def _dict_to_list(data_to_convert, color=None):
if not isinstance(data_to_convert, dict):
return data_to_convert
array = []
for (key, val) in data_to_convert.items():
if color is not None:
array.append('{color}{key}%reset% : {val}'.format(color=color, key=... | [
"def",
"_dict_to_list",
"(",
"data_to_convert",
",",
"color",
"=",
"None",
")",
":",
"if",
"not",
"isinstance",
"(",
"data_to_convert",
",",
"dict",
")",
":",
"return",
"data_to_convert",
"array",
"=",
"[",
"]",
"for",
"(",
"key",
",",
"val",
")",
"in",
... | Converts dictionary elements into list. | [
"Converts",
"dictionary",
"elements",
"into",
"list",
"."
] | [
"\"\"\"Converts dictionary elements into list.\n\n Args:\n data_to_convert: dictionary to convert\n color: color code (i.e. '%red%' for each row)\n\n Returns:\n list with converted data.\n\n \"\"\""
] | [
{
"param": "data_to_convert",
"type": null
},
{
"param": "color",
"type": null
}
] | {
"returns": [
{
"docstring": "list with converted data.",
"docstring_tokens": [
"list",
"with",
"converted",
"data",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "data_to_convert",
"type": null,
... |
6c49d10a2035e06754860be0093a212394aa983c | bplank/DaNplus | mtp/machamp/models/sentence_decoder.py | [
"MIT"
] | Python | make_output_human_readable | Dict[str, torch.Tensor] | def make_output_human_readable(
self, predictions: torch.Tensor
) -> Dict[str, torch.Tensor]:
"""
Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result.
"""
if predictions.dim() == 2:
... |
Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result.
| Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result. | [
"Does",
"a",
"simple",
"argmax",
"over",
"the",
"probabilities",
"converts",
"index",
"to",
"string",
"label",
"and",
"add",
"`",
"\"",
"label",
"\"",
"`",
"key",
"to",
"the",
"dictionary",
"with",
"the",
"result",
"."
] | def make_output_human_readable(
self, predictions: torch.Tensor
) -> Dict[str, torch.Tensor]:
if predictions.dim() == 2:
predictions_list = [predictions[i] for i in range(predictions.shape[0])]
else:
predictions_list = [predictions]
classes = []
for pr... | [
"def",
"make_output_human_readable",
"(",
"self",
",",
"predictions",
":",
"torch",
".",
"Tensor",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"if",
"predictions",
".",
"dim",
"(",
")",
"==",
"2",
":",
"predictions_list",
"=",
... | Does a simple argmax over the probabilities, converts index to string label, and
add `"label"` key to the dictionary with the result. | [
"Does",
"a",
"simple",
"argmax",
"over",
"the",
"probabilities",
"converts",
"index",
"to",
"string",
"label",
"and",
"add",
"`",
"\"",
"label",
"\"",
"`",
"key",
"to",
"the",
"dictionary",
"with",
"the",
"result",
"."
] | [
"\"\"\"\n Does a simple argmax over the probabilities, converts index to string label, and\n add `\"label\"` key to the dictionary with the result.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "predictions",
"type": "torch.Tensor"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "predictions",
"type": "torch.Tensor",
"docstring": null,
"doc... |
f21a03063f089c801e314454a102f6595aa61e9e | bplank/DaNplus | mtp/machamp/dataset_readers/reader_utils.py | [
"MIT"
] | Python | seqs2data | null | def seqs2data(conllu_file, do_lowercase):
"""
Reads a conllu-like file. We do not base the comment identification on
the starting character being a '#' , as in some of the datasets we used
the words where in column 0, and could start with a `#'. Instead we start
at the back, and see how many columns... |
Reads a conllu-like file. We do not base the comment identification on
the starting character being a '#' , as in some of the datasets we used
the words where in column 0, and could start with a `#'. Instead we start
at the back, and see how many columns (tabs) the file has. Then we judge
any sente... | Reads a conllu-like file. We do not base the comment identification on
the starting character being a '#' , as in some of the datasets we used
the words where in column 0, and could start with a `#'. Instead we start
at the back, and see how many columns (tabs) the file has. Then we judge
any sentences at the start whi... | [
"Reads",
"a",
"conllu",
"-",
"like",
"file",
".",
"We",
"do",
"not",
"base",
"the",
"comment",
"identification",
"on",
"the",
"starting",
"character",
"being",
"a",
"'",
"#",
"'",
"as",
"in",
"some",
"of",
"the",
"datasets",
"we",
"used",
"the",
"words... | def seqs2data(conllu_file, do_lowercase):
sent = []
for line in open(conllu_file, mode="r", encoding="utf-8"):
if do_lowercase:
line = line.lower()
if len(line) < 2 or line.replace('\t', '') == '':
if len(sent) == 0:
continue
num_cols = len(sen... | [
"def",
"seqs2data",
"(",
"conllu_file",
",",
"do_lowercase",
")",
":",
"sent",
"=",
"[",
"]",
"for",
"line",
"in",
"open",
"(",
"conllu_file",
",",
"mode",
"=",
"\"r\"",
",",
"encoding",
"=",
"\"utf-8\"",
")",
":",
"if",
"do_lowercase",
":",
"line",
"=... | Reads a conllu-like file. | [
"Reads",
"a",
"conllu",
"-",
"like",
"file",
"."
] | [
"\"\"\"\n Reads a conllu-like file. We do not base the comment identification on\n the starting character being a '#' , as in some of the datasets we used\n the words where in column 0, and could start with a `#'. Instead we start\n at the back, and see how many columns (tabs) the file has. Then we judg... | [
{
"param": "conllu_file",
"type": null
},
{
"param": "do_lowercase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "conllu_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "do_lowercase",
"type": null,
"docstring": null,
"docst... |
f21a03063f089c801e314454a102f6595aa61e9e | bplank/DaNplus | mtp/machamp/dataset_readers/reader_utils.py | [
"MIT"
] | Python | lines2data | null | def lines2data(input_file, do_lowercase):
"""
Simply reads a tab-separated text file. Returns each line split
by a '\t' character.
"""
for line in open(input_file, mode='r', encoding='utf-8'):
if do_lowercase:
line = line.lower()
tok = [part for part in line.strip().split... |
Simply reads a tab-separated text file. Returns each line split
by a '\t' character.
| Simply reads a tab-separated text file. Returns each line split
by a '\t' character. | [
"Simply",
"reads",
"a",
"tab",
"-",
"separated",
"text",
"file",
".",
"Returns",
"each",
"line",
"split",
"by",
"a",
"'",
"\\",
"t",
"'",
"character",
"."
] | def lines2data(input_file, do_lowercase):
for line in open(input_file, mode='r', encoding='utf-8'):
if do_lowercase:
line = line.lower()
tok = [part for part in line.strip().split('\t')]
yield tok | [
"def",
"lines2data",
"(",
"input_file",
",",
"do_lowercase",
")",
":",
"for",
"line",
"in",
"open",
"(",
"input_file",
",",
"mode",
"=",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
":",
"if",
"do_lowercase",
":",
"line",
"=",
"line",
".",
"lower",
"("... | Simply reads a tab-separated text file. | [
"Simply",
"reads",
"a",
"tab",
"-",
"separated",
"text",
"file",
"."
] | [
"\"\"\"\n Simply reads a tab-separated text file. Returns each line split\n by a '\\t' character.\n \"\"\""
] | [
{
"param": "input_file",
"type": null
},
{
"param": "do_lowercase",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "input_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "do_lowercase",
"type": null,
"docstring": null,
"docstr... |
0c1983d222b7f46ef02627d23b52c9d795d6cee0 | bplank/DaNplus | mtp/machamp/dataset_readers/lemma_edit.py | [
"MIT"
] | Python | min_edit_script | <not_specific> | def min_edit_script(source, target, allow_copy=False):
"""
Finds the minimum edit script to transform the source to the target
"""
a = [[(len(source) + len(target) + 1, None)] * (len(target) + 1) for _ in range(len(source) + 1)]
for i in range(0, len(source) + 1):
for j in range(0, len(targe... |
Finds the minimum edit script to transform the source to the target
| Finds the minimum edit script to transform the source to the target | [
"Finds",
"the",
"minimum",
"edit",
"script",
"to",
"transform",
"the",
"source",
"to",
"the",
"target"
] | def min_edit_script(source, target, allow_copy=False):
a = [[(len(source) + len(target) + 1, None)] * (len(target) + 1) for _ in range(len(source) + 1)]
for i in range(0, len(source) + 1):
for j in range(0, len(target) + 1):
if i == 0 and j == 0:
a[i][j] = (0, "")
... | [
"def",
"min_edit_script",
"(",
"source",
",",
"target",
",",
"allow_copy",
"=",
"False",
")",
":",
"a",
"=",
"[",
"[",
"(",
"len",
"(",
"source",
")",
"+",
"len",
"(",
"target",
")",
"+",
"1",
",",
"None",
")",
"]",
"*",
"(",
"len",
"(",
"targe... | Finds the minimum edit script to transform the source to the target | [
"Finds",
"the",
"minimum",
"edit",
"script",
"to",
"transform",
"the",
"source",
"to",
"the",
"target"
] | [
"\"\"\"\n Finds the minimum edit script to transform the source to the target\n \"\"\""
] | [
{
"param": "source",
"type": null
},
{
"param": "target",
"type": null
},
{
"param": "allow_copy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "source",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "target",
"type": null,
"docstring": null,
"docstring_tokens... |
0c1983d222b7f46ef02627d23b52c9d795d6cee0 | bplank/DaNplus | mtp/machamp/dataset_readers/lemma_edit.py | [
"MIT"
] | Python | gen_lemma_rule | <not_specific> | def gen_lemma_rule(form, lemma, allow_copy=False):
"""
Generates a lemma rule to transform the source to the target
"""
form = form.lower()
previous_case = -1
lemma_casing = ""
for i, c in enumerate(lemma):
case = "↑" if c.lower() != c else "↓"
if case != previous_case:
... |
Generates a lemma rule to transform the source to the target
| Generates a lemma rule to transform the source to the target | [
"Generates",
"a",
"lemma",
"rule",
"to",
"transform",
"the",
"source",
"to",
"the",
"target"
] | def gen_lemma_rule(form, lemma, allow_copy=False):
form = form.lower()
previous_case = -1
lemma_casing = ""
for i, c in enumerate(lemma):
case = "↑" if c.lower() != c else "↓"
if case != previous_case:
lemma_casing += "{}{}{}".format("¦" if lemma_casing else "", case, i if i ... | [
"def",
"gen_lemma_rule",
"(",
"form",
",",
"lemma",
",",
"allow_copy",
"=",
"False",
")",
":",
"form",
"=",
"form",
".",
"lower",
"(",
")",
"previous_case",
"=",
"-",
"1",
"lemma_casing",
"=",
"\"\"",
"for",
"i",
",",
"c",
"in",
"enumerate",
"(",
"le... | Generates a lemma rule to transform the source to the target | [
"Generates",
"a",
"lemma",
"rule",
"to",
"transform",
"the",
"source",
"to",
"the",
"target"
] | [
"\"\"\"\n Generates a lemma rule to transform the source to the target\n \"\"\""
] | [
{
"param": "form",
"type": null
},
{
"param": "lemma",
"type": null
},
{
"param": "allow_copy",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "form",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lemma",
"type": null,
"docstring": null,
"docstring_tokens": ... |
0c1983d222b7f46ef02627d23b52c9d795d6cee0 | bplank/DaNplus | mtp/machamp/dataset_readers/lemma_edit.py | [
"MIT"
] | Python | apply_lemma_rule | <not_specific> | def apply_lemma_rule(form, lemma_rule):
"""
Applies the lemma rule to the form to generate the lemma
"""
if lemma_rule.startswith('@@'): # for @@UNK, to avoid crash
return form
casing, rule = lemma_rule.split(";", 1)
if rule.startswith("a"):
lemma = rule[1:]
else:
for... |
Applies the lemma rule to the form to generate the lemma
| Applies the lemma rule to the form to generate the lemma | [
"Applies",
"the",
"lemma",
"rule",
"to",
"the",
"form",
"to",
"generate",
"the",
"lemma"
] | def apply_lemma_rule(form, lemma_rule):
if lemma_rule.startswith('@@'):
return form
casing, rule = lemma_rule.split(";", 1)
if rule.startswith("a"):
lemma = rule[1:]
else:
form = form.lower()
rules, rule_sources = rule[1:].split("¦"), []
assert len(rules) == 2
... | [
"def",
"apply_lemma_rule",
"(",
"form",
",",
"lemma_rule",
")",
":",
"if",
"lemma_rule",
".",
"startswith",
"(",
"'@@'",
")",
":",
"return",
"form",
"casing",
",",
"rule",
"=",
"lemma_rule",
".",
"split",
"(",
"\";\"",
",",
"1",
")",
"if",
"rule",
".",... | Applies the lemma rule to the form to generate the lemma | [
"Applies",
"the",
"lemma",
"rule",
"to",
"the",
"form",
"to",
"generate",
"the",
"lemma"
] | [
"\"\"\"\n Applies the lemma rule to the form to generate the lemma\n \"\"\"",
"# for @@UNK, to avoid crash",
"The lemma is lowercased initially"
] | [
{
"param": "form",
"type": null
},
{
"param": "lemma_rule",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "form",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "lemma_rule",
"type": null,
"docstring": null,
"docstring_toke... |
0a81c440b6c9938bd58deeef6e02afe9564937e6 | bplank/DaNplus | mtp/machamp/models/multiseq_decoder.py | [
"MIT"
] | Python | make_output_human_readable | Dict[str, torch.Tensor] | def make_output_human_readable(
self, predictions: torch.Tensor
) -> Dict[str, torch.Tensor]:
"""
Does a simple position-wise argmax over each token, converts indices to string labels, and
adds a `"tags"` key to the dictionary with the result.
"""
all_predictions = pr... |
Does a simple position-wise argmax over each token, converts indices to string labels, and
adds a `"tags"` key to the dictionary with the result.
| Does a simple position-wise argmax over each token, converts indices to string labels, and
adds a `"tags"` key to the dictionary with the result. | [
"Does",
"a",
"simple",
"position",
"-",
"wise",
"argmax",
"over",
"each",
"token",
"converts",
"indices",
"to",
"string",
"labels",
"and",
"adds",
"a",
"`",
"\"",
"tags",
"\"",
"`",
"key",
"to",
"the",
"dictionary",
"with",
"the",
"result",
"."
] | def make_output_human_readable(
self, predictions: torch.Tensor
) -> Dict[str, torch.Tensor]:
all_predictions = predictions.cpu().data.numpy()
if all_predictions.ndim == 3:
predictions_list = [all_predictions[i] for i in range(all_predictions.shape[0])]
else:
... | [
"def",
"make_output_human_readable",
"(",
"self",
",",
"predictions",
":",
"torch",
".",
"Tensor",
")",
"->",
"Dict",
"[",
"str",
",",
"torch",
".",
"Tensor",
"]",
":",
"all_predictions",
"=",
"predictions",
".",
"cpu",
"(",
")",
".",
"data",
".",
"numpy... | Does a simple position-wise argmax over each token, converts indices to string labels, and
adds a `"tags"` key to the dictionary with the result. | [
"Does",
"a",
"simple",
"position",
"-",
"wise",
"argmax",
"over",
"each",
"token",
"converts",
"indices",
"to",
"string",
"labels",
"and",
"adds",
"a",
"`",
"\"",
"tags",
"\"",
"`",
"key",
"to",
"the",
"dictionary",
"with",
"the",
"result",
"."
] | [
"\"\"\"\n Does a simple position-wise argmax over each token, converts indices to string labels, and\n adds a `\"tags\"` key to the dictionary with the result.\n \"\"\"",
"# @AR: Get the thresholded matrix and prepare the prediction sequence",
"#print(pred_over_thresh)",
"# @AR: For each ... | [
{
"param": "self",
"type": null
},
{
"param": "predictions",
"type": "torch.Tensor"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "predictions",
"type": "torch.Tensor",
"docstring": null,
"doc... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | _read | Iterable[Instance] | def _read(self, file_path: str) -> Iterable[Instance]:
"""
Main reading class, for each dataset it identifies the type of dataset to read,
and calls the corresponding function. A trick is used to be able to use the same
function universally, the actual path is read from the dataset_confi... |
Main reading class, for each dataset it identifies the type of dataset to read,
and calls the corresponding function. A trick is used to be able to use the same
function universally, the actual path is read from the dataset_config based on
which placeholder is saved in `file_path`.
... | Main reading class, for each dataset it identifies the type of dataset to read,
and calls the corresponding function. A trick is used to be able to use the same
function universally, the actual path is read from the dataset_config based on
which placeholder is saved in `file_path`. | [
"Main",
"reading",
"class",
"for",
"each",
"dataset",
"it",
"identifies",
"the",
"type",
"of",
"dataset",
"to",
"read",
"and",
"calls",
"the",
"corresponding",
"function",
".",
"A",
"trick",
"is",
"used",
"to",
"be",
"able",
"to",
"use",
"the",
"same",
"... | def _read(self, file_path: str) -> Iterable[Instance]:
is_train = file_path == 'TRAINPLACEHOLDER'
is_dev = file_path == 'DEVPLACEHOLDER'
is_test = file_path == 'TESTPLACEHOLDER'
for dataset in self.datasets:
if is_train:
file_path = self.datasets[dataset]['tra... | [
"def",
"_read",
"(",
"self",
",",
"file_path",
":",
"str",
")",
"->",
"Iterable",
"[",
"Instance",
"]",
":",
"is_train",
"=",
"file_path",
"==",
"'TRAINPLACEHOLDER'",
"is_dev",
"=",
"file_path",
"==",
"'DEVPLACEHOLDER'",
"is_test",
"=",
"file_path",
"==",
"'... | Main reading class, for each dataset it identifies the type of dataset to read,
and calls the corresponding function. | [
"Main",
"reading",
"class",
"for",
"each",
"dataset",
"it",
"identifies",
"the",
"type",
"of",
"dataset",
"to",
"read",
"and",
"calls",
"the",
"corresponding",
"function",
"."
] | [
"\"\"\"\n Main reading class, for each dataset it identifies the type of dataset to read,\n and calls the corresponding function. A trick is used to be able to use the same\n function universally, the actual path is read from the dataset_config based on\n which placeholder is saved in `f... | [
{
"param": "self",
"type": null
},
{
"param": "file_path",
"type": "str"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "file_path",
"type": "str",
"docstring": null,
"docstring_toke... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | read_raw | <not_specific> | def read_raw(self, dataset, path, is_train, max_sents):
"""
Reads the data from a raw txt file. Assumes that each sentence is on a line, and
the words are separated by a whitespace.
"""
data = []
word_idx = self.datasets[dataset]['word_idx']
for sent_counter, sent... |
Reads the data from a raw txt file. Assumes that each sentence is on a line, and
the words are separated by a whitespace.
| Reads the data from a raw txt file. Assumes that each sentence is on a line, and
the words are separated by a whitespace. | [
"Reads",
"the",
"data",
"from",
"a",
"raw",
"txt",
"file",
".",
"Assumes",
"that",
"each",
"sentence",
"is",
"on",
"a",
"line",
"and",
"the",
"words",
"are",
"separated",
"by",
"a",
"whitespace",
"."
] | def read_raw(self, dataset, path, is_train, max_sents):
data = []
word_idx = self.datasets[dataset]['word_idx']
for sent_counter, sent in enumerate(open(path, encoding='utf-8', mode='r')):
if max_sents != 0 and sent_counter > max_sents:
break
sent = sent.s... | [
"def",
"read_raw",
"(",
"self",
",",
"dataset",
",",
"path",
",",
"is_train",
",",
"max_sents",
")",
":",
"data",
"=",
"[",
"]",
"word_idx",
"=",
"self",
".",
"datasets",
"[",
"dataset",
"]",
"[",
"'word_idx'",
"]",
"for",
"sent_counter",
",",
"sent",
... | Reads the data from a raw txt file. | [
"Reads",
"the",
"data",
"from",
"a",
"raw",
"txt",
"file",
"."
] | [
"\"\"\"\n Reads the data from a raw txt file. Assumes that each sentence is on a line, and\n the words are separated by a whitespace.\n \"\"\"",
"# could also use basictokenizer?"
] | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "max_sents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | read_classification | <not_specific> | def read_classification(self, dataset, path, is_train, max_sents):
"""
Reads classification data, meaning that it reads input text from N columns, and
a corresponding label from a specific column.
"""
data = []
sent_idxs = self.datasets[dataset]['sent_idxs']
for s... |
Reads classification data, meaning that it reads input text from N columns, and
a corresponding label from a specific column.
| Reads classification data, meaning that it reads input text from N columns, and
a corresponding label from a specific column. | [
"Reads",
"classification",
"data",
"meaning",
"that",
"it",
"reads",
"input",
"text",
"from",
"N",
"columns",
"and",
"a",
"corresponding",
"label",
"from",
"a",
"specific",
"column",
"."
] | def read_classification(self, dataset, path, is_train, max_sents):
data = []
sent_idxs = self.datasets[dataset]['sent_idxs']
for sent_counter, instance in enumerate(lines2data(path, self.do_lowercase)):
task2type = {}
if max_sents != 0 and sent_counter > max_sents:
... | [
"def",
"read_classification",
"(",
"self",
",",
"dataset",
",",
"path",
",",
"is_train",
",",
"max_sents",
")",
":",
"data",
"=",
"[",
"]",
"sent_idxs",
"=",
"self",
".",
"datasets",
"[",
"dataset",
"]",
"[",
"'sent_idxs'",
"]",
"for",
"sent_counter",
",... | Reads classification data, meaning that it reads input text from N columns, and
a corresponding label from a specific column. | [
"Reads",
"classification",
"data",
"meaning",
"that",
"it",
"reads",
"input",
"text",
"from",
"N",
"columns",
"and",
"a",
"corresponding",
"label",
"from",
"a",
"specific",
"column",
"."
] | [
"\"\"\"\n Reads classification data, meaning that it reads input text from N columns, and\n a corresponding label from a specific column.\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "max_sents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | read_seq2seq | <not_specific> | def read_seq2seq(self, dataset, path, is_train, max_sents):
"""
Reads generation data. This means that both the input and the output can be a sequence
of words. For now it only supports one input column, multiple tasks (outputs) on the
same dataset are already supported though.
"... |
Reads generation data. This means that both the input and the output can be a sequence
of words. For now it only supports one input column, multiple tasks (outputs) on the
same dataset are already supported though.
| Reads generation data. This means that both the input and the output can be a sequence
of words. For now it only supports one input column, multiple tasks (outputs) on the
same dataset are already supported though. | [
"Reads",
"generation",
"data",
".",
"This",
"means",
"that",
"both",
"the",
"input",
"and",
"the",
"output",
"can",
"be",
"a",
"sequence",
"of",
"words",
".",
"For",
"now",
"it",
"only",
"supports",
"one",
"input",
"column",
"multiple",
"tasks",
"(",
"ou... | def read_seq2seq(self, dataset, path, is_train, max_sents):
data = []
self._source_max_exceeded = 0
self._target_max_exceeded = 0
logger.info("Reading instances from lines in file at: {}".format(path))
for line_num, instance in enumerate(lines2data(path, self.do_lowercase)):
... | [
"def",
"read_seq2seq",
"(",
"self",
",",
"dataset",
",",
"path",
",",
"is_train",
",",
"max_sents",
")",
":",
"data",
"=",
"[",
"]",
"self",
".",
"_source_max_exceeded",
"=",
"0",
"self",
".",
"_target_max_exceeded",
"=",
"0",
"logger",
".",
"info",
"(",... | Reads generation data. | [
"Reads",
"generation",
"data",
"."
] | [
"\"\"\"\n Reads generation data. This means that both the input and the output can be a sequence\n of words. For now it only supports one input column, multiple tasks (outputs) on the\n same dataset are already supported though.\n \"\"\"",
"# TODO support more than 1 input? see read_cl... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "max_sents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | read_unlabeled | <not_specific> | def read_unlabeled(self, dataset, path, is_train, max_sents):
"""
Reads raw data to perform masked language modeling on. This is a separate function, because
it also already masks the data.
"""
# TODO make full use of batch size
data = []
sep_token = self.tokenize... |
Reads raw data to perform masked language modeling on. This is a separate function, because
it also already masks the data.
| Reads raw data to perform masked language modeling on. This is a separate function, because
it also already masks the data. | [
"Reads",
"raw",
"data",
"to",
"perform",
"masked",
"language",
"modeling",
"on",
".",
"This",
"is",
"a",
"separate",
"function",
"because",
"it",
"also",
"already",
"masks",
"the",
"data",
"."
] | def read_unlabeled(self, dataset, path, is_train, max_sents):
data = []
sep_token = self.tokenizer.tokenize(self.tokenizer.tokenizer.sep_token)[0]
cls_token = self.tokenizer.tokenize(self.tokenizer.tokenizer.cls_token)[0]
mask_token = self.tokenizer.tokenize(self.tokenizer.tokenizer.mask... | [
"def",
"read_unlabeled",
"(",
"self",
",",
"dataset",
",",
"path",
",",
"is_train",
",",
"max_sents",
")",
":",
"data",
"=",
"[",
"]",
"sep_token",
"=",
"self",
".",
"tokenizer",
".",
"tokenize",
"(",
"self",
".",
"tokenizer",
".",
"tokenizer",
".",
"s... | Reads raw data to perform masked language modeling on. | [
"Reads",
"raw",
"data",
"to",
"perform",
"masked",
"language",
"modeling",
"on",
"."
] | [
"\"\"\"\n Reads raw data to perform masked language modeling on. This is a separate function, because\n it also already masks the data.\n \"\"\"",
"# TODO make full use of batch size",
"# skip empty lines",
"# R: 106 is taken from mbert, hope its sufficient in most cases?",
"# set them ... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "max_sents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | text_to_instance2 | <not_specific> | def text_to_instance2(self, sent_tasks, col_idxs, is_train, dataset, full_data):
"""
This is a copy of text_to_instance, just meant for read_unsupervised().
They should definitely be merged in the future #TODO
"""
task_name = ''
for item in sent_tasks:
if item... |
This is a copy of text_to_instance, just meant for read_unsupervised().
They should definitely be merged in the future #TODO
| This is a copy of text_to_instance, just meant for read_unsupervised().
They should definitely be merged in the future #TODO | [
"This",
"is",
"a",
"copy",
"of",
"text_to_instance",
"just",
"meant",
"for",
"read_unsupervised",
"()",
".",
"They",
"should",
"definitely",
"be",
"merged",
"in",
"the",
"future",
"#TODO"
] | def text_to_instance2(self, sent_tasks, col_idxs, is_train, dataset, full_data):
task_name = ''
for item in sent_tasks:
if item != 'tokens':
task_name = item
if task_name == '':
logger.error('somehow the mlm task-name is not found, it is not allowed to be ... | [
"def",
"text_to_instance2",
"(",
"self",
",",
"sent_tasks",
",",
"col_idxs",
",",
"is_train",
",",
"dataset",
",",
"full_data",
")",
":",
"task_name",
"=",
"''",
"for",
"item",
"in",
"sent_tasks",
":",
"if",
"item",
"!=",
"'tokens'",
":",
"task_name",
"=",... | This is a copy of text_to_instance, just meant for read_unsupervised(). | [
"This",
"is",
"a",
"copy",
"of",
"text_to_instance",
"just",
"meant",
"for",
"read_unsupervised",
"()",
"."
] | [
"\"\"\"\n This is a copy of text_to_instance, just meant for read_unsupervised().\n They should definitely be merged in the future #TODO\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "sent_tasks",
"type": null
},
{
"param": "col_idxs",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "full_data",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sent_tasks",
"type": null,
"docstring": null,
"docstring_toke... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | read_sequence | <not_specific> | def read_sequence(self, dataset, path, is_train, max_sents):
"""
Reads conllu-like files. It relies heavily on reader_utils.seqs2data.
Can also read sentence classification tasks for which the labels should
be specified in the comments.
Note that this read corresponds to a variet... |
Reads conllu-like files. It relies heavily on reader_utils.seqs2data.
Can also read sentence classification tasks for which the labels should
be specified in the comments.
Note that this read corresponds to a variety of task_types, but the
differences between them during data re... | Reads conllu-like files. It relies heavily on reader_utils.seqs2data.
Can also read sentence classification tasks for which the labels should
be specified in the comments.
Note that this read corresponds to a variety of task_types, but the
differences between them during data reading are kept minimal | [
"Reads",
"conllu",
"-",
"like",
"files",
".",
"It",
"relies",
"heavily",
"on",
"reader_utils",
".",
"seqs2data",
".",
"Can",
"also",
"read",
"sentence",
"classification",
"tasks",
"for",
"which",
"the",
"labels",
"should",
"be",
"specified",
"in",
"the",
"co... | def read_sequence(self, dataset, path, is_train, max_sents):
data = []
word_idx = self.datasets[dataset]['word_idx']
sent_counter = 0
tknzr = BasicTokenizer()
for sent, full_data in seqs2data(path, self.do_lowercase):
task2type = {}
sent_counter += 1
... | [
"def",
"read_sequence",
"(",
"self",
",",
"dataset",
",",
"path",
",",
"is_train",
",",
"max_sents",
")",
":",
"data",
"=",
"[",
"]",
"word_idx",
"=",
"self",
".",
"datasets",
"[",
"dataset",
"]",
"[",
"'word_idx'",
"]",
"sent_counter",
"=",
"0",
"tknz... | Reads conllu-like files. | [
"Reads",
"conllu",
"-",
"like",
"files",
"."
] | [
"\"\"\"\n Reads conllu-like files. It relies heavily on reader_utils.seqs2data.\n Can also read sentence classification tasks for which the labels should\n be specified in the comments.\n Note that this read corresponds to a variety of task_types, but the\n differences between the... | [
{
"param": "self",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "path",
"type": null
},
{
"param": "is_train",
"type": null
},
{
"param": "max_sents",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dataset",
"type": null,
"docstring": null,
"docstring_tokens"... |
0350352f9483f8e882004dacfa49a7eb685931ea | bplank/DaNplus | mtp/machamp/dataset_readers/machamp_universal_reader.py | [
"MIT"
] | Python | text_to_instance | Instance | def text_to_instance(self, # type: ignore
sent_tasks: Dict,
full_data: List[str],
col_idxs: Dict[str, int],
is_train: bool,
task2type: Dict[str, str],
dataset: str
... |
converts the previously read data into an AllenNLP Instance, containing mainly
a TextField and one or more *LabelField's
| converts the previously read data into an AllenNLP Instance, containing mainly
a TextField and one or more *LabelField's | [
"converts",
"the",
"previously",
"read",
"data",
"into",
"an",
"AllenNLP",
"Instance",
"containing",
"mainly",
"a",
"TextField",
"and",
"one",
"or",
"more",
"*",
"LabelField",
"'",
"s"
] | def text_to_instance(self,
sent_tasks: Dict,
full_data: List[str],
col_idxs: Dict[str, int],
is_train: bool,
task2type: Dict[str, str],
dataset: str
... | [
"def",
"text_to_instance",
"(",
"self",
",",
"sent_tasks",
":",
"Dict",
",",
"full_data",
":",
"List",
"[",
"str",
"]",
",",
"col_idxs",
":",
"Dict",
"[",
"str",
",",
"int",
"]",
",",
"is_train",
":",
"bool",
",",
"task2type",
":",
"Dict",
"[",
"str"... | converts the previously read data into an AllenNLP Instance, containing mainly
a TextField and one or more *LabelField's | [
"converts",
"the",
"previously",
"read",
"data",
"into",
"an",
"AllenNLP",
"Instance",
"containing",
"mainly",
"a",
"TextField",
"and",
"one",
"or",
"more",
"*",
"LabelField",
"'",
"s"
] | [
"# type: ignore",
"\"\"\"\n converts the previously read data into an AllenNLP Instance, containing mainly\n a TextField and one or more *LabelField's\n \"\"\"",
"# For each token label, check if it is a multilabel and handle it",
"# seq labeling"
] | [
{
"param": "self",
"type": null
},
{
"param": "sent_tasks",
"type": "Dict"
},
{
"param": "full_data",
"type": "List[str]"
},
{
"param": "col_idxs",
"type": "Dict[str, int]"
},
{
"param": "is_train",
"type": "bool"
},
{
"param": "task2type",
"type":... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "sent_tasks",
"type": "Dict",
"docstring": null,
"docstring_to... |
3eee31cc79fc83a1bd9175743549aeaf453088cc | luminxu/mmpose | mmpose/apis/inference_3d.py | [
"Apache-2.0"
] | Python | _collate_pose_sequence | <not_specific> | def _collate_pose_sequence(pose_results, with_track_id=True):
"""Reorganize multi-frame pose detection results into individual pose
sequences.
Notes:
T: The temporal length of the pose detection results
N: The number of the person instances
K: The number of the keypoints
C: ... | Reorganize multi-frame pose detection results into individual pose
sequences.
Notes:
T: The temporal length of the pose detection results
N: The number of the person instances
K: The number of the keypoints
C: The channel number of each keypoint
Args:
pose_results (... | Reorganize multi-frame pose detection results into individual pose
sequences.
The temporal length of the pose detection results
N: The number of the person instances
K: The number of the keypoints
C: The channel number of each keypoint | [
"Reorganize",
"multi",
"-",
"frame",
"pose",
"detection",
"results",
"into",
"individual",
"pose",
"sequences",
".",
"The",
"temporal",
"length",
"of",
"the",
"pose",
"detection",
"results",
"N",
":",
"The",
"number",
"of",
"the",
"person",
"instances",
"K",
... | def _collate_pose_sequence(pose_results, with_track_id=True):
T = len(pose_results)
assert T > 0
N = len(pose_results[-1])
if N == 0:
return []
K, C = pose_results[-1][0]['keypoints'].shape
track_ids = None
if with_track_id:
track_ids = [res['track_id'] for res in pose_resu... | [
"def",
"_collate_pose_sequence",
"(",
"pose_results",
",",
"with_track_id",
"=",
"True",
")",
":",
"T",
"=",
"len",
"(",
"pose_results",
")",
"assert",
"T",
">",
"0",
"N",
"=",
"len",
"(",
"pose_results",
"[",
"-",
"1",
"]",
")",
"if",
"N",
"==",
"0"... | Reorganize multi-frame pose detection results into individual pose
sequences. | [
"Reorganize",
"multi",
"-",
"frame",
"pose",
"detection",
"results",
"into",
"individual",
"pose",
"sequences",
"."
] | [
"\"\"\"Reorganize multi-frame pose detection results into individual pose\n sequences.\n\n Notes:\n T: The temporal length of the pose detection results\n N: The number of the person instances\n K: The number of the keypoints\n C: The channel number of each keypoint\n\n Args:\n ... | [
{
"param": "pose_results",
"type": null
},
{
"param": "with_track_id",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "pose_results",
"type": null,
"docstring": "Multi-frame pose detection results\nstored in a nested list. Each element of the outer list is the\npose detection results of a single frame, and each element of the\ninner list is the pose... |
3eee31cc79fc83a1bd9175743549aeaf453088cc | luminxu/mmpose | mmpose/apis/inference_3d.py | [
"Apache-2.0"
] | Python | inference_pose_lifter_model | <not_specific> | def inference_pose_lifter_model(model,
pose_results_2d,
dataset,
with_track_id=True):
"""Inference 3D pose from 2D pose sequences using a pose lifter model.
Args:
model (nn.Module): The loaded pose lifter mo... | Inference 3D pose from 2D pose sequences using a pose lifter model.
Args:
model (nn.Module): The loaded pose lifter model
pose_results_2d (List[List[dict]]): The 2D pose sequences stored in a
nested list. Each element of the outer list is the 2D pose results
of a single fram... | Inference 3D pose from 2D pose sequences using a pose lifter model. | [
"Inference",
"3D",
"pose",
"from",
"2D",
"pose",
"sequences",
"using",
"a",
"pose",
"lifter",
"model",
"."
] | def inference_pose_lifter_model(model,
pose_results_2d,
dataset,
with_track_id=True):
cfg = model.cfg
test_pipeline = Compose(cfg.test_pipeline)
flip_pairs = None
if dataset == 'Body3DH36MDataset':
fl... | [
"def",
"inference_pose_lifter_model",
"(",
"model",
",",
"pose_results_2d",
",",
"dataset",
",",
"with_track_id",
"=",
"True",
")",
":",
"cfg",
"=",
"model",
".",
"cfg",
"test_pipeline",
"=",
"Compose",
"(",
"cfg",
".",
"test_pipeline",
")",
"flip_pairs",
"=",... | Inference 3D pose from 2D pose sequences using a pose lifter model. | [
"Inference",
"3D",
"pose",
"from",
"2D",
"pose",
"sequences",
"using",
"a",
"pose",
"lifter",
"model",
"."
] | [
"\"\"\"Inference 3D pose from 2D pose sequences using a pose lifter model.\n\n Args:\n model (nn.Module): The loaded pose lifter model\n pose_results_2d (List[List[dict]]): The 2D pose sequences stored in a\n nested list. Each element of the outer list is the 2D pose results\n ... | [
{
"param": "model",
"type": null
},
{
"param": "pose_results_2d",
"type": null
},
{
"param": "dataset",
"type": null
},
{
"param": "with_track_id",
"type": null
}
] | {
"returns": [
{
"docstring": "3D pose inference results. Each element is the result of\nan instance, which contains:\n\"keypoints_3d\" (ndarray[K,3]): predicted 3D keypoints\n\"keypoints\" (ndarray[K, 2 or 3]): from the last frame in\n``pose_results_2d``.\n\"track_id\" (int): from the last frame in ``pose_... |
3eee31cc79fc83a1bd9175743549aeaf453088cc | luminxu/mmpose | mmpose/apis/inference_3d.py | [
"Apache-2.0"
] | Python | inference_interhand_3d_model | <not_specific> | def inference_interhand_3d_model(model,
img_or_path,
det_results,
bbox_thr=None,
format='xywh',
dataset='InterHand3DDataset'):
"""Inference a single im... | Inference a single image with a list of hand bounding boxes.
num_bboxes: N
num_keypoints: K
Args:
model (nn.Module): The loaded pose model.
img_or_path (str | np.ndarray): Image filename or loaded image.
det_results (List[dict]): The 2D bbox sequences stored in a list.
... | Inference a single image with a list of hand bounding boxes. | [
"Inference",
"a",
"single",
"image",
"with",
"a",
"list",
"of",
"hand",
"bounding",
"boxes",
"."
] | def inference_interhand_3d_model(model,
img_or_path,
det_results,
bbox_thr=None,
format='xywh',
dataset='InterHand3DDataset'):
assert format in ['xyxy'... | [
"def",
"inference_interhand_3d_model",
"(",
"model",
",",
"img_or_path",
",",
"det_results",
",",
"bbox_thr",
"=",
"None",
",",
"format",
"=",
"'xywh'",
",",
"dataset",
"=",
"'InterHand3DDataset'",
")",
":",
"assert",
"format",
"in",
"[",
"'xyxy'",
",",
"'xywh... | Inference a single image with a list of hand bounding boxes. | [
"Inference",
"a",
"single",
"image",
"with",
"a",
"list",
"of",
"hand",
"bounding",
"boxes",
"."
] | [
"\"\"\"Inference a single image with a list of hand bounding boxes.\n\n num_bboxes: N\n num_keypoints: K\n\n Args:\n model (nn.Module): The loaded pose model.\n img_or_path (str | np.ndarray): Image filename or loaded image.\n det_results (List[dict]): The 2D bbox sequences stored in a... | [
{
"param": "model",
"type": null
},
{
"param": "img_or_path",
"type": null
},
{
"param": "det_results",
"type": null
},
{
"param": "bbox_thr",
"type": null
},
{
"param": "format",
"type": null
},
{
"param": "dataset",
"type": null
}
] | {
"returns": [
{
"docstring": "3D pose inference results. Each element is the result of\nan instance, which contains:\n\"keypoints_3d\" (ndarray[K,3]): predicted 3D keypoints\nIf there is no valid instance, an empty list will be returned.",
"docstring_tokens": [
"3D",
"pose",
"... |
ab66b6912107b2ecbb2af0a0289ef34924066ad8 | cyverse/irods | tests/pydevtest/lib_pre410.py | [
"BSD-3-Clause"
] | Python | open_and_load_pre410_env_file | <not_specific> | def open_and_load_pre410_env_file(filename):
'''
A very brittle parsing takes place here:
Each line of .irodsEnv is split into tokens.
If the first token matches a key in our old-new setting map
we use the corresponding json setting, and the second token as value
'''
irods_env = {}
with ... |
A very brittle parsing takes place here:
Each line of .irodsEnv is split into tokens.
If the first token matches a key in our old-new setting map
we use the corresponding json setting, and the second token as value
| A very brittle parsing takes place here:
Each line of .irodsEnv is split into tokens.
If the first token matches a key in our old-new setting map
we use the corresponding json setting, and the second token as value | [
"A",
"very",
"brittle",
"parsing",
"takes",
"place",
"here",
":",
"Each",
"line",
"of",
".",
"irodsEnv",
"is",
"split",
"into",
"tokens",
".",
"If",
"the",
"first",
"token",
"matches",
"a",
"key",
"in",
"our",
"old",
"-",
"new",
"setting",
"map",
"we",... | def open_and_load_pre410_env_file(filename):
irods_env = {}
with open(filename) as env_file:
for line in env_file.readlines():
tokens = line.strip().split()
if len(tokens) > 1 and tokens[0] in json_env_map:
irods_env[json_env_map[tokens[0]]] = tokens[1]
return... | [
"def",
"open_and_load_pre410_env_file",
"(",
"filename",
")",
":",
"irods_env",
"=",
"{",
"}",
"with",
"open",
"(",
"filename",
")",
"as",
"env_file",
":",
"for",
"line",
"in",
"env_file",
".",
"readlines",
"(",
")",
":",
"tokens",
"=",
"line",
".",
"str... | A very brittle parsing takes place here:
Each line of .irodsEnv is split into tokens. | [
"A",
"very",
"brittle",
"parsing",
"takes",
"place",
"here",
":",
"Each",
"line",
"of",
".",
"irodsEnv",
"is",
"split",
"into",
"tokens",
"."
] | [
"'''\n A very brittle parsing takes place here:\n Each line of .irodsEnv is split into tokens.\n If the first token matches a key in our old-new setting map\n we use the corresponding json setting, and the second token as value\n '''"
] | [
{
"param": "filename",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "filename",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | upload_tasks | null | def upload_tasks(logfile, debug, upload_settings=None,
host=None, username=None, password=None,
projects=None, suffix=None, emailaddress=None):
"""
Upload tasks from the queue folder.
:param logfile: Full file of the file used to log to
:param debug: Should debug mode ... |
Upload tasks from the queue folder.
:param logfile: Full file of the file used to log to
:param debug: Should debug mode be used
:param upload_settings: settings file (csv, py, json) to define
xnat host/project relationship.
:param host: XNAT host
:param username: X... | Upload tasks from the queue folder. | [
"Upload",
"tasks",
"from",
"the",
"queue",
"folder",
"."
] | def upload_tasks(logfile, debug, upload_settings=None,
host=None, username=None, password=None,
projects=None, suffix=None, emailaddress=None):
bin.set_logger(logfile, debug)
check_folders()
upload_settings = load_upload_settings(upload_settings, host, username,
... | [
"def",
"upload_tasks",
"(",
"logfile",
",",
"debug",
",",
"upload_settings",
"=",
"None",
",",
"host",
"=",
"None",
",",
"username",
"=",
"None",
",",
"password",
"=",
"None",
",",
"projects",
"=",
"None",
",",
"suffix",
"=",
"None",
",",
"emailaddress",... | Upload tasks from the queue folder. | [
"Upload",
"tasks",
"from",
"the",
"queue",
"folder",
"."
] | [
"\"\"\"\n Upload tasks from the queue folder.\n\n :param logfile: Full file of the file used to log to\n :param debug: Should debug mode be used\n :param upload_settings: settings file (csv, py, json) to define\n xnat host/project relationship.\n :param host: XNAT host\n ... | [
{
"param": "logfile",
"type": null
},
{
"param": "debug",
"type": null
},
{
"param": "upload_settings",
"type": null
},
{
"param": "host",
"type": null
},
{
"param": "username",
"type": null
},
{
"param": "password",
"type": null
},
{
"para... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "logfile",
"type": null,
"docstring": "Full file of the file used to log to",
"docstring_tokens": [
"Full",
"file",
"of",
"the",
"file",
"used",
"to",
"log",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | testing | null | def testing(test_file, project, sessions, host=None, username=None, hide=False,
do_not_remove=False, nb_sess=5):
"""
Function to run test on some files for dax.
:param test_file: file to test
:param project: project ID on XNAT
:param sessions: list of sessions to run on XNAT
:param ... |
Function to run test on some files for dax.
:param test_file: file to test
:param project: project ID on XNAT
:param sessions: list of sessions to run on XNAT
:param host: XNAT host
:param username: XNAT username
:param hide: Hide dax outputs in a logfile in ~/.dax_test/dax_test.log.
:... | Function to run test on some files for dax. | [
"Function",
"to",
"run",
"test",
"on",
"some",
"files",
"for",
"dax",
"."
] | def testing(test_file, project, sessions, host=None, username=None, hide=False,
do_not_remove=False, nb_sess=5):
tests = test_results()
test_obj = load_test(test_file)
if not test_obj:
tests.inc_error()
else:
_host = host if host is not None else os.environ.get('XNAT_HOST', N... | [
"def",
"testing",
"(",
"test_file",
",",
"project",
",",
"sessions",
",",
"host",
"=",
"None",
",",
"username",
"=",
"None",
",",
"hide",
"=",
"False",
",",
"do_not_remove",
"=",
"False",
",",
"nb_sess",
"=",
"5",
")",
":",
"tests",
"=",
"test_results"... | Function to run test on some files for dax. | [
"Function",
"to",
"run",
"test",
"on",
"some",
"files",
"for",
"dax",
"."
] | [
"\"\"\"\n Function to run test on some files for dax.\n\n :param test_file: file to test\n :param project: project ID on XNAT\n :param sessions: list of sessions to run on XNAT\n :param host: XNAT host\n :param username: XNAT username\n :param hide: Hide dax outputs in a logfile in ~/.dax_test/... | [
{
"param": "test_file",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "sessions",
"type": null
},
{
"param": "host",
"type": null
},
{
"param": "username",
"type": null
},
{
"param": "hide",
"type": null
},
{
"param": "do... | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "test_file",
"type": null,
"docstring": "file to test",
"docstring_tokens": [
"file",
"to",
"test"
],
"default": null,
"is_optional": null
},
{
"identifier": "project",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | send_email | null | def send_email(from_add, password, dests, subject, content, server):
"""
Send email using the server/from/pws
:param from_add: address to send the email from
:param password: password for the email address
:param dests: list of emails addresses to send to
:param subject: subject for the email
... |
Send email using the server/from/pws
:param from_add: address to send the email from
:param password: password for the email address
:param dests: list of emails addresses to send to
:param subject: subject for the email
:param content: content of the email
:param server: SMTP server used ... | Send email using the server/from/pws | [
"Send",
"email",
"using",
"the",
"server",
"/",
"from",
"/",
"pws"
] | def send_email(from_add, password, dests, subject, content, server):
msg = MIMEText(content)
msg['Subject'] = subject
msg['From'] = from_add
msg['To'] = ','.join(dests)
s_obj = smtplib.SMTP(server)
s_obj.starttls()
s_obj.login(from_add, password)
s_obj.sendmail(from_add, dests, msg.as_st... | [
"def",
"send_email",
"(",
"from_add",
",",
"password",
",",
"dests",
",",
"subject",
",",
"content",
",",
"server",
")",
":",
"msg",
"=",
"MIMEText",
"(",
"content",
")",
"msg",
"[",
"'Subject'",
"]",
"=",
"subject",
"msg",
"[",
"'From'",
"]",
"=",
"... | Send email using the server/from/pws | [
"Send",
"email",
"using",
"the",
"server",
"/",
"from",
"/",
"pws"
] | [
"\"\"\"\n Send email using the server/from/pws\n\n :param from_add: address to send the email from\n :param password: password for the email address\n :param dests: list of emails addresses to send to\n :param subject: subject for the email\n :param content: content of the email\n :param server... | [
{
"param": "from_add",
"type": null
},
{
"param": "password",
"type": null
},
{
"param": "dests",
"type": null
},
{
"param": "subject",
"type": null
},
{
"param": "content",
"type": null
},
{
"param": "server",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "from_add",
"type": null,
"docstring": "address to send the email from",
"docstring_tokens": [
"address",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | send_warning_emails | null | def send_warning_emails(warnings, emailaddress):
"""
Send warning emails about the dax_upload queue
:param warnings: list of warnings
:param emailaddress: email address
:return: None
"""
if warnings and emailaddress:
content = WARNING_START_CONTENT
for warning in warnings:
... |
Send warning emails about the dax_upload queue
:param warnings: list of warnings
:param emailaddress: email address
:return: None
| Send warning emails about the dax_upload queue | [
"Send",
"warning",
"emails",
"about",
"the",
"dax_upload",
"queue"
] | def send_warning_emails(warnings, emailaddress):
if warnings and emailaddress:
content = WARNING_START_CONTENT
for warning in warnings:
content += ' - %s\n' % (warning)
content += WARNING_END_CONTENT
if SMTP_FROM and SMTP_PASS and SMTP_HOST:
send_email(SMTP_FR... | [
"def",
"send_warning_emails",
"(",
"warnings",
",",
"emailaddress",
")",
":",
"if",
"warnings",
"and",
"emailaddress",
":",
"content",
"=",
"WARNING_START_CONTENT",
"for",
"warning",
"in",
"warnings",
":",
"content",
"+=",
"' - %s\\n'",
"%",
"(",
"warning",
")",... | Send warning emails about the dax_upload queue | [
"Send",
"warning",
"emails",
"about",
"the",
"dax_upload",
"queue"
] | [
"\"\"\"\n Send warning emails about the dax_upload queue\n\n :param warnings: list of warnings\n :param emailaddress: email address\n :return: None\n \"\"\""
] | [
{
"param": "warnings",
"type": null
},
{
"param": "emailaddress",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "warnings",
"type": null,
"docstring": "list of warnings",
"docstring_tokens": [
"list",
"of",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | check_folders | null | def check_folders():
"""
Check that the default folders exist and if not create them
:return: None
"""
# make the directories if they don't exist:
if not os.path.exists(RESULTS_DIR):
os.mkdir(RESULTS_DIR)
if not os.path.exists(os.path.join(RESULTS_DIR, _OUTLOG)):
os.mkdir(os... |
Check that the default folders exist and if not create them
:return: None
| Check that the default folders exist and if not create them | [
"Check",
"that",
"the",
"default",
"folders",
"exist",
"and",
"if",
"not",
"create",
"them"
] | def check_folders():
if not os.path.exists(RESULTS_DIR):
os.mkdir(RESULTS_DIR)
if not os.path.exists(os.path.join(RESULTS_DIR, _OUTLOG)):
os.mkdir(os.path.join(RESULTS_DIR, _OUTLOG))
if not os.path.exists(os.path.join(RESULTS_DIR, _TRASH)):
os.mkdir(os.path.join(RESULTS_DIR, _TRASH))... | [
"def",
"check_folders",
"(",
")",
":",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"RESULTS_DIR",
")",
":",
"os",
".",
"mkdir",
"(",
"RESULTS_DIR",
")",
"if",
"not",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
".",
"join",
"... | Check that the default folders exist and if not create them | [
"Check",
"that",
"the",
"default",
"folders",
"exist",
"and",
"if",
"not",
"create",
"them"
] | [
"\"\"\"\n Check that the default folders exist and if not create them\n\n :return: None\n \"\"\"",
"# make the directories if they don't exist:"
] | [] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | select_assessor | <not_specific> | def select_assessor(xnat, assessor_dict):
"""
Select the assessor pyxnat Eobject from the assessor dictionary information
:param xnat: pyxnat.interface object
:param assessor_dict: assessor dictionary
:return: assessor pyxnat Eobject
"""
return XnatUtils.select_obj(xnat,
... |
Select the assessor pyxnat Eobject from the assessor dictionary information
:param xnat: pyxnat.interface object
:param assessor_dict: assessor dictionary
:return: assessor pyxnat Eobject
| Select the assessor pyxnat Eobject from the assessor dictionary information | [
"Select",
"the",
"assessor",
"pyxnat",
"Eobject",
"from",
"the",
"assessor",
"dictionary",
"information"
] | def select_assessor(xnat, assessor_dict):
return XnatUtils.select_obj(xnat,
assessor_dict['project_id'],
assessor_dict['subject_label'],
assessor_dict['session_label'],
assessor_id=assesso... | [
"def",
"select_assessor",
"(",
"xnat",
",",
"assessor_dict",
")",
":",
"return",
"XnatUtils",
".",
"select_obj",
"(",
"xnat",
",",
"assessor_dict",
"[",
"'project_id'",
"]",
",",
"assessor_dict",
"[",
"'subject_label'",
"]",
",",
"assessor_dict",
"[",
"'session_... | Select the assessor pyxnat Eobject from the assessor dictionary information | [
"Select",
"the",
"assessor",
"pyxnat",
"Eobject",
"from",
"the",
"assessor",
"dictionary",
"information"
] | [
"\"\"\"\n Select the assessor pyxnat Eobject from the assessor dictionary information\n\n :param xnat: pyxnat.interface object\n :param assessor_dict: assessor dictionary\n :return: assessor pyxnat Eobject\n \"\"\""
] | [
{
"param": "xnat",
"type": null
},
{
"param": "assessor_dict",
"type": null
}
] | {
"returns": [
{
"docstring": "assessor pyxnat Eobject",
"docstring_tokens": [
"assessor",
"pyxnat",
"Eobject"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "xnat",
"type": null,
"docstring": null,
"docstring_to... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | is_dax_upload_running | <not_specific> | def is_dax_upload_running(flagfile):
"""
Check if dax_upload is not already running on the station
:return: True if dax_upload already running, False otherwise.
"""
if os.path.exists(flagfile):
LOGGER.warn('Upload already running.')
return True
else:
f_obj = open(flagfil... |
Check if dax_upload is not already running on the station
:return: True if dax_upload already running, False otherwise.
| Check if dax_upload is not already running on the station | [
"Check",
"if",
"dax_upload",
"is",
"not",
"already",
"running",
"on",
"the",
"station"
] | def is_dax_upload_running(flagfile):
if os.path.exists(flagfile):
LOGGER.warn('Upload already running.')
return True
else:
f_obj = open(flagfile, 'w')
today = datetime.now()
datestr = "Date: %s%s%s_%s:%s:%s" % (str(today.year),
... | [
"def",
"is_dax_upload_running",
"(",
"flagfile",
")",
":",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"flagfile",
")",
":",
"LOGGER",
".",
"warn",
"(",
"'Upload already running.'",
")",
"return",
"True",
"else",
":",
"f_obj",
"=",
"open",
"(",
"flagfile"... | Check if dax_upload is not already running on the station | [
"Check",
"if",
"dax_upload",
"is",
"not",
"already",
"running",
"on",
"the",
"station"
] | [
"\"\"\"\n Check if dax_upload is not already running on the station\n\n :return: True if dax_upload already running, False otherwise.\n \"\"\""
] | [
{
"param": "flagfile",
"type": null
}
] | {
"returns": [
{
"docstring": "True if dax_upload already running, False otherwise.",
"docstring_tokens": [
"True",
"if",
"dax_upload",
"already",
"running",
"False",
"otherwise",
"."
],
"type": null
}
],
"raises": [],... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | generate_snapshots | null | def generate_snapshots(assessor_path):
"""
Generate Snapshots from the PDF if it exists.
:param assessor_path: path for the assessor
:return: None
"""
snapshot_dir = os.path.join(assessor_path, 'SNAPSHOTS')
snapshot_original = os.path.join(snapshot_dir, SNAPSHOTS_ORIGINAL)
snapshot_prev... |
Generate Snapshots from the PDF if it exists.
:param assessor_path: path for the assessor
:return: None
| Generate Snapshots from the PDF if it exists. | [
"Generate",
"Snapshots",
"from",
"the",
"PDF",
"if",
"it",
"exists",
"."
] | def generate_snapshots(assessor_path):
snapshot_dir = os.path.join(assessor_path, 'SNAPSHOTS')
snapshot_original = os.path.join(snapshot_dir, SNAPSHOTS_ORIGINAL)
snapshot_preview = os.path.join(snapshot_dir, SNAPSHOTS_PREVIEW)
if not os.path.exists(snapshot_original) and\
os.path.exists(os.path.j... | [
"def",
"generate_snapshots",
"(",
"assessor_path",
")",
":",
"snapshot_dir",
"=",
"os",
".",
"path",
".",
"join",
"(",
"assessor_path",
",",
"'SNAPSHOTS'",
")",
"snapshot_original",
"=",
"os",
".",
"path",
".",
"join",
"(",
"snapshot_dir",
",",
"SNAPSHOTS_ORIG... | Generate Snapshots from the PDF if it exists. | [
"Generate",
"Snapshots",
"from",
"the",
"PDF",
"if",
"it",
"exists",
"."
] | [
"\"\"\"\n Generate Snapshots from the PDF if it exists.\n\n :param assessor_path: path for the assessor\n :return: None\n \"\"\"",
"# Make the snapshots for the assessors with ghostscript",
"# Create the preview snapshot from the original if Snapshots exist :",
"# Make the snapshot_thumbnail"
] | [
{
"param": "assessor_path",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "assessor_path",
"type": null,
"docstring": "path for the assessor",
"docstring_tokens": [
"path",
"... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | copy_outlog | null | def copy_outlog(assessor_dict):
"""
Copy the oulog files to the assessor folder if we are uploading.
:param assessor_dict: dictionary for the assessor
:return: None
"""
outlog_path = os.path.join(RESULTS_DIR, _OUTLOG,
assessor_dict['label'] + '.output')
new_ou... |
Copy the oulog files to the assessor folder if we are uploading.
:param assessor_dict: dictionary for the assessor
:return: None
| Copy the oulog files to the assessor folder if we are uploading. | [
"Copy",
"the",
"oulog",
"files",
"to",
"the",
"assessor",
"folder",
"if",
"we",
"are",
"uploading",
"."
] | def copy_outlog(assessor_dict):
outlog_path = os.path.join(RESULTS_DIR, _OUTLOG,
assessor_dict['label'] + '.output')
new_outlog_path = os.path.join(assessor_dict['path'], _OUTLOG,
assessor_dict['label'] + '.output')
if os.path.exists(outlog_p... | [
"def",
"copy_outlog",
"(",
"assessor_dict",
")",
":",
"outlog_path",
"=",
"os",
".",
"path",
".",
"join",
"(",
"RESULTS_DIR",
",",
"_OUTLOG",
",",
"assessor_dict",
"[",
"'label'",
"]",
"+",
"'.output'",
")",
"new_outlog_path",
"=",
"os",
".",
"path",
".",
... | Copy the oulog files to the assessor folder if we are uploading. | [
"Copy",
"the",
"oulog",
"files",
"to",
"the",
"assessor",
"folder",
"if",
"we",
"are",
"uploading",
"."
] | [
"\"\"\"\n Copy the oulog files to the assessor folder if we are uploading.\n\n :param assessor_dict: dictionary for the assessor\n :return: None\n \"\"\""
] | [
{
"param": "assessor_dict",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "assessor_dict",
"type": null,
"docstring": "dictionary for the assessor",
"docstring_tokens": [
"dictionary... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | is_complete | <not_specific> | def is_complete(assessor_dict, procstatus):
"""
Copy the oulog files to the assessor folder if we are uploading.
:param assessor_dict: dictionary for the assessor
:param procstatus: status to set for the assessor
:return: True if the assessor is Complete, False otherwise
"""
if procstatus =... |
Copy the oulog files to the assessor folder if we are uploading.
:param assessor_dict: dictionary for the assessor
:param procstatus: status to set for the assessor
:return: True if the assessor is Complete, False otherwise
| Copy the oulog files to the assessor folder if we are uploading. | [
"Copy",
"the",
"oulog",
"files",
"to",
"the",
"assessor",
"folder",
"if",
"we",
"are",
"uploading",
"."
] | def is_complete(assessor_dict, procstatus):
if procstatus == READY_TO_COMPLETE or procstatus == COMPLETE:
eflag = os.path.join(assessor_dict['path'], _EMAILED_FLAG_FILE)
open(eflag, 'w').close()
LOGGER.warn(' -->Data already present on XNAT.\n')
return True
else:
return ... | [
"def",
"is_complete",
"(",
"assessor_dict",
",",
"procstatus",
")",
":",
"if",
"procstatus",
"==",
"READY_TO_COMPLETE",
"or",
"procstatus",
"==",
"COMPLETE",
":",
"eflag",
"=",
"os",
".",
"path",
".",
"join",
"(",
"assessor_dict",
"[",
"'path'",
"]",
",",
... | Copy the oulog files to the assessor folder if we are uploading. | [
"Copy",
"the",
"oulog",
"files",
"to",
"the",
"assessor",
"folder",
"if",
"we",
"are",
"uploading",
"."
] | [
"\"\"\"\n Copy the oulog files to the assessor folder if we are uploading.\n\n :param assessor_dict: dictionary for the assessor\n :param procstatus: status to set for the assessor\n :return: True if the assessor is Complete, False otherwise\n \"\"\""
] | [
{
"param": "assessor_dict",
"type": null
},
{
"param": "procstatus",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the assessor is Complete, False otherwise",
"docstring_tokens": [
"True",
"if",
"the",
"assessor",
"is",
"Complete",
"False",
"otherwise"
],
"type": null
}
],
"raises": [],
"par... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | create_freesurfer_assessor | null | def create_freesurfer_assessor(assessor_obj):
"""
Create freesurfer specific assessor using the DEFAULT_FS_DATATYPE from dax
:param assessor_obj: pyxnat assessor Eobject
:return: None
"""
# create the assessor and set the status
assessor_obj.create(assessors=DEFAULT_FS_DATATYPE,
... |
Create freesurfer specific assessor using the DEFAULT_FS_DATATYPE from dax
:param assessor_obj: pyxnat assessor Eobject
:return: None
| Create freesurfer specific assessor using the DEFAULT_FS_DATATYPE from dax | [
"Create",
"freesurfer",
"specific",
"assessor",
"using",
"the",
"DEFAULT_FS_DATATYPE",
"from",
"dax"
] | def create_freesurfer_assessor(assessor_obj):
assessor_obj.create(assessors=DEFAULT_FS_DATATYPE,
**{DEFAULT_FS_DATATYPE + '/fsversion': '0'})
now = datetime.now()
today = '%s-%s-%s-' % (str(now.year), str(now.month), str(now.day))
assessor_obj.attrs.mset(
{DEFAULT_FS_DATA... | [
"def",
"create_freesurfer_assessor",
"(",
"assessor_obj",
")",
":",
"assessor_obj",
".",
"create",
"(",
"assessors",
"=",
"DEFAULT_FS_DATATYPE",
",",
"**",
"{",
"DEFAULT_FS_DATATYPE",
"+",
"'/fsversion'",
":",
"'0'",
"}",
")",
"now",
"=",
"datetime",
".",
"now",... | Create freesurfer specific assessor using the DEFAULT_FS_DATATYPE from dax | [
"Create",
"freesurfer",
"specific",
"assessor",
"using",
"the",
"DEFAULT_FS_DATATYPE",
"from",
"dax"
] | [
"\"\"\"\n Create freesurfer specific assessor using the DEFAULT_FS_DATATYPE from dax\n\n :param assessor_obj: pyxnat assessor Eobject\n :return: None\n \"\"\"",
"# create the assessor and set the status"
] | [
{
"param": "assessor_obj",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "assessor_obj",
"type": null,
"docstring": "pyxnat assessor Eobject",
"docstring_tokens": [
"pyxnat",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | create_default_assessor | null | def create_default_assessor(assessor_obj, proctype):
"""
Create default assessor using the DEFAULT_DATATYPE from dax
:param assessor_obj: pyxnat assessor Eobject
:param proctype: proctype for the assessor
:return: None
"""
# Create the assessor and set attributes
now = datetime.now()
... |
Create default assessor using the DEFAULT_DATATYPE from dax
:param assessor_obj: pyxnat assessor Eobject
:param proctype: proctype for the assessor
:return: None
| Create default assessor using the DEFAULT_DATATYPE from dax | [
"Create",
"default",
"assessor",
"using",
"the",
"DEFAULT_DATATYPE",
"from",
"dax"
] | def create_default_assessor(assessor_obj, proctype):
now = datetime.now()
today = '%s-%s-%s-' % (str(now.year), str(now.month), str(now.day))
assessor_obj.create(assessors=DEFAULT_DATATYPE)
assessor_obj.attrs.mset(
{DEFAULT_DATATYPE + '/validation/status': JOB_PENDING,
DEFAULT_DATATYPE ... | [
"def",
"create_default_assessor",
"(",
"assessor_obj",
",",
"proctype",
")",
":",
"now",
"=",
"datetime",
".",
"now",
"(",
")",
"today",
"=",
"'%s-%s-%s-'",
"%",
"(",
"str",
"(",
"now",
".",
"year",
")",
",",
"str",
"(",
"now",
".",
"month",
")",
","... | Create default assessor using the DEFAULT_DATATYPE from dax | [
"Create",
"default",
"assessor",
"using",
"the",
"DEFAULT_DATATYPE",
"from",
"dax"
] | [
"\"\"\"\n Create default assessor using the DEFAULT_DATATYPE from dax\n\n :param assessor_obj: pyxnat assessor Eobject\n :param proctype: proctype for the assessor\n :return: None\n \"\"\"",
"# Create the assessor and set attributes",
"# Call mset to only make a single HTTP request"
] | [
{
"param": "assessor_obj",
"type": null
},
{
"param": "proctype",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "assessor_obj",
"type": null,
"docstring": "pyxnat assessor Eobject",
"docstring_tokens": [
"pyxnat",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | should_upload_assessor | <not_specific> | def should_upload_assessor(assessor_obj, assessor_dict, xsitype, version):
"""
Check if the assessor is ready to be uploaded to XNAT
:param assessor_obj: pyxnat assessor Eobject
:param assessor_dict: assessor dictionary
:param xsitype: xsitype for the assessor (fsData or proc:GenProcData, ...)
... |
Check if the assessor is ready to be uploaded to XNAT
:param assessor_obj: pyxnat assessor Eobject
:param assessor_dict: assessor dictionary
:param xsitype: xsitype for the assessor (fsData or proc:GenProcData, ...)
:param version: version for the assessor
:return: True if the assessor should ... | Check if the assessor is ready to be uploaded to XNAT | [
"Check",
"if",
"the",
"assessor",
"is",
"ready",
"to",
"be",
"uploaded",
"to",
"XNAT"
] | def should_upload_assessor(assessor_obj, assessor_dict, xsitype, version):
if not assessor_obj.exists():
if xsitype == DEFAULT_FS_DATATYPE:
create_freesurfer_assessor(assessor_obj)
else:
create_default_assessor(assessor_obj, assessor_dict['proctype'])
else:
procst... | [
"def",
"should_upload_assessor",
"(",
"assessor_obj",
",",
"assessor_dict",
",",
"xsitype",
",",
"version",
")",
":",
"if",
"not",
"assessor_obj",
".",
"exists",
"(",
")",
":",
"if",
"xsitype",
"==",
"DEFAULT_FS_DATATYPE",
":",
"create_freesurfer_assessor",
"(",
... | Check if the assessor is ready to be uploaded to XNAT | [
"Check",
"if",
"the",
"assessor",
"is",
"ready",
"to",
"be",
"uploaded",
"to",
"XNAT"
] | [
"\"\"\"\n Check if the assessor is ready to be uploaded to XNAT\n\n :param assessor_obj: pyxnat assessor Eobject\n :param assessor_dict: assessor dictionary\n :param xsitype: xsitype for the assessor (fsData or proc:GenProcData, ...)\n :param version: version for the assessor\n :return: True if th... | [
{
"param": "assessor_obj",
"type": null
},
{
"param": "assessor_dict",
"type": null
},
{
"param": "xsitype",
"type": null
},
{
"param": "version",
"type": null
}
] | {
"returns": [
{
"docstring": "True if the assessor should be upload, False otherwise",
"docstring_tokens": [
"True",
"if",
"the",
"assessor",
"should",
"be",
"upload",
"False",
"otherwise"
],
"type": null
}
],
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | upload_resource | null | def upload_resource(assessor_obj, resource, resource_path):
"""
Upload a resource folder to an assessor
:param assessor_obj: pyxnat assessor Eobject
:param resource: resource to upload
:param resource_path: resource path on the station
:return: None
"""
if resource == 'SNAPSHOTS':
... |
Upload a resource folder to an assessor
:param assessor_obj: pyxnat assessor Eobject
:param resource: resource to upload
:param resource_path: resource path on the station
:return: None
| Upload a resource folder to an assessor | [
"Upload",
"a",
"resource",
"folder",
"to",
"an",
"assessor"
] | def upload_resource(assessor_obj, resource, resource_path):
if resource == 'SNAPSHOTS':
upload_snapshots(assessor_obj, resource_path)
else:
rfiles_list = os.listdir(resource_path)
if not rfiles_list:
LOGGER.warn('No files in {}'.format(resource_path))
elif len(rfiles_... | [
"def",
"upload_resource",
"(",
"assessor_obj",
",",
"resource",
",",
"resource_path",
")",
":",
"if",
"resource",
"==",
"'SNAPSHOTS'",
":",
"upload_snapshots",
"(",
"assessor_obj",
",",
"resource_path",
")",
"else",
":",
"rfiles_list",
"=",
"os",
".",
"listdir",... | Upload a resource folder to an assessor | [
"Upload",
"a",
"resource",
"folder",
"to",
"an",
"assessor"
] | [
"\"\"\"\n Upload a resource folder to an assessor\n\n :param assessor_obj: pyxnat assessor Eobject\n :param resource: resource to upload\n :param resource_path: resource path on the station\n :return: None\n \"\"\"",
"# One or two file, let just upload them:"
] | [
{
"param": "assessor_obj",
"type": null
},
{
"param": "resource",
"type": null
},
{
"param": "resource_path",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "assessor_obj",
"type": null,
"docstring": "pyxnat assessor Eobject",
"docstring_tokens": [
"pyxnat",
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | upload_pbs | null | def upload_pbs(xnat, projects):
"""
Upload all pbs files to XNAT
:param xnat: pyxnat.Interface object
:param projects: list of projects to upload to XNAT
:return: None
"""
pbs_list = get_pbs_list(projects)
number_pbs = len(pbs_list)
for index, pbsfile in enumerate(pbs_list):
... |
Upload all pbs files to XNAT
:param xnat: pyxnat.Interface object
:param projects: list of projects to upload to XNAT
:return: None
| Upload all pbs files to XNAT | [
"Upload",
"all",
"pbs",
"files",
"to",
"XNAT"
] | def upload_pbs(xnat, projects):
pbs_list = get_pbs_list(projects)
number_pbs = len(pbs_list)
for index, pbsfile in enumerate(pbs_list):
pbs_fpath = os.path.join(RESULTS_DIR, _PBS, pbsfile)
mess = """ *Uploading PBS {index}/{max} -- File name: {file}"""
LOGGER.info(mess.format(index... | [
"def",
"upload_pbs",
"(",
"xnat",
",",
"projects",
")",
":",
"pbs_list",
"=",
"get_pbs_list",
"(",
"projects",
")",
"number_pbs",
"=",
"len",
"(",
"pbs_list",
")",
"for",
"index",
",",
"pbsfile",
"in",
"enumerate",
"(",
"pbs_list",
")",
":",
"pbs_fpath",
... | Upload all pbs files to XNAT | [
"Upload",
"all",
"pbs",
"files",
"to",
"XNAT"
] | [
"\"\"\"\n Upload all pbs files to XNAT\n\n :param xnat: pyxnat.Interface object\n :param projects: list of projects to upload to XNAT\n :return: None\n \"\"\"",
"# upload the file"
] | [
{
"param": "xnat",
"type": null
},
{
"param": "projects",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "xnat",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | upload_outlog | null | def upload_outlog(xnat, projects):
"""
Upload all outlog files to XNAT
:param xnat: pyxnat.Interface object
:param projects: list of projects to upload to XNAT
:return: None
"""
outlogs_list = os.listdir(os.path.join(RESULTS_DIR, _OUTLOG))
if projects:
outlogs_list = [logfile fo... |
Upload all outlog files to XNAT
:param xnat: pyxnat.Interface object
:param projects: list of projects to upload to XNAT
:return: None
| Upload all outlog files to XNAT | [
"Upload",
"all",
"outlog",
"files",
"to",
"XNAT"
] | def upload_outlog(xnat, projects):
outlogs_list = os.listdir(os.path.join(RESULTS_DIR, _OUTLOG))
if projects:
outlogs_list = [logfile for logfile in outlogs_list
if logfile.split('-x-')[0] in projects]
number_outlog = len(outlogs_list)
for index, outlogfile in enumerate(o... | [
"def",
"upload_outlog",
"(",
"xnat",
",",
"projects",
")",
":",
"outlogs_list",
"=",
"os",
".",
"listdir",
"(",
"os",
".",
"path",
".",
"join",
"(",
"RESULTS_DIR",
",",
"_OUTLOG",
")",
")",
"if",
"projects",
":",
"outlogs_list",
"=",
"[",
"logfile",
"f... | Upload all outlog files to XNAT | [
"Upload",
"all",
"outlog",
"files",
"to",
"XNAT"
] | [
"\"\"\"\n Upload all outlog files to XNAT\n\n :param xnat: pyxnat.Interface object\n :param projects: list of projects to upload to XNAT\n :return: None\n \"\"\""
] | [
{
"param": "xnat",
"type": null
},
{
"param": "projects",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "xnat",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | upload_results | null | def upload_results(upload_settings, emailaddress):
"""
Main function to upload the results / PBS / OUTLOG of assessors
from the queue folder
:param upload_settings: dictionary defining the upload information
:return: None
"""
if len(os.listdir(RESULTS_DIR)) == 0:
LOGGER.warn('No da... |
Main function to upload the results / PBS / OUTLOG of assessors
from the queue folder
:param upload_settings: dictionary defining the upload information
:return: None
| Main function to upload the results / PBS / OUTLOG of assessors
from the queue folder | [
"Main",
"function",
"to",
"upload",
"the",
"results",
"/",
"PBS",
"/",
"OUTLOG",
"of",
"assessors",
"from",
"the",
"queue",
"folder"
] | def upload_results(upload_settings, emailaddress):
if len(os.listdir(RESULTS_DIR)) == 0:
LOGGER.warn('No data need to be uploaded.\n')
sys.exit()
warnings = list()
for upload_dict in upload_settings:
with XnatUtils.get_interface(host=upload_dict['host'],
... | [
"def",
"upload_results",
"(",
"upload_settings",
",",
"emailaddress",
")",
":",
"if",
"len",
"(",
"os",
".",
"listdir",
"(",
"RESULTS_DIR",
")",
")",
"==",
"0",
":",
"LOGGER",
".",
"warn",
"(",
"'No data need to be uploaded.\\n'",
")",
"sys",
".",
"exit",
... | Main function to upload the results / PBS / OUTLOG of assessors
from the queue folder | [
"Main",
"function",
"to",
"upload",
"the",
"results",
"/",
"PBS",
"/",
"OUTLOG",
"of",
"assessors",
"from",
"the",
"queue",
"folder"
] | [
"\"\"\"\n Main function to upload the results / PBS / OUTLOG of assessors\n from the queue folder\n\n :param upload_settings: dictionary defining the upload information\n :return: None\n \"\"\"",
"# 1) Upload the assessor data",
"# For each assessor label that need to be upload :",
"# 2) Uploa... | [
{
"param": "upload_settings",
"type": null
},
{
"param": "emailaddress",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "upload_settings",
"type": null,
"docstring": "dictionary defining the upload information",
"docstring_tokens": [
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | print_upload_settings | null | def print_upload_settings(upload_settings):
"""
Display Host/Username/Projects that will be used to upload data from
the queue.
:return: None
"""
LOGGER.info('Upload Settings selected by user:')
for info in upload_settings:
proj_str = ','.join(info['projects']) if info['projects'] ... |
Display Host/Username/Projects that will be used to upload data from
the queue.
:return: None
| Display Host/Username/Projects that will be used to upload data from
the queue. | [
"Display",
"Host",
"/",
"Username",
"/",
"Projects",
"that",
"will",
"be",
"used",
"to",
"upload",
"data",
"from",
"the",
"queue",
"."
] | def print_upload_settings(upload_settings):
LOGGER.info('Upload Settings selected by user:')
for info in upload_settings:
proj_str = ','.join(info['projects']) if info['projects'] else 'all'
user_str = info['username'] if info['username'] else ''
msg = 'XNAT Host: %s -- Xnat Username: %s... | [
"def",
"print_upload_settings",
"(",
"upload_settings",
")",
":",
"LOGGER",
".",
"info",
"(",
"'Upload Settings selected by user:'",
")",
"for",
"info",
"in",
"upload_settings",
":",
"proj_str",
"=",
"','",
".",
"join",
"(",
"info",
"[",
"'projects'",
"]",
")",
... | Display Host/Username/Projects that will be used to upload data from
the queue. | [
"Display",
"Host",
"/",
"Username",
"/",
"Projects",
"that",
"will",
"be",
"used",
"to",
"upload",
"data",
"from",
"the",
"queue",
"."
] | [
"\"\"\"\n Display Host/Username/Projects that will be used to upload data from\n the queue.\n\n :return: None\n \"\"\""
] | [
{
"param": "upload_settings",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "upload_settings",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optiona... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | display_pbs_file | <not_specific> | def display_pbs_file(self, project, sessions):
"""
Function to display one of the pbs file created
:param tests: tests_results object
:param project: XNAT project
:param sessions: XNAT sessions
:return: True if PBS created, False if not.
"""
pbs_files = l... |
Function to display one of the pbs file created
:param tests: tests_results object
:param project: XNAT project
:param sessions: XNAT sessions
:return: True if PBS created, False if not.
| Function to display one of the pbs file created | [
"Function",
"to",
"display",
"one",
"of",
"the",
"pbs",
"file",
"created"
] | def display_pbs_file(self, project, sessions):
pbs_files = list()
for sess in sessions:
pbs_files.extend(glob.glob(os.path.join(DAX_TEST_DIR,
'%s-x-*-x-%s-x-*.pbs' % (project, sess))))
if len(pbs_files) == 0:
print('[ERROR] No PBS file generat... | [
"def",
"display_pbs_file",
"(",
"self",
",",
"project",
",",
"sessions",
")",
":",
"pbs_files",
"=",
"list",
"(",
")",
"for",
"sess",
"in",
"sessions",
":",
"pbs_files",
".",
"extend",
"(",
"glob",
".",
"glob",
"(",
"os",
".",
"path",
".",
"join",
"(... | Function to display one of the pbs file created | [
"Function",
"to",
"display",
"one",
"of",
"the",
"pbs",
"file",
"created"
] | [
"\"\"\"\n Function to display one of the pbs file created\n\n :param tests: tests_results object\n :param project: XNAT project\n :param sessions: XNAT sessions\n :return: True if PBS created, False if not.\n \"\"\"",
"# get a PBS file created:",
"# if empty raise Error... | [
{
"param": "self",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "sessions",
"type": null
}
] | {
"returns": [
{
"docstring": "True if PBS created, False if not.",
"docstring_tokens": [
"True",
"if",
"PBS",
"created",
"False",
"if",
"not",
"."
],
"type": null
}
],
"raises": [],
"params": [
{
"identifi... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | display_settings | null | def display_settings(self):
"""
Function to display from the settings:
- projects
- processors and the default values
- modules and the default values
- launcher and the default values
:return: None
"""
proj_list = list()
p... |
Function to display from the settings:
- projects
- processors and the default values
- modules and the default values
- launcher and the default values
:return: None
| Function to display from the settings:
projects
processors and the default values
modules and the default values
launcher and the default values | [
"Function",
"to",
"display",
"from",
"the",
"settings",
":",
"projects",
"processors",
"and",
"the",
"default",
"values",
"modules",
"and",
"the",
"default",
"values",
"launcher",
"and",
"the",
"default",
"values"
] | def display_settings(self):
proj_list = list()
print('Settings arguments:')
print_settings(self.launch_obj.__dict__)
proj_mods = self.launch_obj.project_modules_dict
proj_procs = self.launch_obj.project_process_dict
proj_list.extend(list(proj_mods.keys()))
proj_li... | [
"def",
"display_settings",
"(",
"self",
")",
":",
"proj_list",
"=",
"list",
"(",
")",
"print",
"(",
"'Settings arguments:'",
")",
"print_settings",
"(",
"self",
".",
"launch_obj",
".",
"__dict__",
")",
"proj_mods",
"=",
"self",
".",
"launch_obj",
".",
"proje... | Function to display from the settings:
projects
processors and the default values
modules and the default values
launcher and the default values | [
"Function",
"to",
"display",
"from",
"the",
"settings",
":",
"projects",
"processors",
"and",
"the",
"default",
"values",
"modules",
"and",
"the",
"default",
"values",
"launcher",
"and",
"the",
"default",
"values"
] | [
"\"\"\"\n Function to display from the settings:\n - projects\n - processors and the default values\n - modules and the default values\n - launcher and the default values\n\n :return: None\n \"\"\""
] | [
{
"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
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | randomly_get_sessions | <not_specific> | def randomly_get_sessions(xnat, project, nb_sess=5):
"""
Retrieve nb_sess sessions label randomly from the test project on XNAT
:param project: XNAT project
:return: list of sessions label
"""
sessions = list()
list_sess = XnatUtils.list_sessions(xnat, project)
if len(list_sess) < int(n... |
Retrieve nb_sess sessions label randomly from the test project on XNAT
:param project: XNAT project
:return: list of sessions label
| Retrieve nb_sess sessions label randomly from the test project on XNAT | [
"Retrieve",
"nb_sess",
"sessions",
"label",
"randomly",
"from",
"the",
"test",
"project",
"on",
"XNAT"
] | def randomly_get_sessions(xnat, project, nb_sess=5):
sessions = list()
list_sess = XnatUtils.list_sessions(xnat, project)
if len(list_sess) < int(nb_sess):
sessions = [sess['label'] for sess in list_sess]
else:
for _ in range(int(nb_sess)):
session_added = False
w... | [
"def",
"randomly_get_sessions",
"(",
"xnat",
",",
"project",
",",
"nb_sess",
"=",
"5",
")",
":",
"sessions",
"=",
"list",
"(",
")",
"list_sess",
"=",
"XnatUtils",
".",
"list_sessions",
"(",
"xnat",
",",
"project",
")",
"if",
"len",
"(",
"list_sess",
")",... | Retrieve nb_sess sessions label randomly from the test project on XNAT | [
"Retrieve",
"nb_sess",
"sessions",
"label",
"randomly",
"from",
"the",
"test",
"project",
"on",
"XNAT"
] | [
"\"\"\"\n Retrieve nb_sess sessions label randomly from the test project on XNAT\n\n :param project: XNAT project\n :return: list of sessions label\n \"\"\""
] | [
{
"param": "xnat",
"type": null
},
{
"param": "project",
"type": null
},
{
"param": "nb_sess",
"type": null
}
] | {
"returns": [
{
"docstring": "list of sessions label",
"docstring_tokens": [
"list",
"of",
"sessions",
"label"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "xnat",
"type": null,
"docstring": null,
"doc... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | is_python_file | <not_specific> | def is_python_file(filepath):
"""
Check if a file is a python file using bash command file
:param filepath: path to the file to test
:return: True if it's a python file, False otherwise
"""
file_call = '''file {fpath}'''.format(fpath=filepath)
output = sb.check_output(file_call.split())
... |
Check if a file is a python file using bash command file
:param filepath: path to the file to test
:return: True if it's a python file, False otherwise
| Check if a file is a python file using bash command file | [
"Check",
"if",
"a",
"file",
"is",
"a",
"python",
"file",
"using",
"bash",
"command",
"file"
] | def is_python_file(filepath):
file_call = '''file {fpath}'''.format(fpath=filepath)
output = sb.check_output(file_call.split())
if 'python' in output.lower():
return True
return False | [
"def",
"is_python_file",
"(",
"filepath",
")",
":",
"file_call",
"=",
"'''file {fpath}'''",
".",
"format",
"(",
"fpath",
"=",
"filepath",
")",
"output",
"=",
"sb",
".",
"check_output",
"(",
"file_call",
".",
"split",
"(",
")",
")",
"if",
"'python'",
"in",
... | Check if a file is a python file using bash command file | [
"Check",
"if",
"a",
"file",
"is",
"a",
"python",
"file",
"using",
"bash",
"command",
"file"
] | [
"\"\"\"\n Check if a file is a python file using bash command file\n\n :param filepath: path to the file to test\n :return: True if it's a python file, False otherwise\n \"\"\""
] | [
{
"param": "filepath",
"type": null
}
] | {
"returns": [
{
"docstring": "True if it's a python file, False otherwise",
"docstring_tokens": [
"True",
"if",
"it",
"'",
"s",
"a",
"python",
"file",
"False",
"otherwise"
],
"type": null
}
],
"raises"... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | exists | <not_specific> | def exists(self):
"""Check if ini file exists.
:return: True if exists, False otherwise
"""
return os.path.isfile(self.settings_file) | Check if ini file exists.
:return: True if exists, False otherwise
| Check if ini file exists. | [
"Check",
"if",
"ini",
"file",
"exists",
"."
] | def exists(self):
return os.path.isfile(self.settings_file) | [
"def",
"exists",
"(",
"self",
")",
":",
"return",
"os",
".",
"path",
".",
"isfile",
"(",
"self",
".",
"settings_file",
")"
] | Check if ini file exists. | [
"Check",
"if",
"ini",
"file",
"exists",
"."
] | [
"\"\"\"Check if ini file exists.\n\n :return: True if exists, False otherwise\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if exists, False otherwise",
"docstring_tokens": [
"True",
"if",
"exists",
"False",
"otherwise"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | config | null | def config(self):
"""Config the configParser for each section and ask user for value.
Caller for all of the _get* methods.
:return: True if using default settings, False otherwise
"""
# For each section ask the user if he wants to edit it:
print('Starting to config the d... | Config the configParser for each section and ask user for value.
Caller for all of the _get* methods.
:return: True if using default settings, False otherwise
| Config the configParser for each section and ask user for value.
Caller for all of the _get* methods. | [
"Config",
"the",
"configParser",
"for",
"each",
"section",
"and",
"ask",
"user",
"for",
"value",
".",
"Caller",
"for",
"all",
"of",
"the",
"_get",
"*",
"methods",
"."
] | def config(self):
print('Starting to config the dax_settings.ini file:')
for section in self.config_parser.sections():
sys.stdout.write(' - Section: %s\n' % section)
qst = ' Do you want to set/modify the section [%s] in the \
settings file?' % section
modify = xna... | [
"def",
"config",
"(",
"self",
")",
":",
"print",
"(",
"'Starting to config the dax_settings.ini file:'",
")",
"for",
"section",
"in",
"self",
".",
"config_parser",
".",
"sections",
"(",
")",
":",
"sys",
".",
"stdout",
".",
"write",
"(",
"' - Section: %s\\n'",
... | Config the configParser for each section and ask user for value. | [
"Config",
"the",
"configParser",
"for",
"each",
"section",
"and",
"ask",
"user",
"for",
"value",
"."
] | [
"\"\"\"Config the configParser for each section and ask user for value.\n\n Caller for all of the _get* methods.\n :return: True if using default settings, False otherwise\n \"\"\"",
"# For each section ask the user if he wants to edit it:"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [
{
"docstring": "True if using default settings, False otherwise",
"docstring_tokens": [
"True",
"if",
"using",
"default",
"settings",
"False",
"otherwise"
],
"type": null
}
],
"raises": [],
"params": [
{
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | _prompt | <not_specific> | def _prompt(self, section, option):
"""Method to prompt a user for an input for the option in the template.
:param option: option name
:return: String of the input
"""
if option in list(OPTIONS_DESCRIPTION.keys()):
if 'confidential' in list(OPTIONS_DESCRIPTION[option... | Method to prompt a user for an input for the option in the template.
:param option: option name
:return: String of the input
| Method to prompt a user for an input for the option in the template. | [
"Method",
"to",
"prompt",
"a",
"user",
"for",
"an",
"input",
"for",
"the",
"option",
"in",
"the",
"template",
"."
] | def _prompt(self, section, option):
if option in list(OPTIONS_DESCRIPTION.keys()):
if 'confidential' in list(OPTIONS_DESCRIPTION[option].keys()):
msg = OPTIONS_DESCRIPTION[option]['msg']
stdin = getpass.getpass(prompt=msg)
else:
stdin = inp... | [
"def",
"_prompt",
"(",
"self",
",",
"section",
",",
"option",
")",
":",
"if",
"option",
"in",
"list",
"(",
"OPTIONS_DESCRIPTION",
".",
"keys",
"(",
")",
")",
":",
"if",
"'confidential'",
"in",
"list",
"(",
"OPTIONS_DESCRIPTION",
"[",
"option",
"]",
".",
... | Method to prompt a user for an input for the option in the template. | [
"Method",
"to",
"prompt",
"a",
"user",
"for",
"an",
"input",
"for",
"the",
"option",
"in",
"the",
"template",
"."
] | [
"\"\"\"Method to prompt a user for an input for the option in the template.\n\n :param option: option name\n :return: String of the input\n \"\"\""
] | [
{
"param": "self",
"type": null
},
{
"param": "section",
"type": null
},
{
"param": "option",
"type": null
}
] | {
"returns": [
{
"docstring": "String of the input",
"docstring_tokens": [
"String",
"of",
"the",
"input"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | _set_cluster_default | null | def _set_cluster_default(self, ctype=False):
"""Use the default cluster settings from the cluster type selected.
:param ctype: True if set to default
:return: None
"""
cluster_type = '0'
while cluster_type not in ['1', '2', '3']:
cluster_type = input("Which c... | Use the default cluster settings from the cluster type selected.
:param ctype: True if set to default
:return: None
| Use the default cluster settings from the cluster type selected. | [
"Use",
"the",
"default",
"cluster",
"settings",
"from",
"the",
"cluster",
"type",
"selected",
"."
] | def _set_cluster_default(self, ctype=False):
cluster_type = '0'
while cluster_type not in ['1', '2', '3']:
cluster_type = input("Which cluster are you using? \
[1.SGE 2.SLURM 3.MOAB] ")
sys.stdout.write('Warning: You can edit the cluster templates files \
at any time in ~/.dax_templa... | [
"def",
"_set_cluster_default",
"(",
"self",
",",
"ctype",
"=",
"False",
")",
":",
"cluster_type",
"=",
"'0'",
"while",
"cluster_type",
"not",
"in",
"[",
"'1'",
",",
"'2'",
",",
"'3'",
"]",
":",
"cluster_type",
"=",
"input",
"(",
"\"Which cluster are you usin... | Use the default cluster settings from the cluster type selected. | [
"Use",
"the",
"default",
"cluster",
"settings",
"from",
"the",
"cluster",
"type",
"selected",
"."
] | [
"\"\"\"Use the default cluster settings from the cluster type selected.\n\n :param ctype: True if set to default\n :return: None\n \"\"\"",
"# Copy the files from the template:"
] | [
{
"param": "self",
"type": null
},
{
"param": "ctype",
"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
... |
f83682bdd7dfa3ffcdfd9ebebcc037016246ca29 | atbenmurray/dax | dax/dax_tools_utils.py | [
"MIT"
] | Python | init_profile | null | def init_profile(host):
"""Function to init your profile file to call xnat_profile.
:param host: Host of XNAT to add to your profile
:return: None
"""
# link the file in the bashrc or profile
profile = os.path.join(os.path.expanduser('~'), '.bash_profile')
if os.path.exists(os.path.join(os... | Function to init your profile file to call xnat_profile.
:param host: Host of XNAT to add to your profile
:return: None
| Function to init your profile file to call xnat_profile. | [
"Function",
"to",
"init",
"your",
"profile",
"file",
"to",
"call",
"xnat_profile",
"."
] | def init_profile(host):
profile = os.path.join(os.path.expanduser('~'), '.bash_profile')
if os.path.exists(os.path.join(os.path.expanduser('~'), '.bash_profile')):
profile = os.path.join(os.path.expanduser('~'), '.bash_profile')
elif os.path.exists(os.path.join(os.path.expanduser('~'), '.bashrc')):
... | [
"def",
"init_profile",
"(",
"host",
")",
":",
"profile",
"=",
"os",
".",
"path",
".",
"join",
"(",
"os",
".",
"path",
".",
"expanduser",
"(",
"'~'",
")",
",",
"'.bash_profile'",
")",
"if",
"os",
".",
"path",
".",
"exists",
"(",
"os",
".",
"path",
... | Function to init your profile file to call xnat_profile. | [
"Function",
"to",
"init",
"your",
"profile",
"file",
"to",
"call",
"xnat_profile",
"."
] | [
"\"\"\"Function to init your profile file to call xnat_profile.\n\n :param host: Host of XNAT to add to your profile\n :return: None\n \"\"\"",
"# link the file in the bashrc or profile",
"# Add the line to the profile"
] | [
{
"param": "host",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "host",
"type": null,
"docstring": "Host of XNAT to add to your profile",
"docstring_tokens": [
"Host",
... |
4d683648f5fce2ef9e285e3a97598263a6f08215 | krishnaganjigatti/recordlinkage | recordlinkage/contrib/index/neighbourhoodblock/neighbourhoodblock_test.py | [
"BSD-3-Clause"
] | Python | incomplete_df_copy | <not_specific> | def incomplete_df_copy(df, nan_proportion=0.1):
'copy of DataFrame with some cells set to NaN'
nan_count = int(round(len(df) * nan_proportion))
def with_nulls(vals):
vals = vals.copy()
vals.iloc[np.random.choice(
len(df), size=nan_... | copy of DataFrame with some cells set to NaN | copy of DataFrame with some cells set to NaN | [
"copy",
"of",
"DataFrame",
"with",
"some",
"cells",
"set",
"to",
"NaN"
] | def incomplete_df_copy(df, nan_proportion=0.1):
nan_count = int(round(len(df) * nan_proportion))
def with_nulls(vals):
vals = vals.copy()
vals.iloc[np.random.choice(
len(df), size=nan_count, replace=False)] = np.nan
return vals
... | [
"def",
"incomplete_df_copy",
"(",
"df",
",",
"nan_proportion",
"=",
"0.1",
")",
":",
"nan_count",
"=",
"int",
"(",
"round",
"(",
"len",
"(",
"df",
")",
"*",
"nan_proportion",
")",
")",
"def",
"with_nulls",
"(",
"vals",
")",
":",
"vals",
"=",
"vals",
... | copy of DataFrame with some cells set to NaN | [
"copy",
"of",
"DataFrame",
"with",
"some",
"cells",
"set",
"to",
"NaN"
] | [
"'copy of DataFrame with some cells set to NaN'"
] | [
{
"param": "df",
"type": null
},
{
"param": "nan_proportion",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "df",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "nan_proportion",
"type": null,
"docstring": null,
"docstring_to... |
4617c00f77aad7afcea858f94918a72a812893db | samiraabnar/lm_1b_fullgraph | lm1b/model/vocab_nodes.py | [
"MIT"
] | Python | attach_vocab_nodes | <not_specific> | def attach_vocab_nodes( vocab_path, hparams ):
"""
Attach vocab nodes for looking up word or char IDs
:param vocab_path:
:param hparams:
:return:
"""
lookup_id_to_word=lookup_ops.index_to_string_table_from_file(vocab_path,default_value=hparams.tokens_unknown)
lookup_word_to_id= lookup_op... |
Attach vocab nodes for looking up word or char IDs
:param vocab_path:
:param hparams:
:return:
| Attach vocab nodes for looking up word or char IDs | [
"Attach",
"vocab",
"nodes",
"for",
"looking",
"up",
"word",
"or",
"char",
"IDs"
] | def attach_vocab_nodes( vocab_path, hparams ):
lookup_id_to_word=lookup_ops.index_to_string_table_from_file(vocab_path,default_value=hparams.tokens_unknown)
lookup_word_to_id= lookup_ops.index_table_from_file(vocab_path, default_value=-1)
all_chars = list(map( lambda i: chr( i ), range( 0, 255 )))
print... | [
"def",
"attach_vocab_nodes",
"(",
"vocab_path",
",",
"hparams",
")",
":",
"lookup_id_to_word",
"=",
"lookup_ops",
".",
"index_to_string_table_from_file",
"(",
"vocab_path",
",",
"default_value",
"=",
"hparams",
".",
"tokens_unknown",
")",
"lookup_word_to_id",
"=",
"lo... | Attach vocab nodes for looking up word or char IDs | [
"Attach",
"vocab",
"nodes",
"for",
"looking",
"up",
"word",
"or",
"char",
"IDs"
] | [
"\"\"\"\n Attach vocab nodes for looking up word or char IDs\n :param vocab_path:\n :param hparams:\n :return:\n \"\"\""
] | [
{
"param": "vocab_path",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "vocab_path",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
ea7558dedafdca5a7e8219aa5d2b10b54a487bcd | samiraabnar/lm_1b_fullgraph | lm1b/model/char_embedding_nodes.py | [
"MIT"
] | Python | attach_char_embedding_nodes | <not_specific> | def attach_char_embedding_nodes( char_inputs, num_shards, hparams=None ):
"""
Char CNN, encode character representations to ~ word embeddings.
Based on: https://arxiv.org/abs/1508.06615
(see also: https://github.com/mkroutikov/tf-lstm-char-cnn)
:param char_inputs: [?,max_word_length] tensor of ... |
Char CNN, encode character representations to ~ word embeddings.
Based on: https://arxiv.org/abs/1508.06615
(see also: https://github.com/mkroutikov/tf-lstm-char-cnn)
:param char_inputs: [?,max_word_length] tensor of token character arrays
:param hparams:
:return: [hparams.batch_size, hpar... | Char CNN, encode character representations to ~ word embeddings. | [
"Char",
"CNN",
"encode",
"character",
"representations",
"to",
"~",
"word",
"embeddings",
"."
] | def attach_char_embedding_nodes( char_inputs, num_shards, hparams=None ):
char_embeddings_lookup = tf.get_variable( "W", shape=(hparams.char_vocab_size, hparams.char_embedding_size),
dtype=tf.float32,
initializer=tf.random_u... | [
"def",
"attach_char_embedding_nodes",
"(",
"char_inputs",
",",
"num_shards",
",",
"hparams",
"=",
"None",
")",
":",
"char_embeddings_lookup",
"=",
"tf",
".",
"get_variable",
"(",
"\"W\"",
",",
"shape",
"=",
"(",
"hparams",
".",
"char_vocab_size",
",",
"hparams",... | Char CNN, encode character representations to ~ word embeddings. | [
"Char",
"CNN",
"encode",
"character",
"representations",
"to",
"~",
"word",
"embeddings",
"."
] | [
"\"\"\"\n Char CNN, encode character representations to ~ word embeddings.\n Based on: https://arxiv.org/abs/1508.06615\n (see also: https://github.com/mkroutikov/tf-lstm-char-cnn)\n\n :param char_inputs: [?,max_word_length] tensor of token character arrays\n :param hparams:\n :return: [hparam... | [
{
"param": "char_inputs",
"type": null
},
{
"param": "num_shards",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "char_inputs",
"type": null,
"docstring": "[?,max_word_length] tensor of token character arrays",
"docstring_tokens"... |
69caeb4fb74aa02195252c9355b387491f6a73f3 | samiraabnar/lm_1b_fullgraph | lm1b/utils/model.py | [
"MIT"
] | Python | create_sharded_weights | <not_specific> | def create_sharded_weights( shape, num_shards, name="W", concat_dim=0 ):
"""
todo: see if tf's built in variable sharding can replace
:param shape:
:param num_shards:
:param name:
:param concat_dim:
:return:
"""
weights = []
for i in range( 0, num_shards ):
cur_w = tf.ge... |
todo: see if tf's built in variable sharding can replace
:param shape:
:param num_shards:
:param name:
:param concat_dim:
:return:
| see if tf's built in variable sharding can replace | [
"see",
"if",
"tf",
"'",
"s",
"built",
"in",
"variable",
"sharding",
"can",
"replace"
] | def create_sharded_weights( shape, num_shards, name="W", concat_dim=0 ):
weights = []
for i in range( 0, num_shards ):
cur_w = tf.get_variable( name + "_" + str( i ), shape=shape,
initializer=tf.random_normal_initializer,
dtype=tf.float32... | [
"def",
"create_sharded_weights",
"(",
"shape",
",",
"num_shards",
",",
"name",
"=",
"\"W\"",
",",
"concat_dim",
"=",
"0",
")",
":",
"weights",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"0",
",",
"num_shards",
")",
":",
"cur_w",
"=",
"tf",
".",
... | todo: see if tf's built in variable sharding can replace | [
"todo",
":",
"see",
"if",
"tf",
"'",
"s",
"built",
"in",
"variable",
"sharding",
"can",
"replace"
] | [
"\"\"\"\n todo: see if tf's built in variable sharding can replace\n :param shape:\n :param num_shards:\n :param name:\n :param concat_dim:\n :return:\n \"\"\""
] | [
{
"param": "shape",
"type": null
},
{
"param": "num_shards",
"type": null
},
{
"param": "name",
"type": null
},
{
"param": "concat_dim",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "shape",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
69caeb4fb74aa02195252c9355b387491f6a73f3 | samiraabnar/lm_1b_fullgraph | lm1b/utils/model.py | [
"MIT"
] | Python | sharded_linear | <not_specific> | def sharded_linear( input, shape, num_shards ):
"""
todo: see if tf's built in variable sharding can replace
:param input:
:param shape:
:param num_shards:
:return:
"""
w = create_sharded_weights( shape, num_shards=num_shards )
b = tf.get_variable( "b", shape=(1, shape[1],), dtype=tf... |
todo: see if tf's built in variable sharding can replace
:param input:
:param shape:
:param num_shards:
:return:
| see if tf's built in variable sharding can replace | [
"see",
"if",
"tf",
"'",
"s",
"built",
"in",
"variable",
"sharding",
"can",
"replace"
] | def sharded_linear( input, shape, num_shards ):
w = create_sharded_weights( shape, num_shards=num_shards )
b = tf.get_variable( "b", shape=(1, shape[1],), dtype=tf.float32 )
return tf.matmul( input, w ) + b | [
"def",
"sharded_linear",
"(",
"input",
",",
"shape",
",",
"num_shards",
")",
":",
"w",
"=",
"create_sharded_weights",
"(",
"shape",
",",
"num_shards",
"=",
"num_shards",
")",
"b",
"=",
"tf",
".",
"get_variable",
"(",
"\"b\"",
",",
"shape",
"=",
"(",
"1",... | todo: see if tf's built in variable sharding can replace | [
"todo",
":",
"see",
"if",
"tf",
"'",
"s",
"built",
"in",
"variable",
"sharding",
"can",
"replace"
] | [
"\"\"\"\n todo: see if tf's built in variable sharding can replace\n :param input:\n :param shape:\n :param num_shards:\n :return:\n \"\"\""
] | [
{
"param": "input",
"type": null
},
{
"param": "shape",
"type": null
},
{
"param": "num_shards",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "input",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
b8794fd5fa7639a25cde7c9074fbdb8d047beaf5 | samiraabnar/lm_1b_fullgraph | lm1b/utils/vocab.py | [
"MIT"
] | Python | encode_token | <not_specific> | def encode_token( token, char_to_id_lookup_table, hparams ):
"""
Encode a word to a padded vector of character IDs
:param token: tensor of strings representing single word / tokens
:param char_to_id_lookup_table: Lookup table mapping characters to ids. See utils.vocab for reference
:param hparams:
... |
Encode a word to a padded vector of character IDs
:param token: tensor of strings representing single word / tokens
:param char_to_id_lookup_table: Lookup table mapping characters to ids. See utils.vocab for reference
:param hparams:
:return: tensor of shape [len(token), max_word_length], represen... | Encode a word to a padded vector of character IDs | [
"Encode",
"a",
"word",
"to",
"a",
"padded",
"vector",
"of",
"character",
"IDs"
] | def encode_token( token, char_to_id_lookup_table, hparams ):
max_word_length = hparams.max_word_length
chars_padding_id = hparams.chars_padding_id
tokens_bos = hparams.tokens_bos
tokens_eos = hparams.tokens_eos
chars_bow_id = hparams.chars_bow_id
chars_eow_id = hparams.chars_eow_id
s... | [
"def",
"encode_token",
"(",
"token",
",",
"char_to_id_lookup_table",
",",
"hparams",
")",
":",
"max_word_length",
"=",
"hparams",
".",
"max_word_length",
"chars_padding_id",
"=",
"hparams",
".",
"chars_padding_id",
"tokens_bos",
"=",
"hparams",
".",
"tokens_bos",
"t... | Encode a word to a padded vector of character IDs | [
"Encode",
"a",
"word",
"to",
"a",
"padded",
"vector",
"of",
"character",
"IDs"
] | [
"\"\"\"\n Encode a word to a padded vector of character IDs\n\n :param token: tensor of strings representing single word / tokens\n :param char_to_id_lookup_table: Lookup table mapping characters to ids. See utils.vocab for reference\n :param hparams:\n :return: tensor of shape [len(token), max_word_... | [
{
"param": "token",
"type": null
},
{
"param": "char_to_id_lookup_table",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": "tensor of shape [len(token), max_word_length], representing each word as a vector of character IDs",
"docstring_tokens": [
"tensor",
"of",
"shape",
"[",
"len",
"(",
"token",
")",
"max_word_length",
... |
b8794fd5fa7639a25cde7c9074fbdb8d047beaf5 | samiraabnar/lm_1b_fullgraph | lm1b/utils/vocab.py | [
"MIT"
] | Python | encode_sequence | <not_specific> | def encode_sequence( seq, char_to_id_lookup_table, hparams ):
"""
Encode strings to padded character vectors.
Note: Original model didn't pad sequences, it was trained with one long sequences of sentences concated together.
Will need to do something slightly different for re-training.
:param seq: ... |
Encode strings to padded character vectors.
Note: Original model didn't pad sequences, it was trained with one long sequences of sentences concated together.
Will need to do something slightly different for re-training.
:param seq: tensor of strings representing a sequence of words (e.g. a sentence).... | Encode strings to padded character vectors.
Note: Original model didn't pad sequences, it was trained with one long sequences of sentences concated together.
Will need to do something slightly different for re-training. | [
"Encode",
"strings",
"to",
"padded",
"character",
"vectors",
".",
"Note",
":",
"Original",
"model",
"didn",
"'",
"t",
"pad",
"sequences",
"it",
"was",
"trained",
"with",
"one",
"long",
"sequences",
"of",
"sentences",
"concated",
"together",
".",
"Will",
"nee... | def encode_sequence( seq, char_to_id_lookup_table, hparams ):
sequence_length = hparams.sequence_length
seq = tf.string_split( seq )
seq = tf.sparse_tensor_to_dense( seq, default_value=hparams.tokens_padding )
seq_padding = tf.fill( [sequence_length], tf.constant( hparams.tokens_padding ) )
seq = tf... | [
"def",
"encode_sequence",
"(",
"seq",
",",
"char_to_id_lookup_table",
",",
"hparams",
")",
":",
"sequence_length",
"=",
"hparams",
".",
"sequence_length",
"seq",
"=",
"tf",
".",
"string_split",
"(",
"seq",
")",
"seq",
"=",
"tf",
".",
"sparse_tensor_to_dense",
... | Encode strings to padded character vectors. | [
"Encode",
"strings",
"to",
"padded",
"character",
"vectors",
"."
] | [
"\"\"\"\n Encode strings to padded character vectors.\n\n Note: Original model didn't pad sequences, it was trained with one long sequences of sentences concated together.\n Will need to do something slightly different for re-training.\n\n :param seq: tensor of strings representing a sequence of words (... | [
{
"param": "seq",
"type": null
},
{
"param": "char_to_id_lookup_table",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "seq",
"type": null,
"docstring": "tensor of strings representing a sequence of words . Should typically be wrapped with\n... |
f1c26f56098c1fdf4e7e91ad418ea6afa74bea82 | samiraabnar/lm_1b_fullgraph | lm1b/model/model_nodes.py | [
"MIT"
] | Python | _attach_projection_nodes | <not_specific> | def _attach_projection_nodes(input, hparams=None):
"""
Project LSTM outputs to sparse vectors / word predictions
:param input: lstm outputs
:param hparams:
:return: tensor shaped [?,vocab_size]
"""
softmax_w = create_sharded_weights((hparams.vocab_size / NUM_SHARDS, hparams.word_embedding_size),
... |
Project LSTM outputs to sparse vectors / word predictions
:param input: lstm outputs
:param hparams:
:return: tensor shaped [?,vocab_size]
| Project LSTM outputs to sparse vectors / word predictions | [
"Project",
"LSTM",
"outputs",
"to",
"sparse",
"vectors",
"/",
"word",
"predictions"
] | def _attach_projection_nodes(input, hparams=None):
softmax_w = create_sharded_weights((hparams.vocab_size / NUM_SHARDS, hparams.word_embedding_size),
num_shards=NUM_SHARDS,
concat_dim=1)
softmax_w = tf.reshape(softmax_w, shape=(-1, hparams.wo... | [
"def",
"_attach_projection_nodes",
"(",
"input",
",",
"hparams",
"=",
"None",
")",
":",
"softmax_w",
"=",
"create_sharded_weights",
"(",
"(",
"hparams",
".",
"vocab_size",
"/",
"NUM_SHARDS",
",",
"hparams",
".",
"word_embedding_size",
")",
",",
"num_shards",
"="... | Project LSTM outputs to sparse vectors / word predictions | [
"Project",
"LSTM",
"outputs",
"to",
"sparse",
"vectors",
"/",
"word",
"predictions"
] | [
"\"\"\"\n Project LSTM outputs to sparse vectors / word predictions\n :param input: lstm outputs\n :param hparams:\n :return: tensor shaped [?,vocab_size]\n \"\"\""
] | [
{
"param": "input",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": "tensor shaped [?,vocab_size]",
"docstring_tokens": [
"tensor",
"shaped",
"[",
"?",
"vocab_size",
"]"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "input",
"type": null... |
f1c26f56098c1fdf4e7e91ad418ea6afa74bea82 | samiraabnar/lm_1b_fullgraph | lm1b/model/model_nodes.py | [
"MIT"
] | Python | attach_inference_nodes | <not_specific> | def attach_inference_nodes(input_seqs, hparams=None):
"""
Predict next word for each sequence / timestep in input_seqs
:param input_seqs: tensor of character encoded words
:param hparams:
:return: dict of inference nodes
"""
with tf.variable_scope(CHAR_EMBEDDING_SCOPE):
word_embeddings = char_embeddin... |
Predict next word for each sequence / timestep in input_seqs
:param input_seqs: tensor of character encoded words
:param hparams:
:return: dict of inference nodes
| Predict next word for each sequence / timestep in input_seqs | [
"Predict",
"next",
"word",
"for",
"each",
"sequence",
"/",
"timestep",
"in",
"input_seqs"
] | def attach_inference_nodes(input_seqs, hparams=None):
with tf.variable_scope(CHAR_EMBEDDING_SCOPE):
word_embeddings = char_embedding_nodes.attach_char_embedding_nodes(input_seqs, num_shards=NUM_SHARDS,
hparams=hparams)
word_embeddings = tf... | [
"def",
"attach_inference_nodes",
"(",
"input_seqs",
",",
"hparams",
"=",
"None",
")",
":",
"with",
"tf",
".",
"variable_scope",
"(",
"CHAR_EMBEDDING_SCOPE",
")",
":",
"word_embeddings",
"=",
"char_embedding_nodes",
".",
"attach_char_embedding_nodes",
"(",
"input_seqs"... | Predict next word for each sequence / timestep in input_seqs | [
"Predict",
"next",
"word",
"for",
"each",
"sequence",
"/",
"timestep",
"in",
"input_seqs"
] | [
"\"\"\"\n Predict next word for each sequence / timestep in input_seqs\n :param input_seqs: tensor of character encoded words\n :param hparams:\n :return: dict of inference nodes\n \"\"\""
] | [
{
"param": "input_seqs",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": "dict of inference nodes",
"docstring_tokens": [
"dict",
"of",
"inference",
"nodes"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "input_seqs",
"type": null,
"docstring": "tensor ... |
f1c26f56098c1fdf4e7e91ad418ea6afa74bea82 | samiraabnar/lm_1b_fullgraph | lm1b/model/model_nodes.py | [
"MIT"
] | Python | attach_predicted_word_nodes | <not_specific> | def attach_predicted_word_nodes(logits, id_to_word_lookup_table, k=5, hparams=None):
"""
Helper to pull out the most likely words
:param logits:
:param id_to_word_lookup_table:
:param k:
:param hparams:
:return:
"""
top_k = tf.nn.top_k(logits, k)
top_word_ids = top_k.indices
word_predictions = tf.... |
Helper to pull out the most likely words
:param logits:
:param id_to_word_lookup_table:
:param k:
:param hparams:
:return:
| Helper to pull out the most likely words | [
"Helper",
"to",
"pull",
"out",
"the",
"most",
"likely",
"words"
] | def attach_predicted_word_nodes(logits, id_to_word_lookup_table, k=5, hparams=None):
top_k = tf.nn.top_k(logits, k)
top_word_ids = top_k.indices
word_predictions = tf.reshape(id_to_word_lookup_table.lookup(tf.to_int64(tf.reshape(top_word_ids, [-1]))), [-1, k])
return {"predicted_words": word_predictions,
... | [
"def",
"attach_predicted_word_nodes",
"(",
"logits",
",",
"id_to_word_lookup_table",
",",
"k",
"=",
"5",
",",
"hparams",
"=",
"None",
")",
":",
"top_k",
"=",
"tf",
".",
"nn",
".",
"top_k",
"(",
"logits",
",",
"k",
")",
"top_word_ids",
"=",
"top_k",
".",
... | Helper to pull out the most likely words | [
"Helper",
"to",
"pull",
"out",
"the",
"most",
"likely",
"words"
] | [
"\"\"\"\n Helper to pull out the most likely words\n :param logits:\n :param id_to_word_lookup_table:\n :param k:\n :param hparams:\n :return:\n \"\"\""
] | [
{
"param": "logits",
"type": null
},
{
"param": "id_to_word_lookup_table",
"type": null
},
{
"param": "k",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "logits",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
f1c26f56098c1fdf4e7e91ad418ea6afa74bea82 | samiraabnar/lm_1b_fullgraph | lm1b/model/model_nodes.py | [
"MIT"
] | Python | attach_training_nodes | <not_specific> | def attach_training_nodes(loss, hparams=None):
"""
Attach nodes for training. Work in progress...
:param loss:
:param hparams:
:return:
"""
trainable_vars = tf.trainable_variables()
tf.get_collection(tf.GraphKeys.MODEL_VARIABLES, scope="")
tf.global_variables()
all_gradients = tf.gradients(loss, tra... |
Attach nodes for training. Work in progress...
:param loss:
:param hparams:
:return:
| Attach nodes for training. Work in progress | [
"Attach",
"nodes",
"for",
"training",
".",
"Work",
"in",
"progress"
] | def attach_training_nodes(loss, hparams=None):
trainable_vars = tf.trainable_variables()
tf.get_collection(tf.GraphKeys.MODEL_VARIABLES, scope="")
tf.global_variables()
all_gradients = tf.gradients(loss, trainable_vars)
lstm_gradients = filter(lambda x: -1 < x.op.name.find("lstm"), all_gradients)
non_lstm_g... | [
"def",
"attach_training_nodes",
"(",
"loss",
",",
"hparams",
"=",
"None",
")",
":",
"trainable_vars",
"=",
"tf",
".",
"trainable_variables",
"(",
")",
"tf",
".",
"get_collection",
"(",
"tf",
".",
"GraphKeys",
".",
"MODEL_VARIABLES",
",",
"scope",
"=",
"\"\""... | Attach nodes for training. | [
"Attach",
"nodes",
"for",
"training",
"."
] | [
"\"\"\"\n Attach nodes for training. Work in progress...\n :param loss:\n :param hparams:\n :return:\n \"\"\""
] | [
{
"param": "loss",
"type": null
},
{
"param": "hparams",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "loss",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
f1c26f56098c1fdf4e7e91ad418ea6afa74bea82 | samiraabnar/lm_1b_fullgraph | lm1b/model/model_nodes.py | [
"MIT"
] | Python | restore_original_lm1b | <not_specific> | def restore_original_lm1b(sess, run_config):
"""
Var mapping shenanigans to restore the pre-trained model to the current graph
:param sess:
:param run_config:
:return:
"""
def create_lm1b_restoration_var_map(char_embedding_vars, lstm_vars, softmax_vars):
var_map = {}
# Map char embedding vars
... |
Var mapping shenanigans to restore the pre-trained model to the current graph
:param sess:
:param run_config:
:return:
| Var mapping shenanigans to restore the pre-trained model to the current graph | [
"Var",
"mapping",
"shenanigans",
"to",
"restore",
"the",
"pre",
"-",
"trained",
"model",
"to",
"the",
"current",
"graph"
] | def restore_original_lm1b(sess, run_config):
def create_lm1b_restoration_var_map(char_embedding_vars, lstm_vars, softmax_vars):
var_map = {}
var_map = merge(var_map, dict(map(lambda x: (x.op.name, x), char_embedding_vars)))
var_map_regexes = {r"^(" + LSTM_SCOPE_PREFIX + "\d)/lstm_cell/projection/kernel/pa... | [
"def",
"restore_original_lm1b",
"(",
"sess",
",",
"run_config",
")",
":",
"def",
"create_lm1b_restoration_var_map",
"(",
"char_embedding_vars",
",",
"lstm_vars",
",",
"softmax_vars",
")",
":",
"var_map",
"=",
"{",
"}",
"var_map",
"=",
"merge",
"(",
"var_map",
",... | Var mapping shenanigans to restore the pre-trained model to the current graph | [
"Var",
"mapping",
"shenanigans",
"to",
"restore",
"the",
"pre",
"-",
"trained",
"model",
"to",
"the",
"current",
"graph"
] | [
"\"\"\"\n Var mapping shenanigans to restore the pre-trained model to the current graph\n :param sess:\n :param run_config:\n :return:\n \"\"\"",
"# Map char embedding vars",
"# Map lstm embedding vars",
"# Map softmax embedding vars"
] | [
{
"param": "sess",
"type": null
},
{
"param": "run_config",
"type": null
}
] | {
"returns": [
{
"docstring": null,
"docstring_tokens": [
"None"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier": "sess",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
... |
9cb26331a7ea7a330e3d1450146963e2945dd083 | samiraabnar/lm_1b_fullgraph | model_consistency_test.py | [
"MIT"
] | Python | _SampleModel | null | def _SampleModel(prefix_words, vocab):
"""Predict next words using the given prefix words.
Args:
prefix_words: Prefix words.
vocab: Vocabulary. Contains max word chard id length and converts between
words and ids.
"""
targets = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
weights = np.ones(... | Predict next words using the given prefix words.
Args:
prefix_words: Prefix words.
vocab: Vocabulary. Contains max word chard id length and converts between
words and ids.
| Predict next words using the given prefix words. | [
"Predict",
"next",
"words",
"using",
"the",
"given",
"prefix",
"words",
"."
] | def _SampleModel(prefix_words, vocab):
targets = np.zeros([BATCH_SIZE, NUM_TIMESTEPS], np.int32)
weights = np.ones([BATCH_SIZE, NUM_TIMESTEPS], np.float32)
sess, t, input = _LoadModel()
if prefix_words.find('<S>') != 0:
prefix_words = '<S> ' + prefix_words
prefix = [vocab.word_to_id(w) for w in prefix_wor... | [
"def",
"_SampleModel",
"(",
"prefix_words",
",",
"vocab",
")",
":",
"targets",
"=",
"np",
".",
"zeros",
"(",
"[",
"BATCH_SIZE",
",",
"NUM_TIMESTEPS",
"]",
",",
"np",
".",
"int32",
")",
"weights",
"=",
"np",
".",
"ones",
"(",
"[",
"BATCH_SIZE",
",",
"... | Predict next words using the given prefix words. | [
"Predict",
"next",
"words",
"using",
"the",
"given",
"prefix",
"words",
"."
] | [
"\"\"\"Predict next words using the given prefix words.\n Args:\n prefix_words: Prefix words.\n vocab: Vocabulary. Contains max word chard id length and converts between\n words and ids.\n \"\"\""
] | [
{
"param": "prefix_words",
"type": null
},
{
"param": "vocab",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "prefix_words",
"type": null,
"docstring": null,
"docstring_tokens": [
"None"
],
"default": null,
"is_optional": null
},
{
"identifier": "vocab",
"type": null,
"docstring": "V... |
8dd32b627ffd981b730c3bdb6deee341d0363c2b | isaacazuelos/wiggler | code.py | [
"MIT"
] | Python | tick | <not_specific> | def tick(self):
""" This method should be called in the main loop. It looks
at the `previous` state and if the button `is_active`, and
then calls the correct callbacks.
This will return the result of any callback called.
"""
current = self.is_active()
if curr... | This method should be called in the main loop. It looks
at the `previous` state and if the button `is_active`, and
then calls the correct callbacks.
This will return the result of any callback called.
| This method should be called in the main loop. It looks
at the `previous` state and if the button `is_active`, and
then calls the correct callbacks.
This will return the result of any callback called. | [
"This",
"method",
"should",
"be",
"called",
"in",
"the",
"main",
"loop",
".",
"It",
"looks",
"at",
"the",
"`",
"previous",
"`",
"state",
"and",
"if",
"the",
"button",
"`",
"is_active",
"`",
"and",
"then",
"calls",
"the",
"correct",
"callbacks",
".",
"T... | def tick(self):
current = self.is_active()
if current and not self.previous:
print("{} was pressed".format(self.name))
result = self.on_press()
elif current and self.previous:
print("{} is held".format(self.name))
result = self.on_held()
el... | [
"def",
"tick",
"(",
"self",
")",
":",
"current",
"=",
"self",
".",
"is_active",
"(",
")",
"if",
"current",
"and",
"not",
"self",
".",
"previous",
":",
"print",
"(",
"\"{} was pressed\"",
".",
"format",
"(",
"self",
".",
"name",
")",
")",
"result",
"=... | This method should be called in the main loop. | [
"This",
"method",
"should",
"be",
"called",
"in",
"the",
"main",
"loop",
"."
] | [
"\"\"\" This method should be called in the main loop. It looks \n at the `previous` state and if the button `is_active`, and \n then calls the correct callbacks.\n\n This will return the result of any callback called.\n \"\"\"",
"# so previous is correctly tracked for next tick"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8dd32b627ffd981b730c3bdb6deee341d0363c2b | isaacazuelos/wiggler | code.py | [
"MIT"
] | Python | next_colour | <not_specific> | def next_colour(c):
""" Takes a colour and returns the next stoplight colour, in the
following order: `RED`, `YELLOW`, `GREEN`.
Will return `RED` as the next colour for unrecognized colours.
"""
if c == RED:
return YELLOW
elif c == YELLOW:
return GREEN
else:
return ... | Takes a colour and returns the next stoplight colour, in the
following order: `RED`, `YELLOW`, `GREEN`.
Will return `RED` as the next colour for unrecognized colours.
|
Will return `RED` as the next colour for unrecognized colours. | [
"Will",
"return",
"`",
"RED",
"`",
"as",
"the",
"next",
"colour",
"for",
"unrecognized",
"colours",
"."
] | def next_colour(c):
if c == RED:
return YELLOW
elif c == YELLOW:
return GREEN
else:
return RED | [
"def",
"next_colour",
"(",
"c",
")",
":",
"if",
"c",
"==",
"RED",
":",
"return",
"YELLOW",
"elif",
"c",
"==",
"YELLOW",
":",
"return",
"GREEN",
"else",
":",
"return",
"RED"
] | Takes a colour and returns the next stoplight colour, in the
following order: `RED`, `YELLOW`, `GREEN`. | [
"Takes",
"a",
"colour",
"and",
"returns",
"the",
"next",
"stoplight",
"colour",
"in",
"the",
"following",
"order",
":",
"`",
"RED",
"`",
"`",
"YELLOW",
"`",
"`",
"GREEN",
"`",
"."
] | [
"\"\"\" Takes a colour and returns the next stoplight colour, in the\n following order: `RED`, `YELLOW`, `GREEN`.\n\n Will return `RED` as the next colour for unrecognized colours.\n \"\"\""
] | [
{
"param": "c",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "c",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8dd32b627ffd981b730c3bdb6deee341d0363c2b | isaacazuelos/wiggler | code.py | [
"MIT"
] | Python | wiggle | null | def wiggle(mouse):
""" Wiggles the `mouse` around.
Makes `MOVES_PER_WIGGLE` moves, going at most `MAX_WIGGLE_DISTANCE`
in either direction horizontally and vertically.
In testing, the wigging was annoying since it would jump the cursor
away from the path I had it on, so there's an extra final move... | Wiggles the `mouse` around.
Makes `MOVES_PER_WIGGLE` moves, going at most `MAX_WIGGLE_DISTANCE`
in either direction horizontally and vertically.
In testing, the wigging was annoying since it would jump the cursor
away from the path I had it on, so there's an extra final move back
towards the ori... | Wiggles the `mouse` around.
Makes `MOVES_PER_WIGGLE` moves, going at most `MAX_WIGGLE_DISTANCE`
in either direction horizontally and vertically.
In testing, the wigging was annoying since it would jump the cursor
away from the path I had it on, so there's an extra final move back
towards the original coordinates. | [
"Wiggles",
"the",
"`",
"mouse",
"`",
"around",
".",
"Makes",
"`",
"MOVES_PER_WIGGLE",
"`",
"moves",
"going",
"at",
"most",
"`",
"MAX_WIGGLE_DISTANCE",
"`",
"in",
"either",
"direction",
"horizontally",
"and",
"vertically",
".",
"In",
"testing",
"the",
"wigging"... | def wiggle(mouse):
print("wiggle!")
dx = 0
dy = 0
for _ in range(MOVES_PER_WIGGLE):
x = random.randint(-MAX_WIGGLE_DISTANCE, MAX_WIGGLE_DISTANCE)
y = random.randint(-MAX_WIGGLE_DISTANCE, MAX_WIGGLE_DISTANCE)
dx -= x
dy -= y
mouse.move(x=x, y=y)
mouse.move(x=dx... | [
"def",
"wiggle",
"(",
"mouse",
")",
":",
"print",
"(",
"\"wiggle!\"",
")",
"dx",
"=",
"0",
"dy",
"=",
"0",
"for",
"_",
"in",
"range",
"(",
"MOVES_PER_WIGGLE",
")",
":",
"x",
"=",
"random",
".",
"randint",
"(",
"-",
"MAX_WIGGLE_DISTANCE",
",",
"MAX_WI... | Wiggles the `mouse` around. | [
"Wiggles",
"the",
"`",
"mouse",
"`",
"around",
"."
] | [
"\"\"\" Wiggles the `mouse` around.\n\n Makes `MOVES_PER_WIGGLE` moves, going at most `MAX_WIGGLE_DISTANCE`\n in either direction horizontally and vertically.\n\n In testing, the wigging was annoying since it would jump the cursor\n away from the path I had it on, so there's an extra final move back \n ... | [
{
"param": "mouse",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "mouse",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8dd32b627ffd981b730c3bdb6deee341d0363c2b | isaacazuelos/wiggler | code.py | [
"MIT"
] | Python | make_button | <not_specific> | def make_button():
""" Make a `Button` to model the MX switch and set up our
callbacks for lighting up the LED and cycling `current_colour`.
"""
pin = DigitalInOut(board.SWITCH)
pin.switch_to_input(pull=Pull.DOWN)
button = Button(pin, "button")
button.on_press = update_current_colour
b... | Make a `Button` to model the MX switch and set up our
callbacks for lighting up the LED and cycling `current_colour`.
| Make a `Button` to model the MX switch and set up our
callbacks for lighting up the LED and cycling `current_colour`. | [
"Make",
"a",
"`",
"Button",
"`",
"to",
"model",
"the",
"MX",
"switch",
"and",
"set",
"up",
"our",
"callbacks",
"for",
"lighting",
"up",
"the",
"LED",
"and",
"cycling",
"`",
"current_colour",
"`",
"."
] | def make_button():
pin = DigitalInOut(board.SWITCH)
pin.switch_to_input(pull=Pull.DOWN)
button = Button(pin, "button")
button.on_press = update_current_colour
button.on_release = schedule_future_wiggle
button.on_held = set_led_to_current_colour
return button | [
"def",
"make_button",
"(",
")",
":",
"pin",
"=",
"DigitalInOut",
"(",
"board",
".",
"SWITCH",
")",
"pin",
".",
"switch_to_input",
"(",
"pull",
"=",
"Pull",
".",
"DOWN",
")",
"button",
"=",
"Button",
"(",
"pin",
",",
"\"button\"",
")",
"button",
".",
... | Make a `Button` to model the MX switch and set up our
callbacks for lighting up the LED and cycling `current_colour`. | [
"Make",
"a",
"`",
"Button",
"`",
"to",
"model",
"the",
"MX",
"switch",
"and",
"set",
"up",
"our",
"callbacks",
"for",
"lighting",
"up",
"the",
"LED",
"and",
"cycling",
"`",
"current_colour",
"`",
"."
] | [
"\"\"\" Make a `Button` to model the MX switch and set up our\n callbacks for lighting up the LED and cycling `current_colour`.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
8dd32b627ffd981b730c3bdb6deee341d0363c2b | isaacazuelos/wiggler | code.py | [
"MIT"
] | Python | make_touch | <not_specific> | def make_touch():
""" Make a `Button` to model the touch sensor and set up the
callback for showing `current_colour` on the LED.
"""
touch = Button(touchio.TouchIn(board.TOUCH), "touch")
touch.on_held = set_led_to_current_colour
return touch | Make a `Button` to model the touch sensor and set up the
callback for showing `current_colour` on the LED.
| Make a `Button` to model the touch sensor and set up the
callback for showing `current_colour` on the LED. | [
"Make",
"a",
"`",
"Button",
"`",
"to",
"model",
"the",
"touch",
"sensor",
"and",
"set",
"up",
"the",
"callback",
"for",
"showing",
"`",
"current_colour",
"`",
"on",
"the",
"LED",
"."
] | def make_touch():
touch = Button(touchio.TouchIn(board.TOUCH), "touch")
touch.on_held = set_led_to_current_colour
return touch | [
"def",
"make_touch",
"(",
")",
":",
"touch",
"=",
"Button",
"(",
"touchio",
".",
"TouchIn",
"(",
"board",
".",
"TOUCH",
")",
",",
"\"touch\"",
")",
"touch",
".",
"on_held",
"=",
"set_led_to_current_colour",
"return",
"touch"
] | Make a `Button` to model the touch sensor and set up the
callback for showing `current_colour` on the LED. | [
"Make",
"a",
"`",
"Button",
"`",
"to",
"model",
"the",
"touch",
"sensor",
"and",
"set",
"up",
"the",
"callback",
"for",
"showing",
"`",
"current_colour",
"`",
"on",
"the",
"LED",
"."
] | [
"\"\"\" Make a `Button` to model the touch sensor and set up the\n callback for showing `current_colour` on the LED.\n \"\"\""
] | [] | {
"returns": [],
"raises": [],
"params": [],
"outlier_params": [],
"others": []
} |
bf876d2d54f171b2221048bbfc11088b92511565 | eL0ck/tlx | tlx/dynamodb/batch.py | [
"Apache-2.0"
] | Python | load_scan_dump | null | def load_scan_dump(dump_file, table=None):
"""
Loads the results of a scan opperation into a table.
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`
and writes to an existing table. Similar to the `aws dynamodb batch-write-item` c... |
Loads the results of a scan opperation into a table.
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`
and writes to an existing table. Similar to the `aws dynamodb batch-write-item` command except:
- No limit to amount of... | Loads the results of a scan opperation into a table.
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name `
and writes to an existing table. Similar to the `aws dynamodb batch-write-item` command except:
No limit to amount of items in the upload (25 with awscli)
Take the output of a ... | [
"Loads",
"the",
"results",
"of",
"a",
"scan",
"opperation",
"into",
"a",
"table",
".",
"Details",
":",
"Takes",
"the",
"output",
"of",
"a",
"`",
"scan",
"`",
"operation",
"such",
"as",
":",
"`",
"aws",
"dynamodb",
"scan",
"--",
"table",
"-",
"name",
... | def load_scan_dump(dump_file, table=None):
table = get_ddb_table(table)
items = json.load(dump_file)['Items']
batch_write(table, [_pull_values(item) for item in items]) | [
"def",
"load_scan_dump",
"(",
"dump_file",
",",
"table",
"=",
"None",
")",
":",
"table",
"=",
"get_ddb_table",
"(",
"table",
")",
"items",
"=",
"json",
".",
"load",
"(",
"dump_file",
")",
"[",
"'Items'",
"]",
"batch_write",
"(",
"table",
",",
"[",
"_pu... | Loads the results of a scan opperation into a table. | [
"Loads",
"the",
"results",
"of",
"a",
"scan",
"opperation",
"into",
"a",
"table",
"."
] | [
"\"\"\"\n Loads the results of a scan opperation into a table.\n\n Details:\n Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`\n and writes to an existing table. Similar to the `aws dynamodb batch-write-item` command except:\n - No l... | [
{
"param": "dump_file",
"type": null
},
{
"param": "table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_toke... |
bf876d2d54f171b2221048bbfc11088b92511565 | eL0ck/tlx | tlx/dynamodb/batch.py | [
"Apache-2.0"
] | Python | load_from_csv | <not_specific> | def load_from_csv(csv_file, table):
""" CSV must conform to the following format:
first row: Field names
second row: Field types. One of: ['N', 'S']
N.B Only works for flat data structures. i.e Maps/Lists/Sets are not supported
"""
table = get_ddb_table(table)
with io... | CSV must conform to the following format:
first row: Field names
second row: Field types. One of: ['N', 'S']
N.B Only works for flat data structures. i.e Maps/Lists/Sets are not supported
| CSV must conform to the following format:
first row: Field names
second row: Field types.
N.B Only works for flat data structures. i.e Maps/Lists/Sets are not supported | [
"CSV",
"must",
"conform",
"to",
"the",
"following",
"format",
":",
"first",
"row",
":",
"Field",
"names",
"second",
"row",
":",
"Field",
"types",
".",
"N",
".",
"B",
"Only",
"works",
"for",
"flat",
"data",
"structures",
".",
"i",
".",
"e",
"Maps",
"/... | def load_from_csv(csv_file, table):
table = get_ddb_table(table)
with io.open(csv_file, newline='') as csvfile:
data = list(csv.reader(csvfile))
field_names, types = data[0], data[1]
def _format_number(x):
tmp = Decimal(x if x else 'Nan')
if math.isnan(tmp) or math.isinf(tmp):
... | [
"def",
"load_from_csv",
"(",
"csv_file",
",",
"table",
")",
":",
"table",
"=",
"get_ddb_table",
"(",
"table",
")",
"with",
"io",
".",
"open",
"(",
"csv_file",
",",
"newline",
"=",
"''",
")",
"as",
"csvfile",
":",
"data",
"=",
"list",
"(",
"csv",
".",... | CSV must conform to the following format:
first row: Field names
second row: Field types. | [
"CSV",
"must",
"conform",
"to",
"the",
"following",
"format",
":",
"first",
"row",
":",
"Field",
"names",
"second",
"row",
":",
"Field",
"types",
"."
] | [
"\"\"\" CSV must conform to the following format:\n first row: Field names\n second row: Field types. One of: ['N', 'S']\n\n N.B Only works for flat data structures. i.e Maps/Lists/Sets are not supported\n \"\"\"",
"# Throws KeyError if missing. Only string and number are supporte... | [
{
"param": "csv_file",
"type": null
},
{
"param": "table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "csv_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_token... |
bf876d2d54f171b2221048bbfc11088b92511565 | eL0ck/tlx | tlx/dynamodb/batch.py | [
"Apache-2.0"
] | Python | load_json_dump | null | def load_json_dump(file_name, table_name, primary_key=False):
""" Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump).
If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
I... | Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump).
If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
If not provided, the input data must contain the keys of the dynamodb.... | Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump).
If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.
If not provided, the input data must contain the keys of the dynamodb. | [
"Loads",
"a",
"file",
"consisting",
"of",
"newline",
"seperated",
"items",
"in",
"which",
"each",
"item",
"is",
"a",
"json",
"row",
"object",
"(",
"Such",
"as",
"a",
"BigQuery",
"dump",
")",
".",
"If",
"`",
"primary_key",
"`",
"is",
"provided",
"the",
... | def load_json_dump(file_name, table_name, primary_key=False):
table = get_ddb_table(table_name)
with open(file_name, 'r') as f:
items = [
json.loads(line.replace('\n', ''), parse_int=Decimal, parse_float=Decimal)
for line in f
]
if primary_key:
for i in items:... | [
"def",
"load_json_dump",
"(",
"file_name",
",",
"table_name",
",",
"primary_key",
"=",
"False",
")",
":",
"table",
"=",
"get_ddb_table",
"(",
"table_name",
")",
"with",
"open",
"(",
"file_name",
",",
"'r'",
")",
"as",
"f",
":",
"items",
"=",
"[",
"json",... | Loads a file consisting of newline seperated items, in which each item is
a json row object (Such as a BigQuery dump). | [
"Loads",
"a",
"file",
"consisting",
"of",
"newline",
"seperated",
"items",
"in",
"which",
"each",
"item",
"is",
"a",
"json",
"row",
"object",
"(",
"Such",
"as",
"a",
"BigQuery",
"dump",
")",
"."
] | [
"\"\"\" Loads a file consisting of newline seperated items, in which each item is\n a json row object (Such as a BigQuery dump).\n\n If `primary_key` is provided the field is added to each item with a unique id as the sole partition key.\n If not provided, the input data must contain the keys o... | [
{
"param": "file_name",
"type": null
},
{
"param": "table_name",
"type": null
},
{
"param": "primary_key",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "file_name",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table_name",
"type": null,
"docstring": null,
"docstring... |
0cd145e3e053bfb9dc2477a990314b9c2db2770e | eL0ck/tlx | tlx/util/helper.py | [
"Apache-2.0"
] | Python | paginate | null | def paginate(method, **kwargs):
""" Automatically paginates through result lists regardless of what type of marker/token/continuation
AWS decided to use on that service. Will raise `OperationNotPageableError` if the operation is
not pagable.
e.g Get all Log groups rather than just the first... | Automatically paginates through result lists regardless of what type of marker/token/continuation
AWS decided to use on that service. Will raise `OperationNotPageableError` if the operation is
not pagable.
e.g Get all Log groups rather than just the first 50
>>> log_groups = [lg['l... | Automatically paginates through result lists regardless of what type of marker/token/continuation
AWS decided to use on that service. Will raise `OperationNotPageableError` if the operation is
not pagable.
| [
"Automatically",
"paginates",
"through",
"result",
"lists",
"regardless",
"of",
"what",
"type",
"of",
"marker",
"/",
"token",
"/",
"continuation",
"AWS",
"decided",
"to",
"use",
"on",
"that",
"service",
".",
"Will",
"raise",
"`",
"OperationNotPageableError",
"`"... | def paginate(method, **kwargs):
client = method.__self__
paginator = client.get_paginator(method.__name__)
for page in paginator.paginate(**kwargs).result_key_iters():
try:
for result in page:
yield result
except TypeError:
pass | [
"def",
"paginate",
"(",
"method",
",",
"**",
"kwargs",
")",
":",
"client",
"=",
"method",
".",
"__self__",
"paginator",
"=",
"client",
".",
"get_paginator",
"(",
"method",
".",
"__name__",
")",
"for",
"page",
"in",
"paginator",
".",
"paginate",
"(",
"**"... | Automatically paginates through result lists regardless of what type of marker/token/continuation
AWS decided to use on that service. | [
"Automatically",
"paginates",
"through",
"result",
"lists",
"regardless",
"of",
"what",
"type",
"of",
"marker",
"/",
"token",
"/",
"continuation",
"AWS",
"decided",
"to",
"use",
"on",
"that",
"service",
"."
] | [
"\"\"\" Automatically paginates through result lists regardless of what type of marker/token/continuation\n AWS decided to use on that service. Will raise `OperationNotPageableError` if the operation is\n not pagable.\n\n e.g Get all Log groups rather than just the first 50\n >>> log... | [
{
"param": "method",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "method",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8e2f08e8e62dd748adea50661a14d4ec1a3bc301 | eL0ck/tlx | tlx/apigateway/__init__.py | [
"Apache-2.0"
] | Python | proxy_response_handler | <not_specific> | def proxy_response_handler(func=None, running_local=False, quiet=True):
""" A Decorator for lambda functions. The function to be decorated by have two positional arguments
(event, context) as any lambda handler would. Decorating your handler allows you to write idomatic python
using returns and rai... | A Decorator for lambda functions. The function to be decorated by have two positional arguments
(event, context) as any lambda handler would. Decorating your handler allows you to write idomatic python
using returns and raising exception. This handler catches and formats them as proxy response object... | A Decorator for lambda functions. The function to be decorated by have two positional arguments
(event, context) as any lambda handler would. Decorating your handler allows you to write idomatic python
using returns and raising exception. This handler catches and formats them as proxy response objects
suitable for AP... | [
"A",
"Decorator",
"for",
"lambda",
"functions",
".",
"The",
"function",
"to",
"be",
"decorated",
"by",
"have",
"two",
"positional",
"arguments",
"(",
"event",
"context",
")",
"as",
"any",
"lambda",
"handler",
"would",
".",
"Decorating",
"your",
"handler",
"a... | def proxy_response_handler(func=None, running_local=False, quiet=True):
if not func:
return functools.partial(proxy_response_handler, running_local=running_local, quiet=quiet)
@functools.wraps(func)
def wrapper(*axgs):
response = {
"statusCode": 500,
"body": {},
... | [
"def",
"proxy_response_handler",
"(",
"func",
"=",
"None",
",",
"running_local",
"=",
"False",
",",
"quiet",
"=",
"True",
")",
":",
"if",
"not",
"func",
":",
"return",
"functools",
".",
"partial",
"(",
"proxy_response_handler",
",",
"running_local",
"=",
"ru... | A Decorator for lambda functions. | [
"A",
"Decorator",
"for",
"lambda",
"functions",
"."
] | [
"\"\"\" A Decorator for lambda functions. The function to be decorated by have two positional arguments\n (event, context) as any lambda handler would. Decorating your handler allows you to write idomatic python\n using returns and raising exception. This handler catches and formats them as proxy re... | [
{
"param": "func",
"type": null
},
{
"param": "running_local",
"type": null
},
{
"param": "quiet",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "running_local",
"type": null,
"docstring": null,
"docstring_t... |
8e2f08e8e62dd748adea50661a14d4ec1a3bc301 | eL0ck/tlx | tlx/apigateway/__init__.py | [
"Apache-2.0"
] | Python | require_valid_inputs | null | def require_valid_inputs(supplied, required):
""" Returns None if `supplied` is a superset of `required`. Raises `APIGException` with
error code 400 if not.
Bothe params must be an iterable.
"""
try:
missing_parameters = set(required).difference(supplied)
except TypeError:
... | Returns None if `supplied` is a superset of `required`. Raises `APIGException` with
error code 400 if not.
Bothe params must be an iterable.
| Returns None if `supplied` is a superset of `required`. Raises `APIGException` with
error code 400 if not.
Bothe params must be an iterable. | [
"Returns",
"None",
"if",
"`",
"supplied",
"`",
"is",
"a",
"superset",
"of",
"`",
"required",
"`",
".",
"Raises",
"`",
"APIGException",
"`",
"with",
"error",
"code",
"400",
"if",
"not",
".",
"Bothe",
"params",
"must",
"be",
"an",
"iterable",
"."
] | def require_valid_inputs(supplied, required):
try:
missing_parameters = set(required).difference(supplied)
except TypeError:
missing_parameters = required
if missing_parameters:
msg = "Invalid input parameters: {missing_parameters}".format(**locals())
raise APIGException(msg,... | [
"def",
"require_valid_inputs",
"(",
"supplied",
",",
"required",
")",
":",
"try",
":",
"missing_parameters",
"=",
"set",
"(",
"required",
")",
".",
"difference",
"(",
"supplied",
")",
"except",
"TypeError",
":",
"missing_parameters",
"=",
"required",
"if",
"mi... | Returns None if `supplied` is a superset of `required`. | [
"Returns",
"None",
"if",
"`",
"supplied",
"`",
"is",
"a",
"superset",
"of",
"`",
"required",
"`",
"."
] | [
"\"\"\" Returns None if `supplied` is a superset of `required`. Raises `APIGException` with\n error code 400 if not.\n Bothe params must be an iterable.\n \"\"\"",
"# supplied is not itterable"
] | [
{
"param": "supplied",
"type": null
},
{
"param": "required",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "supplied",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "required",
"type": null,
"docstring": null,
"docstring_to... |
e3851fbf6159ddc8474a20bd349f33c7582e459b | eL0ck/tlx | tlx/dynamodb/cli_apps/dynamodb_batch_write.py | [
"Apache-2.0"
] | Python | dbw | null | def dbw(dump_file, table=None):
"""
DYNAMO BATCH WRITE
Loads the results of a scan operation into a table.
\b
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`
and writes to an existing table. Similar to the `aws d... |
DYNAMO BATCH WRITE
Loads the results of a scan operation into a table.
\b
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`
and writes to an existing table. Similar to the `aws dynamodb batch-write-item` command excep... | DYNAMO BATCH WRITE
Loads the results of a scan operation into a table.
\b
Details:
Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name `
and writes to an existing table. Similar to the `aws dynamodb batch-write-item` command except:
No limit to amount of items in the upload (25 with awscli)... | [
"DYNAMO",
"BATCH",
"WRITE",
"Loads",
"the",
"results",
"of",
"a",
"scan",
"operation",
"into",
"a",
"table",
".",
"\\",
"b",
"Details",
":",
"Takes",
"the",
"output",
"of",
"a",
"`",
"scan",
"`",
"operation",
"such",
"as",
":",
"`",
"aws",
"dynamodb",
... | def dbw(dump_file, table=None):
try:
load_scan_dump(dump_file, table)
except Exception as e:
print("{}: {}".format(type(e).__name__, e))
sys.exit(1) | [
"def",
"dbw",
"(",
"dump_file",
",",
"table",
"=",
"None",
")",
":",
"try",
":",
"load_scan_dump",
"(",
"dump_file",
",",
"table",
")",
"except",
"Exception",
"as",
"e",
":",
"print",
"(",
"\"{}: {}\"",
".",
"format",
"(",
"type",
"(",
"e",
")",
".",... | DYNAMO BATCH WRITE
Loads the results of a scan operation into a table. | [
"DYNAMO",
"BATCH",
"WRITE",
"Loads",
"the",
"results",
"of",
"a",
"scan",
"operation",
"into",
"a",
"table",
"."
] | [
"\"\"\"\n DYNAMO BATCH WRITE\n\n Loads the results of a scan operation into a table.\n\n \\b\n Details:\n Takes the output of a `scan` operation such as: `aws dynamodb scan --table-name <TableName>`\n and writes to an existing table. Similar to the `aws dynamodb batch-write... | [
{
"param": "dump_file",
"type": null
},
{
"param": "table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dump_file",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_toke... |
8ce234d55525772513bdcb269d47f49fc8953731 | eL0ck/tlx | tlx/dynamodb/table.py | [
"Apache-2.0"
] | Python | add_key | <not_specific> | def add_key(table, key, item):
""" If the item doesn't exist yet. Create the key.
!! Does NOT support tables with Partition and Sort keys Yet.
"""
key_names = [k for k in key]
full_item = {**key, **item} # noqa: E999 - only invalid in old pythons
logger.debug(f'submitting item: {full_ite... | If the item doesn't exist yet. Create the key.
!! Does NOT support tables with Partition and Sort keys Yet.
| If the item doesn't exist yet. Create the key.
Does NOT support tables with Partition and Sort keys Yet. | [
"If",
"the",
"item",
"doesn",
"'",
"t",
"exist",
"yet",
".",
"Create",
"the",
"key",
".",
"Does",
"NOT",
"support",
"tables",
"with",
"Partition",
"and",
"Sort",
"keys",
"Yet",
"."
] | def add_key(table, key, item):
key_names = [k for k in key]
full_item = {**key, **item}
logger.debug(f'submitting item: {full_item}')
logger.info(f"Attempting to add new record for: {key} ")
res = table.put_item(
Item=full_item,
ConditionExpression=f"attribute_not_exists({key_nam... | [
"def",
"add_key",
"(",
"table",
",",
"key",
",",
"item",
")",
":",
"key_names",
"=",
"[",
"k",
"for",
"k",
"in",
"key",
"]",
"full_item",
"=",
"{",
"**",
"key",
",",
"**",
"item",
"}",
"logger",
".",
"debug",
"(",
"f'submitting item: {full_item}'",
"... | If the item doesn't exist yet. | [
"If",
"the",
"item",
"doesn",
"'",
"t",
"exist",
"yet",
"."
] | [
"\"\"\" If the item doesn't exist yet. Create the key.\n !! Does NOT support tables with Partition and Sort keys Yet.\n \"\"\"",
"# noqa: E999 - only invalid in old pythons",
"# noqa: E999 - only invalid in old pythons",
"# TODO fix for items with Partition and Sort key"
] | [
{
"param": "table",
"type": null
},
{
"param": "key",
"type": null
},
{
"param": "item",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "key",
"type": null,
"docstring": null,
"docstring_tokens": [... |
8ce234d55525772513bdcb269d47f49fc8953731 | eL0ck/tlx | tlx/dynamodb/table.py | [
"Apache-2.0"
] | Python | clear_table | null | def clear_table(table):
""" in Alpha
- WILL IMMEDIATELY DELETE ALL ITEMS WITHOUT CONFIRMATION !
NOT TESTED with Primary and Sort Key Tables !!!
TODO:
- test on multikey tables
- make cli app for it
"""
table = get_ddb_table(table)
ddb = table.meta.clien... | in Alpha
- WILL IMMEDIATELY DELETE ALL ITEMS WITHOUT CONFIRMATION !
NOT TESTED with Primary and Sort Key Tables !!!
TODO:
- test on multikey tables
- make cli app for it
| in Alpha
WILL IMMEDIATELY DELETE ALL ITEMS WITHOUT CONFIRMATION !
NOT TESTED with Primary and Sort Key Tables
TODO:
test on multikey tables
make cli app for it | [
"in",
"Alpha",
"WILL",
"IMMEDIATELY",
"DELETE",
"ALL",
"ITEMS",
"WITHOUT",
"CONFIRMATION",
"!",
"NOT",
"TESTED",
"with",
"Primary",
"and",
"Sort",
"Key",
"Tables",
"TODO",
":",
"test",
"on",
"multikey",
"tables",
"make",
"cli",
"app",
"for",
"it"
] | def clear_table(table):
table = get_ddb_table(table)
ddb = table.meta.client
table_keys = [key['AttributeName'] for key in table.key_schema]
all_ids = ({key: r[key] for key in table_keys} for r in paginate(ddb.scan, TableName=table.name))
batch_delete(table, all_ids) | [
"def",
"clear_table",
"(",
"table",
")",
":",
"table",
"=",
"get_ddb_table",
"(",
"table",
")",
"ddb",
"=",
"table",
".",
"meta",
".",
"client",
"table_keys",
"=",
"[",
"key",
"[",
"'AttributeName'",
"]",
"for",
"key",
"in",
"table",
".",
"key_schema",
... | in Alpha
WILL IMMEDIATELY DELETE ALL ITEMS WITHOUT CONFIRMATION ! | [
"in",
"Alpha",
"WILL",
"IMMEDIATELY",
"DELETE",
"ALL",
"ITEMS",
"WITHOUT",
"CONFIRMATION",
"!"
] | [
"\"\"\" in Alpha\n\n - WILL IMMEDIATELY DELETE ALL ITEMS WITHOUT CONFIRMATION !\n\n NOT TESTED with Primary and Sort Key Tables !!!\n TODO:\n - test on multikey tables\n - make cli app for it\n \"\"\""
] | [
{
"param": "table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
8ce234d55525772513bdcb269d47f49fc8953731 | eL0ck/tlx | tlx/dynamodb/table.py | [
"Apache-2.0"
] | Python | full_scan | <not_specific> | def full_scan(table, **table_scan_params):
""" Paginates fully over the table resource scan method wich is not natively pagable.
Although the client scan method is pagable using with the generic paginator in tlx,
it won't accept the FilterExpression from `boto3.dynamodb.conditions` (`Key, Attr`)
... | Paginates fully over the table resource scan method wich is not natively pagable.
Although the client scan method is pagable using with the generic paginator in tlx,
it won't accept the FilterExpression from `boto3.dynamodb.conditions` (`Key, Attr`)
This method takes normal table scan paramete... | Paginates fully over the table resource scan method wich is not natively pagable.
Although the client scan method is pagable using with the generic paginator in tlx,
it won't accept the FilterExpression from `boto3.dynamodb.conditions` (`Key, Attr`)
This method takes normal table scan parameters and returns the comple... | [
"Paginates",
"fully",
"over",
"the",
"table",
"resource",
"scan",
"method",
"wich",
"is",
"not",
"natively",
"pagable",
".",
"Although",
"the",
"client",
"scan",
"method",
"is",
"pagable",
"using",
"with",
"the",
"generic",
"paginator",
"in",
"tlx",
"it",
"w... | def full_scan(table, **table_scan_params):
table = get_ddb_table(table)
items = []
scan_incomplete = True
while scan_incomplete:
res = table.scan(**table_scan_params)
items.extend(res['Items'])
try:
table_scan_params['ExclusiveStartKey'] = res['LastEvaluatedKey']
... | [
"def",
"full_scan",
"(",
"table",
",",
"**",
"table_scan_params",
")",
":",
"table",
"=",
"get_ddb_table",
"(",
"table",
")",
"items",
"=",
"[",
"]",
"scan_incomplete",
"=",
"True",
"while",
"scan_incomplete",
":",
"res",
"=",
"table",
".",
"scan",
"(",
... | Paginates fully over the table resource scan method wich is not natively pagable. | [
"Paginates",
"fully",
"over",
"the",
"table",
"resource",
"scan",
"method",
"wich",
"is",
"not",
"natively",
"pagable",
"."
] | [
"\"\"\" Paginates fully over the table resource scan method wich is not natively pagable.\n Although the client scan method is pagable using with the generic paginator in tlx,\n it won't accept the FilterExpression from `boto3.dynamodb.conditions` (`Key, Attr`)\n\n This method takes normal tabl... | [
{
"param": "table",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "table",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6357138b388a655044f981f94d58cee09686bf1f | Michael-F-Bryan/cheesecake_kwalitee_index | cheesecake_kwalitee_index/kwalitee/evaluator.py | [
"MIT"
] | Python | download | <not_specific> | def download(package, dest):
"""
Download a package to a specified location. Making sure to get a source
distribution.
"""
logger.info('Downloading %s', package)
return pip.main(['install',
'--target', dest,
'--no-binary', ':all:',
p... |
Download a package to a specified location. Making sure to get a source
distribution.
| Download a package to a specified location. Making sure to get a source
distribution. | [
"Download",
"a",
"package",
"to",
"a",
"specified",
"location",
".",
"Making",
"sure",
"to",
"get",
"a",
"source",
"distribution",
"."
] | def download(package, dest):
logger.info('Downloading %s', package)
return pip.main(['install',
'--target', dest,
'--no-binary', ':all:',
package]) | [
"def",
"download",
"(",
"package",
",",
"dest",
")",
":",
"logger",
".",
"info",
"(",
"'Downloading %s'",
",",
"package",
")",
"return",
"pip",
".",
"main",
"(",
"[",
"'install'",
",",
"'--target'",
",",
"dest",
",",
"'--no-binary'",
",",
"':all:'",
",",... | Download a package to a specified location. | [
"Download",
"a",
"package",
"to",
"a",
"specified",
"location",
"."
] | [
"\"\"\"\n Download a package to a specified location. Making sure to get a source\n distribution.\n \"\"\""
] | [
{
"param": "package",
"type": null
},
{
"param": "dest",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "package",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "dest",
"type": null,
"docstring": null,
"docstring_tokens"... |
6357138b388a655044f981f94d58cee09686bf1f | Michael-F-Bryan/cheesecake_kwalitee_index | cheesecake_kwalitee_index/kwalitee/evaluator.py | [
"MIT"
] | Python | lint | <not_specific> | def lint(dest, name):
"""
Run Pylint and get the overall score of a package.
"""
package = os.path.join(dest, name)
logger.info('Lint checking %s', name)
cmd = 'pylint {}'.format(package)
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
... |
Run Pylint and get the overall score of a package.
| Run Pylint and get the overall score of a package. | [
"Run",
"Pylint",
"and",
"get",
"the",
"overall",
"score",
"of",
"a",
"package",
"."
] | def lint(dest, name):
package = os.path.join(dest, name)
logger.info('Lint checking %s', name)
cmd = 'pylint {}'.format(package)
proc = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True)
... | [
"def",
"lint",
"(",
"dest",
",",
"name",
")",
":",
"package",
"=",
"os",
".",
"path",
".",
"join",
"(",
"dest",
",",
"name",
")",
"logger",
".",
"info",
"(",
"'Lint checking %s'",
",",
"name",
")",
"cmd",
"=",
"'pylint {}'",
".",
"format",
"(",
"pa... | Run Pylint and get the overall score of a package. | [
"Run",
"Pylint",
"and",
"get",
"the",
"overall",
"score",
"of",
"a",
"package",
"."
] | [
"\"\"\"\n Run Pylint and get the overall score of a package.\n \"\"\"",
"# It couldn't find our score so there must have been an error"
] | [
{
"param": "dest",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "dest",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "name",
"type": null,
"docstring": null,
"docstring_tokens": [... |
6357138b388a655044f981f94d58cee09686bf1f | Michael-F-Bryan/cheesecake_kwalitee_index | cheesecake_kwalitee_index/kwalitee/evaluator.py | [
"MIT"
] | Python | evaluate_score | <not_specific> | def evaluate_score(self):
"""
Run the entire test suite and get the package's score.
"""
logger.info('Evaluating score for %s', self.package)
try:
ins = self.score['install']
ins.value = self.install_package()
# Stop early if we couldn't insta... |
Run the entire test suite and get the package's score.
| Run the entire test suite and get the package's score. | [
"Run",
"the",
"entire",
"test",
"suite",
"and",
"get",
"the",
"package",
"'",
"s",
"score",
"."
] | def evaluate_score(self):
logger.info('Evaluating score for %s', self.package)
try:
ins = self.score['install']
ins.value = self.install_package()
if self.score['install'].value == 0:
return
self.score['version_number'].value = self.get_ver... | [
"def",
"evaluate_score",
"(",
"self",
")",
":",
"logger",
".",
"info",
"(",
"'Evaluating score for %s'",
",",
"self",
".",
"package",
")",
"try",
":",
"ins",
"=",
"self",
".",
"score",
"[",
"'install'",
"]",
"ins",
".",
"value",
"=",
"self",
".",
"inst... | Run the entire test suite and get the package's score. | [
"Run",
"the",
"entire",
"test",
"suite",
"and",
"get",
"the",
"package",
"'",
"s",
"score",
"."
] | [
"\"\"\"\n Run the entire test suite and get the package's score.\n \"\"\"",
"# Stop early if we couldn't install",
"# Let the tempdir be deleted and return the final score as a tuple"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6357138b388a655044f981f94d58cee09686bf1f | Michael-F-Bryan/cheesecake_kwalitee_index | cheesecake_kwalitee_index/kwalitee/evaluator.py | [
"MIT"
] | Python | install_package | <not_specific> | def install_package(self):
"""
Try to install the package. If it installs, you get 10 points.
Otherwise you get nothing.
"""
package_version = self.package + '==' + self.version
ret = download(package_version, self.dest)
if ret:
return 0
else:... |
Try to install the package. If it installs, you get 10 points.
Otherwise you get nothing.
| Try to install the package. If it installs, you get 10 points.
Otherwise you get nothing. | [
"Try",
"to",
"install",
"the",
"package",
".",
"If",
"it",
"installs",
"you",
"get",
"10",
"points",
".",
"Otherwise",
"you",
"get",
"nothing",
"."
] | def install_package(self):
package_version = self.package + '==' + self.version
ret = download(package_version, self.dest)
if ret:
return 0
else:
return self.score['install'].total | [
"def",
"install_package",
"(",
"self",
")",
":",
"package_version",
"=",
"self",
".",
"package",
"+",
"'=='",
"+",
"self",
".",
"version",
"ret",
"=",
"download",
"(",
"package_version",
",",
"self",
".",
"dest",
")",
"if",
"ret",
":",
"return",
"0",
"... | Try to install the package. | [
"Try",
"to",
"install",
"the",
"package",
"."
] | [
"\"\"\"\n Try to install the package. If it installs, you get 10 points.\n Otherwise you get nothing.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
6357138b388a655044f981f94d58cee09686bf1f | Michael-F-Bryan/cheesecake_kwalitee_index | cheesecake_kwalitee_index/kwalitee/evaluator.py | [
"MIT"
] | Python | clean_up | null | def clean_up(self):
"""
Remove the installed directory and do any other necessary clean up.
"""
if self.dest is not None:
logger.info('Cleaning up %s', self.dest)
shutil.rmtree(self.dest)
self.dest = None |
Remove the installed directory and do any other necessary clean up.
| Remove the installed directory and do any other necessary clean up. | [
"Remove",
"the",
"installed",
"directory",
"and",
"do",
"any",
"other",
"necessary",
"clean",
"up",
"."
] | def clean_up(self):
if self.dest is not None:
logger.info('Cleaning up %s', self.dest)
shutil.rmtree(self.dest)
self.dest = None | [
"def",
"clean_up",
"(",
"self",
")",
":",
"if",
"self",
".",
"dest",
"is",
"not",
"None",
":",
"logger",
".",
"info",
"(",
"'Cleaning up %s'",
",",
"self",
".",
"dest",
")",
"shutil",
".",
"rmtree",
"(",
"self",
".",
"dest",
")",
"self",
".",
"dest... | Remove the installed directory and do any other necessary clean up. | [
"Remove",
"the",
"installed",
"directory",
"and",
"do",
"any",
"other",
"necessary",
"clean",
"up",
"."
] | [
"\"\"\"\n Remove the installed directory and do any other necessary clean up.\n \"\"\""
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
ab2f1ab1e42fa071be83fbdbf5d787b36fbfbc3d | VIVelev/nujo | nujo/init/basic.py | [
"MIT"
] | Python | empty | Tensor | def empty(*shape: int, diff=False, name='Tensor[empty]') -> Tensor:
''' Return a new Tensor of given shape, without initializing entries.
'''
return Tensor(np_empty(shape), diff=diff, name=name) | Return a new Tensor of given shape, without initializing entries.
| Return a new Tensor of given shape, without initializing entries. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"without",
"initializing",
"entries",
"."
] | def empty(*shape: int, diff=False, name='Tensor[empty]') -> Tensor:
return Tensor(np_empty(shape), diff=diff, name=name) | [
"def",
"empty",
"(",
"*",
"shape",
":",
"int",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[empty]'",
")",
"->",
"Tensor",
":",
"return",
"Tensor",
"(",
"np_empty",
"(",
"shape",
")",
",",
"diff",
"=",
"diff",
",",
"name",
"=",
"name",
")"... | Return a new Tensor of given shape, without initializing entries. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"without",
"initializing",
"entries",
"."
] | [
"''' Return a new Tensor of given shape, without initializing entries.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "diff",
"type": null,
"docstring": null,
"docstring_tokens":... |
ab2f1ab1e42fa071be83fbdbf5d787b36fbfbc3d | VIVelev/nujo | nujo/init/basic.py | [
"MIT"
] | Python | full | Tensor | def full(*shape: int,
fill_value=0,
diff=False,
name='Tensor[full]]') -> Tensor:
''' Return a new Tensor of given shape, filled with `fill_value`.
'''
return Tensor(np_full(shape, fill_value), diff=diff, name=name) | Return a new Tensor of given shape, filled with `fill_value`.
| Return a new Tensor of given shape, filled with `fill_value`. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"`",
"fill_value",
"`",
"."
] | def full(*shape: int,
fill_value=0,
diff=False,
name='Tensor[full]]') -> Tensor:
return Tensor(np_full(shape, fill_value), diff=diff, name=name) | [
"def",
"full",
"(",
"*",
"shape",
":",
"int",
",",
"fill_value",
"=",
"0",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[full]]'",
")",
"->",
"Tensor",
":",
"return",
"Tensor",
"(",
"np_full",
"(",
"shape",
",",
"fill_value",
")",
",",
"diff"... | Return a new Tensor of given shape, filled with `fill_value`. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"`",
"fill_value",
"`",
"."
] | [
"''' Return a new Tensor of given shape, filled with `fill_value`.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "fill_value",
"type": null
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "fill_value",
"type": null,
"docstring": null,
"docstring_to... |
ab2f1ab1e42fa071be83fbdbf5d787b36fbfbc3d | VIVelev/nujo | nujo/init/basic.py | [
"MIT"
] | Python | ones | Tensor | def ones(*shape: int, diff=False, name='Tensor[ones]') -> Tensor:
''' Return a new Tensor of given shape, filled with ones.
'''
return full(*shape, fill_value=1, diff=diff, name=name) | Return a new Tensor of given shape, filled with ones.
| Return a new Tensor of given shape, filled with ones. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"ones",
"."
] | def ones(*shape: int, diff=False, name='Tensor[ones]') -> Tensor:
return full(*shape, fill_value=1, diff=diff, name=name) | [
"def",
"ones",
"(",
"*",
"shape",
":",
"int",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[ones]'",
")",
"->",
"Tensor",
":",
"return",
"full",
"(",
"*",
"shape",
",",
"fill_value",
"=",
"1",
",",
"diff",
"=",
"diff",
",",
"name",
"=",
"... | Return a new Tensor of given shape, filled with ones. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"ones",
"."
] | [
"''' Return a new Tensor of given shape, filled with ones.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "diff",
"type": null,
"docstring": null,
"docstring_tokens":... |
ab2f1ab1e42fa071be83fbdbf5d787b36fbfbc3d | VIVelev/nujo | nujo/init/basic.py | [
"MIT"
] | Python | zeros | Tensor | def zeros(*shape: int, diff=False, name='Tensor[zeros]') -> Tensor:
''' Return a new Tensor of given shape, filled with zeros.
'''
return full(*shape, fill_value=0, diff=diff, name=name) | Return a new Tensor of given shape, filled with zeros.
| Return a new Tensor of given shape, filled with zeros. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"zeros",
"."
] | def zeros(*shape: int, diff=False, name='Tensor[zeros]') -> Tensor:
return full(*shape, fill_value=0, diff=diff, name=name) | [
"def",
"zeros",
"(",
"*",
"shape",
":",
"int",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[zeros]'",
")",
"->",
"Tensor",
":",
"return",
"full",
"(",
"*",
"shape",
",",
"fill_value",
"=",
"0",
",",
"diff",
"=",
"diff",
",",
"name",
"=",
... | Return a new Tensor of given shape, filled with zeros. | [
"Return",
"a",
"new",
"Tensor",
"of",
"given",
"shape",
"filled",
"with",
"zeros",
"."
] | [
"''' Return a new Tensor of given shape, filled with zeros.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "diff",
"type": null,
"docstring": null,
"docstring_tokens":... |
0d8fea53616f965dc1ab3d05052ae316fa64dbbc | VIVelev/nujo | nujo/optim/optimizer.py | [
"MIT"
] | Python | zero_grad | None | def zero_grad(self) -> None:
''' Zeros the gradients of the parameters.
'''
for param in self.params():
param.zero_grad() | Zeros the gradients of the parameters.
| Zeros the gradients of the parameters. | [
"Zeros",
"the",
"gradients",
"of",
"the",
"parameters",
"."
] | def zero_grad(self) -> None:
for param in self.params():
param.zero_grad() | [
"def",
"zero_grad",
"(",
"self",
")",
"->",
"None",
":",
"for",
"param",
"in",
"self",
".",
"params",
"(",
")",
":",
"param",
".",
"zero_grad",
"(",
")"
] | Zeros the gradients of the parameters. | [
"Zeros",
"the",
"gradients",
"of",
"the",
"parameters",
"."
] | [
"''' Zeros the gradients of the parameters.\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
bae47b10955e8c44cad504ff6917898a57fb25c2 | VIVelev/nujo | nujo/autodiff/tensor.py | [
"MIT"
] | Python | backward | None | def backward(self, _debug=False) -> None:
''' It uses Breadth First Search to traverse the computation graph
and compute the gradient for each differentiable Tensor in the graph.
'''
nodes_to_visit: List['Tensor'] = [self]
if _debug:
i = 1
while nodes_to_vi... | It uses Breadth First Search to traverse the computation graph
and compute the gradient for each differentiable Tensor in the graph.
| It uses Breadth First Search to traverse the computation graph
and compute the gradient for each differentiable Tensor in the graph. | [
"It",
"uses",
"Breadth",
"First",
"Search",
"to",
"traverse",
"the",
"computation",
"graph",
"and",
"compute",
"the",
"gradient",
"for",
"each",
"differentiable",
"Tensor",
"in",
"the",
"graph",
"."
] | def backward(self, _debug=False) -> None:
nodes_to_visit: List['Tensor'] = [self]
if _debug:
i = 1
while nodes_to_visit:
node = nodes_to_visit.pop()
node.compute_grad()
if _debug:
nstr = f' [{i}]'
node.name += nstr i... | [
"def",
"backward",
"(",
"self",
",",
"_debug",
"=",
"False",
")",
"->",
"None",
":",
"nodes_to_visit",
":",
"List",
"[",
"'Tensor'",
"]",
"=",
"[",
"self",
"]",
"if",
"_debug",
":",
"i",
"=",
"1",
"while",
"nodes_to_visit",
":",
"node",
"=",
"nodes_t... | It uses Breadth First Search to traverse the computation graph
and compute the gradient for each differentiable Tensor in the graph. | [
"It",
"uses",
"Breadth",
"First",
"Search",
"to",
"traverse",
"the",
"computation",
"graph",
"and",
"compute",
"the",
"gradient",
"for",
"each",
"differentiable",
"Tensor",
"in",
"the",
"graph",
"."
] | [
"''' It uses Breadth First Search to traverse the computation graph\n and compute the gradient for each differentiable Tensor in the graph.\n\n '''",
"# Avoid visiting the same node twice"
] | [
{
"param": "self",
"type": null
},
{
"param": "_debug",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "_debug",
"type": null,
"docstring": null,
"docstring_tokens":... |
90f3a88b85a7ca512400c77e62b65118c186758a | VIVelev/nujo | nujo/autodiff/function.py | [
"MIT"
] | Python | forward | ndarray | def forward(self) -> ndarray:
''' Implement forward pass of the function here.
Use the `self.children` list to access the inputs.
'''
pass | Implement forward pass of the function here.
Use the `self.children` list to access the inputs.
| Implement forward pass of the function here.
Use the `self.children` list to access the inputs. | [
"Implement",
"forward",
"pass",
"of",
"the",
"function",
"here",
".",
"Use",
"the",
"`",
"self",
".",
"children",
"`",
"list",
"to",
"access",
"the",
"inputs",
"."
] | def forward(self) -> ndarray:
pass | [
"def",
"forward",
"(",
"self",
")",
"->",
"ndarray",
":",
"pass"
] | Implement forward pass of the function here. | [
"Implement",
"forward",
"pass",
"of",
"the",
"function",
"here",
"."
] | [
"''' Implement forward pass of the function here.\n\n Use the `self.children` list to access the inputs.\n\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90f3a88b85a7ca512400c77e62b65118c186758a | VIVelev/nujo | nujo/autodiff/function.py | [
"MIT"
] | Python | _parse_inputs | List[Tensor] | def _parse_inputs(inputs: Iterable[Any]) -> List[Tensor]:
''' Parse all inputs that are not Nodes to Tensors
'''
return [
x if isinstance(x, _Node) else Tensor(x, name=str(x)) for x in inputs
] | Parse all inputs that are not Nodes to Tensors
| Parse all inputs that are not Nodes to Tensors | [
"Parse",
"all",
"inputs",
"that",
"are",
"not",
"Nodes",
"to",
"Tensors"
] | def _parse_inputs(inputs: Iterable[Any]) -> List[Tensor]:
return [
x if isinstance(x, _Node) else Tensor(x, name=str(x)) for x in inputs
] | [
"def",
"_parse_inputs",
"(",
"inputs",
":",
"Iterable",
"[",
"Any",
"]",
")",
"->",
"List",
"[",
"Tensor",
"]",
":",
"return",
"[",
"x",
"if",
"isinstance",
"(",
"x",
",",
"_Node",
")",
"else",
"Tensor",
"(",
"x",
",",
"name",
"=",
"str",
"(",
"x... | Parse all inputs that are not Nodes to Tensors | [
"Parse",
"all",
"inputs",
"that",
"are",
"not",
"Nodes",
"to",
"Tensors"
] | [
"''' Parse all inputs that are not Nodes to Tensors\n '''"
] | [
{
"param": "inputs",
"type": "Iterable[Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "inputs",
"type": "Iterable[Any]",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
90f3a88b85a7ca512400c77e62b65118c186758a | VIVelev/nujo | nujo/autodiff/function.py | [
"MIT"
] | Python | _get_function_identifier | str | def _get_function_identifier(func_type: type, inputs: Iterable[Any]) -> str:
''' Returns a string identifier for the current function type and its inputs,
used for a key in the cache.
'''
key = str(hash(func_type)) # Inlcude the function type hash in the key
# Include the inputs' (children's) ide... | Returns a string identifier for the current function type and its inputs,
used for a key in the cache.
| Returns a string identifier for the current function type and its inputs,
used for a key in the cache. | [
"Returns",
"a",
"string",
"identifier",
"for",
"the",
"current",
"function",
"type",
"and",
"its",
"inputs",
"used",
"for",
"a",
"key",
"in",
"the",
"cache",
"."
] | def _get_function_identifier(func_type: type, inputs: Iterable[Any]) -> str:
key = str(hash(func_type))
key += ''.join(('T' + str(x.id) if isinstance(x, Tensor) else 'P' + str(x)
for x in inputs))
return key | [
"def",
"_get_function_identifier",
"(",
"func_type",
":",
"type",
",",
"inputs",
":",
"Iterable",
"[",
"Any",
"]",
")",
"->",
"str",
":",
"key",
"=",
"str",
"(",
"hash",
"(",
"func_type",
")",
")",
"key",
"+=",
"''",
".",
"join",
"(",
"(",
"'T'",
"... | Returns a string identifier for the current function type and its inputs,
used for a key in the cache. | [
"Returns",
"a",
"string",
"identifier",
"for",
"the",
"current",
"function",
"type",
"and",
"its",
"inputs",
"used",
"for",
"a",
"key",
"in",
"the",
"cache",
"."
] | [
"''' Returns a string identifier for the current function type and its inputs,\n used for a key in the cache.\n\n '''",
"# Inlcude the function type hash in the key",
"# Include the inputs' (children's) identifiers in the key",
"# 'T' and 'P' signatures were added in order to avoid",
"# collisions bet... | [
{
"param": "func_type",
"type": "type"
},
{
"param": "inputs",
"type": "Iterable[Any]"
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "func_type",
"type": "type",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "inputs",
"type": "Iterable[Any]",
"docstring": null,
"... |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | parameters | Tensor | def parameters(self) -> Tensor:
''' Generator for all the parameters of the current flow
'''
for param in self._total_parameters():
yield param | Generator for all the parameters of the current flow
| Generator for all the parameters of the current flow | [
"Generator",
"for",
"all",
"the",
"parameters",
"of",
"the",
"current",
"flow"
] | def parameters(self) -> Tensor:
for param in self._total_parameters():
yield param | [
"def",
"parameters",
"(",
"self",
")",
"->",
"Tensor",
":",
"for",
"param",
"in",
"self",
".",
"_total_parameters",
"(",
")",
":",
"yield",
"param"
] | Generator for all the parameters of the current flow | [
"Generator",
"for",
"all",
"the",
"parameters",
"of",
"the",
"current",
"flow"
] | [
"''' Generator for all the parameters of the current flow\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | _total_parameters | Tensor | def _total_parameters(self) -> Tensor:
''' Returns an iterable of all the parameters of the current flow
Including those of other flows that are used in the current one
(namely other flows bounded to `self`).
'''
total_params = [self._current_parameters()]
for prop_na... | Returns an iterable of all the parameters of the current flow
Including those of other flows that are used in the current one
(namely other flows bounded to `self`).
| Returns an iterable of all the parameters of the current flow
Including those of other flows that are used in the current one
(namely other flows bounded to `self`). | [
"Returns",
"an",
"iterable",
"of",
"all",
"the",
"parameters",
"of",
"the",
"current",
"flow",
"Including",
"those",
"of",
"other",
"flows",
"that",
"are",
"used",
"in",
"the",
"current",
"one",
"(",
"namely",
"other",
"flows",
"bounded",
"to",
"`",
"self"... | def _total_parameters(self) -> Tensor:
total_params = [self._current_parameters()]
for prop_name in dir(self):
prop = getattr(self, prop_name)
if isinstance(prop, Flow):
total_params.append(prop.parameters())
return chain(*total_params) | [
"def",
"_total_parameters",
"(",
"self",
")",
"->",
"Tensor",
":",
"total_params",
"=",
"[",
"self",
".",
"_current_parameters",
"(",
")",
"]",
"for",
"prop_name",
"in",
"dir",
"(",
"self",
")",
":",
"prop",
"=",
"getattr",
"(",
"self",
",",
"prop_name",... | Returns an iterable of all the parameters of the current flow
Including those of other flows that are used in the current one
(namely other flows bounded to `self`). | [
"Returns",
"an",
"iterable",
"of",
"all",
"the",
"parameters",
"of",
"the",
"current",
"flow",
"Including",
"those",
"of",
"other",
"flows",
"that",
"are",
"used",
"in",
"the",
"current",
"one",
"(",
"namely",
"other",
"flows",
"bounded",
"to",
"`",
"self"... | [
"''' Returns an iterable of all the parameters of the current flow\n\n Including those of other flows that are used in the current one\n (namely other flows bounded to `self`).\n\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | _current_parameters | Tensor | def _current_parameters(self) -> Tensor:
''' Generator for the current tensor parameters bounded to `self`
'''
for flow in self._chain:
for prop_name in dir(flow):
prop = getattr(flow, prop_name)
if isinstance(prop, Tensor):
yield... | Generator for the current tensor parameters bounded to `self`
| Generator for the current tensor parameters bounded to `self` | [
"Generator",
"for",
"the",
"current",
"tensor",
"parameters",
"bounded",
"to",
"`",
"self",
"`"
] | def _current_parameters(self) -> Tensor:
for flow in self._chain:
for prop_name in dir(flow):
prop = getattr(flow, prop_name)
if isinstance(prop, Tensor):
yield prop | [
"def",
"_current_parameters",
"(",
"self",
")",
"->",
"Tensor",
":",
"for",
"flow",
"in",
"self",
".",
"_chain",
":",
"for",
"prop_name",
"in",
"dir",
"(",
"flow",
")",
":",
"prop",
"=",
"getattr",
"(",
"flow",
",",
"prop_name",
")",
"if",
"isinstance"... | Generator for the current tensor parameters bounded to `self` | [
"Generator",
"for",
"the",
"current",
"tensor",
"parameters",
"bounded",
"to",
"`",
"self",
"`"
] | [
"''' Generator for the current tensor parameters bounded to `self`\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | append | 'Flow' | def append(self, *flows: 'Flow') -> 'Flow':
''' Flow Append
Connect the current chain with those of `flows` by adding them
at the end.
Parameters:
-----------
- flows : varargs, the flows to append, sequantially
Returns:
--------
- flow : Flow... | Flow Append
Connect the current chain with those of `flows` by adding them
at the end.
Parameters:
-----------
- flows : varargs, the flows to append, sequantially
Returns:
--------
- flow : Flow, the total computation flow
| Flow Append
Connect the current chain with those of `flows` by adding them
at the end. | [
"Flow",
"Append",
"Connect",
"the",
"current",
"chain",
"with",
"those",
"of",
"`",
"flows",
"`",
"by",
"adding",
"them",
"at",
"the",
"end",
"."
] | def append(self, *flows: 'Flow') -> 'Flow':
for flow in flows:
for chain_section in flow:
self._chain.append(chain_section)
self.name = self._generate_chain_name()
return self | [
"def",
"append",
"(",
"self",
",",
"*",
"flows",
":",
"'Flow'",
")",
"->",
"'Flow'",
":",
"for",
"flow",
"in",
"flows",
":",
"for",
"chain_section",
"in",
"flow",
":",
"self",
".",
"_chain",
".",
"append",
"(",
"chain_section",
")",
"self",
".",
"nam... | Flow Append
Connect the current chain with those of `flows` by adding them
at the end. | [
"Flow",
"Append",
"Connect",
"the",
"current",
"chain",
"with",
"those",
"of",
"`",
"flows",
"`",
"by",
"adding",
"them",
"at",
"the",
"end",
"."
] | [
"''' Flow Append\n\n Connect the current chain with those of `flows` by adding them\n at the end.\n\n Parameters:\n -----------\n - flows : varargs, the flows to append, sequantially\n\n Returns:\n --------\n - flow : Flow, the total computation flow\n\n ... | [
{
"param": "self",
"type": null
},
{
"param": "flows",
"type": "'Flow'"
}
] | {
"returns": [
{
"docstring": "flow : Flow, the total computation flow",
"docstring_tokens": [
"flow",
":",
"Flow",
"the",
"total",
"computation",
"flow"
],
"type": null
}
],
"raises": [],
"params": [
{
"identifier... |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | copy | 'Flow' | def copy(self) -> 'Flow':
''' Make a copy of the flow
'''
return deepcopy(self) | Make a copy of the flow
| Make a copy of the flow | [
"Make",
"a",
"copy",
"of",
"the",
"flow"
] | def copy(self) -> 'Flow':
return deepcopy(self) | [
"def",
"copy",
"(",
"self",
")",
"->",
"'Flow'",
":",
"return",
"deepcopy",
"(",
"self",
")"
] | Make a copy of the flow | [
"Make",
"a",
"copy",
"of",
"the",
"flow"
] | [
"''' Make a copy of the flow\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
75ed8f8792aa0403bcbe3888c64789dbea6c0864 | VIVelev/nujo | nujo/flow.py | [
"MIT"
] | Python | forward | Tensor | def forward(self, *args, **kwargs) -> Tensor:
''' Flow Forward
The flow computation is defined here.
'''
pass | Flow Forward
The flow computation is defined here.
| Flow Forward
The flow computation is defined here. | [
"Flow",
"Forward",
"The",
"flow",
"computation",
"is",
"defined",
"here",
"."
] | def forward(self, *args, **kwargs) -> Tensor:
pass | [
"def",
"forward",
"(",
"self",
",",
"*",
"args",
",",
"**",
"kwargs",
")",
"->",
"Tensor",
":",
"pass"
] | Flow Forward
The flow computation is defined here. | [
"Flow",
"Forward",
"The",
"flow",
"computation",
"is",
"defined",
"here",
"."
] | [
"''' Flow Forward\n\n The flow computation is defined here.\n\n '''"
] | [
{
"param": "self",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "self",
"type": null,
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
}
],
"outlier_params": [],
"others": []
} |
fd1d8d125215261dfb8f81915520e57a6610e7cd | VIVelev/nujo | nujo/init/random.py | [
"MIT"
] | Python | rand | Tensor | def rand(*shape: int, diff=False, name='Tensor[rand]') -> Tensor:
''' Random values in a given shape.
'''
return Tensor(np_rand(*shape), diff=diff, name=name) | Random values in a given shape.
| Random values in a given shape. | [
"Random",
"values",
"in",
"a",
"given",
"shape",
"."
] | def rand(*shape: int, diff=False, name='Tensor[rand]') -> Tensor:
return Tensor(np_rand(*shape), diff=diff, name=name) | [
"def",
"rand",
"(",
"*",
"shape",
":",
"int",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[rand]'",
")",
"->",
"Tensor",
":",
"return",
"Tensor",
"(",
"np_rand",
"(",
"*",
"shape",
")",
",",
"diff",
"=",
"diff",
",",
"name",
"=",
"name",
... | Random values in a given shape. | [
"Random",
"values",
"in",
"a",
"given",
"shape",
"."
] | [
"''' Random values in a given shape.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "diff",
"type": null,
"docstring": null,
"docstring_tokens":... |
fd1d8d125215261dfb8f81915520e57a6610e7cd | VIVelev/nujo | nujo/init/random.py | [
"MIT"
] | Python | randn | Tensor | def randn(*shape: int, diff=False, name='Tensor[randn]') -> Tensor:
''' Return a sample (or samples) from the "standard normal" distribution.
'''
return Tensor(np_randn(*shape), diff=diff, name=name) | Return a sample (or samples) from the "standard normal" distribution.
| Return a sample (or samples) from the "standard normal" distribution. | [
"Return",
"a",
"sample",
"(",
"or",
"samples",
")",
"from",
"the",
"\"",
"standard",
"normal",
"\"",
"distribution",
"."
] | def randn(*shape: int, diff=False, name='Tensor[randn]') -> Tensor:
return Tensor(np_randn(*shape), diff=diff, name=name) | [
"def",
"randn",
"(",
"*",
"shape",
":",
"int",
",",
"diff",
"=",
"False",
",",
"name",
"=",
"'Tensor[randn]'",
")",
"->",
"Tensor",
":",
"return",
"Tensor",
"(",
"np_randn",
"(",
"*",
"shape",
")",
",",
"diff",
"=",
"diff",
",",
"name",
"=",
"name"... | Return a sample (or samples) from the "standard normal" distribution. | [
"Return",
"a",
"sample",
"(",
"or",
"samples",
")",
"from",
"the",
"\"",
"standard",
"normal",
"\"",
"distribution",
"."
] | [
"''' Return a sample (or samples) from the \"standard normal\" distribution.\n '''"
] | [
{
"param": "shape",
"type": "int"
},
{
"param": "diff",
"type": null
},
{
"param": "name",
"type": null
}
] | {
"returns": [],
"raises": [],
"params": [
{
"identifier": "shape",
"type": "int",
"docstring": null,
"docstring_tokens": [],
"default": null,
"is_optional": null
},
{
"identifier": "diff",
"type": null,
"docstring": null,
"docstring_tokens":... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.