partition stringclasses 3
values | func_name stringlengths 1 134 | docstring stringlengths 1 46.9k | path stringlengths 4 223 | original_string stringlengths 75 104k | code stringlengths 75 104k | docstring_tokens listlengths 1 1.97k | repo stringlengths 7 55 | language stringclasses 1
value | url stringlengths 87 315 | code_tokens listlengths 19 28.4k | sha stringlengths 40 40 |
|---|---|---|---|---|---|---|---|---|---|---|---|
train | Drawing.assign_node_colors_and_style | Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a list of colors to pass to Drawing.node_colors
which is ... | toytree/Drawing.py | def assign_node_colors_and_style(self):
"""
Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a list... | def assign_node_colors_and_style(self):
"""
Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a list... | [
"Resolve",
"conflict",
"of",
"node_color",
"and",
"node_style",
"[",
"fill",
"]",
"args",
"which",
"are",
"redundant",
".",
"Default",
"is",
"node_style",
".",
"fill",
"unless",
"user",
"entered",
"node_color",
".",
"To",
"enter",
"multiple",
"colors",
"user",... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L180-L236 | [
"def",
"assign_node_colors_and_style",
"(",
"self",
")",
":",
"# SET node_colors and POP node_style.fill",
"colors",
"=",
"self",
".",
"style",
".",
"node_colors",
"style",
"=",
"self",
".",
"style",
".",
"node_style",
"if",
"colors",
"is",
"None",
":",
"if",
"s... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.assign_node_labels_and_sizes | assign features of nodes to be plotted based on user kwargs | toytree/Drawing.py | def assign_node_labels_and_sizes(self):
"assign features of nodes to be plotted based on user kwargs"
# shorthand
nvals = self.ttree.get_node_values()
# False == Hide nodes and labels unless user entered size
if self.style.node_labels is False:
self.node_labels = [... | def assign_node_labels_and_sizes(self):
"assign features of nodes to be plotted based on user kwargs"
# shorthand
nvals = self.ttree.get_node_values()
# False == Hide nodes and labels unless user entered size
if self.style.node_labels is False:
self.node_labels = [... | [
"assign",
"features",
"of",
"nodes",
"to",
"be",
"plotted",
"based",
"on",
"user",
"kwargs"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L240-L311 | [
"def",
"assign_node_labels_and_sizes",
"(",
"self",
")",
":",
"# shorthand",
"nvals",
"=",
"self",
".",
"ttree",
".",
"get_node_values",
"(",
")",
"# False == Hide nodes and labels unless user entered size ",
"if",
"self",
".",
"style",
".",
"node_labels",
"is",
"Fals... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.assign_tip_labels_and_colors | assign tip labels based on user provided kwargs | toytree/Drawing.py | def assign_tip_labels_and_colors(self):
"assign tip labels based on user provided kwargs"
# COLOR
# tip color overrides tipstyle.fill
if self.style.tip_labels_colors:
#if self.style.tip_labels_style.fill:
# self.style.tip_labels_style.fill = None
if... | def assign_tip_labels_and_colors(self):
"assign tip labels based on user provided kwargs"
# COLOR
# tip color overrides tipstyle.fill
if self.style.tip_labels_colors:
#if self.style.tip_labels_style.fill:
# self.style.tip_labels_style.fill = None
if... | [
"assign",
"tip",
"labels",
"based",
"on",
"user",
"provided",
"kwargs"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L314-L349 | [
"def",
"assign_tip_labels_and_colors",
"(",
"self",
")",
":",
"# COLOR",
"# tip color overrides tipstyle.fill",
"if",
"self",
".",
"style",
".",
"tip_labels_colors",
":",
"#if self.style.tip_labels_style.fill:",
"# self.style.tip_labels_style.fill = None",
"if",
"self",
".",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.assign_edge_colors_and_widths | Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a list of colors to pass to Drawing.node_colors
which is ... | toytree/Drawing.py | def assign_edge_colors_and_widths(self):
"""
Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a lis... | def assign_edge_colors_and_widths(self):
"""
Resolve conflict of 'node_color' and 'node_style['fill'] args which are
redundant. Default is node_style.fill unless user entered node_color.
To enter multiple colors user must use node_color not style fill.
Either way, we build a lis... | [
"Resolve",
"conflict",
"of",
"node_color",
"and",
"node_style",
"[",
"fill",
"]",
"args",
"which",
"are",
"redundant",
".",
"Default",
"is",
"node_style",
".",
"fill",
"unless",
"user",
"entered",
"node_color",
".",
"To",
"enter",
"multiple",
"colors",
"user",... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L352-L421 | [
"def",
"assign_edge_colors_and_widths",
"(",
"self",
")",
":",
"# node_color overrides fill. Tricky to catch cuz it can be many types.",
"# SET edge_widths and POP edge_style.stroke-width",
"if",
"self",
".",
"style",
".",
"edge_widths",
"is",
"None",
":",
"if",
"not",
"self",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.add_nodes_to_axes | Creates a new marker for every node from idx indexes and lists of
node_values, node_colors, node_sizes, node_style, node_labels_style.
Pulls from node_color and adds to a copy of the style dict for each
node to create marker.
Node_colors has priority to overwrite node_style['fill'] | toytree/Drawing.py | def add_nodes_to_axes(self):
"""
Creates a new marker for every node from idx indexes and lists of
node_values, node_colors, node_sizes, node_style, node_labels_style.
Pulls from node_color and adds to a copy of the style dict for each
node to create marker.
Node_color... | def add_nodes_to_axes(self):
"""
Creates a new marker for every node from idx indexes and lists of
node_values, node_colors, node_sizes, node_style, node_labels_style.
Pulls from node_color and adds to a copy of the style dict for each
node to create marker.
Node_color... | [
"Creates",
"a",
"new",
"marker",
"for",
"every",
"node",
"from",
"idx",
"indexes",
"and",
"lists",
"of",
"node_values",
"node_colors",
"node_sizes",
"node_style",
"node_labels_style",
".",
"Pulls",
"from",
"node_color",
"and",
"adds",
"to",
"a",
"copy",
"of",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L504-L566 | [
"def",
"add_nodes_to_axes",
"(",
"self",
")",
":",
"# bail out if not any visible nodes (e.g., none w/ size>0)",
"if",
"all",
"(",
"[",
"i",
"==",
"\"\"",
"for",
"i",
"in",
"self",
".",
"node_labels",
"]",
")",
":",
"return",
"# build markers for each node.",
"marks... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.get_tip_label_coords | Get starting position of tip labels text based on locations of the
leaf nodes on the tree and style offset and align options. Node
positions are found using the .verts attribute of coords and is
already oriented for the tree face direction. | toytree/Drawing.py | def get_tip_label_coords(self):
"""
Get starting position of tip labels text based on locations of the
leaf nodes on the tree and style offset and align options. Node
positions are found using the .verts attribute of coords and is
already oriented for the tree face direction.
... | def get_tip_label_coords(self):
"""
Get starting position of tip labels text based on locations of the
leaf nodes on the tree and style offset and align options. Node
positions are found using the .verts attribute of coords and is
already oriented for the tree face direction.
... | [
"Get",
"starting",
"position",
"of",
"tip",
"labels",
"text",
"based",
"on",
"locations",
"of",
"the",
"leaf",
"nodes",
"on",
"the",
"tree",
"and",
"style",
"offset",
"and",
"align",
"options",
".",
"Node",
"positions",
"are",
"found",
"using",
"the",
".",... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L624-L665 | [
"def",
"get_tip_label_coords",
"(",
"self",
")",
":",
"# number of tips",
"ns",
"=",
"self",
".",
"ttree",
".",
"ntips",
"# x-coordinate of tips assuming down-face",
"tip_xpos",
"=",
"self",
".",
"coords",
".",
"verts",
"[",
":",
"ns",
",",
"0",
"]",
"tip_ypos... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.get_dims_from_tree_size | Calculate reasonable canvas height and width for tree given N tips | toytree/Drawing.py | def get_dims_from_tree_size(self):
"Calculate reasonable canvas height and width for tree given N tips"
ntips = len(self.ttree)
if self.style.orient in ("right", "left"):
# height is long tip-wise dimension
if not self.style.height:
self.style.height = ma... | def get_dims_from_tree_size(self):
"Calculate reasonable canvas height and width for tree given N tips"
ntips = len(self.ttree)
if self.style.orient in ("right", "left"):
# height is long tip-wise dimension
if not self.style.height:
self.style.height = ma... | [
"Calculate",
"reasonable",
"canvas",
"height",
"and",
"width",
"for",
"tree",
"given",
"N",
"tips"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L693-L707 | [
"def",
"get_dims_from_tree_size",
"(",
"self",
")",
":",
"ntips",
"=",
"len",
"(",
"self",
".",
"ttree",
")",
"if",
"self",
".",
"style",
".",
"orient",
"in",
"(",
"\"right\"",
",",
"\"left\"",
")",
":",
"# height is long tip-wise dimension",
"if",
"not",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_longest_line_length | Get the length longest line in a paragraph | dashtable/data2rst/cell/get_longest_line_length.py | def get_longest_line_length(text):
"""Get the length longest line in a paragraph"""
lines = text.split("\n")
length = 0
for i in range(len(lines)):
if len(lines[i]) > length:
length = len(lines[i])
return length | def get_longest_line_length(text):
"""Get the length longest line in a paragraph"""
lines = text.split("\n")
length = 0
for i in range(len(lines)):
if len(lines[i]) > length:
length = len(lines[i])
return length | [
"Get",
"the",
"length",
"longest",
"line",
"in",
"a",
"paragraph"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_longest_line_length.py#L1-L10 | [
"def",
"get_longest_line_length",
"(",
"text",
")",
":",
"lines",
"=",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"length",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"lines",
")",
")",
":",
"if",
"len",
"(",
"lines",
"[",
"i",
"]",
")... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | isnumeric | Return true if obj is a numeric value | dynts/utils/numbers.py | def isnumeric(obj):
'''
Return true if obj is a numeric value
'''
from decimal import Decimal
if type(obj) == Decimal:
return True
else:
try:
float(obj)
except:
return False
return True | def isnumeric(obj):
'''
Return true if obj is a numeric value
'''
from decimal import Decimal
if type(obj) == Decimal:
return True
else:
try:
float(obj)
except:
return False
return True | [
"Return",
"true",
"if",
"obj",
"is",
"a",
"numeric",
"value"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/numbers.py#L10-L22 | [
"def",
"isnumeric",
"(",
"obj",
")",
":",
"from",
"decimal",
"import",
"Decimal",
"if",
"type",
"(",
"obj",
")",
"==",
"Decimal",
":",
"return",
"True",
"else",
":",
"try",
":",
"float",
"(",
"obj",
")",
"except",
":",
"return",
"False",
"return",
"T... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | significant_format | Format a number according to a given number of significant figures. | dynts/utils/numbers.py | def significant_format(number, decimal_sep='.', thousand_sep=',', n=3):
"""Format a number according to a given number of significant figures.
"""
str_number = significant(number, n)
# sign
if float(number) < 0:
sign = '-'
else:
sign = ''
if str_number[0] == '-':... | def significant_format(number, decimal_sep='.', thousand_sep=',', n=3):
"""Format a number according to a given number of significant figures.
"""
str_number = significant(number, n)
# sign
if float(number) < 0:
sign = '-'
else:
sign = ''
if str_number[0] == '-':... | [
"Format",
"a",
"number",
"according",
"to",
"a",
"given",
"number",
"of",
"significant",
"figures",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/numbers.py#L34-L60 | [
"def",
"significant_format",
"(",
"number",
",",
"decimal_sep",
"=",
"'.'",
",",
"thousand_sep",
"=",
"','",
",",
"n",
"=",
"3",
")",
":",
"str_number",
"=",
"significant",
"(",
"number",
",",
"n",
")",
"# sign\r",
"if",
"float",
"(",
"number",
")",
"<... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | to_text_string | Convert `obj` to (unicode) text string | formlayout.py | def to_text_string(obj, encoding=None):
"""Convert `obj` to (unicode) text string"""
if PY2:
# Python 2
if encoding is None:
return unicode(obj)
else:
return unicode(obj, encoding)
else:
# Python 3
if encoding is None:
return str(ob... | def to_text_string(obj, encoding=None):
"""Convert `obj` to (unicode) text string"""
if PY2:
# Python 2
if encoding is None:
return unicode(obj)
else:
return unicode(obj, encoding)
else:
# Python 3
if encoding is None:
return str(ob... | [
"Convert",
"obj",
"to",
"(",
"unicode",
")",
"text",
"string"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L134-L150 | [
"def",
"to_text_string",
"(",
"obj",
",",
"encoding",
"=",
"None",
")",
":",
"if",
"PY2",
":",
"# Python 2",
"if",
"encoding",
"is",
"None",
":",
"return",
"unicode",
"(",
"obj",
")",
"else",
":",
"return",
"unicode",
"(",
"obj",
",",
"encoding",
")",
... | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | text_to_qcolor | Create a QColor from specified string
Avoid warning from Qt when an invalid QColor is instantiated | formlayout.py | def text_to_qcolor(text):
"""
Create a QColor from specified string
Avoid warning from Qt when an invalid QColor is instantiated
"""
color = QColor()
if not is_string(text): # testing for QString (PyQt API#1)
text = str(text)
if not is_text_string(text):
return color
if t... | def text_to_qcolor(text):
"""
Create a QColor from specified string
Avoid warning from Qt when an invalid QColor is instantiated
"""
color = QColor()
if not is_string(text): # testing for QString (PyQt API#1)
text = str(text)
if not is_text_string(text):
return color
if t... | [
"Create",
"a",
"QColor",
"from",
"specified",
"string",
"Avoid",
"warning",
"from",
"Qt",
"when",
"an",
"invalid",
"QColor",
"is",
"instantiated"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L194-L212 | [
"def",
"text_to_qcolor",
"(",
"text",
")",
":",
"color",
"=",
"QColor",
"(",
")",
"if",
"not",
"is_string",
"(",
"text",
")",
":",
"# testing for QString (PyQt API#1)",
"text",
"=",
"str",
"(",
"text",
")",
"if",
"not",
"is_text_string",
"(",
"text",
")",
... | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | tuple_to_qfont | Create a QFont from tuple:
(family [string], size [int], italic [bool], bold [bool]) | formlayout.py | def tuple_to_qfont(tup):
"""
Create a QFont from tuple:
(family [string], size [int], italic [bool], bold [bool])
"""
if not isinstance(tup, tuple) or len(tup) != 4 \
or not is_text_string(tup[0]) \
or not isinstance(tup[1], int) \
or not isinstance(tup[2], bool) \
or... | def tuple_to_qfont(tup):
"""
Create a QFont from tuple:
(family [string], size [int], italic [bool], bold [bool])
"""
if not isinstance(tup, tuple) or len(tup) != 4 \
or not is_text_string(tup[0]) \
or not isinstance(tup[1], int) \
or not isinstance(tup[2], bool) \
or... | [
"Create",
"a",
"QFont",
"from",
"tuple",
":",
"(",
"family",
"[",
"string",
"]",
"size",
"[",
"int",
"]",
"italic",
"[",
"bool",
"]",
"bold",
"[",
"bool",
"]",
")"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L423-L440 | [
"def",
"tuple_to_qfont",
"(",
"tup",
")",
":",
"if",
"not",
"isinstance",
"(",
"tup",
",",
"tuple",
")",
"or",
"len",
"(",
"tup",
")",
"!=",
"4",
"or",
"not",
"is_text_string",
"(",
"tup",
"[",
"0",
"]",
")",
"or",
"not",
"isinstance",
"(",
"tup",
... | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | fedit | Create form dialog and return result
(if Cancel button is pressed, return None)
:param tuple data: datalist, datagroup (see below)
:param str title: form title
:param str comment: header comment
:param QIcon icon: dialog box icon
:param QWidget parent: parent widget
:param str ok: customize... | formlayout.py | def fedit(data, title="", comment="", icon=None, parent=None, apply=None,
ok=True, cancel=True, result='list', outfile=None, type='form',
scrollbar=False, background_color=None, widget_color=None):
"""
Create form dialog and return result
(if Cancel button is pressed, return None)
:... | def fedit(data, title="", comment="", icon=None, parent=None, apply=None,
ok=True, cancel=True, result='list', outfile=None, type='form',
scrollbar=False, background_color=None, widget_color=None):
"""
Create form dialog and return result
(if Cancel button is pressed, return None)
:... | [
"Create",
"form",
"dialog",
"and",
"return",
"result",
"(",
"if",
"Cancel",
"button",
"is",
"pressed",
"return",
"None",
")"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L1190-L1266 | [
"def",
"fedit",
"(",
"data",
",",
"title",
"=",
"\"\"",
",",
"comment",
"=",
"\"\"",
",",
"icon",
"=",
"None",
",",
"parent",
"=",
"None",
",",
"apply",
"=",
"None",
",",
"ok",
"=",
"True",
",",
"cancel",
"=",
"True",
",",
"result",
"=",
"'list'"... | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | FormWidget.get_dialog | Return FormDialog instance | formlayout.py | def get_dialog(self):
"""Return FormDialog instance"""
dialog = self.parent()
while not isinstance(dialog, QDialog):
dialog = dialog.parent()
return dialog | def get_dialog(self):
"""Return FormDialog instance"""
dialog = self.parent()
while not isinstance(dialog, QDialog):
dialog = dialog.parent()
return dialog | [
"Return",
"FormDialog",
"instance"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L548-L553 | [
"def",
"get_dialog",
"(",
"self",
")",
":",
"dialog",
"=",
"self",
".",
"parent",
"(",
")",
"while",
"not",
"isinstance",
"(",
"dialog",
",",
"QDialog",
")",
":",
"dialog",
"=",
"dialog",
".",
"parent",
"(",
")",
"return",
"dialog"
] | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | FormDialog.get | Return form result | formlayout.py | def get(self):
"""Return form result"""
# It is import to avoid accessing Qt C++ object as it has probably
# already been destroyed, due to the Qt.WA_DeleteOnClose attribute
if self.outfile:
if self.result in ['list', 'dict', 'OrderedDict']:
fd = open(self.out... | def get(self):
"""Return form result"""
# It is import to avoid accessing Qt C++ object as it has probably
# already been destroyed, due to the Qt.WA_DeleteOnClose attribute
if self.outfile:
if self.result in ['list', 'dict', 'OrderedDict']:
fd = open(self.out... | [
"Return",
"form",
"result"
] | PierreRaybaut/formlayout | python | https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L1168-L1187 | [
"def",
"get",
"(",
"self",
")",
":",
"# It is import to avoid accessing Qt C++ object as it has probably",
"# already been destroyed, due to the Qt.WA_DeleteOnClose attribute",
"if",
"self",
".",
"outfile",
":",
"if",
"self",
".",
"result",
"in",
"[",
"'list'",
",",
"'dict'... | 832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0 |
train | ts_merge | Merge timeseries into a new :class:`~.TimeSeries` instance.
:parameter series: an iterable over :class:`~.TimeSeries`. | dynts/api/timeseries.py | def ts_merge(series):
'''Merge timeseries into a new :class:`~.TimeSeries` instance.
:parameter series: an iterable over :class:`~.TimeSeries`.
'''
series = iter(series)
ts = next(series)
return ts.merge(series) | def ts_merge(series):
'''Merge timeseries into a new :class:`~.TimeSeries` instance.
:parameter series: an iterable over :class:`~.TimeSeries`.
'''
series = iter(series)
ts = next(series)
return ts.merge(series) | [
"Merge",
"timeseries",
"into",
"a",
"new",
":",
"class",
":",
"~",
".",
"TimeSeries",
"instance",
".",
":",
"parameter",
"series",
":",
"an",
"iterable",
"over",
":",
"class",
":",
"~",
".",
"TimeSeries",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L31-L38 | [
"def",
"ts_merge",
"(",
"series",
")",
":",
"series",
"=",
"iter",
"(",
"series",
")",
"ts",
"=",
"next",
"(",
"series",
")",
"return",
"ts",
".",
"merge",
"(",
"series",
")"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | ts_bin_op | Entry point for any arithmetic type function performed on a timeseries
and/or a scalar.
op_name - name of the function to be performed
ts1, ts2 - timeseries or scalars that the function is to performed over
all - whether all dates should be included in the result
fill - the value that should be... | dynts/api/timeseries.py | def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None):
'''Entry point for any arithmetic type function performed on a timeseries
and/or a scalar.
op_name - name of the function to be performed
ts1, ts2 - timeseries or scalars that the function is to performed over
all - whether all d... | def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None):
'''Entry point for any arithmetic type function performed on a timeseries
and/or a scalar.
op_name - name of the function to be performed
ts1, ts2 - timeseries or scalars that the function is to performed over
all - whether all d... | [
"Entry",
"point",
"for",
"any",
"arithmetic",
"type",
"function",
"performed",
"on",
"a",
"timeseries",
"and",
"/",
"or",
"a",
"scalar",
".",
"op_name",
"-",
"name",
"of",
"the",
"function",
"to",
"be",
"performed",
"ts1",
"ts2",
"-",
"timeseries",
"or",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L41-L72 | [
"def",
"ts_bin_op",
"(",
"op_name",
",",
"ts1",
",",
"ts2",
",",
"all",
"=",
"True",
",",
"fill",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"op",
"=",
"op_get",
"(",
"op_name",
")",
"fill",
"=",
"fill",
"if",
"fill",
"is",
"not",
"None",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.getalgo | Return the algorithm for *operation* named *name* | dynts/api/timeseries.py | def getalgo(self, operation, name):
'''Return the algorithm for *operation* named *name*'''
if operation not in self._algorithms:
raise NotAvailable('{0} not registered.'.format(operation))
oper = self._algorithms[operation]
try:
return oper[name]
e... | def getalgo(self, operation, name):
'''Return the algorithm for *operation* named *name*'''
if operation not in self._algorithms:
raise NotAvailable('{0} not registered.'.format(operation))
oper = self._algorithms[operation]
try:
return oper[name]
e... | [
"Return",
"the",
"algorithm",
"for",
"*",
"operation",
"*",
"named",
"*",
"name",
"*"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L119-L128 | [
"def",
"getalgo",
"(",
"self",
",",
"operation",
",",
"name",
")",
":",
"if",
"operation",
"not",
"in",
"self",
".",
"_algorithms",
":",
"raise",
"NotAvailable",
"(",
"'{0} not registered.'",
".",
"format",
"(",
"operation",
")",
")",
"oper",
"=",
"self",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.dates | Returns an iterable over ``datetime.date`` instances
in the timeseries. | dynts/api/timeseries.py | def dates(self, desc=None):
'''Returns an iterable over ``datetime.date`` instances
in the timeseries.'''
c = self.dateinverse
for key in self.keys(desc=desc):
yield c(key) | def dates(self, desc=None):
'''Returns an iterable over ``datetime.date`` instances
in the timeseries.'''
c = self.dateinverse
for key in self.keys(desc=desc):
yield c(key) | [
"Returns",
"an",
"iterable",
"over",
"datetime",
".",
"date",
"instances",
"in",
"the",
"timeseries",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L150-L155 | [
"def",
"dates",
"(",
"self",
",",
"desc",
"=",
"None",
")",
":",
"c",
"=",
"self",
".",
"dateinverse",
"for",
"key",
"in",
"self",
".",
"keys",
"(",
"desc",
"=",
"desc",
")",
":",
"yield",
"c",
"(",
"key",
")"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.items | Returns a python ``generator`` which can be used to iterate over
:func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values`
returning a two dimensional
tuple ``(date,value)`` in each iteration.
Similar to the python dictionary items
function.
:parameter de... | dynts/api/timeseries.py | def items(self, desc=None, start_value=None, shift_by=None):
'''Returns a python ``generator`` which can be used to iterate over
:func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values`
returning a two dimensional
tuple ``(date,value)`` in each iteration.
Similar t... | def items(self, desc=None, start_value=None, shift_by=None):
'''Returns a python ``generator`` which can be used to iterate over
:func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values`
returning a two dimensional
tuple ``(date,value)`` in each iteration.
Similar t... | [
"Returns",
"a",
"python",
"generator",
"which",
"can",
"be",
"used",
"to",
"iterate",
"over",
":",
"func",
":",
"dynts",
".",
"TimeSeries",
".",
"dates",
"and",
":",
"func",
":",
"dynts",
".",
"TimeSeries",
".",
"values",
"returning",
"a",
"two",
"dimens... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L170-L209 | [
"def",
"items",
"(",
"self",
",",
"desc",
"=",
"None",
",",
"start_value",
"=",
"None",
",",
"shift_by",
"=",
"None",
")",
":",
"if",
"self",
":",
"if",
"shift_by",
"is",
"None",
"and",
"start_value",
"is",
"not",
"None",
":",
"for",
"cross",
"in",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.series | Generator of single series data (no dates are included). | dynts/api/timeseries.py | def series(self):
'''Generator of single series data (no dates are included).'''
data = self.values()
if len(data):
for c in range(self.count()):
yield data[:, c]
else:
raise StopIteration | def series(self):
'''Generator of single series data (no dates are included).'''
data = self.values()
if len(data):
for c in range(self.count()):
yield data[:, c]
else:
raise StopIteration | [
"Generator",
"of",
"single",
"series",
"data",
"(",
"no",
"dates",
"are",
"included",
")",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L211-L218 | [
"def",
"series",
"(",
"self",
")",
":",
"data",
"=",
"self",
".",
"values",
"(",
")",
"if",
"len",
"(",
"data",
")",
":",
"for",
"c",
"in",
"range",
"(",
"self",
".",
"count",
"(",
")",
")",
":",
"yield",
"data",
"[",
":",
",",
"c",
"]",
"e... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.named_series | Generator of tuples with name and serie data. | dynts/api/timeseries.py | def named_series(self, ordering=None):
'''Generator of tuples with name and serie data.'''
series = self.series()
if ordering:
series = list(series)
todo = dict(((n, idx) for idx, n in enumerate(self.names())))
for name in ordering:
if n... | def named_series(self, ordering=None):
'''Generator of tuples with name and serie data.'''
series = self.series()
if ordering:
series = list(series)
todo = dict(((n, idx) for idx, n in enumerate(self.names())))
for name in ordering:
if n... | [
"Generator",
"of",
"tuples",
"with",
"name",
"and",
"serie",
"data",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L220-L235 | [
"def",
"named_series",
"(",
"self",
",",
"ordering",
"=",
"None",
")",
":",
"series",
"=",
"self",
".",
"series",
"(",
")",
"if",
"ordering",
":",
"series",
"=",
"list",
"(",
"series",
")",
"todo",
"=",
"dict",
"(",
"(",
"(",
"n",
",",
"idx",
")"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.clone | Create a clone of timeseries | dynts/api/timeseries.py | def clone(self, date=None, data=None, name=None):
'''Create a clone of timeseries'''
name = name or self.name
data = data if data is not None else self.values()
ts = self.__class__(name)
ts._dtype = self._dtype
if date is None:
# dates not provided
... | def clone(self, date=None, data=None, name=None):
'''Create a clone of timeseries'''
name = name or self.name
data = data if data is not None else self.values()
ts = self.__class__(name)
ts._dtype = self._dtype
if date is None:
# dates not provided
... | [
"Create",
"a",
"clone",
"of",
"timeseries"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L286-L297 | [
"def",
"clone",
"(",
"self",
",",
"date",
"=",
"None",
",",
"data",
"=",
"None",
",",
"name",
"=",
"None",
")",
":",
"name",
"=",
"name",
"or",
"self",
".",
"name",
"data",
"=",
"data",
"if",
"data",
"is",
"not",
"None",
"else",
"self",
".",
"v... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.reduce | Trim :class:`Timeseries` to a new *size* using the algorithm
*method*. If *size* is greater or equal than len(self) it does nothing. | dynts/api/timeseries.py | def reduce(self, size, method='simple', **kwargs):
'''Trim :class:`Timeseries` to a new *size* using the algorithm
*method*. If *size* is greater or equal than len(self) it does nothing.'''
if size >= len(self):
return self
return self.getalgo('reduce', method)(self, size, **kwa... | def reduce(self, size, method='simple', **kwargs):
'''Trim :class:`Timeseries` to a new *size* using the algorithm
*method*. If *size* is greater or equal than len(self) it does nothing.'''
if size >= len(self):
return self
return self.getalgo('reduce', method)(self, size, **kwa... | [
"Trim",
":",
"class",
":",
"Timeseries",
"to",
"a",
"new",
"*",
"size",
"*",
"using",
"the",
"algorithm",
"*",
"method",
"*",
".",
"If",
"*",
"size",
"*",
"is",
"greater",
"or",
"equal",
"than",
"len",
"(",
"self",
")",
"it",
"does",
"nothing",
"."... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L299-L304 | [
"def",
"reduce",
"(",
"self",
",",
"size",
",",
"method",
"=",
"'simple'",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"size",
">=",
"len",
"(",
"self",
")",
":",
"return",
"self",
"return",
"self",
".",
"getalgo",
"(",
"'reduce'",
",",
"method",
")",... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.clean | Create a new :class:`TimeSeries` with missing data removed or
replaced by the *algorithm* provided | dynts/api/timeseries.py | def clean(self, algorithm=None):
'''Create a new :class:`TimeSeries` with missing data removed or
replaced by the *algorithm* provided'''
# all dates
original_dates = list(self.dates())
series = []
all_dates = set()
for serie in self.series():
dstart, ... | def clean(self, algorithm=None):
'''Create a new :class:`TimeSeries` with missing data removed or
replaced by the *algorithm* provided'''
# all dates
original_dates = list(self.dates())
series = []
all_dates = set()
for serie in self.series():
dstart, ... | [
"Create",
"a",
"new",
":",
"class",
":",
"TimeSeries",
"with",
"missing",
"data",
"removed",
"or",
"replaced",
"by",
"the",
"*",
"algorithm",
"*",
"provided"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L306-L356 | [
"def",
"clean",
"(",
"self",
",",
"algorithm",
"=",
"None",
")",
":",
"# all dates\r",
"original_dates",
"=",
"list",
"(",
"self",
".",
"dates",
"(",
")",
")",
"series",
"=",
"[",
"]",
"all_dates",
"=",
"set",
"(",
")",
"for",
"serie",
"in",
"self",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.isconsistent | Check if the timeseries is consistent | dynts/api/timeseries.py | def isconsistent(self):
'''Check if the timeseries is consistent'''
for dt1, dt0 in laggeddates(self):
if dt1 <= dt0:
return False
return True | def isconsistent(self):
'''Check if the timeseries is consistent'''
for dt1, dt0 in laggeddates(self):
if dt1 <= dt0:
return False
return True | [
"Check",
"if",
"the",
"timeseries",
"is",
"consistent"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L394-L399 | [
"def",
"isconsistent",
"(",
"self",
")",
":",
"for",
"dt1",
",",
"dt0",
"in",
"laggeddates",
"(",
"self",
")",
":",
"if",
"dt1",
"<=",
"dt0",
":",
"return",
"False",
"return",
"True"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.var | Calculate variance of timeseries. Return a vector containing
the variances of each series in the timeseries.
:parameter ddof: delta degree of freedom, the divisor used in the calculation
is given by ``N - ddof`` where ``N`` represents the length
of timeseries. Default ``0``.
.... | dynts/api/timeseries.py | def var(self, ddof=0):
'''Calculate variance of timeseries. Return a vector containing
the variances of each series in the timeseries.
:parameter ddof: delta degree of freedom, the divisor used in the calculation
is given by ``N - ddof`` where ``N`` represents the length
... | def var(self, ddof=0):
'''Calculate variance of timeseries. Return a vector containing
the variances of each series in the timeseries.
:parameter ddof: delta degree of freedom, the divisor used in the calculation
is given by ``N - ddof`` where ``N`` represents the length
... | [
"Calculate",
"variance",
"of",
"timeseries",
".",
"Return",
"a",
"vector",
"containing",
"the",
"variances",
"of",
"each",
"series",
"in",
"the",
"timeseries",
".",
":",
"parameter",
"ddof",
":",
"delta",
"degree",
"of",
"freedom",
"the",
"divisor",
"used",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L461-L479 | [
"def",
"var",
"(",
"self",
",",
"ddof",
"=",
"0",
")",
":",
"N",
"=",
"len",
"(",
"self",
")",
"if",
"N",
":",
"v",
"=",
"self",
".",
"values",
"(",
")",
"mu",
"=",
"sum",
"(",
"v",
")",
"return",
"(",
"sum",
"(",
"v",
"*",
"v",
")",
"-... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.sd | Calculate standard deviation of timeseries | dynts/api/timeseries.py | def sd(self):
'''Calculate standard deviation of timeseries'''
v = self.var()
if len(v):
return np.sqrt(v)
else:
return None | def sd(self):
'''Calculate standard deviation of timeseries'''
v = self.var()
if len(v):
return np.sqrt(v)
else:
return None | [
"Calculate",
"standard",
"deviation",
"of",
"timeseries"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L481-L487 | [
"def",
"sd",
"(",
"self",
")",
":",
"v",
"=",
"self",
".",
"var",
"(",
")",
"if",
"len",
"(",
"v",
")",
":",
"return",
"np",
".",
"sqrt",
"(",
"v",
")",
"else",
":",
"return",
"None"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.apply | Apply function ``func`` to the timeseries.
:keyword func: string indicating function to apply
:keyword window: Rolling window, If not defined ``func`` is applied on
the whole dataset. Default ``None``.
:keyword bycolumn: If ``True``, function ``func`` is applied on
... | dynts/api/timeseries.py | def apply(self, func, window=None, bycolumn=True, align=None, **kwargs):
'''Apply function ``func`` to the timeseries.
:keyword func: string indicating function to apply
:keyword window: Rolling window, If not defined ``func`` is applied on
the whole dataset. Default ``None``.
... | def apply(self, func, window=None, bycolumn=True, align=None, **kwargs):
'''Apply function ``func`` to the timeseries.
:keyword func: string indicating function to apply
:keyword window: Rolling window, If not defined ``func`` is applied on
the whole dataset. Default ``None``.
... | [
"Apply",
"function",
"func",
"to",
"the",
"timeseries",
".",
":",
"keyword",
"func",
":",
"string",
"indicating",
"function",
"to",
"apply",
":",
"keyword",
"window",
":",
"Rolling",
"window",
"If",
"not",
"defined",
"func",
"is",
"applied",
"on",
"the",
"... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L489-L510 | [
"def",
"apply",
"(",
"self",
",",
"func",
",",
"window",
"=",
"None",
",",
"bycolumn",
"=",
"True",
",",
"align",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"N",
"=",
"len",
"(",
"self",
")",
"window",
"=",
"window",
"or",
"N",
"self",
"."... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.rollapply | A generic :ref:`rolling function <rolling-function>`
for function *func*.
Same construct as :meth:`dynts.TimeSeries.apply` but with default
``window`` set to ``20``. | dynts/api/timeseries.py | def rollapply(self, func, window=20, **kwargs):
'''A generic :ref:`rolling function <rolling-function>`
for function *func*.
Same construct as :meth:`dynts.TimeSeries.apply` but with default
``window`` set to ``20``.
'''
return self.apply(func, window=window, **kwar... | def rollapply(self, func, window=20, **kwargs):
'''A generic :ref:`rolling function <rolling-function>`
for function *func*.
Same construct as :meth:`dynts.TimeSeries.apply` but with default
``window`` set to ``20``.
'''
return self.apply(func, window=window, **kwar... | [
"A",
"generic",
":",
"ref",
":",
"rolling",
"function",
"<rolling",
"-",
"function",
">",
"for",
"function",
"*",
"func",
"*",
".",
"Same",
"construct",
"as",
":",
"meth",
":",
"dynts",
".",
"TimeSeries",
".",
"apply",
"but",
"with",
"default",
"window",... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L512-L518 | [
"def",
"rollapply",
"(",
"self",
",",
"func",
",",
"window",
"=",
"20",
",",
"*",
"*",
"kwargs",
")",
":",
"return",
"self",
".",
"apply",
"(",
"func",
",",
"window",
"=",
"window",
",",
"*",
"*",
"kwargs",
")"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | TimeSeries.rollsd | A :ref:`rolling function <rolling-function>` for
stadard-deviation values:
Same as::
self.rollapply('sd', **kwargs) | dynts/api/timeseries.py | def rollsd(self, scale=1, **kwargs):
'''A :ref:`rolling function <rolling-function>` for
stadard-deviation values:
Same as::
self.rollapply('sd', **kwargs)
'''
ts = self.rollapply('sd', **kwargs)
if scale != 1:
ts *= scale
return... | def rollsd(self, scale=1, **kwargs):
'''A :ref:`rolling function <rolling-function>` for
stadard-deviation values:
Same as::
self.rollapply('sd', **kwargs)
'''
ts = self.rollapply('sd', **kwargs)
if scale != 1:
ts *= scale
return... | [
"A",
":",
"ref",
":",
"rolling",
"function",
"<rolling",
"-",
"function",
">",
"for",
"stadard",
"-",
"deviation",
"values",
":",
"Same",
"as",
"::",
"self",
".",
"rollapply",
"(",
"sd",
"**",
"kwargs",
")"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L552-L562 | [
"def",
"rollsd",
"(",
"self",
",",
"scale",
"=",
"1",
",",
"*",
"*",
"kwargs",
")",
":",
"ts",
"=",
"self",
".",
"rollapply",
"(",
"'sd'",
",",
"*",
"*",
"kwargs",
")",
"if",
"scale",
"!=",
"1",
":",
"ts",
"*=",
"scale",
"return",
"ts"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | Expr.unwind | Unwind expression by applying *values* to the abstract nodes.
The ``kwargs`` dictionary can contain data which can be used
to override values | dynts/dsl/ast/base.py | def unwind(self, values, backend, **kwargs):
'''Unwind expression by applying *values* to the abstract nodes.
The ``kwargs`` dictionary can contain data which can be used
to override values
'''
if not hasattr(self, "_unwind_value"):
self._unwind_value = self._... | def unwind(self, values, backend, **kwargs):
'''Unwind expression by applying *values* to the abstract nodes.
The ``kwargs`` dictionary can contain data which can be used
to override values
'''
if not hasattr(self, "_unwind_value"):
self._unwind_value = self._... | [
"Unwind",
"expression",
"by",
"applying",
"*",
"values",
"*",
"to",
"the",
"abstract",
"nodes",
".",
"The",
"kwargs",
"dictionary",
"can",
"contain",
"data",
"which",
"can",
"be",
"used",
"to",
"override",
"values"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/ast/base.py#L43-L51 | [
"def",
"unwind",
"(",
"self",
",",
"values",
",",
"backend",
",",
"*",
"*",
"kwargs",
")",
":",
"if",
"not",
"hasattr",
"(",
"self",
",",
"\"_unwind_value\"",
")",
":",
"self",
".",
"_unwind_value",
"=",
"self",
".",
"_unwind",
"(",
"values",
",",
"b... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | MultiExpression.removeduplicates | Loop over children a remove duplicate entries.
@return - a list of removed entries | dynts/dsl/ast/base.py | def removeduplicates(self, entries = None):
'''
Loop over children a remove duplicate entries.
@return - a list of removed entries
'''
removed = []
if entries == None:
entries = {}
new_children = []
for c in self.children:
... | def removeduplicates(self, entries = None):
'''
Loop over children a remove duplicate entries.
@return - a list of removed entries
'''
removed = []
if entries == None:
entries = {}
new_children = []
for c in self.children:
... | [
"Loop",
"over",
"children",
"a",
"remove",
"duplicate",
"entries",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/ast/base.py#L209-L231 | [
"def",
"removeduplicates",
"(",
"self",
",",
"entries",
"=",
"None",
")",
":",
"removed",
"=",
"[",
"]",
"if",
"entries",
"==",
"None",
":",
"entries",
"=",
"{",
"}",
"new_children",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"children",
":",
"c... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | html2md | Convert a string or html file to a markdown table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
Returns
-------
str
The html table converted to a Markdown table
Notes
-----
This function requires BeautifulSoup_ ... | dashtable/html2md.py | def html2md(html_string):
"""
Convert a string or html file to a markdown table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
Returns
-------
str
The html table converted to a Markdown table
Notes
-----
... | def html2md(html_string):
"""
Convert a string or html file to a markdown table string.
Parameters
----------
html_string : str
Either the html string, or the filepath to the html
Returns
-------
str
The html table converted to a Markdown table
Notes
-----
... | [
"Convert",
"a",
"string",
"or",
"html",
"file",
"to",
"a",
"markdown",
"table",
"string",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2md.py#L6-L70 | [
"def",
"html2md",
"(",
"html_string",
")",
":",
"if",
"os",
".",
"path",
".",
"isfile",
"(",
"html_string",
")",
":",
"file",
"=",
"open",
"(",
"html_string",
",",
"'r'",
",",
"encoding",
"=",
"'utf-8'",
")",
"lines",
"=",
"file",
".",
"readlines",
"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | table_cells_2_spans | Converts the table to a list of spans, for consistency.
This method combines the table data with the span data into a
single, more consistent type. Any normal cell will become a span
of just 1 column and 1 row.
Parameters
----------
table : list of lists of str
spans : list of lists of int... | dashtable/data2rst/table_cells_2_spans.py | def table_cells_2_spans(table, spans):
"""
Converts the table to a list of spans, for consistency.
This method combines the table data with the span data into a
single, more consistent type. Any normal cell will become a span
of just 1 column and 1 row.
Parameters
----------
table : li... | def table_cells_2_spans(table, spans):
"""
Converts the table to a list of spans, for consistency.
This method combines the table data with the span data into a
single, more consistent type. Any normal cell will become a span
of just 1 column and 1 row.
Parameters
----------
table : li... | [
"Converts",
"the",
"table",
"to",
"a",
"list",
"of",
"spans",
"for",
"consistency",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/table_cells_2_spans.py#L4-L34 | [
"def",
"table_cells_2_spans",
"(",
"table",
",",
"spans",
")",
":",
"new_spans",
"=",
"[",
"]",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | RTS.keys | numpy asarray does not copy data | dynts/backends/r/base.py | def keys(self, desc = None):
'''numpy asarray does not copy data'''
res = asarray(self.rc('index'))
if desc == True:
return reversed(res)
else:
return res | def keys(self, desc = None):
'''numpy asarray does not copy data'''
res = asarray(self.rc('index'))
if desc == True:
return reversed(res)
else:
return res | [
"numpy",
"asarray",
"does",
"not",
"copy",
"data"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L54-L60 | [
"def",
"keys",
"(",
"self",
",",
"desc",
"=",
"None",
")",
":",
"res",
"=",
"asarray",
"(",
"self",
".",
"rc",
"(",
"'index'",
")",
")",
"if",
"desc",
"==",
"True",
":",
"return",
"reversed",
"(",
"res",
")",
"else",
":",
"return",
"res"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | RTS.values | numpy asarray does not copy data | dynts/backends/r/base.py | def values(self, desc = None):
'''numpy asarray does not copy data'''
if self._ts:
res = asarray(self._ts)
if desc == True:
return reversed(res)
else:
return res
else:
return ndarray([0,0]) | def values(self, desc = None):
'''numpy asarray does not copy data'''
if self._ts:
res = asarray(self._ts)
if desc == True:
return reversed(res)
else:
return res
else:
return ndarray([0,0]) | [
"numpy",
"asarray",
"does",
"not",
"copy",
"data"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L62-L71 | [
"def",
"values",
"(",
"self",
",",
"desc",
"=",
"None",
")",
":",
"if",
"self",
".",
"_ts",
":",
"res",
"=",
"asarray",
"(",
"self",
".",
"_ts",
")",
"if",
"desc",
"==",
"True",
":",
"return",
"reversed",
"(",
"res",
")",
"else",
":",
"return",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | RTS.rcts | General function for applying a rolling R function to a timeserie | dynts/backends/r/base.py | def rcts(self, command, *args, **kwargs):
'''General function for applying a rolling R function to a timeserie'''
cls = self.__class__
name = kwargs.pop('name','')
date = kwargs.pop('date',None)
data = kwargs.pop('data',None)
kwargs.pop('bycolumn',None)
ts ... | def rcts(self, command, *args, **kwargs):
'''General function for applying a rolling R function to a timeserie'''
cls = self.__class__
name = kwargs.pop('name','')
date = kwargs.pop('date',None)
data = kwargs.pop('data',None)
kwargs.pop('bycolumn',None)
ts ... | [
"General",
"function",
"for",
"applying",
"a",
"rolling",
"R",
"function",
"to",
"a",
"timeserie"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L117-L126 | [
"def",
"rcts",
"(",
"self",
",",
"command",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"cls",
"=",
"self",
".",
"__class__",
"name",
"=",
"kwargs",
".",
"pop",
"(",
"'name'",
",",
"''",
")",
"date",
"=",
"kwargs",
".",
"pop",
"(",
"'d... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | get_html_column_count | Gets the number of columns in an html table.
Paramters
---------
html_string : str
Returns
-------
int
The number of columns in the table | dashtable/html2data/get_html_column_count.py | def get_html_column_count(html_string):
"""
Gets the number of columns in an html table.
Paramters
---------
html_string : str
Returns
-------
int
The number of columns in the table
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ER... | def get_html_column_count(html_string):
"""
Gets the number of columns in an html table.
Paramters
---------
html_string : str
Returns
-------
int
The number of columns in the table
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ER... | [
"Gets",
"the",
"number",
"of",
"columns",
"in",
"an",
"html",
"table",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/get_html_column_count.py#L1-L47 | [
"def",
"get_html_column_count",
"(",
"html_string",
")",
":",
"try",
":",
"from",
"bs4",
"import",
"BeautifulSoup",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: You must have BeautifulSoup to use html2data\"",
")",
"return",
"soup",
"=",
"BeautifulSoup",
"(",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | add_cushions | Add space to start and end of each string in a list of lists
Parameters
----------
table : list of lists of str
A table of rows of strings. For example::
[
['dog', 'cat', 'bicycle'],
['mouse', trumpet', '']
]
Returns
-------
tabl... | dashtable/dashutils/add_cushions.py | def add_cushions(table):
"""
Add space to start and end of each string in a list of lists
Parameters
----------
table : list of lists of str
A table of rows of strings. For example::
[
['dog', 'cat', 'bicycle'],
['mouse', trumpet', '']
... | def add_cushions(table):
"""
Add space to start and end of each string in a list of lists
Parameters
----------
table : list of lists of str
A table of rows of strings. For example::
[
['dog', 'cat', 'bicycle'],
['mouse', trumpet', '']
... | [
"Add",
"space",
"to",
"start",
"and",
"end",
"of",
"each",
"string",
"in",
"a",
"list",
"of",
"lists"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/add_cushions.py#L1-L48 | [
"def",
"add_cushions",
"(",
"table",
")",
":",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
")",
":",
"lines",
"=",
"table",
"[",
"row",
"]... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | rollsingle | Efficient rolling window calculation for min, max type functions | dynts/api/roll.py | def rollsingle(self, func, window=20, name=None, fallback=False,
align='right', **kwargs):
'''Efficient rolling window calculation for min, max type functions
'''
rname = 'roll_{0}'.format(func)
if fallback:
rfunc = getattr(lib.fallback, rname)
else:
rfunc = getattr(li... | def rollsingle(self, func, window=20, name=None, fallback=False,
align='right', **kwargs):
'''Efficient rolling window calculation for min, max type functions
'''
rname = 'roll_{0}'.format(func)
if fallback:
rfunc = getattr(lib.fallback, rname)
else:
rfunc = getattr(li... | [
"Efficient",
"rolling",
"window",
"calculation",
"for",
"min",
"max",
"type",
"functions"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/roll.py#L8-L27 | [
"def",
"rollsingle",
"(",
"self",
",",
"func",
",",
"window",
"=",
"20",
",",
"name",
"=",
"None",
",",
"fallback",
"=",
"False",
",",
"align",
"=",
"'right'",
",",
"*",
"*",
"kwargs",
")",
":",
"rname",
"=",
"'roll_{0}'",
".",
"format",
"(",
"func... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | asbtree.find_ge | Building block of all searches. Find the index
corresponding to the leftmost value greater or equal to *dt*.
If *dt* is greater than the
:func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance. | dynts/utils/wrappers.py | def find_ge(self, dt):
'''Building block of all searches. Find the index
corresponding to the leftmost value greater or equal to *dt*.
If *dt* is greater than the
:func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance.'... | def find_ge(self, dt):
'''Building block of all searches. Find the index
corresponding to the leftmost value greater or equal to *dt*.
If *dt* is greater than the
:func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance.'... | [
"Building",
"block",
"of",
"all",
"searches",
".",
"Find",
"the",
"index",
"corresponding",
"to",
"the",
"leftmost",
"value",
"greater",
"or",
"equal",
"to",
"*",
"dt",
"*",
".",
"If",
"*",
"dt",
"*",
"is",
"greater",
"than",
"the",
":",
"func",
":",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/wrappers.py#L77-L88 | [
"def",
"find_ge",
"(",
"self",
",",
"dt",
")",
":",
"i",
"=",
"bisect_left",
"(",
"self",
".",
"dates",
",",
"dt",
")",
"if",
"i",
"!=",
"len",
"(",
"self",
".",
"dates",
")",
":",
"return",
"i",
"raise",
"RightOutOfBound"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | asbtree.find_le | Find the index corresponding to the rightmost
value less than or equal to *dt*.
If *dt* is less than :func:`dynts.TimeSeries.end`
a :class:`dynts.exceptions.LeftOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance. | dynts/utils/wrappers.py | def find_le(self, dt):
'''Find the index corresponding to the rightmost
value less than or equal to *dt*.
If *dt* is less than :func:`dynts.TimeSeries.end`
a :class:`dynts.exceptions.LeftOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance.'''
i = bisect_right(self.dat... | def find_le(self, dt):
'''Find the index corresponding to the rightmost
value less than or equal to *dt*.
If *dt* is less than :func:`dynts.TimeSeries.end`
a :class:`dynts.exceptions.LeftOutOfBound`
exception will raise.
*dt* must be a python datetime.date instance.'''
i = bisect_right(self.dat... | [
"Find",
"the",
"index",
"corresponding",
"to",
"the",
"rightmost",
"value",
"less",
"than",
"or",
"equal",
"to",
"*",
"dt",
"*",
".",
"If",
"*",
"dt",
"*",
"is",
"less",
"than",
":",
"func",
":",
"dynts",
".",
"TimeSeries",
".",
"end",
"a",
":",
"c... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/wrappers.py#L90-L101 | [
"def",
"find_le",
"(",
"self",
",",
"dt",
")",
":",
"i",
"=",
"bisect_right",
"(",
"self",
".",
"dates",
",",
"dt",
")",
"if",
"i",
":",
"return",
"i",
"-",
"1",
"raise",
"LeftOutOfBound"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | upgrade | Update database. | invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py | def upgrade():
"""Update database."""
op.create_table(
'transaction',
sa.Column('issued_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('remote_addr', sa.String(length=50), nullable=True),
)
op.create_primary_key('pk_transac... | def upgrade():
"""Update database."""
op.create_table(
'transaction',
sa.Column('issued_at', sa.DateTime(), nullable=True),
sa.Column('id', sa.BigInteger(), nullable=False),
sa.Column('remote_addr', sa.String(length=50), nullable=True),
)
op.create_primary_key('pk_transac... | [
"Update",
"database",
"."
] | inveniosoftware/invenio-db | python | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py#L23-L33 | [
"def",
"upgrade",
"(",
")",
":",
"op",
".",
"create_table",
"(",
"'transaction'",
",",
"sa",
".",
"Column",
"(",
"'issued_at'",
",",
"sa",
".",
"DateTime",
"(",
")",
",",
"nullable",
"=",
"True",
")",
",",
"sa",
".",
"Column",
"(",
"'id'",
",",
"sa... | 9009a4cf79574083e129909cf3d2656568550184 |
train | downgrade | Downgrade database. | invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py | def downgrade():
"""Downgrade database."""
op.drop_table('transaction')
if op._proxy.migration_context.dialect.supports_sequences:
op.execute(DropSequence(Sequence('transaction_id_seq'))) | def downgrade():
"""Downgrade database."""
op.drop_table('transaction')
if op._proxy.migration_context.dialect.supports_sequences:
op.execute(DropSequence(Sequence('transaction_id_seq'))) | [
"Downgrade",
"database",
"."
] | inveniosoftware/invenio-db | python | https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py#L36-L40 | [
"def",
"downgrade",
"(",
")",
":",
"op",
".",
"drop_table",
"(",
"'transaction'",
")",
"if",
"op",
".",
"_proxy",
".",
"migration_context",
".",
"dialect",
".",
"supports_sequences",
":",
"op",
".",
"execute",
"(",
"DropSequence",
"(",
"Sequence",
"(",
"'t... | 9009a4cf79574083e129909cf3d2656568550184 |
train | Rules.t_NUMBER | r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)? | dynts/dsl/rules.py | def t_NUMBER(self, t):
r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?'
try:
sv = t.value
v = float(sv)
iv = int(v)
t.value = (iv if iv == v else v, sv)
except ValueError:
print("Number %s is too large!" % t.value)
... | def t_NUMBER(self, t):
r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?'
try:
sv = t.value
v = float(sv)
iv = int(v)
t.value = (iv if iv == v else v, sv)
except ValueError:
print("Number %s is too large!" % t.value)
... | [
"r",
"(",
"[",
"0",
"-",
"9",
"]",
"+",
"\\",
".",
"?",
"[",
"0",
"-",
"9",
"]",
"*",
"|",
"\\",
".",
"[",
"0",
"-",
"9",
"]",
"+",
")",
"(",
"[",
"eE",
"]",
"(",
"\\",
"+",
"|",
"-",
")",
"?",
"[",
"0",
"-",
"9",
"]",
"+",
")",... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/rules.py#L64-L74 | [
"def",
"t_NUMBER",
"(",
"self",
",",
"t",
")",
":",
"try",
":",
"sv",
"=",
"t",
".",
"value",
"v",
"=",
"float",
"(",
"sv",
")",
"iv",
"=",
"int",
"(",
"v",
")",
"t",
".",
"value",
"=",
"(",
"iv",
"if",
"iv",
"==",
"v",
"else",
"v",
",",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | Rules.t_ID | r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]* | dynts/dsl/rules.py | def t_ID(self, t):
r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]*'
res = self.oper.get(t.value, None) # Check for reserved words
if res is None:
res = t.value.upper()
if res == 'FALSE':
t.type = 'BOOL'
t.value = False
elif res == '... | def t_ID(self, t):
r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]*'
res = self.oper.get(t.value, None) # Check for reserved words
if res is None:
res = t.value.upper()
if res == 'FALSE':
t.type = 'BOOL'
t.value = False
elif res == '... | [
"r",
"[",
"^",
"]",
"*",
"|",
"[",
"a",
"-",
"zA",
"-",
"Z_",
"]",
"[",
"a",
"-",
"zA",
"-",
"Z_0",
"-",
"9",
":"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/rules.py#L76-L92 | [
"def",
"t_ID",
"(",
"self",
",",
"t",
")",
":",
"res",
"=",
"self",
".",
"oper",
".",
"get",
"(",
"t",
".",
"value",
",",
"None",
")",
"# Check for reserved words\r",
"if",
"res",
"is",
"None",
":",
"res",
"=",
"t",
".",
"value",
".",
"upper",
"(... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | read_newick | Reads a newick tree from either a string or a file, and returns
an ETE tree structure.
A previously existent node object can be passed as the root of the
tree, which means that all its new children will belong to the same
class as the root (This allows to work with custom TreeNode objects).
You ca... | toytree/newick.py | def read_newick(newick, root_node=None, format=0):
"""
Reads a newick tree from either a string or a file, and returns
an ETE tree structure.
A previously existent node object can be passed as the root of the
tree, which means that all its new children will belong to the same
class as the root... | def read_newick(newick, root_node=None, format=0):
"""
Reads a newick tree from either a string or a file, and returns
an ETE tree structure.
A previously existent node object can be passed as the root of the
tree, which means that all its new children will belong to the same
class as the root... | [
"Reads",
"a",
"newick",
"tree",
"from",
"either",
"a",
"string",
"or",
"a",
"file",
"and",
"returns",
"an",
"ETE",
"tree",
"structure",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L162-L197 | [
"def",
"read_newick",
"(",
"newick",
",",
"root_node",
"=",
"None",
",",
"format",
"=",
"0",
")",
":",
"## check newick type as a string or filepath, Toytree parses urls to str's",
"if",
"isinstance",
"(",
"newick",
",",
"six",
".",
"string_types",
")",
":",
"if",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | _read_newick_from_string | Reads a newick string in the New Hampshire format. | toytree/newick.py | def _read_newick_from_string(nw, root_node, matcher, formatcode):
""" Reads a newick string in the New Hampshire format. """
if nw.count('(') != nw.count(')'):
raise NewickError('Parentheses do not match. Broken tree structure?')
# white spaces and separators are removed
nw = re.sub("[\n\r\t]+"... | def _read_newick_from_string(nw, root_node, matcher, formatcode):
""" Reads a newick string in the New Hampshire format. """
if nw.count('(') != nw.count(')'):
raise NewickError('Parentheses do not match. Broken tree structure?')
# white spaces and separators are removed
nw = re.sub("[\n\r\t]+"... | [
"Reads",
"a",
"newick",
"string",
"in",
"the",
"New",
"Hampshire",
"format",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L201-L250 | [
"def",
"_read_newick_from_string",
"(",
"nw",
",",
"root_node",
",",
"matcher",
",",
"formatcode",
")",
":",
"if",
"nw",
".",
"count",
"(",
"'('",
")",
"!=",
"nw",
".",
"count",
"(",
"')'",
")",
":",
"raise",
"NewickError",
"(",
"'Parentheses do not match.... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | _parse_extra_features | Reads node's extra data form its NHX string. NHX uses this
format: [&&NHX:prop1=value1:prop2=value2] | toytree/newick.py | def _parse_extra_features(node, NHX_string):
"""
Reads node's extra data form its NHX string. NHX uses this
format: [&&NHX:prop1=value1:prop2=value2]
"""
NHX_string = NHX_string.replace("[&&NHX:", "")
NHX_string = NHX_string.replace("]", "")
for field in NHX_string.split(":"):
try... | def _parse_extra_features(node, NHX_string):
"""
Reads node's extra data form its NHX string. NHX uses this
format: [&&NHX:prop1=value1:prop2=value2]
"""
NHX_string = NHX_string.replace("[&&NHX:", "")
NHX_string = NHX_string.replace("]", "")
for field in NHX_string.split(":"):
try... | [
"Reads",
"node",
"s",
"extra",
"data",
"form",
"its",
"NHX",
"string",
".",
"NHX",
"uses",
"this",
"format",
":",
"[",
"&&NHX",
":",
"prop1",
"=",
"value1",
":",
"prop2",
"=",
"value2",
"]"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L254-L266 | [
"def",
"_parse_extra_features",
"(",
"node",
",",
"NHX_string",
")",
":",
"NHX_string",
"=",
"NHX_string",
".",
"replace",
"(",
"\"[&&NHX:\"",
",",
"\"\"",
")",
"NHX_string",
"=",
"NHX_string",
".",
"replace",
"(",
"\"]\"",
",",
"\"\"",
")",
"for",
"field",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | compile_matchers | Tests newick string against format types? and makes a re.compile | toytree/newick.py | def compile_matchers(formatcode):
"""
Tests newick string against format types? and makes a re.compile
"""
matchers = {}
for node_type in ["leaf", "single", "internal"]:
if node_type == "leaf" or node_type == "single":
container1 = NW_FORMAT[formatcode][0][0]
containe... | def compile_matchers(formatcode):
"""
Tests newick string against format types? and makes a re.compile
"""
matchers = {}
for node_type in ["leaf", "single", "internal"]:
if node_type == "leaf" or node_type == "single":
container1 = NW_FORMAT[formatcode][0][0]
containe... | [
"Tests",
"newick",
"string",
"against",
"format",
"types?",
"and",
"makes",
"a",
"re",
".",
"compile"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L271-L315 | [
"def",
"compile_matchers",
"(",
"formatcode",
")",
":",
"matchers",
"=",
"{",
"}",
"for",
"node_type",
"in",
"[",
"\"leaf\"",
",",
"\"single\"",
",",
"\"internal\"",
"]",
":",
"if",
"node_type",
"==",
"\"leaf\"",
"or",
"node_type",
"==",
"\"single\"",
":",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | _read_node_data | Reads a leaf node from a subpart of the original newicktree | toytree/newick.py | def _read_node_data(subnw, current_node, node_type, matcher, formatcode):
"""
Reads a leaf node from a subpart of the original newicktree
"""
if node_type == "leaf" or node_type == "single":
if node_type == "leaf":
node = current_node.add_child()
else:
node = cu... | def _read_node_data(subnw, current_node, node_type, matcher, formatcode):
"""
Reads a leaf node from a subpart of the original newicktree
"""
if node_type == "leaf" or node_type == "single":
if node_type == "leaf":
node = current_node.add_child()
else:
node = cu... | [
"Reads",
"a",
"leaf",
"node",
"from",
"a",
"subpart",
"of",
"the",
"original",
"newicktree"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L319-L358 | [
"def",
"_read_node_data",
"(",
"subnw",
",",
"current_node",
",",
"node_type",
",",
"matcher",
",",
"formatcode",
")",
":",
"if",
"node_type",
"==",
"\"leaf\"",
"or",
"node_type",
"==",
"\"single\"",
":",
"if",
"node_type",
"==",
"\"leaf\"",
":",
"node",
"="... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | write_newick | Iteratively export a tree structure and returns its NHX
representation. | toytree/newick.py | def write_newick(rootnode,
features=None,
format=1,
format_root_node=True,
is_leaf_fn=None,
dist_formatter=None,
support_formatter=None,
name_formatter=None):
"""
Iteratively export a tree structure and returns its NHX
representation.
"""
newick = []
leaf = is_leaf_fn if... | def write_newick(rootnode,
features=None,
format=1,
format_root_node=True,
is_leaf_fn=None,
dist_formatter=None,
support_formatter=None,
name_formatter=None):
"""
Iteratively export a tree structure and returns its NHX
representation.
"""
newick = []
leaf = is_leaf_fn if... | [
"Iteratively",
"export",
"a",
"tree",
"structure",
"and",
"returns",
"its",
"NHX",
"representation",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L362-L401 | [
"def",
"write_newick",
"(",
"rootnode",
",",
"features",
"=",
"None",
",",
"format",
"=",
"1",
",",
"format_root_node",
"=",
"True",
",",
"is_leaf_fn",
"=",
"None",
",",
"dist_formatter",
"=",
"None",
",",
"support_formatter",
"=",
"None",
",",
"name_formatt... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | _get_features_string | Generates the extended newick string NHX with extra data about a node. | toytree/newick.py | def _get_features_string(self, features=None):
""" Generates the extended newick string NHX with extra data about a node."""
string = ""
if features is None:
features = []
elif features == []:
features = self.features
for pr in features:
if hasattr(self, pr):
raw... | def _get_features_string(self, features=None):
""" Generates the extended newick string NHX with extra data about a node."""
string = ""
if features is None:
features = []
elif features == []:
features = self.features
for pr in features:
if hasattr(self, pr):
raw... | [
"Generates",
"the",
"extended",
"newick",
"string",
"NHX",
"with",
"extra",
"data",
"about",
"a",
"node",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L405-L434 | [
"def",
"_get_features_string",
"(",
"self",
",",
"features",
"=",
"None",
")",
":",
"string",
"=",
"\"\"",
"if",
"features",
"is",
"None",
":",
"features",
"=",
"[",
"]",
"elif",
"features",
"==",
"[",
"]",
":",
"features",
"=",
"self",
".",
"features"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_column_width | Get the character width of a column in a table
Parameters
----------
column : int
The column index analyze
table : list of lists of str
The table of rows of strings. For this to be accurate, each
string must only be 1 line long.
Returns
-------
width : int | dashtable/data2md/get_column_width.py | def get_column_width(column, table):
"""
Get the character width of a column in a table
Parameters
----------
column : int
The column index analyze
table : list of lists of str
The table of rows of strings. For this to be accurate, each
string must only be 1 line long.
... | def get_column_width(column, table):
"""
Get the character width of a column in a table
Parameters
----------
column : int
The column index analyze
table : list of lists of str
The table of rows of strings. For this to be accurate, each
string must only be 1 line long.
... | [
"Get",
"the",
"character",
"width",
"of",
"a",
"column",
"in",
"a",
"table"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2md/get_column_width.py#L1-L24 | [
"def",
"get_column_width",
"(",
"column",
",",
"table",
")",
":",
"width",
"=",
"3",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"cell_width",
"=",
"len",
"(",
"table",
"[",
"row",
"]",
"[",
"column",
"]",
")",
"if",
"ce... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | get_text_mark | makes a simple Text Mark object | toytree/html.py | def get_text_mark(ttree):
""" makes a simple Text Mark object"""
if ttree._orient in ["right"]:
angle = 0.
ypos = ttree.verts[-1*len(ttree.tree):, 1]
if ttree._kwargs["tip_labels_align"]:
xpos = [ttree.verts[:, 0].max()] * len(ttree.tree)
start = xpos
... | def get_text_mark(ttree):
""" makes a simple Text Mark object"""
if ttree._orient in ["right"]:
angle = 0.
ypos = ttree.verts[-1*len(ttree.tree):, 1]
if ttree._kwargs["tip_labels_align"]:
xpos = [ttree.verts[:, 0].max()] * len(ttree.tree)
start = xpos
... | [
"makes",
"a",
"simple",
"Text",
"Mark",
"object"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L196-L253 | [
"def",
"get_text_mark",
"(",
"ttree",
")",
":",
"if",
"ttree",
".",
"_orient",
"in",
"[",
"\"right\"",
"]",
":",
"angle",
"=",
"0.",
"ypos",
"=",
"ttree",
".",
"verts",
"[",
"-",
"1",
"*",
"len",
"(",
"ttree",
".",
"tree",
")",
":",
",",
"1",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_edge_mark | makes a simple Graph Mark object | toytree/html.py | def get_edge_mark(ttree):
""" makes a simple Graph Mark object"""
## tree style
if ttree._kwargs["tree_style"] in ["c", "cladogram"]:
a=ttree.edges
vcoordinates=ttree.verts
else:
a=ttree._lines
vcoordinates=ttree._coords
## fixed args
a... | def get_edge_mark(ttree):
""" makes a simple Graph Mark object"""
## tree style
if ttree._kwargs["tree_style"] in ["c", "cladogram"]:
a=ttree.edges
vcoordinates=ttree.verts
else:
a=ttree._lines
vcoordinates=ttree._coords
## fixed args
a... | [
"makes",
"a",
"simple",
"Graph",
"Mark",
"object"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L257-L363 | [
"def",
"get_edge_mark",
"(",
"ttree",
")",
":",
"## tree style",
"if",
"ttree",
".",
"_kwargs",
"[",
"\"tree_style\"",
"]",
"in",
"[",
"\"c\"",
",",
"\"cladogram\"",
"]",
":",
"a",
"=",
"ttree",
".",
"edges",
"vcoordinates",
"=",
"ttree",
".",
"verts",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | split_styles | get shared styles | toytree/html.py | def split_styles(mark):
""" get shared styles """
markers = [mark._table[key] for key in mark._marker][0]
nstyles = []
for m in markers:
## fill and stroke are already rgb() since already in markers
msty = toyplot.style.combine({
"fill": m.mstyle['fill'],
"st... | def split_styles(mark):
""" get shared styles """
markers = [mark._table[key] for key in mark._marker][0]
nstyles = []
for m in markers:
## fill and stroke are already rgb() since already in markers
msty = toyplot.style.combine({
"fill": m.mstyle['fill'],
"st... | [
"get",
"shared",
"styles"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/html.py#L373-L447 | [
"def",
"split_styles",
"(",
"mark",
")",
":",
"markers",
"=",
"[",
"mark",
".",
"_table",
"[",
"key",
"]",
"for",
"key",
"in",
"mark",
".",
"_marker",
"]",
"[",
"0",
"]",
"nstyles",
"=",
"[",
"]",
"for",
"m",
"in",
"markers",
":",
"## fill and stro... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | center_cell_text | Horizontally center the text within a cell's grid
Like this::
+---------+ +---------+
| foo | --> | foo |
+---------+ +---------+
Parameters
----------
cell : dashtable.data2rst.Cell
Returns
-------
cell : dashtable.data2rst.Cell | dashtable/data2rst/cell/center_cell_text.py | def center_cell_text(cell):
"""
Horizontally center the text within a cell's grid
Like this::
+---------+ +---------+
| foo | --> | foo |
+---------+ +---------+
Parameters
----------
cell : dashtable.data2rst.Cell
Returns
-------
cell : da... | def center_cell_text(cell):
"""
Horizontally center the text within a cell's grid
Like this::
+---------+ +---------+
| foo | --> | foo |
+---------+ +---------+
Parameters
----------
cell : dashtable.data2rst.Cell
Returns
-------
cell : da... | [
"Horizontally",
"center",
"the",
"text",
"within",
"a",
"cell",
"s",
"grid"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/center_cell_text.py#L4-L50 | [
"def",
"center_cell_text",
"(",
"cell",
")",
":",
"lines",
"=",
"cell",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"cell_width",
"=",
"len",
"(",
"lines",
"[",
"0",
"]",
")",
"-",
"2",
"truncated_lines",
"=",
"[",
"''",
"]",
"for",
"i",
"in",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | hamming_distance | Computes the Hamming distance.
[Reference]: https://en.wikipedia.org/wiki/Hamming_distance
[Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes",
Bell System Technical Journal 29 (2): 147–160 | pyphonetics/distance_metrics/hamming.py | def hamming_distance(word1, word2):
"""
Computes the Hamming distance.
[Reference]: https://en.wikipedia.org/wiki/Hamming_distance
[Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes",
Bell System Technical Journal 29 (2): 147–160
"""
from operator import ... | def hamming_distance(word1, word2):
"""
Computes the Hamming distance.
[Reference]: https://en.wikipedia.org/wiki/Hamming_distance
[Article]: Hamming, Richard W. (1950), "Error detecting and error correcting codes",
Bell System Technical Journal 29 (2): 147–160
"""
from operator import ... | [
"Computes",
"the",
"Hamming",
"distance",
"."
] | Lilykos/pyphonetics | python | https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/distance_metrics/hamming.py#L4-L16 | [
"def",
"hamming_distance",
"(",
"word1",
",",
"word2",
")",
":",
"from",
"operator",
"import",
"ne",
"if",
"len",
"(",
"word1",
")",
"!=",
"len",
"(",
"word2",
")",
":",
"raise",
"WrongLengthException",
"(",
"'The words need to be of the same length!'",
")",
"... | 7f55cccc1135e6015520a895eb6859318a4b6111 |
train | polygen | Polynomial generating function | dynts/utils/populate.py | def polygen(*coefficients):
'''Polynomial generating function'''
if not coefficients:
return lambda i: 0
else:
c0 = coefficients[0]
coefficients = coefficients[1:]
def _(i):
v = c0
for c in coefficients:
v += c*i
... | def polygen(*coefficients):
'''Polynomial generating function'''
if not coefficients:
return lambda i: 0
else:
c0 = coefficients[0]
coefficients = coefficients[1:]
def _(i):
v = c0
for c in coefficients:
v += c*i
... | [
"Polynomial",
"generating",
"function"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/populate.py#L34-L49 | [
"def",
"polygen",
"(",
"*",
"coefficients",
")",
":",
"if",
"not",
"coefficients",
":",
"return",
"lambda",
"i",
":",
"0",
"else",
":",
"c0",
"=",
"coefficients",
"[",
"0",
"]",
"coefficients",
"=",
"coefficients",
"[",
"1",
":",
"]",
"def",
"_",
"("... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | timeseries | Create a new :class:`dynts.TimeSeries` instance using a ``backend``
and populating it with provided the data.
:parameter name: optional timeseries name. For multivarate timeseries
the :func:`dynts.tsname` utility function can be used
to build it.
:parameter b... | dynts/api/main.py | def timeseries(name='', backend=None, date=None, data=None, **kwargs):
'''Create a new :class:`dynts.TimeSeries` instance using a ``backend``
and populating it with provided the data.
:parameter name: optional timeseries name. For multivarate timeseries
the :func:`dynts.tsname` ut... | def timeseries(name='', backend=None, date=None, data=None, **kwargs):
'''Create a new :class:`dynts.TimeSeries` instance using a ``backend``
and populating it with provided the data.
:parameter name: optional timeseries name. For multivarate timeseries
the :func:`dynts.tsname` ut... | [
"Create",
"a",
"new",
":",
"class",
":",
"dynts",
".",
"TimeSeries",
"instance",
"using",
"a",
"backend",
"and",
"populating",
"it",
"with",
"provided",
"the",
"data",
".",
":",
"parameter",
"name",
":",
"optional",
"timeseries",
"name",
".",
"For",
"multi... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/main.py#L7-L25 | [
"def",
"timeseries",
"(",
"name",
"=",
"''",
",",
"backend",
"=",
"None",
",",
"date",
"=",
"None",
",",
"data",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"backend",
"=",
"backend",
"or",
"settings",
".",
"backend",
"TS",
"=",
"BACKENDS",
"."... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | ensure_table_strings | Force each cell in the table to be a string
Parameters
----------
table : list of lists
Returns
-------
table : list of lists of str | dashtable/dashutils/ensure_table_strings.py | def ensure_table_strings(table):
"""
Force each cell in the table to be a string
Parameters
----------
table : list of lists
Returns
-------
table : list of lists of str
"""
for row in range(len(table)):
for column in range(len(table[row])):
table[row][colum... | def ensure_table_strings(table):
"""
Force each cell in the table to be a string
Parameters
----------
table : list of lists
Returns
-------
table : list of lists of str
"""
for row in range(len(table)):
for column in range(len(table[row])):
table[row][colum... | [
"Force",
"each",
"cell",
"in",
"the",
"table",
"to",
"be",
"a",
"string"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/ensure_table_strings.py#L1-L16 | [
"def",
"ensure_table_strings",
"(",
"table",
")",
":",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
")",
":",
"table",
"[",
"row",
"]",
"[",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | Cell.left_sections | The number of sections that touch the left side.
During merging, the cell's text will grow to include other
cells. This property keeps track of the number of sections that
are touching the left side. For example::
+-----+-----+
section --> | foo | dog | <-- ... | dashtable/data2rst/cell/cell.py | def left_sections(self):
"""
The number of sections that touch the left side.
During merging, the cell's text will grow to include other
cells. This property keeps track of the number of sections that
are touching the left side. For example::
+-----+----... | def left_sections(self):
"""
The number of sections that touch the left side.
During merging, the cell's text will grow to include other
cells. This property keeps track of the number of sections that
are touching the left side. For example::
+-----+----... | [
"The",
"number",
"of",
"sections",
"that",
"touch",
"the",
"left",
"side",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L37-L66 | [
"def",
"left_sections",
"(",
"self",
")",
":",
"lines",
"=",
"self",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"sections",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"lines",
")",
")",
":",
"if",
"lines",
"[",
"i",
"]",
".",
"sta... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | Cell.right_sections | The number of sections that touch the right side.
Returns
-------
sections : int
The number of sections on the right | dashtable/data2rst/cell/cell.py | def right_sections(self):
"""
The number of sections that touch the right side.
Returns
-------
sections : int
The number of sections on the right
"""
lines = self.text.split('\n')
sections = 0
for i in range(len(lines)):
i... | def right_sections(self):
"""
The number of sections that touch the right side.
Returns
-------
sections : int
The number of sections on the right
"""
lines = self.text.split('\n')
sections = 0
for i in range(len(lines)):
i... | [
"The",
"number",
"of",
"sections",
"that",
"touch",
"the",
"right",
"side",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L69-L83 | [
"def",
"right_sections",
"(",
"self",
")",
":",
"lines",
"=",
"self",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"sections",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"lines",
")",
")",
":",
"if",
"lines",
"[",
"i",
"]",
".",
"en... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | Cell.top_sections | The number of sections that touch the top side.
Returns
-------
sections : int
The number of sections on the top | dashtable/data2rst/cell/cell.py | def top_sections(self):
"""
The number of sections that touch the top side.
Returns
-------
sections : int
The number of sections on the top
"""
top_line = self.text.split('\n')[0]
sections = len(top_line.split('+')) - 2
return secti... | def top_sections(self):
"""
The number of sections that touch the top side.
Returns
-------
sections : int
The number of sections on the top
"""
top_line = self.text.split('\n')[0]
sections = len(top_line.split('+')) - 2
return secti... | [
"The",
"number",
"of",
"sections",
"that",
"touch",
"the",
"top",
"side",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L86-L99 | [
"def",
"top_sections",
"(",
"self",
")",
":",
"top_line",
"=",
"self",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"[",
"0",
"]",
"sections",
"=",
"len",
"(",
"top_line",
".",
"split",
"(",
"'+'",
")",
")",
"-",
"2",
"return",
"sections"
] | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | Cell.bottom_sections | The number of cells that touch the bottom side.
Returns
-------
sections : int
The number of sections on the top | dashtable/data2rst/cell/cell.py | def bottom_sections(self):
"""
The number of cells that touch the bottom side.
Returns
-------
sections : int
The number of sections on the top
"""
bottom_line = self.text.split('\n')[-1]
sections = len(bottom_line.split('+')) - 2
ret... | def bottom_sections(self):
"""
The number of cells that touch the bottom side.
Returns
-------
sections : int
The number of sections on the top
"""
bottom_line = self.text.split('\n')[-1]
sections = len(bottom_line.split('+')) - 2
ret... | [
"The",
"number",
"of",
"cells",
"that",
"touch",
"the",
"bottom",
"side",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L102-L114 | [
"def",
"bottom_sections",
"(",
"self",
")",
":",
"bottom_line",
"=",
"self",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"[",
"-",
"1",
"]",
"sections",
"=",
"len",
"(",
"bottom_line",
".",
"split",
"(",
"'+'",
")",
")",
"-",
"2",
"return",
"sect... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | Cell.is_header | Whether or not the cell is a header
Any header cell will have "=" instead of "-" on its border.
For example, this is a header cell::
+-----+
| foo |
+=====+
while this cell is not::
+-----+
| foo |
+-----+
Retu... | dashtable/data2rst/cell/cell.py | def is_header(self):
"""
Whether or not the cell is a header
Any header cell will have "=" instead of "-" on its border.
For example, this is a header cell::
+-----+
| foo |
+=====+
while this cell is not::
+-----+
... | def is_header(self):
"""
Whether or not the cell is a header
Any header cell will have "=" instead of "-" on its border.
For example, this is a header cell::
+-----+
| foo |
+=====+
while this cell is not::
+-----+
... | [
"Whether",
"or",
"not",
"the",
"cell",
"is",
"a",
"header"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/cell.py#L117-L145 | [
"def",
"is_header",
"(",
"self",
")",
":",
"bottom_line",
"=",
"self",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"[",
"-",
"1",
"]",
"if",
"is_only",
"(",
"bottom_line",
",",
"[",
"'+'",
",",
"'='",
"]",
")",
":",
"return",
"True",
"return",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | get_git_changeset | Returns a numeric identifier of the latest git changeset.
The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the development version numbers. | dynts/utils/version.py | def get_git_changeset(filename=None):
"""Returns a numeric identifier of the latest git changeset.
The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the developmen... | def get_git_changeset(filename=None):
"""Returns a numeric identifier of the latest git changeset.
The result is the UTC timestamp of the changeset in YYYYMMDDHHMMSS format.
This value isn't guaranteed to be unique, but collisions are very unlikely,
so it's sufficient for generating the developmen... | [
"Returns",
"a",
"numeric",
"identifier",
"of",
"the",
"latest",
"git",
"changeset",
".",
"The",
"result",
"is",
"the",
"UTC",
"timestamp",
"of",
"the",
"changeset",
"in",
"YYYYMMDDHHMMSS",
"format",
".",
"This",
"value",
"isn",
"t",
"guaranteed",
"to",
"be",... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/version.py#L31-L46 | [
"def",
"get_git_changeset",
"(",
"filename",
"=",
"None",
")",
":",
"dirname",
"=",
"os",
".",
"path",
".",
"dirname",
"(",
"filename",
"or",
"__file__",
")",
"git_show",
"=",
"sh",
"(",
"'git show --pretty=format:%ct --quiet HEAD'",
",",
"cwd",
"=",
"dirname"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | headers_present | Checks if the html table contains headers and returns True/False
Parameters
----------
html_string : str
Returns
-------
bool | dashtable/html2data/headers_present.py | def headers_present(html_string):
"""
Checks if the html table contains headers and returns True/False
Parameters
----------
html_string : str
Returns
-------
bool
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ERROR: You must have Beautif... | def headers_present(html_string):
"""
Checks if the html table contains headers and returns True/False
Parameters
----------
html_string : str
Returns
-------
bool
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ERROR: You must have Beautif... | [
"Checks",
"if",
"the",
"html",
"table",
"contains",
"headers",
"and",
"returns",
"True",
"/",
"False"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/headers_present.py#L1-L28 | [
"def",
"headers_present",
"(",
"html_string",
")",
":",
"try",
":",
"from",
"bs4",
"import",
"BeautifulSoup",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: You must have BeautifulSoup to use html2data\"",
")",
"return",
"soup",
"=",
"BeautifulSoup",
"(",
"html... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | extract_spans | Creates a list of the spanned cell groups of [row, column] pairs.
Parameters
----------
html_string : str
Returns
-------
list of lists of lists of int | dashtable/html2data/extract_spans.py | def extract_spans(html_string):
"""
Creates a list of the spanned cell groups of [row, column] pairs.
Parameters
----------
html_string : str
Returns
-------
list of lists of lists of int
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ERRO... | def extract_spans(html_string):
"""
Creates a list of the spanned cell groups of [row, column] pairs.
Parameters
----------
html_string : str
Returns
-------
list of lists of lists of int
"""
try:
from bs4 import BeautifulSoup
except ImportError:
print("ERRO... | [
"Creates",
"a",
"list",
"of",
"the",
"spanned",
"cell",
"groups",
"of",
"[",
"row",
"column",
"]",
"pairs",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/extract_spans.py#L4-L64 | [
"def",
"extract_spans",
"(",
"html_string",
")",
":",
"try",
":",
"from",
"bs4",
"import",
"BeautifulSoup",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: You must have BeautifulSoup to use html2data\"",
")",
"return",
"soup",
"=",
"BeautifulSoup",
"(",
"html_s... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | translation | Create an index of mapped letters (zip to dict). | pyphonetics/utils.py | def translation(first, second):
"""Create an index of mapped letters (zip to dict)."""
if len(first) != len(second):
raise WrongLengthException('The lists are not of the same length!')
return dict(zip(first, second)) | def translation(first, second):
"""Create an index of mapped letters (zip to dict)."""
if len(first) != len(second):
raise WrongLengthException('The lists are not of the same length!')
return dict(zip(first, second)) | [
"Create",
"an",
"index",
"of",
"mapped",
"letters",
"(",
"zip",
"to",
"dict",
")",
"."
] | Lilykos/pyphonetics | python | https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/utils.py#L6-L10 | [
"def",
"translation",
"(",
"first",
",",
"second",
")",
":",
"if",
"len",
"(",
"first",
")",
"!=",
"len",
"(",
"second",
")",
":",
"raise",
"WrongLengthException",
"(",
"'The lists are not of the same length!'",
")",
"return",
"dict",
"(",
"zip",
"(",
"first... | 7f55cccc1135e6015520a895eb6859318a4b6111 |
train | process_tag | Recursively go through a tag's children, converting them, then
convert the tag itself. | dashtable/html2data/restructify/process_tag.py | def process_tag(node):
"""
Recursively go through a tag's children, converting them, then
convert the tag itself.
"""
text = ''
exceptions = ['table']
for element in node.children:
if isinstance(element, NavigableString):
text += element
elif not node.name in e... | def process_tag(node):
"""
Recursively go through a tag's children, converting them, then
convert the tag itself.
"""
text = ''
exceptions = ['table']
for element in node.children:
if isinstance(element, NavigableString):
text += element
elif not node.name in e... | [
"Recursively",
"go",
"through",
"a",
"tag",
"s",
"children",
"converting",
"them",
"then",
"convert",
"the",
"tag",
"itself",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/process_tag.py#L13-L36 | [
"def",
"process_tag",
"(",
"node",
")",
":",
"text",
"=",
"''",
"exceptions",
"=",
"[",
"'table'",
"]",
"for",
"element",
"in",
"node",
".",
"children",
":",
"if",
"isinstance",
"(",
"element",
",",
"NavigableString",
")",
":",
"text",
"+=",
"element",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | laggeddates | Lagged iterator over dates | dynts/utils/iterators.py | def laggeddates(ts, step=1):
'''Lagged iterator over dates'''
if step == 1:
dates = ts.dates()
if not hasattr(dates, 'next'):
dates = dates.__iter__()
dt0 = next(dates)
for dt1 in dates:
yield dt1, dt0
dt0 = dt1
else:
whi... | def laggeddates(ts, step=1):
'''Lagged iterator over dates'''
if step == 1:
dates = ts.dates()
if not hasattr(dates, 'next'):
dates = dates.__iter__()
dt0 = next(dates)
for dt1 in dates:
yield dt1, dt0
dt0 = dt1
else:
whi... | [
"Lagged",
"iterator",
"over",
"dates"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/iterators.py#L4-L20 | [
"def",
"laggeddates",
"(",
"ts",
",",
"step",
"=",
"1",
")",
":",
"if",
"step",
"==",
"1",
":",
"dates",
"=",
"ts",
".",
"dates",
"(",
")",
"if",
"not",
"hasattr",
"(",
"dates",
",",
"'next'",
")",
":",
"dates",
"=",
"dates",
".",
"__iter__",
"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | make_skiplist | Create a new skiplist | dynts/lib/__init__.py | def make_skiplist(*args, use_fallback=False):
'''Create a new skiplist'''
sl = fallback.Skiplist if use_fallback else Skiplist
return sl(*args) | def make_skiplist(*args, use_fallback=False):
'''Create a new skiplist'''
sl = fallback.Skiplist if use_fallback else Skiplist
return sl(*args) | [
"Create",
"a",
"new",
"skiplist"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/__init__.py#L6-L9 | [
"def",
"make_skiplist",
"(",
"*",
"args",
",",
"use_fallback",
"=",
"False",
")",
":",
"sl",
"=",
"fallback",
".",
"Skiplist",
"if",
"use_fallback",
"else",
"Skiplist",
"return",
"sl",
"(",
"*",
"args",
")"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | data2md | Creates a markdown table. The first row will be headers.
Parameters
----------
table : list of lists of str
A list of rows containing strings. If any of these strings
consist of multiple lines, they will be converted to single line
because markdown tables do not support multiline ce... | dashtable/data2md/data2md.py | def data2md(table):
"""
Creates a markdown table. The first row will be headers.
Parameters
----------
table : list of lists of str
A list of rows containing strings. If any of these strings
consist of multiple lines, they will be converted to single line
because markdown ta... | def data2md(table):
"""
Creates a markdown table. The first row will be headers.
Parameters
----------
table : list of lists of str
A list of rows containing strings. If any of these strings
consist of multiple lines, they will be converted to single line
because markdown ta... | [
"Creates",
"a",
"markdown",
"table",
".",
"The",
"first",
"row",
"will",
"be",
"headers",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2md/data2md.py#L10-L73 | [
"def",
"data2md",
"(",
"table",
")",
":",
"table",
"=",
"copy",
".",
"deepcopy",
"(",
"table",
")",
"table",
"=",
"ensure_table_strings",
"(",
"table",
")",
"table",
"=",
"multis_2_mono",
"(",
"table",
")",
"table",
"=",
"add_cushions",
"(",
"table",
")"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | v_center_cell_text | Vertically center the text within the cell's grid.
Like this::
+--------+ +--------+
| foobar | | |
| | | |
| | --> | foobar |
| | | |
| | | |
+--------+ +--------+
Paramete... | dashtable/data2rst/cell/v_center_cell_text.py | def v_center_cell_text(cell):
"""
Vertically center the text within the cell's grid.
Like this::
+--------+ +--------+
| foobar | | |
| | | |
| | --> | foobar |
| | | |
| | | |
... | def v_center_cell_text(cell):
"""
Vertically center the text within the cell's grid.
Like this::
+--------+ +--------+
| foobar | | |
| | | |
| | --> | foobar |
| | | |
| | | |
... | [
"Vertically",
"center",
"the",
"text",
"within",
"the",
"cell",
"s",
"grid",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/v_center_cell_text.py#L4-L73 | [
"def",
"v_center_cell_text",
"(",
"cell",
")",
":",
"lines",
"=",
"cell",
".",
"text",
".",
"split",
"(",
"'\\n'",
")",
"cell_width",
"=",
"len",
"(",
"lines",
"[",
"0",
"]",
")",
"-",
"2",
"truncated_lines",
"=",
"[",
"]",
"for",
"i",
"in",
"range... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | data2rst | Convert a list of lists of str into a reStructuredText Grid Table
Parameters
----------
table : list of lists of str
spans : list of lists of lists of int, optional
These are [row, column] pairs of cells that are merged in the
table. Rows and columns start in the top left of the table.F... | dashtable/data2rst/data2rst.py | def data2rst(table, spans=[[[0, 0]]], use_headers=True,
center_cells=False, center_headers=False):
"""
Convert a list of lists of str into a reStructuredText Grid Table
Parameters
----------
table : list of lists of str
spans : list of lists of lists of int, optional
These ... | def data2rst(table, spans=[[[0, 0]]], use_headers=True,
center_cells=False, center_headers=False):
"""
Convert a list of lists of str into a reStructuredText Grid Table
Parameters
----------
table : list of lists of str
spans : list of lists of lists of int, optional
These ... | [
"Convert",
"a",
"list",
"of",
"lists",
"of",
"str",
"into",
"a",
"reStructuredText",
"Grid",
"Table"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/data2rst.py#L19-L119 | [
"def",
"data2rst",
"(",
"table",
",",
"spans",
"=",
"[",
"[",
"[",
"0",
",",
"0",
"]",
"]",
"]",
",",
"use_headers",
"=",
"True",
",",
"center_cells",
"=",
"False",
",",
"center_headers",
"=",
"False",
")",
":",
"table",
"=",
"copy",
".",
"deepcopy... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | CloudTree.set_dims_from_tree_size | Calculate reasonable height and width for tree given N tips | toytree/MultiDrawing.py | def set_dims_from_tree_size(self):
"Calculate reasonable height and width for tree given N tips"
tlen = len(self.treelist[0])
if self.style.orient in ("right", "left"):
# long tip-wise dimension
if not self.style.height:
self.style.height = max(275, min(10... | def set_dims_from_tree_size(self):
"Calculate reasonable height and width for tree given N tips"
tlen = len(self.treelist[0])
if self.style.orient in ("right", "left"):
# long tip-wise dimension
if not self.style.height:
self.style.height = max(275, min(10... | [
"Calculate",
"reasonable",
"height",
"and",
"width",
"for",
"tree",
"given",
"N",
"tips"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L153-L167 | [
"def",
"set_dims_from_tree_size",
"(",
"self",
")",
":",
"tlen",
"=",
"len",
"(",
"self",
".",
"treelist",
"[",
"0",
"]",
")",
"if",
"self",
".",
"style",
".",
"orient",
"in",
"(",
"\"right\"",
",",
"\"left\"",
")",
":",
"# long tip-wise dimension",
"if"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | CloudTree.add_tip_labels_to_axes | Add text offset from tips of tree with correction for orientation,
and fixed_order which is usually used in multitree plotting. | toytree/MultiDrawing.py | def add_tip_labels_to_axes(self):
"""
Add text offset from tips of tree with correction for orientation,
and fixed_order which is usually used in multitree plotting.
"""
# get tip-coords and replace if using fixed_order
if self.style.orient in ("up", "down"):
... | def add_tip_labels_to_axes(self):
"""
Add text offset from tips of tree with correction for orientation,
and fixed_order which is usually used in multitree plotting.
"""
# get tip-coords and replace if using fixed_order
if self.style.orient in ("up", "down"):
... | [
"Add",
"text",
"offset",
"from",
"tips",
"of",
"tree",
"with",
"correction",
"for",
"orientation",
"and",
"fixed_order",
"which",
"is",
"usually",
"used",
"in",
"multitree",
"plotting",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L170-L206 | [
"def",
"add_tip_labels_to_axes",
"(",
"self",
")",
":",
"# get tip-coords and replace if using fixed_order",
"if",
"self",
".",
"style",
".",
"orient",
"in",
"(",
"\"up\"",
",",
"\"down\"",
")",
":",
"ypos",
"=",
"np",
".",
"zeros",
"(",
"self",
".",
"ntips",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | CloudTree.fit_tip_labels | Modifies display range to ensure tip labels fit. This is a bit hackish
still. The problem is that the 'extents' range of the rendered text
is totally correct. So we add a little buffer here. Should add for
user to be able to modify this if needed. If not using edge lengths
then need to ... | toytree/MultiDrawing.py | def fit_tip_labels(self):
"""
Modifies display range to ensure tip labels fit. This is a bit hackish
still. The problem is that the 'extents' range of the rendered text
is totally correct. So we add a little buffer here. Should add for
user to be able to modify this if needed. I... | def fit_tip_labels(self):
"""
Modifies display range to ensure tip labels fit. This is a bit hackish
still. The problem is that the 'extents' range of the rendered text
is totally correct. So we add a little buffer here. Should add for
user to be able to modify this if needed. I... | [
"Modifies",
"display",
"range",
"to",
"ensure",
"tip",
"labels",
"fit",
".",
"This",
"is",
"a",
"bit",
"hackish",
"still",
".",
"The",
"problem",
"is",
"that",
"the",
"extents",
"range",
"of",
"the",
"rendered",
"text",
"is",
"totally",
"correct",
".",
"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/MultiDrawing.py#L209-L238 | [
"def",
"fit_tip_labels",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"tip_labels",
":",
"return",
"# longest name (this will include html hacks)",
"longest_name",
"=",
"max",
"(",
"[",
"len",
"(",
"i",
")",
"for",
"i",
"in",
"self",
".",
"tip_labels",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | convert_p | Adds 2 newlines to the end of text | dashtable/html2data/restructify/converters/convert_p.py | def convert_p(element, text):
"""
Adds 2 newlines to the end of text
"""
depth = -1
while element:
if (not element.name == '[document]' and
not element.parent.get('id') == '__RESTRUCTIFY_WRAPPER__'):
depth += 1
element = element.parent
if text:
... | def convert_p(element, text):
"""
Adds 2 newlines to the end of text
"""
depth = -1
while element:
if (not element.name == '[document]' and
not element.parent.get('id') == '__RESTRUCTIFY_WRAPPER__'):
depth += 1
element = element.parent
if text:
... | [
"Adds",
"2",
"newlines",
"to",
"the",
"end",
"of",
"text"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/converters/convert_p.py#L1-L15 | [
"def",
"convert_p",
"(",
"element",
",",
"text",
")",
":",
"depth",
"=",
"-",
"1",
"while",
"element",
":",
"if",
"(",
"not",
"element",
".",
"name",
"==",
"'[document]'",
"and",
"not",
"element",
".",
"parent",
".",
"get",
"(",
"'id'",
")",
"==",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | simple2data | Convert a simple table to data (the kind used by DashTable)
Parameters
----------
text : str
A valid simple rst table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a [row, column] pair that defines a group of merged
cel... | dashtable/simple2data/simple2data.py | def simple2data(text):
"""
Convert a simple table to data (the kind used by DashTable)
Parameters
----------
text : str
A valid simple rst table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a [row, column] pair that de... | def simple2data(text):
"""
Convert a simple table to data (the kind used by DashTable)
Parameters
----------
text : str
A valid simple rst table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a [row, column] pair that de... | [
"Convert",
"a",
"simple",
"table",
"to",
"data",
"(",
"the",
"kind",
"used",
"by",
"DashTable",
")"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/simple2data/simple2data.py#L9-L121 | [
"def",
"simple2data",
"(",
"text",
")",
":",
"try",
":",
"import",
"docutils",
".",
"statemachine",
"import",
"docutils",
".",
"parsers",
".",
"rst",
".",
"tableparser",
"except",
"ImportError",
":",
"print",
"(",
"\"ERROR: You must install the docutils library to u... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | get_output_column_widths | Gets the widths of the columns of the output table
Parameters
----------
table : list of lists of str
The table of rows of text
spans : list of lists of int
The [row, column] pairs of combined cells
Returns
-------
widths : list of int
The widths of each column in t... | dashtable/data2rst/get_output_column_widths.py | def get_output_column_widths(table, spans):
"""
Gets the widths of the columns of the output table
Parameters
----------
table : list of lists of str
The table of rows of text
spans : list of lists of int
The [row, column] pairs of combined cells
Returns
-------
wid... | def get_output_column_widths(table, spans):
"""
Gets the widths of the columns of the output table
Parameters
----------
table : list of lists of str
The table of rows of text
spans : list of lists of int
The [row, column] pairs of combined cells
Returns
-------
wid... | [
"Gets",
"the",
"widths",
"of",
"the",
"columns",
"of",
"the",
"output",
"table"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/get_output_column_widths.py#L5-L69 | [
"def",
"get_output_column_widths",
"(",
"table",
",",
"spans",
")",
":",
"widths",
"=",
"[",
"]",
"for",
"column",
"in",
"table",
"[",
"0",
"]",
":",
"widths",
".",
"append",
"(",
"3",
")",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | make_empty_table | Make an empty table
Parameters
----------
row_count : int
The number of rows in the new table
column_count : int
The number of columns in the new table
Returns
-------
table : list of lists of str
Each cell will be an empty str ('') | dashtable/dashutils/make_empty_table.py | def make_empty_table(row_count, column_count):
"""
Make an empty table
Parameters
----------
row_count : int
The number of rows in the new table
column_count : int
The number of columns in the new table
Returns
-------
table : list of lists of str
Each cell ... | def make_empty_table(row_count, column_count):
"""
Make an empty table
Parameters
----------
row_count : int
The number of rows in the new table
column_count : int
The number of columns in the new table
Returns
-------
table : list of lists of str
Each cell ... | [
"Make",
"an",
"empty",
"table"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/make_empty_table.py#L1-L24 | [
"def",
"make_empty_table",
"(",
"row_count",
",",
"column_count",
")",
":",
"table",
"=",
"[",
"]",
"while",
"row_count",
">",
"0",
":",
"row",
"=",
"[",
"]",
"for",
"column",
"in",
"range",
"(",
"column_count",
")",
":",
"row",
".",
"append",
"(",
"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | ols.beta | \
The linear estimation of the parameter vector :math:`\beta` given by
.. math::
\beta = (X^T X)^-1 X^T y | dynts/lib/fallback/ols.py | def beta(self):
'''\
The linear estimation of the parameter vector :math:`\beta` given by
.. math::
\beta = (X^T X)^-1 X^T y
'''
t = self.X.transpose()
XX = dot(t,self.X)
XY = dot(t,self.y)
return linalg.solve(XX,XY) | def beta(self):
'''\
The linear estimation of the parameter vector :math:`\beta` given by
.. math::
\beta = (X^T X)^-1 X^T y
'''
t = self.X.transpose()
XX = dot(t,self.X)
XY = dot(t,self.y)
return linalg.solve(XX,XY) | [
"\\",
"The",
"linear",
"estimation",
"of",
"the",
"parameter",
"vector",
":",
"math",
":",
"\\",
"beta",
"given",
"by"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/ols.py#L30-L42 | [
"def",
"beta",
"(",
"self",
")",
":",
"t",
"=",
"self",
".",
"X",
".",
"transpose",
"(",
")",
"XX",
"=",
"dot",
"(",
"t",
",",
"self",
".",
"X",
")",
"XY",
"=",
"dot",
"(",
"t",
",",
"self",
".",
"y",
")",
"return",
"linalg",
".",
"solve",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | FormatterDict.oftype | Return a generator of formatters codes of type typ | dynts/api/data.py | def oftype(self, typ):
'''Return a generator of formatters codes of type typ'''
for key, val in self.items():
if val.type == typ:
yield key | def oftype(self, typ):
'''Return a generator of formatters codes of type typ'''
for key, val in self.items():
if val.type == typ:
yield key | [
"Return",
"a",
"generator",
"of",
"formatters",
"codes",
"of",
"type",
"typ"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L7-L11 | [
"def",
"oftype",
"(",
"self",
",",
"typ",
")",
":",
"for",
"key",
",",
"val",
"in",
"self",
".",
"items",
"(",
")",
":",
"if",
"val",
".",
"type",
"==",
"typ",
":",
"yield",
"key"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | Data.names | List of names for series in dataset.
It will always return a list or names with length given by
:class:`~.DynData.count`. | dynts/api/data.py | def names(self, with_namespace=False):
'''List of names for series in dataset.
It will always return a list or names with length given by
:class:`~.DynData.count`.
'''
N = self.count()
names = self.name.split(settings.splittingnames)[:N]
n = 0
while len(n... | def names(self, with_namespace=False):
'''List of names for series in dataset.
It will always return a list or names with length given by
:class:`~.DynData.count`.
'''
N = self.count()
names = self.name.split(settings.splittingnames)[:N]
n = 0
while len(n... | [
"List",
"of",
"names",
"for",
"series",
"in",
"dataset",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L50-L67 | [
"def",
"names",
"(",
"self",
",",
"with_namespace",
"=",
"False",
")",
":",
"N",
"=",
"self",
".",
"count",
"(",
")",
"names",
"=",
"self",
".",
"name",
".",
"split",
"(",
"settings",
".",
"splittingnames",
")",
"[",
":",
"N",
"]",
"n",
"=",
"0",... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | Data.dump | Dump the timeseries using a specific ``format``. | dynts/api/data.py | def dump(self, format=None, **kwargs):
"""Dump the timeseries using a specific ``format``.
"""
formatter = Formatters.get(format, None)
if not format:
return self.display()
elif not formatter:
raise FormattingException('Formatter %s not available' % format... | def dump(self, format=None, **kwargs):
"""Dump the timeseries using a specific ``format``.
"""
formatter = Formatters.get(format, None)
if not format:
return self.display()
elif not formatter:
raise FormattingException('Formatter %s not available' % format... | [
"Dump",
"the",
"timeseries",
"using",
"a",
"specific",
"format",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/data.py#L88-L97 | [
"def",
"dump",
"(",
"self",
",",
"format",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"formatter",
"=",
"Formatters",
".",
"get",
"(",
"format",
",",
"None",
")",
"if",
"not",
"format",
":",
"return",
"self",
".",
"display",
"(",
")",
"elif",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | p_expression_binop | expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression
| expression EQUAL expression
| expression CONCAT expression
| expression S... | dynts/dsl/grammar.py | def p_expression_binop(p):
'''expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression
| expression EQUAL expression
| expression CONCAT expressio... | def p_expression_binop(p):
'''expression : expression PLUS expression
| expression MINUS expression
| expression TIMES expression
| expression DIVIDE expression
| expression EQUAL expression
| expression CONCAT expressio... | [
"expression",
":",
"expression",
"PLUS",
"expression",
"|",
"expression",
"MINUS",
"expression",
"|",
"expression",
"TIMES",
"expression",
"|",
"expression",
"DIVIDE",
"expression",
"|",
"expression",
"EQUAL",
"expression",
"|",
"expression",
"CONCAT",
"expression",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/grammar.py#L15-L39 | [
"def",
"p_expression_binop",
"(",
"p",
")",
":",
"v",
"=",
"p",
"[",
"2",
"]",
"if",
"v",
"==",
"'+'",
":",
"p",
"[",
"0",
"]",
"=",
"PlusOp",
"(",
"p",
"[",
"1",
"]",
",",
"p",
"[",
"3",
"]",
")",
"elif",
"v",
"==",
"'-'",
":",
"p",
"[... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | p_expression_group | expression : LPAREN expression RPAREN
| LSQUARE expression RSQUARE | dynts/dsl/grammar.py | def p_expression_group(p):
'''expression : LPAREN expression RPAREN
| LSQUARE expression RSQUARE'''
v = p[1]
if v == '(':
p[0] = functionarguments(p[2])
elif v == '[':
p[0] = tsentry(p[2]) | def p_expression_group(p):
'''expression : LPAREN expression RPAREN
| LSQUARE expression RSQUARE'''
v = p[1]
if v == '(':
p[0] = functionarguments(p[2])
elif v == '[':
p[0] = tsentry(p[2]) | [
"expression",
":",
"LPAREN",
"expression",
"RPAREN",
"|",
"LSQUARE",
"expression",
"RSQUARE"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/grammar.py#L42-L49 | [
"def",
"p_expression_group",
"(",
"p",
")",
":",
"v",
"=",
"p",
"[",
"1",
"]",
"if",
"v",
"==",
"'('",
":",
"p",
"[",
"0",
"]",
"=",
"functionarguments",
"(",
"p",
"[",
"2",
"]",
")",
"elif",
"v",
"==",
"'['",
":",
"p",
"[",
"0",
"]",
"=",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | merge_cells | Combine the side of cell1's grid text with cell2's text.
For example::
cell1 cell2 merge "RIGHT"
+-----+ +------+ +-----+------+
| foo | | dog | | foo | dog |
| | +------+ | +------+
| | | cat | | | cat |
| | +------+ ... | dashtable/data2rst/cell/merge_cells.py | def merge_cells(cell1, cell2, direction):
"""
Combine the side of cell1's grid text with cell2's text.
For example::
cell1 cell2 merge "RIGHT"
+-----+ +------+ +-----+------+
| foo | | dog | | foo | dog |
| | +------+ | +------+
| | ... | def merge_cells(cell1, cell2, direction):
"""
Combine the side of cell1's grid text with cell2's text.
For example::
cell1 cell2 merge "RIGHT"
+-----+ +------+ +-----+------+
| foo | | dog | | foo | dog |
| | +------+ | +------+
| | ... | [
"Combine",
"the",
"side",
"of",
"cell1",
"s",
"grid",
"text",
"with",
"cell2",
"s",
"text",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/merge_cells.py#L1-L59 | [
"def",
"merge_cells",
"(",
"cell1",
",",
"cell2",
",",
"direction",
")",
":",
"cell1_lines",
"=",
"cell1",
".",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"cell2_lines",
"=",
"cell2",
".",
"text",
".",
"split",
"(",
"\"\\n\"",
")",
"if",
"direction",
"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | iterclass | Iterates over (valid) attributes of a class.
Args:
cls (object): the class to iterate over
Yields:
(str, obj) tuples: the class-level attributes. | src/xworkflows/utils.py | def iterclass(cls):
"""Iterates over (valid) attributes of a class.
Args:
cls (object): the class to iterate over
Yields:
(str, obj) tuples: the class-level attributes.
"""
for field in dir(cls):
if hasattr(cls, field):
value = getattr(cls, field)
yi... | def iterclass(cls):
"""Iterates over (valid) attributes of a class.
Args:
cls (object): the class to iterate over
Yields:
(str, obj) tuples: the class-level attributes.
"""
for field in dir(cls):
if hasattr(cls, field):
value = getattr(cls, field)
yi... | [
"Iterates",
"over",
"(",
"valid",
")",
"attributes",
"of",
"a",
"class",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/utils.py#L9-L21 | [
"def",
"iterclass",
"(",
"cls",
")",
":",
"for",
"field",
"in",
"dir",
"(",
"cls",
")",
":",
"if",
"hasattr",
"(",
"cls",
",",
"field",
")",
":",
"value",
"=",
"getattr",
"(",
"cls",
",",
"field",
")",
"yield",
"field",
",",
"value"
] | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | _mksocket | Returns a tcp socket to (host/port). Retries forever if connection fails | potsdb/client.py | def _mksocket(host, port, q, done, stop):
"""Returns a tcp socket to (host/port). Retries forever if connection fails"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
attempt = 0
while not stop.is_set():
try:
s.connect((host, port))
return s
... | def _mksocket(host, port, q, done, stop):
"""Returns a tcp socket to (host/port). Retries forever if connection fails"""
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.settimeout(2)
attempt = 0
while not stop.is_set():
try:
s.connect((host, port))
return s
... | [
"Returns",
"a",
"tcp",
"socket",
"to",
"(",
"host",
"/",
"port",
")",
".",
"Retries",
"forever",
"if",
"connection",
"fails"
] | orionvm/potsdb | python | https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L21-L33 | [
"def",
"_mksocket",
"(",
"host",
",",
"port",
",",
"q",
",",
"done",
",",
"stop",
")",
":",
"s",
"=",
"socket",
".",
"socket",
"(",
"socket",
".",
"AF_INET",
",",
"socket",
".",
"SOCK_STREAM",
")",
"s",
".",
"settimeout",
"(",
"2",
")",
"attempt",
... | f242f8ad97c4e5887b3c39a082f6bdc4be46661c |
train | _push | Worker thread. Connect to host/port, pull data from q until done is set | potsdb/client.py | def _push(host, port, q, done, mps, stop, test_mode):
"""Worker thread. Connect to host/port, pull data from q until done is set"""
sock = None
retry_line = None
while not ( stop.is_set() or ( done.is_set() and retry_line == None and q.empty()) ):
stime = time.time()
if sock == None and... | def _push(host, port, q, done, mps, stop, test_mode):
"""Worker thread. Connect to host/port, pull data from q until done is set"""
sock = None
retry_line = None
while not ( stop.is_set() or ( done.is_set() and retry_line == None and q.empty()) ):
stime = time.time()
if sock == None and... | [
"Worker",
"thread",
".",
"Connect",
"to",
"host",
"/",
"port",
"pull",
"data",
"from",
"q",
"until",
"done",
"is",
"set"
] | orionvm/potsdb | python | https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L35-L76 | [
"def",
"_push",
"(",
"host",
",",
"port",
",",
"q",
",",
"done",
",",
"mps",
",",
"stop",
",",
"test_mode",
")",
":",
"sock",
"=",
"None",
"retry_line",
"=",
"None",
"while",
"not",
"(",
"stop",
".",
"is_set",
"(",
")",
"or",
"(",
"done",
".",
... | f242f8ad97c4e5887b3c39a082f6bdc4be46661c |
train | Client.log | Log metric name with value val. You must include at least one tag as a kwarg | potsdb/client.py | def log(self, name, val, **tags):
"""Log metric name with value val. You must include at least one tag as a kwarg"""
global _last_timestamp, _last_metrics
# do not allow .log after closing
assert not self.done.is_set(), "worker thread has been closed"
# check if valid metric nam... | def log(self, name, val, **tags):
"""Log metric name with value val. You must include at least one tag as a kwarg"""
global _last_timestamp, _last_metrics
# do not allow .log after closing
assert not self.done.is_set(), "worker thread has been closed"
# check if valid metric nam... | [
"Log",
"metric",
"name",
"with",
"value",
"val",
".",
"You",
"must",
"include",
"at",
"least",
"one",
"tag",
"as",
"a",
"kwarg"
] | orionvm/potsdb | python | https://github.com/orionvm/potsdb/blob/f242f8ad97c4e5887b3c39a082f6bdc4be46661c/potsdb/client.py#L112-L159 | [
"def",
"log",
"(",
"self",
",",
"name",
",",
"val",
",",
"*",
"*",
"tags",
")",
":",
"global",
"_last_timestamp",
",",
"_last_metrics",
"# do not allow .log after closing",
"assert",
"not",
"self",
".",
"done",
".",
"is_set",
"(",
")",
",",
"\"worker thread ... | f242f8ad97c4e5887b3c39a082f6bdc4be46661c |
train | GenericSerialPort.available_ports | Scans COM1 through COM255 for available serial ports
returns a list of available ports | pyxid/serial_wrapper.py | def available_ports():
"""
Scans COM1 through COM255 for available serial ports
returns a list of available ports
"""
ports = []
for i in range(256):
try:
p = Serial('COM%d' % i)
p.close()
ports.append(p)
... | def available_ports():
"""
Scans COM1 through COM255 for available serial ports
returns a list of available ports
"""
ports = []
for i in range(256):
try:
p = Serial('COM%d' % i)
p.close()
ports.append(p)
... | [
"Scans",
"COM1",
"through",
"COM255",
"for",
"available",
"serial",
"ports"
] | cedrus-opensource/pyxid | python | https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/serial_wrapper.py#L62-L78 | [
"def",
"available_ports",
"(",
")",
":",
"ports",
"=",
"[",
"]",
"for",
"i",
"in",
"range",
"(",
"256",
")",
":",
"try",
":",
"p",
"=",
"Serial",
"(",
"'COM%d'",
"%",
"i",
")",
"p",
".",
"close",
"(",
")",
"ports",
".",
"append",
"(",
"p",
")... | 02dba3a825f0d4f4c0bfa044c6a361492e4c25b6 |
train | XidConnection.get_current_response | reads the current response data from the object and returns
it in a dict.
Currently 'time' is reported as 0 until clock drift issues are
resolved. | pyxid/internal.py | def get_current_response(self):
"""
reads the current response data from the object and returns
it in a dict.
Currently 'time' is reported as 0 until clock drift issues are
resolved.
"""
response = {'port': 0,
'pressed': False,
... | def get_current_response(self):
"""
reads the current response data from the object and returns
it in a dict.
Currently 'time' is reported as 0 until clock drift issues are
resolved.
"""
response = {'port': 0,
'pressed': False,
... | [
"reads",
"the",
"current",
"response",
"data",
"from",
"the",
"object",
"and",
"returns",
"it",
"in",
"a",
"dict",
"."
] | cedrus-opensource/pyxid | python | https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/internal.py#L230-L250 | [
"def",
"get_current_response",
"(",
"self",
")",
":",
"response",
"=",
"{",
"'port'",
":",
"0",
",",
"'pressed'",
":",
"False",
",",
"'key'",
":",
"0",
",",
"'time'",
":",
"0",
"}",
"if",
"len",
"(",
"self",
".",
"__response_structs_queue",
")",
">",
... | 02dba3a825f0d4f4c0bfa044c6a361492e4c25b6 |
train | XidScanner.detect_xid_devices | For all of the com ports connected to the computer, send an
XID command '_c1'. If the device response with '_xid', it is
an xid device. | pyxid/pyxid_impl.py | def detect_xid_devices(self):
"""
For all of the com ports connected to the computer, send an
XID command '_c1'. If the device response with '_xid', it is
an xid device.
"""
self.__xid_cons = []
for c in self.__com_ports:
device_found = False
... | def detect_xid_devices(self):
"""
For all of the com ports connected to the computer, send an
XID command '_c1'. If the device response with '_xid', it is
an xid device.
"""
self.__xid_cons = []
for c in self.__com_ports:
device_found = False
... | [
"For",
"all",
"of",
"the",
"com",
"ports",
"connected",
"to",
"the",
"computer",
"send",
"an",
"XID",
"command",
"_c1",
".",
"If",
"the",
"device",
"response",
"with",
"_xid",
"it",
"is",
"an",
"xid",
"device",
"."
] | cedrus-opensource/pyxid | python | https://github.com/cedrus-opensource/pyxid/blob/02dba3a825f0d4f4c0bfa044c6a361492e4c25b6/pyxid/pyxid_impl.py#L21-L61 | [
"def",
"detect_xid_devices",
"(",
"self",
")",
":",
"self",
".",
"__xid_cons",
"=",
"[",
"]",
"for",
"c",
"in",
"self",
".",
"__com_ports",
":",
"device_found",
"=",
"False",
"for",
"b",
"in",
"[",
"115200",
",",
"19200",
",",
"9600",
",",
"57600",
"... | 02dba3a825f0d4f4c0bfa044c6a361492e4c25b6 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.