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 | check_span | Ensure the span is valid.
A span is a list of [row, column] pairs. These coordinates
must form a rectangular shape. For example, this span will cause an
error because it is not rectangular in shape.::
span = [[0, 1], [0, 2], [1, 0]]
Spans must be
* Rectanglular
* A list of li... | dashtable/dashutils/check_span.py | def check_span(span, table):
"""
Ensure the span is valid.
A span is a list of [row, column] pairs. These coordinates
must form a rectangular shape. For example, this span will cause an
error because it is not rectangular in shape.::
span = [[0, 1], [0, 2], [1, 0]]
Spans must be
... | def check_span(span, table):
"""
Ensure the span is valid.
A span is a list of [row, column] pairs. These coordinates
must form a rectangular shape. For example, this span will cause an
error because it is not rectangular in shape.::
span = [[0, 1], [0, 2], [1, 0]]
Spans must be
... | [
"Ensure",
"the",
"span",
"is",
"valid",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/check_span.py#L7-L81 | [
"def",
"check_span",
"(",
"span",
",",
"table",
")",
":",
"if",
"not",
"type",
"(",
"span",
")",
"is",
"list",
":",
"return",
"\"Spans must be a list of lists\"",
"for",
"pair",
"in",
"span",
":",
"if",
"not",
"type",
"(",
"pair",
")",
"is",
"list",
":... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | merge_all_cells | Loop through list of cells and piece them together one by one
Parameters
----------
cells : list of dashtable.data2rst.Cell
Returns
-------
grid_table : str
The final grid table | dashtable/data2rst/merge_all_cells.py | def merge_all_cells(cells):
"""
Loop through list of cells and piece them together one by one
Parameters
----------
cells : list of dashtable.data2rst.Cell
Returns
-------
grid_table : str
The final grid table
"""
current = 0
while len(cells) > 1:
count = 0... | def merge_all_cells(cells):
"""
Loop through list of cells and piece them together one by one
Parameters
----------
cells : list of dashtable.data2rst.Cell
Returns
-------
grid_table : str
The final grid table
"""
current = 0
while len(cells) > 1:
count = 0... | [
"Loop",
"through",
"list",
"of",
"cells",
"and",
"piece",
"them",
"together",
"one",
"by",
"one"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/merge_all_cells.py#L5-L44 | [
"def",
"merge_all_cells",
"(",
"cells",
")",
":",
"current",
"=",
"0",
"while",
"len",
"(",
"cells",
")",
">",
"1",
":",
"count",
"=",
"0",
"while",
"count",
"<",
"len",
"(",
"cells",
")",
":",
"cell1",
"=",
"cells",
"[",
"current",
"]",
"cell2",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | bpp2newick | converts bpp newick format to normal newick | toytree/utils.py | def bpp2newick(bppnewick):
"converts bpp newick format to normal newick"
regex1 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[:]")
regex2 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[;]")
regex3 = re.compile(r": ")
new = regex1.sub(":", bppnewick)
new = regex2.sub(";", new)
new = regex3.sub(":", new)
r... | def bpp2newick(bppnewick):
"converts bpp newick format to normal newick"
regex1 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[:]")
regex2 = re.compile(r" #[-+]?[0-9]*\.?[0-9]*[;]")
regex3 = re.compile(r": ")
new = regex1.sub(":", bppnewick)
new = regex2.sub(";", new)
new = regex3.sub(":", new)
r... | [
"converts",
"bpp",
"newick",
"format",
"to",
"normal",
"newick"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L396-L404 | [
"def",
"bpp2newick",
"(",
"bppnewick",
")",
":",
"regex1",
"=",
"re",
".",
"compile",
"(",
"r\" #[-+]?[0-9]*\\.?[0-9]*[:]\"",
")",
"regex2",
"=",
"re",
".",
"compile",
"(",
"r\" #[-+]?[0-9]*\\.?[0-9]*[;]\"",
")",
"regex3",
"=",
"re",
".",
"compile",
"(",
"r\":... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | return_small_clade | used to produce balanced trees, returns a tip node from the smaller clade | toytree/utils.py | def return_small_clade(treenode):
"used to produce balanced trees, returns a tip node from the smaller clade"
node = treenode
while 1:
if node.children:
c1, c2 = node.children
node = sorted([c1, c2], key=lambda x: len(x.get_leaves()))[0]
else:
return node | def return_small_clade(treenode):
"used to produce balanced trees, returns a tip node from the smaller clade"
node = treenode
while 1:
if node.children:
c1, c2 = node.children
node = sorted([c1, c2], key=lambda x: len(x.get_leaves()))[0]
else:
return node | [
"used",
"to",
"produce",
"balanced",
"trees",
"returns",
"a",
"tip",
"node",
"from",
"the",
"smaller",
"clade"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L408-L416 | [
"def",
"return_small_clade",
"(",
"treenode",
")",
":",
"node",
"=",
"treenode",
"while",
"1",
":",
"if",
"node",
".",
"children",
":",
"c1",
",",
"c2",
"=",
"node",
".",
"children",
"node",
"=",
"sorted",
"(",
"[",
"c1",
",",
"c2",
"]",
",",
"key"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | fuzzy_match_tipnames | Used in multiple internal functions (e.g., .root()) and .drop_tips())
to select an internal mrca node, or multiple tipnames, using fuzzy matching
so that every name does not need to be written out by hand.
name: verbose list
wildcard: matching unique string
regex: regex expression
mrca: return ... | toytree/utils.py | def fuzzy_match_tipnames(ttree, names, wildcard, regex, mrca=True, mono=True):
"""
Used in multiple internal functions (e.g., .root()) and .drop_tips())
to select an internal mrca node, or multiple tipnames, using fuzzy matching
so that every name does not need to be written out by hand.
name: verb... | def fuzzy_match_tipnames(ttree, names, wildcard, regex, mrca=True, mono=True):
"""
Used in multiple internal functions (e.g., .root()) and .drop_tips())
to select an internal mrca node, or multiple tipnames, using fuzzy matching
so that every name does not need to be written out by hand.
name: verb... | [
"Used",
"in",
"multiple",
"internal",
"functions",
"(",
"e",
".",
"g",
".",
".",
"root",
"()",
")",
"and",
".",
"drop_tips",
"()",
")",
"to",
"select",
"an",
"internal",
"mrca",
"node",
"or",
"multiple",
"tipnames",
"using",
"fuzzy",
"matching",
"so",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L424-L497 | [
"def",
"fuzzy_match_tipnames",
"(",
"ttree",
",",
"names",
",",
"wildcard",
",",
"regex",
",",
"mrca",
"=",
"True",
",",
"mono",
"=",
"True",
")",
":",
"# require arguments",
"if",
"not",
"any",
"(",
"[",
"names",
",",
"wildcard",
",",
"regex",
"]",
")... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeMod.node_scale_root_height | Returns a toytree copy with all nodes scaled so that the root
height equals the value entered for treeheight. | toytree/utils.py | def node_scale_root_height(self, treeheight=1):
"""
Returns a toytree copy with all nodes scaled so that the root
height equals the value entered for treeheight.
"""
# make tree height = 1 * treeheight
ctree = self._ttree.copy()
_height = ctree.treenode.height
... | def node_scale_root_height(self, treeheight=1):
"""
Returns a toytree copy with all nodes scaled so that the root
height equals the value entered for treeheight.
"""
# make tree height = 1 * treeheight
ctree = self._ttree.copy()
_height = ctree.treenode.height
... | [
"Returns",
"a",
"toytree",
"copy",
"with",
"all",
"nodes",
"scaled",
"so",
"that",
"the",
"root",
"height",
"equals",
"the",
"value",
"entered",
"for",
"treeheight",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L30-L41 | [
"def",
"node_scale_root_height",
"(",
"self",
",",
"treeheight",
"=",
"1",
")",
":",
"# make tree height = 1 * treeheight",
"ctree",
"=",
"self",
".",
"_ttree",
".",
"copy",
"(",
")",
"_height",
"=",
"ctree",
".",
"treenode",
".",
"height",
"for",
"node",
"i... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeMod.node_slider | Returns a toytree copy with node heights modified while retaining
the same topology but not necessarily node branching order.
Node heights are moved up or down uniformly between their parent
and highest child node heights in 'levelorder' from root to tips.
The total tree height is ret... | toytree/utils.py | def node_slider(self, seed=None):
"""
Returns a toytree copy with node heights modified while retaining
the same topology but not necessarily node branching order.
Node heights are moved up or down uniformly between their parent
and highest child node heights in 'levelorder' f... | def node_slider(self, seed=None):
"""
Returns a toytree copy with node heights modified while retaining
the same topology but not necessarily node branching order.
Node heights are moved up or down uniformly between their parent
and highest child node heights in 'levelorder' f... | [
"Returns",
"a",
"toytree",
"copy",
"with",
"node",
"heights",
"modified",
"while",
"retaining",
"the",
"same",
"topology",
"but",
"not",
"necessarily",
"node",
"branching",
"order",
".",
"Node",
"heights",
"are",
"moved",
"up",
"or",
"down",
"uniformly",
"betw... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L44-L77 | [
"def",
"node_slider",
"(",
"self",
",",
"seed",
"=",
"None",
")",
":",
"# I don't think user's should need to access prop",
"prop",
"=",
"0.999",
"assert",
"isinstance",
"(",
"prop",
",",
"float",
")",
",",
"\"prop must be a float\"",
"assert",
"prop",
"<",
"1",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeMod.node_multiplier | Returns a toytree copy with all nodes multiplied by a constant
sampled uniformly between (multiplier, 1/multiplier). | toytree/utils.py | def node_multiplier(self, multiplier=0.5, seed=None):
"""
Returns a toytree copy with all nodes multiplied by a constant
sampled uniformly between (multiplier, 1/multiplier).
"""
random.seed(seed)
ctree = self._ttree.copy()
low, high = sorted([multiplier, 1. / mu... | def node_multiplier(self, multiplier=0.5, seed=None):
"""
Returns a toytree copy with all nodes multiplied by a constant
sampled uniformly between (multiplier, 1/multiplier).
"""
random.seed(seed)
ctree = self._ttree.copy()
low, high = sorted([multiplier, 1. / mu... | [
"Returns",
"a",
"toytree",
"copy",
"with",
"all",
"nodes",
"multiplied",
"by",
"a",
"constant",
"sampled",
"uniformly",
"between",
"(",
"multiplier",
"1",
"/",
"multiplier",
")",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L80-L92 | [
"def",
"node_multiplier",
"(",
"self",
",",
"multiplier",
"=",
"0.5",
",",
"seed",
"=",
"None",
")",
":",
"random",
".",
"seed",
"(",
"seed",
")",
"ctree",
"=",
"self",
".",
"_ttree",
".",
"copy",
"(",
")",
"low",
",",
"high",
"=",
"sorted",
"(",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeMod.make_ultrametric | Returns a tree with branch lengths transformed so that the tree is
ultrametric. Strategies include (1) tip-align: extend tips to the length
of the fartest tip from the root; (2) non-parametric rate-smoothing:
minimize ancestor-descendant local rates on branches to align tips (
not yet ... | toytree/utils.py | def make_ultrametric(self, strategy=1):
"""
Returns a tree with branch lengths transformed so that the tree is
ultrametric. Strategies include (1) tip-align: extend tips to the length
of the fartest tip from the root; (2) non-parametric rate-smoothing:
minimize ancestor-descend... | def make_ultrametric(self, strategy=1):
"""
Returns a tree with branch lengths transformed so that the tree is
ultrametric. Strategies include (1) tip-align: extend tips to the length
of the fartest tip from the root; (2) non-parametric rate-smoothing:
minimize ancestor-descend... | [
"Returns",
"a",
"tree",
"with",
"branch",
"lengths",
"transformed",
"so",
"that",
"the",
"tree",
"is",
"ultrametric",
".",
"Strategies",
"include",
"(",
"1",
")",
"tip",
"-",
"align",
":",
"extend",
"tips",
"to",
"the",
"length",
"of",
"the",
"fartest",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L95-L115 | [
"def",
"make_ultrametric",
"(",
"self",
",",
"strategy",
"=",
"1",
")",
":",
"ctree",
"=",
"self",
".",
"_ttree",
".",
"copy",
"(",
")",
"if",
"strategy",
"==",
"1",
":",
"for",
"node",
"in",
"ctree",
".",
"treenode",
".",
"traverse",
"(",
")",
":"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | RandomTree.coaltree | Returns a coalescent tree with ntips samples and waiting times
between coalescent events drawn from the kingman coalescent:
(4N)/(k*(k-1)), where N is population size and k is sample size.
Edge lengths on the tree are in generations.
If no Ne argument is entered then edge lengths are r... | toytree/utils.py | def coaltree(ntips, ne=None, seed=None):
"""
Returns a coalescent tree with ntips samples and waiting times
between coalescent events drawn from the kingman coalescent:
(4N)/(k*(k-1)), where N is population size and k is sample size.
Edge lengths on the tree are in generations.
... | def coaltree(ntips, ne=None, seed=None):
"""
Returns a coalescent tree with ntips samples and waiting times
between coalescent events drawn from the kingman coalescent:
(4N)/(k*(k-1)), where N is population size and k is sample size.
Edge lengths on the tree are in generations.
... | [
"Returns",
"a",
"coalescent",
"tree",
"with",
"ntips",
"samples",
"and",
"waiting",
"times",
"between",
"coalescent",
"events",
"drawn",
"from",
"the",
"kingman",
"coalescent",
":",
"(",
"4N",
")",
"/",
"(",
"k",
"*",
"(",
"k",
"-",
"1",
"))",
"where",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L218-L275 | [
"def",
"coaltree",
"(",
"ntips",
",",
"ne",
"=",
"None",
",",
"seed",
"=",
"None",
")",
":",
"# seed generator",
"random",
".",
"seed",
"(",
"seed",
")",
"# convert units",
"coalunits",
"=",
"False",
"if",
"not",
"ne",
":",
"coalunits",
"=",
"True",
"n... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | RandomTree.unittree | Returns a random tree topology w/ N tips and a root height set to
1 or a user-entered treeheight value. Descendant nodes are evenly
spaced between the root and time 0.
Parameters
-----------
ntips (int):
The number of tips in the randomly generated tree
tre... | toytree/utils.py | def unittree(ntips, treeheight=1.0, seed=None):
"""
Returns a random tree topology w/ N tips and a root height set to
1 or a user-entered treeheight value. Descendant nodes are evenly
spaced between the root and time 0.
Parameters
-----------
ntips (int):
... | def unittree(ntips, treeheight=1.0, seed=None):
"""
Returns a random tree topology w/ N tips and a root height set to
1 or a user-entered treeheight value. Descendant nodes are evenly
spaced between the root and time 0.
Parameters
-----------
ntips (int):
... | [
"Returns",
"a",
"random",
"tree",
"topology",
"w",
"/",
"N",
"tips",
"and",
"a",
"root",
"height",
"set",
"to",
"1",
"or",
"a",
"user",
"-",
"entered",
"treeheight",
"value",
".",
"Descendant",
"nodes",
"are",
"evenly",
"spaced",
"between",
"the",
"root"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L279-L320 | [
"def",
"unittree",
"(",
"ntips",
",",
"treeheight",
"=",
"1.0",
",",
"seed",
"=",
"None",
")",
":",
"# seed generator",
"random",
".",
"seed",
"(",
"seed",
")",
"# generate tree with N tips.",
"tmptree",
"=",
"TreeNode",
"(",
")",
"tmptree",
".",
"populate",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | RandomTree.imbtree | Return an imbalanced (comb-like) tree topology. | toytree/utils.py | def imbtree(ntips, treeheight=1.0):
"""
Return an imbalanced (comb-like) tree topology.
"""
rtree = toytree.tree()
rtree.treenode.add_child(name="0")
rtree.treenode.add_child(name="1")
for i in range(2, ntips):
# empty node
cherry = toytre... | def imbtree(ntips, treeheight=1.0):
"""
Return an imbalanced (comb-like) tree topology.
"""
rtree = toytree.tree()
rtree.treenode.add_child(name="0")
rtree.treenode.add_child(name="1")
for i in range(2, ntips):
# empty node
cherry = toytre... | [
"Return",
"an",
"imbalanced",
"(",
"comb",
"-",
"like",
")",
"tree",
"topology",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L324-L347 | [
"def",
"imbtree",
"(",
"ntips",
",",
"treeheight",
"=",
"1.0",
")",
":",
"rtree",
"=",
"toytree",
".",
"tree",
"(",
")",
"rtree",
".",
"treenode",
".",
"add_child",
"(",
"name",
"=",
"\"0\"",
")",
"rtree",
".",
"treenode",
".",
"add_child",
"(",
"nam... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | RandomTree.baltree | Returns a balanced tree topology. | toytree/utils.py | def baltree(ntips, treeheight=1.0):
"""
Returns a balanced tree topology.
"""
# require even number of tips
if ntips % 2:
raise ToytreeError("balanced trees must have even number of tips.")
# make first cherry
rtree = toytree.tree()
rtree.tree... | def baltree(ntips, treeheight=1.0):
"""
Returns a balanced tree topology.
"""
# require even number of tips
if ntips % 2:
raise ToytreeError("balanced trees must have even number of tips.")
# make first cherry
rtree = toytree.tree()
rtree.tree... | [
"Returns",
"a",
"balanced",
"tree",
"topology",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L351-L389 | [
"def",
"baltree",
"(",
"ntips",
",",
"treeheight",
"=",
"1.0",
")",
":",
"# require even number of tips",
"if",
"ntips",
"%",
"2",
":",
"raise",
"ToytreeError",
"(",
"\"balanced trees must have even number of tips.\"",
")",
"# make first cherry",
"rtree",
"=",
"toytre... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_span_char_height | Get the height of a span in the number of newlines it fills.
Parameters
----------
span : list of list of int
A list of [row, column] pairs that make up the span
row_heights : list of int
A list of the number of newlines for each row in the table
Returns
-------
total_heigh... | dashtable/dashutils/get_span_char_height.py | def get_span_char_height(span, row_heights):
"""
Get the height of a span in the number of newlines it fills.
Parameters
----------
span : list of list of int
A list of [row, column] pairs that make up the span
row_heights : list of int
A list of the number of newlines for each ... | def get_span_char_height(span, row_heights):
"""
Get the height of a span in the number of newlines it fills.
Parameters
----------
span : list of list of int
A list of [row, column] pairs that make up the span
row_heights : list of int
A list of the number of newlines for each ... | [
"Get",
"the",
"height",
"of",
"a",
"span",
"in",
"the",
"number",
"of",
"newlines",
"it",
"fills",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_char_height.py#L4-L28 | [
"def",
"get_span_char_height",
"(",
"span",
",",
"row_heights",
")",
":",
"start_row",
"=",
"span",
"[",
"0",
"]",
"[",
"0",
"]",
"row_count",
"=",
"get_span_row_count",
"(",
"span",
")",
"total_height",
"=",
"0",
"for",
"i",
"in",
"range",
"(",
"start_r... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | html2data | Convert an html table to a data table and spans.
Parameters
----------
html_string : str
The string containing the html table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a list of [row, column] pairs that define what cells
... | dashtable/html2data/html2data.py | def html2data(html_string):
"""
Convert an html table to a data table and spans.
Parameters
----------
html_string : str
The string containing the html table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a list of [row,... | def html2data(html_string):
"""
Convert an html table to a data table and spans.
Parameters
----------
html_string : str
The string containing the html table
Returns
-------
table : list of lists of str
spans : list of lists of lists of int
A span is a list of [row,... | [
"Convert",
"an",
"html",
"table",
"to",
"a",
"data",
"table",
"and",
"spans",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/html2data.py#L7-L40 | [
"def",
"html2data",
"(",
"html_string",
")",
":",
"spans",
"=",
"extract_spans",
"(",
"html_string",
")",
"column_count",
"=",
"get_html_column_count",
"(",
"html_string",
")",
"row_count",
"=",
"get_html_row_count",
"(",
"spans",
")",
"count",
"=",
"0",
"while"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | ToyTree.newick | Returns newick represenation of the tree in its current state. | toytree/Toytree.py | def newick(self, tree_format=0):
"Returns newick represenation of the tree in its current state."
# checks one of root's children for features and extra feats.
if self.treenode.children:
features = {"name", "dist", "support", "height", "idx"}
testnode = self.treenode.chil... | def newick(self, tree_format=0):
"Returns newick represenation of the tree in its current state."
# checks one of root's children for features and extra feats.
if self.treenode.children:
features = {"name", "dist", "support", "height", "idx"}
testnode = self.treenode.chil... | [
"Returns",
"newick",
"represenation",
"of",
"the",
"tree",
"in",
"its",
"current",
"state",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L132-L140 | [
"def",
"newick",
"(",
"self",
",",
"tree_format",
"=",
"0",
")",
":",
"# checks one of root's children for features and extra feats.",
"if",
"self",
".",
"treenode",
".",
"children",
":",
"features",
"=",
"{",
"\"name\"",
",",
"\"dist\"",
",",
"\"support\"",
",",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_edge_values | Returns edge values in the order they are plotted (see .get_edges()) | toytree/Toytree.py | def get_edge_values(self, feature='idx'):
"""
Returns edge values in the order they are plotted (see .get_edges())
"""
elist = []
for cidx in self._coords.edges[:, 1]:
node = self.treenode.search_nodes(idx=cidx)[0]
elist.append(
(node.__get... | def get_edge_values(self, feature='idx'):
"""
Returns edge values in the order they are plotted (see .get_edges())
"""
elist = []
for cidx in self._coords.edges[:, 1]:
node = self.treenode.search_nodes(idx=cidx)[0]
elist.append(
(node.__get... | [
"Returns",
"edge",
"values",
"in",
"the",
"order",
"they",
"are",
"plotted",
"(",
"see",
".",
"get_edges",
"()",
")"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L173-L183 | [
"def",
"get_edge_values",
"(",
"self",
",",
"feature",
"=",
"'idx'",
")",
":",
"elist",
"=",
"[",
"]",
"for",
"cidx",
"in",
"self",
".",
"_coords",
".",
"edges",
"[",
":",
",",
"1",
"]",
":",
"node",
"=",
"self",
".",
"treenode",
".",
"search_nodes... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_edge_values_from_dict | Enter a dictionary mapping node 'idx' or tuple of tipnames to values
that you want mapped to the stem and descendant edges that node.
Edge values are returned in proper plot order to be entered to the
edge_colors or edge_widths arguments to draw(). To see node idx values
use node_lab... | toytree/Toytree.py | def get_edge_values_from_dict(self, node_value_dict=None, include_stem=True):
"""
Enter a dictionary mapping node 'idx' or tuple of tipnames to values
that you want mapped to the stem and descendant edges that node.
Edge values are returned in proper plot order to be entered to the
... | def get_edge_values_from_dict(self, node_value_dict=None, include_stem=True):
"""
Enter a dictionary mapping node 'idx' or tuple of tipnames to values
that you want mapped to the stem and descendant edges that node.
Edge values are returned in proper plot order to be entered to the
... | [
"Enter",
"a",
"dictionary",
"mapping",
"node",
"idx",
"or",
"tuple",
"of",
"tipnames",
"to",
"values",
"that",
"you",
"want",
"mapped",
"to",
"the",
"stem",
"and",
"descendant",
"edges",
"that",
"node",
".",
"Edge",
"values",
"are",
"returned",
"in",
"prop... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L186-L242 | [
"def",
"get_edge_values_from_dict",
"(",
"self",
",",
"node_value_dict",
"=",
"None",
",",
"include_stem",
"=",
"True",
")",
":",
"# map node idxs to the order in which edges are plotted",
"idxs",
"=",
"{",
"j",
":",
"i",
"for",
"(",
"i",
",",
"j",
")",
"in",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_mrca_idx_from_tip_labels | Returns the node idx label of the most recent common ancestor node
for the clade that includes the selected tips. Arguments can use fuzzy
name matching: a list of tip names, wildcard selector, or regex string. | toytree/Toytree.py | def get_mrca_idx_from_tip_labels(self, names=None, wildcard=None, regex=None):
"""
Returns the node idx label of the most recent common ancestor node
for the clade that includes the selected tips. Arguments can use fuzzy
name matching: a list of tip names, wildcard selector, or regex st... | def get_mrca_idx_from_tip_labels(self, names=None, wildcard=None, regex=None):
"""
Returns the node idx label of the most recent common ancestor node
for the clade that includes the selected tips. Arguments can use fuzzy
name matching: a list of tip names, wildcard selector, or regex st... | [
"Returns",
"the",
"node",
"idx",
"label",
"of",
"the",
"most",
"recent",
"common",
"ancestor",
"node",
"for",
"the",
"clade",
"that",
"includes",
"the",
"selected",
"tips",
".",
"Arguments",
"can",
"use",
"fuzzy",
"name",
"matching",
":",
"a",
"list",
"of"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L245-L255 | [
"def",
"get_mrca_idx_from_tip_labels",
"(",
"self",
",",
"names",
"=",
"None",
",",
"wildcard",
"=",
"None",
",",
"regex",
"=",
"None",
")",
":",
"if",
"not",
"any",
"(",
"[",
"names",
",",
"wildcard",
",",
"regex",
"]",
")",
":",
"raise",
"ToytreeErro... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_node_values | Returns node values from tree object in node plot order. To modify
values you must modify the .treenode object directly by setting new
'features'. For example
for node in ttree.treenode.traverse():
node.add_feature("PP", 100)
By default node and tip values are hidden (set t... | toytree/Toytree.py | def get_node_values(
self,
feature=None,
show_root=False,
show_tips=False,
):
"""
Returns node values from tree object in node plot order. To modify
values you must modify the .treenode object directly by setting new
'features'. For example
... | def get_node_values(
self,
feature=None,
show_root=False,
show_tips=False,
):
"""
Returns node values from tree object in node plot order. To modify
values you must modify the .treenode object directly by setting new
'features'. For example
... | [
"Returns",
"node",
"values",
"from",
"tree",
"object",
"in",
"node",
"plot",
"order",
".",
"To",
"modify",
"values",
"you",
"must",
"modify",
"the",
".",
"treenode",
"object",
"directly",
"by",
"setting",
"new",
"features",
".",
"For",
"example"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L268-L313 | [
"def",
"get_node_values",
"(",
"self",
",",
"feature",
"=",
"None",
",",
"show_root",
"=",
"False",
",",
"show_tips",
"=",
"False",
",",
")",
":",
"# access nodes in the order they will be plotted",
"ndict",
"=",
"self",
".",
"get_node_dict",
"(",
"return_internal... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_node_dict | Return node labels as a dictionary mapping {idx: name} where idx is
the order of nodes in 'preorder' traversal. Used internally by the
func .get_node_values() to return values in proper order.
return_internal: if True all nodes are returned, if False only tips.
return_nodes: if True r... | toytree/Toytree.py | def get_node_dict(self, return_internal=False, return_nodes=False):
"""
Return node labels as a dictionary mapping {idx: name} where idx is
the order of nodes in 'preorder' traversal. Used internally by the
func .get_node_values() to return values in proper order.
return_inter... | def get_node_dict(self, return_internal=False, return_nodes=False):
"""
Return node labels as a dictionary mapping {idx: name} where idx is
the order of nodes in 'preorder' traversal. Used internally by the
func .get_node_values() to return values in proper order.
return_inter... | [
"Return",
"node",
"labels",
"as",
"a",
"dictionary",
"mapping",
"{",
"idx",
":",
"name",
"}",
"where",
"idx",
"is",
"the",
"order",
"of",
"nodes",
"in",
"preorder",
"traversal",
".",
"Used",
"internally",
"by",
"the",
"func",
".",
"get_node_values",
"()",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L316-L344 | [
"def",
"get_node_dict",
"(",
"self",
",",
"return_internal",
"=",
"False",
",",
"return_nodes",
"=",
"False",
")",
":",
"if",
"return_internal",
":",
"if",
"return_nodes",
":",
"return",
"{",
"i",
".",
"idx",
":",
"i",
"for",
"i",
"in",
"self",
".",
"t... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_tip_coordinates | Returns coordinates of the tip positions for a tree. If no argument
for axis then a 2-d array is returned. The first column is the x
coordinates the second column is the y-coordinates. If you enter an
argument for axis then a 1-d array will be returned of just that axis. | toytree/Toytree.py | def get_tip_coordinates(self, axis=None):
"""
Returns coordinates of the tip positions for a tree. If no argument
for axis then a 2-d array is returned. The first column is the x
coordinates the second column is the y-coordinates. If you enter an
argument for axis then a 1-d ar... | def get_tip_coordinates(self, axis=None):
"""
Returns coordinates of the tip positions for a tree. If no argument
for axis then a 2-d array is returned. The first column is the x
coordinates the second column is the y-coordinates. If you enter an
argument for axis then a 1-d ar... | [
"Returns",
"coordinates",
"of",
"the",
"tip",
"positions",
"for",
"a",
"tree",
".",
"If",
"no",
"argument",
"for",
"axis",
"then",
"a",
"2",
"-",
"d",
"array",
"is",
"returned",
".",
"The",
"first",
"column",
"is",
"the",
"x",
"coordinates",
"the",
"se... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L347-L360 | [
"def",
"get_tip_coordinates",
"(",
"self",
",",
"axis",
"=",
"None",
")",
":",
"# get coordinates array",
"coords",
"=",
"self",
".",
"get_node_coordinates",
"(",
")",
"if",
"axis",
"==",
"'x'",
":",
"return",
"coords",
"[",
":",
"self",
".",
"ntips",
",",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.get_tip_labels | Returns tip labels in the order they will be plotted on the tree, i.e.,
starting from zero axis and counting up by units of 1 (bottom to top
in right-facing trees; left to right in down-facing). If 'idx' is
indicated then a list of tip labels descended from that node will be
returned,... | toytree/Toytree.py | def get_tip_labels(self, idx=None):
"""
Returns tip labels in the order they will be plotted on the tree, i.e.,
starting from zero axis and counting up by units of 1 (bottom to top
in right-facing trees; left to right in down-facing). If 'idx' is
indicated then a list of tip la... | def get_tip_labels(self, idx=None):
"""
Returns tip labels in the order they will be plotted on the tree, i.e.,
starting from zero axis and counting up by units of 1 (bottom to top
in right-facing trees; left to right in down-facing). If 'idx' is
indicated then a list of tip la... | [
"Returns",
"tip",
"labels",
"in",
"the",
"order",
"they",
"will",
"be",
"plotted",
"on",
"the",
"tree",
"i",
".",
"e",
".",
"starting",
"from",
"zero",
"axis",
"and",
"counting",
"up",
"by",
"units",
"of",
"1",
"(",
"bottom",
"to",
"top",
"in",
"righ... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L363-L386 | [
"def",
"get_tip_labels",
"(",
"self",
",",
"idx",
"=",
"None",
")",
":",
"if",
"not",
"idx",
":",
"return",
"self",
".",
"treenode",
".",
"get_leaf_names",
"(",
")",
"[",
":",
":",
"-",
"1",
"]",
"else",
":",
"treenode",
"=",
"self",
".",
"treenode... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.is_bifurcating | Returns False if there is a polytomy in the tree, including if the tree
is unrooted (basal polytomy), unless you use the include_root=False
argument. | toytree/Toytree.py | def is_bifurcating(self, include_root=True):
"""
Returns False if there is a polytomy in the tree, including if the tree
is unrooted (basal polytomy), unless you use the include_root=False
argument.
"""
ctn1 = -1 + (2 * len(self))
ctn2 = -2 + (2 * len(self))
... | def is_bifurcating(self, include_root=True):
"""
Returns False if there is a polytomy in the tree, including if the tree
is unrooted (basal polytomy), unless you use the include_root=False
argument.
"""
ctn1 = -1 + (2 * len(self))
ctn2 = -2 + (2 * len(self))
... | [
"Returns",
"False",
"if",
"there",
"is",
"a",
"polytomy",
"in",
"the",
"tree",
"including",
"if",
"the",
"tree",
"is",
"unrooted",
"(",
"basal",
"polytomy",
")",
"unless",
"you",
"use",
"the",
"include_root",
"=",
"False",
"argument",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L403-L415 | [
"def",
"is_bifurcating",
"(",
"self",
",",
"include_root",
"=",
"True",
")",
":",
"ctn1",
"=",
"-",
"1",
"+",
"(",
"2",
"*",
"len",
"(",
"self",
")",
")",
"ctn2",
"=",
"-",
"2",
"+",
"(",
"2",
"*",
"len",
"(",
"self",
")",
")",
"if",
"self",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.ladderize | Ladderize tree (order descendants) so that top child has fewer
descendants than the bottom child in a left to right tree plot.
To reverse this pattern use direction=1. | toytree/Toytree.py | def ladderize(self, direction=0):
"""
Ladderize tree (order descendants) so that top child has fewer
descendants than the bottom child in a left to right tree plot.
To reverse this pattern use direction=1.
"""
nself = deepcopy(self)
nself.treenode.ladderize(dire... | def ladderize(self, direction=0):
"""
Ladderize tree (order descendants) so that top child has fewer
descendants than the bottom child in a left to right tree plot.
To reverse this pattern use direction=1.
"""
nself = deepcopy(self)
nself.treenode.ladderize(dire... | [
"Ladderize",
"tree",
"(",
"order",
"descendants",
")",
"so",
"that",
"top",
"child",
"has",
"fewer",
"descendants",
"than",
"the",
"bottom",
"child",
"in",
"a",
"left",
"to",
"right",
"tree",
"plot",
".",
"To",
"reverse",
"this",
"pattern",
"use",
"directi... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L420-L430 | [
"def",
"ladderize",
"(",
"self",
",",
"direction",
"=",
"0",
")",
":",
"nself",
"=",
"deepcopy",
"(",
"self",
")",
"nself",
".",
"treenode",
".",
"ladderize",
"(",
"direction",
"=",
"direction",
")",
"nself",
".",
"_fixed_order",
"=",
"None",
"nself",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.collapse_nodes | Returns a copy of the tree where internal nodes with dist <= min_dist
are deleted, resulting in a collapsed tree. e.g.:
newtre = tre.collapse_nodes(min_dist=0.001)
newtre = tre.collapse_nodes(min_support=50) | toytree/Toytree.py | def collapse_nodes(self, min_dist=1e-6, min_support=0):
"""
Returns a copy of the tree where internal nodes with dist <= min_dist
are deleted, resulting in a collapsed tree. e.g.:
newtre = tre.collapse_nodes(min_dist=0.001)
newtre = tre.collapse_nodes(min_support=50)
"""... | def collapse_nodes(self, min_dist=1e-6, min_support=0):
"""
Returns a copy of the tree where internal nodes with dist <= min_dist
are deleted, resulting in a collapsed tree. e.g.:
newtre = tre.collapse_nodes(min_dist=0.001)
newtre = tre.collapse_nodes(min_support=50)
"""... | [
"Returns",
"a",
"copy",
"of",
"the",
"tree",
"where",
"internal",
"nodes",
"with",
"dist",
"<",
"=",
"min_dist",
"are",
"deleted",
"resulting",
"in",
"a",
"collapsed",
"tree",
".",
"e",
".",
"g",
".",
":"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L433-L447 | [
"def",
"collapse_nodes",
"(",
"self",
",",
"min_dist",
"=",
"1e-6",
",",
"min_support",
"=",
"0",
")",
":",
"nself",
"=",
"self",
".",
"copy",
"(",
")",
"for",
"node",
"in",
"nself",
".",
"treenode",
".",
"traverse",
"(",
")",
":",
"if",
"not",
"no... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.drop_tips | Returns a copy of the tree with the selected tips removed. The entered
value can be a name or list of names. To prune on an internal node to
create a subtree see the .prune() function instead.
Parameters:
tips: list of tip names.
# example:
ptre = tre.drop_tips(['a', 'b... | toytree/Toytree.py | def drop_tips(self, names=None, wildcard=None, regex=None):
"""
Returns a copy of the tree with the selected tips removed. The entered
value can be a name or list of names. To prune on an internal node to
create a subtree see the .prune() function instead.
Parameters:
ti... | def drop_tips(self, names=None, wildcard=None, regex=None):
"""
Returns a copy of the tree with the selected tips removed. The entered
value can be a name or list of names. To prune on an internal node to
create a subtree see the .prune() function instead.
Parameters:
ti... | [
"Returns",
"a",
"copy",
"of",
"the",
"tree",
"with",
"the",
"selected",
"tips",
"removed",
".",
"The",
"entered",
"value",
"can",
"be",
"a",
"name",
"or",
"list",
"of",
"names",
".",
"To",
"prune",
"on",
"an",
"internal",
"node",
"to",
"create",
"a",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L451-L489 | [
"def",
"drop_tips",
"(",
"self",
",",
"names",
"=",
"None",
",",
"wildcard",
"=",
"None",
",",
"regex",
"=",
"None",
")",
":",
"# make a deepcopy of the tree",
"nself",
"=",
"self",
".",
"copy",
"(",
")",
"# return if nothing to drop",
"if",
"not",
"any",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.rotate_node | Returns a ToyTree with the selected node rotated for plotting.
tip colors do not align correct currently if nodes are rotated... | toytree/Toytree.py | def rotate_node(
self,
names=None,
wildcard=None,
regex=None,
idx=None,
# modify_tree=False,
):
"""
Returns a ToyTree with the selected node rotated for plotting.
tip colors do not align correct currently if nodes are rotated...
... | def rotate_node(
self,
names=None,
wildcard=None,
regex=None,
idx=None,
# modify_tree=False,
):
"""
Returns a ToyTree with the selected node rotated for plotting.
tip colors do not align correct currently if nodes are rotated...
... | [
"Returns",
"a",
"ToyTree",
"with",
"the",
"selected",
"node",
"rotated",
"for",
"plotting",
".",
"tip",
"colors",
"do",
"not",
"align",
"correct",
"currently",
"if",
"nodes",
"are",
"rotated",
"..."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L493-L542 | [
"def",
"rotate_node",
"(",
"self",
",",
"names",
"=",
"None",
",",
"wildcard",
"=",
"None",
",",
"regex",
"=",
"None",
",",
"idx",
"=",
"None",
",",
"# modify_tree=False,",
")",
":",
"# make a copy",
"revd",
"=",
"{",
"j",
":",
"i",
"for",
"(",
"i",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.resolve_polytomy | Returns a copy of the tree with all polytomies randomly resolved.
Does not transform tree in-place. | toytree/Toytree.py | def resolve_polytomy(
self,
dist=1.0,
support=100,
recursive=True):
"""
Returns a copy of the tree with all polytomies randomly resolved.
Does not transform tree in-place.
"""
nself = self.copy()
nself.treenode.resolve_polytomy(
... | def resolve_polytomy(
self,
dist=1.0,
support=100,
recursive=True):
"""
Returns a copy of the tree with all polytomies randomly resolved.
Does not transform tree in-place.
"""
nself = self.copy()
nself.treenode.resolve_polytomy(
... | [
"Returns",
"a",
"copy",
"of",
"the",
"tree",
"with",
"all",
"polytomies",
"randomly",
"resolved",
".",
"Does",
"not",
"transform",
"tree",
"in",
"-",
"place",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L545-L560 | [
"def",
"resolve_polytomy",
"(",
"self",
",",
"dist",
"=",
"1.0",
",",
"support",
"=",
"100",
",",
"recursive",
"=",
"True",
")",
":",
"nself",
"=",
"self",
".",
"copy",
"(",
")",
"nself",
".",
"treenode",
".",
"resolve_polytomy",
"(",
"default_dist",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.unroot | Returns a copy of the tree unrooted. Does not transform tree in-place. | toytree/Toytree.py | def unroot(self):
"""
Returns a copy of the tree unrooted. Does not transform tree in-place.
"""
nself = self.copy()
nself.treenode.unroot()
nself.treenode.ladderize()
nself._coords.update()
return nself | def unroot(self):
"""
Returns a copy of the tree unrooted. Does not transform tree in-place.
"""
nself = self.copy()
nself.treenode.unroot()
nself.treenode.ladderize()
nself._coords.update()
return nself | [
"Returns",
"a",
"copy",
"of",
"the",
"tree",
"unrooted",
".",
"Does",
"not",
"transform",
"tree",
"in",
"-",
"place",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L563-L571 | [
"def",
"unroot",
"(",
"self",
")",
":",
"nself",
"=",
"self",
".",
"copy",
"(",
")",
"nself",
".",
"treenode",
".",
"unroot",
"(",
")",
"nself",
".",
"treenode",
".",
"ladderize",
"(",
")",
"nself",
".",
"_coords",
".",
"update",
"(",
")",
"return"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.root | (Re-)root a tree by creating selecting a existing split in the tree,
or creating a new node to split an edge in the tree. Rooting location
is selected by entering the tips descendant from one child of the root
split (e.g., names='a' or names=['a', 'b']). You can alternatively
select a li... | toytree/Toytree.py | def root(self, names=None, wildcard=None, regex=None):
"""
(Re-)root a tree by creating selecting a existing split in the tree,
or creating a new node to split an edge in the tree. Rooting location
is selected by entering the tips descendant from one child of the root
split (e.g.... | def root(self, names=None, wildcard=None, regex=None):
"""
(Re-)root a tree by creating selecting a existing split in the tree,
or creating a new node to split an edge in the tree. Rooting location
is selected by entering the tips descendant from one child of the root
split (e.g.... | [
"(",
"Re",
"-",
")",
"root",
"a",
"tree",
"by",
"creating",
"selecting",
"a",
"existing",
"split",
"in",
"the",
"tree",
"or",
"creating",
"a",
"new",
"node",
"to",
"split",
"an",
"edge",
"in",
"the",
"tree",
".",
"Rooting",
"location",
"is",
"selected"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L574-L659 | [
"def",
"root",
"(",
"self",
",",
"names",
"=",
"None",
",",
"wildcard",
"=",
"None",
",",
"regex",
"=",
"None",
")",
":",
"# make a deepcopy of the tree",
"nself",
"=",
"self",
".",
"copy",
"(",
")",
"# get treenode of the common ancestor of selected tips",
"try... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | ToyTree.draw | Plot a Toytree tree, returns a tuple of Toyplot (Canvas, Axes) objects.
Parameters:
-----------
tree_style: str
One of several preset styles for tree plotting. The default is 'n'
(normal). Other options inlude 'c' (coalescent), 'd' (dark), and
'm' (multitree)... | toytree/Toytree.py | def draw(
self,
tree_style=None,
height=None,
width=None,
axes=None,
orient=None,
tip_labels=None,
tip_labels_colors=None,
tip_labels_style=None,
tip_labels_align=None,
node_labels=None,
node_labels_style=None,
... | def draw(
self,
tree_style=None,
height=None,
width=None,
axes=None,
orient=None,
tip_labels=None,
tip_labels_colors=None,
tip_labels_style=None,
tip_labels_align=None,
node_labels=None,
node_labels_style=None,
... | [
"Plot",
"a",
"Toytree",
"tree",
"returns",
"a",
"tuple",
"of",
"Toyplot",
"(",
"Canvas",
"Axes",
")",
"objects",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L664-L823 | [
"def",
"draw",
"(",
"self",
",",
"tree_style",
"=",
"None",
",",
"height",
"=",
"None",
",",
"width",
"=",
"None",
",",
"axes",
"=",
"None",
",",
"orient",
"=",
"None",
",",
"tip_labels",
"=",
"None",
",",
"tip_labels_colors",
"=",
"None",
",",
"tip_... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_merge_direction | Determine the side of cell1 that can be merged with cell2.
This is based on the location of the two cells in the table as well
as the compatability of their height and width.
For example these cells can merge::
cell1 cell2 merge "RIGHT"
+-----+ +------+ +-----+------+
... | dashtable/data2rst/cell/get_merge_direction.py | def get_merge_direction(cell1, cell2):
"""
Determine the side of cell1 that can be merged with cell2.
This is based on the location of the two cells in the table as well
as the compatability of their height and width.
For example these cells can merge::
cell1 cell2 merge "RIGHT"
... | def get_merge_direction(cell1, cell2):
"""
Determine the side of cell1 that can be merged with cell2.
This is based on the location of the two cells in the table as well
as the compatability of their height and width.
For example these cells can merge::
cell1 cell2 merge "RIGHT"
... | [
"Determine",
"the",
"side",
"of",
"cell1",
"that",
"can",
"be",
"merged",
"with",
"cell2",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_merge_direction.py#L1-L74 | [
"def",
"get_merge_direction",
"(",
"cell1",
",",
"cell2",
")",
":",
"cell1_left",
"=",
"cell1",
".",
"column",
"cell1_right",
"=",
"cell1",
".",
"column",
"+",
"cell1",
".",
"column_count",
"cell1_top",
"=",
"cell1",
".",
"row",
"cell1_bottom",
"=",
"cell1",... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | parse_nhx | NHX format: [&&NHX:prop1=value1:prop2=value2]
MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ... | toytree/TreeParser.py | def parse_nhx(NHX_string):
"""
NHX format: [&&NHX:prop1=value1:prop2=value2]
MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ...
"""
# store features
ndict = {}
# parse NHX or MB features
if "[&&NHX:" in NHX_string:
NHX_string = NHX_string.replace("[&&NHX:", "")
... | def parse_nhx(NHX_string):
"""
NHX format: [&&NHX:prop1=value1:prop2=value2]
MB format: ((a[&Z=1,Y=2], b[&Z=1,Y=2]):1.0[&L=1,W=0], ...
"""
# store features
ndict = {}
# parse NHX or MB features
if "[&&NHX:" in NHX_string:
NHX_string = NHX_string.replace("[&&NHX:", "")
... | [
"NHX",
"format",
":",
"[",
"&&NHX",
":",
"prop1",
"=",
"value1",
":",
"prop2",
"=",
"value2",
"]",
"MB",
"format",
":",
"((",
"a",
"[",
"&Z",
"=",
"1",
"Y",
"=",
"2",
"]",
"b",
"[",
"&Z",
"=",
"1",
"Y",
"=",
"2",
"]",
")",
":",
"1",
".",
... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L586-L605 | [
"def",
"parse_nhx",
"(",
"NHX_string",
")",
":",
"# store features",
"ndict",
"=",
"{",
"}",
"# parse NHX or MB features",
"if",
"\"[&&NHX:\"",
"in",
"NHX_string",
":",
"NHX_string",
"=",
"NHX_string",
".",
"replace",
"(",
"\"[&&NHX:\"",
",",
"\"\"",
")",
"NHX_s... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeParser.get_data_from_intree | Load *data* from a file or string and return as a list of strings.
The data contents could be one newick string; a multiline NEXUS format
for one tree; multiple newick strings on multiple lines; or multiple
newick strings in a multiline NEXUS format. In any case, we will read
in the data... | toytree/TreeParser.py | def get_data_from_intree(self):
"""
Load *data* from a file or string and return as a list of strings.
The data contents could be one newick string; a multiline NEXUS format
for one tree; multiple newick strings on multiple lines; or multiple
newick strings in a multiline NEXUS f... | def get_data_from_intree(self):
"""
Load *data* from a file or string and return as a list of strings.
The data contents could be one newick string; a multiline NEXUS format
for one tree; multiple newick strings on multiple lines; or multiple
newick strings in a multiline NEXUS f... | [
"Load",
"*",
"data",
"*",
"from",
"a",
"file",
"or",
"string",
"and",
"return",
"as",
"a",
"list",
"of",
"strings",
".",
"The",
"data",
"contents",
"could",
"be",
"one",
"newick",
"string",
";",
"a",
"multiline",
"NEXUS",
"format",
"for",
"one",
"tree"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L196-L228 | [
"def",
"get_data_from_intree",
"(",
"self",
")",
":",
"# load string: filename or data stream",
"if",
"isinstance",
"(",
"self",
".",
"intree",
",",
"(",
"str",
",",
"bytes",
")",
")",
":",
"# strip it",
"self",
".",
"intree",
"=",
"self",
".",
"intree",
"."... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeParser.parse_nexus | get newick data from NEXUS | toytree/TreeParser.py | def parse_nexus(self):
"get newick data from NEXUS"
if self.data[0].strip().upper() == "#NEXUS":
nex = NexusParser(self.data)
self.data = nex.newicks
self.tdict = nex.tdict | def parse_nexus(self):
"get newick data from NEXUS"
if self.data[0].strip().upper() == "#NEXUS":
nex = NexusParser(self.data)
self.data = nex.newicks
self.tdict = nex.tdict | [
"get",
"newick",
"data",
"from",
"NEXUS"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L231-L236 | [
"def",
"parse_nexus",
"(",
"self",
")",
":",
"if",
"self",
".",
"data",
"[",
"0",
"]",
".",
"strip",
"(",
")",
".",
"upper",
"(",
")",
"==",
"\"#NEXUS\"",
":",
"nex",
"=",
"NexusParser",
"(",
"self",
".",
"data",
")",
"self",
".",
"data",
"=",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | TreeParser.get_treenodes | test format of intree nex/nwk, extra features | toytree/TreeParser.py | def get_treenodes(self):
"test format of intree nex/nwk, extra features"
if not self.multitree:
# get TreeNodes from Newick
extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt)
# extract one tree
self.treenodes.append(extractor.newick_... | def get_treenodes(self):
"test format of intree nex/nwk, extra features"
if not self.multitree:
# get TreeNodes from Newick
extractor = Newick2TreeNode(self.data[0].strip(), fmt=self.fmt)
# extract one tree
self.treenodes.append(extractor.newick_... | [
"test",
"format",
"of",
"intree",
"nex",
"/",
"nwk",
"extra",
"features"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L239-L255 | [
"def",
"get_treenodes",
"(",
"self",
")",
":",
"if",
"not",
"self",
".",
"multitree",
":",
"# get TreeNodes from Newick",
"extractor",
"=",
"Newick2TreeNode",
"(",
"self",
".",
"data",
"[",
"0",
"]",
".",
"strip",
"(",
")",
",",
"fmt",
"=",
"self",
".",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Newick2TreeNode.newick_from_string | Reads a newick string in the New Hampshire format. | toytree/TreeParser.py | def newick_from_string(self):
"Reads a newick string in the New Hampshire format."
# split on parentheses to traverse hierarchical tree structure
for chunk in self.data.split("(")[1:]:
# add child to make this node a parent.
self.current_parent = (
self.r... | def newick_from_string(self):
"Reads a newick string in the New Hampshire format."
# split on parentheses to traverse hierarchical tree structure
for chunk in self.data.split("(")[1:]:
# add child to make this node a parent.
self.current_parent = (
self.r... | [
"Reads",
"a",
"newick",
"string",
"in",
"the",
"New",
"Hampshire",
"format",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L319-L352 | [
"def",
"newick_from_string",
"(",
"self",
")",
":",
"# split on parentheses to traverse hierarchical tree structure",
"for",
"chunk",
"in",
"self",
".",
"data",
".",
"split",
"(",
"\"(\"",
")",
"[",
"1",
":",
"]",
":",
"# add child to make this node a parent.",
"self"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | NexusParser.extract_tree_block | iterate through data file to extract trees | toytree/TreeParser.py | def extract_tree_block(self):
"iterate through data file to extract trees"
lines = iter(self.data)
while 1:
try:
line = next(lines).strip()
except StopIteration:
break
# enter trees block
if line.lower(... | def extract_tree_block(self):
"iterate through data file to extract trees"
lines = iter(self.data)
while 1:
try:
line = next(lines).strip()
except StopIteration:
break
# enter trees block
if line.lower(... | [
"iterate",
"through",
"data",
"file",
"to",
"extract",
"trees"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L422-L454 | [
"def",
"extract_tree_block",
"(",
"self",
")",
":",
"lines",
"=",
"iter",
"(",
"self",
".",
"data",
")",
"while",
"1",
":",
"try",
":",
"line",
"=",
"next",
"(",
"lines",
")",
".",
"strip",
"(",
")",
"except",
"StopIteration",
":",
"break",
"# enter ... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | parse_command_line | Parse CLI args. | versioner.py | def parse_command_line():
""" Parse CLI args."""
## create the parser
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
* Example command-line usage:
## push test branch to conda --label=conda-test for travis CI
./versioner.py -p toyt... | def parse_command_line():
""" Parse CLI args."""
## create the parser
parser = argparse.ArgumentParser(
formatter_class=argparse.RawDescriptionHelpFormatter,
epilog="""
* Example command-line usage:
## push test branch to conda --label=conda-test for travis CI
./versioner.py -p toyt... | [
"Parse",
"CLI",
"args",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L293-L354 | [
"def",
"parse_command_line",
"(",
")",
":",
"## create the parser",
"parser",
"=",
"argparse",
".",
"ArgumentParser",
"(",
"formatter_class",
"=",
"argparse",
".",
"RawDescriptionHelpFormatter",
",",
"epilog",
"=",
"\"\"\"\n * Example command-line usage: \n\n ## push test b... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version.get_git_status | Gets git and init versions and commits since the init version | versioner.py | def get_git_status(self):
"""
Gets git and init versions and commits since the init version
"""
## get git branch
self._get_git_branch()
## get tag in the init file
self._get_init_release_tag()
## get log commits since <tag>
try:
self... | def get_git_status(self):
"""
Gets git and init versions and commits since the init version
"""
## get git branch
self._get_git_branch()
## get tag in the init file
self._get_init_release_tag()
## get log commits since <tag>
try:
self... | [
"Gets",
"git",
"and",
"init",
"versions",
"and",
"commits",
"since",
"the",
"init",
"version"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L39-L67 | [
"def",
"get_git_status",
"(",
"self",
")",
":",
"## get git branch",
"self",
".",
"_get_git_branch",
"(",
")",
"## get tag in the init file",
"self",
".",
"_get_init_release_tag",
"(",
")",
"## get log commits since <tag>",
"try",
":",
"self",
".",
"_get_log_commits",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version.push_git_package | if no conflicts then write new tag to | versioner.py | def push_git_package(self):
"""
if no conflicts then write new tag to
"""
## check for conflicts, then write to local files
self._pull_branch_from_origin()
## log commits to releasenotes
if self.deploy:
self._write_commits_to_release_notes()
... | def push_git_package(self):
"""
if no conflicts then write new tag to
"""
## check for conflicts, then write to local files
self._pull_branch_from_origin()
## log commits to releasenotes
if self.deploy:
self._write_commits_to_release_notes()
... | [
"if",
"no",
"conflicts",
"then",
"write",
"new",
"tag",
"to"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L72-L92 | [
"def",
"push_git_package",
"(",
"self",
")",
":",
"## check for conflicts, then write to local files",
"self",
".",
"_pull_branch_from_origin",
"(",
")",
"## log commits to releasenotes",
"if",
"self",
".",
"deploy",
":",
"self",
".",
"_write_commits_to_release_notes",
"(",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._pull_branch_from_origin | Pulls from origin/master, if you have unmerged conflicts
it will raise an exception. You will need to resolve these. | versioner.py | def _pull_branch_from_origin(self):
"""
Pulls from origin/master, if you have unmerged conflicts
it will raise an exception. You will need to resolve these.
"""
try:
## self.repo.git.pull()
subprocess.check_call(["git", "pull", "origin", self.branch])
... | def _pull_branch_from_origin(self):
"""
Pulls from origin/master, if you have unmerged conflicts
it will raise an exception. You will need to resolve these.
"""
try:
## self.repo.git.pull()
subprocess.check_call(["git", "pull", "origin", self.branch])
... | [
"Pulls",
"from",
"origin",
"/",
"master",
"if",
"you",
"have",
"unmerged",
"conflicts",
"it",
"will",
"raise",
"an",
"exception",
".",
"You",
"will",
"need",
"to",
"resolve",
"these",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L105-L117 | [
"def",
"_pull_branch_from_origin",
"(",
"self",
")",
":",
"try",
":",
"## self.repo.git.pull()",
"subprocess",
".",
"check_call",
"(",
"[",
"\"git\"",
",",
"\"pull\"",
",",
"\"origin\"",
",",
"self",
".",
"branch",
"]",
")",
"except",
"Exception",
"as",
"inst"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._get_init_release_tag | parses init.py to get previous version | versioner.py | def _get_init_release_tag(self):
"""
parses init.py to get previous version
"""
self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
open(self.init_file, "r").read(),
re.M).group(1) | def _get_init_release_tag(self):
"""
parses init.py to get previous version
"""
self.init_version = re.search(r"^__version__ = ['\"]([^'\"]*)['\"]",
open(self.init_file, "r").read(),
re.M).group(1) | [
"parses",
"init",
".",
"py",
"to",
"get",
"previous",
"version"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L121-L127 | [
"def",
"_get_init_release_tag",
"(",
"self",
")",
":",
"self",
".",
"init_version",
"=",
"re",
".",
"search",
"(",
"r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"",
",",
"open",
"(",
"self",
".",
"init_file",
",",
"\"r\"",
")",
".",
"read",
"(",
")",
",",
"re... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._get_log_commits | calls git log to complile a change list | versioner.py | def _get_log_commits(self):
"""
calls git log to complile a change list
"""
## check if update is necessary
cmd = "git log --pretty=oneline {}..".format(self.init_version)
cmdlist = shlex.split(cmd)
commits = subprocess.check_output(cmdlist)
## Sp... | def _get_log_commits(self):
"""
calls git log to complile a change list
"""
## check if update is necessary
cmd = "git log --pretty=oneline {}..".format(self.init_version)
cmdlist = shlex.split(cmd)
commits = subprocess.check_output(cmdlist)
## Sp... | [
"calls",
"git",
"log",
"to",
"complile",
"a",
"change",
"list"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L131-L141 | [
"def",
"_get_log_commits",
"(",
"self",
")",
":",
"## check if update is necessary",
"cmd",
"=",
"\"git log --pretty=oneline {}..\"",
".",
"format",
"(",
"self",
".",
"init_version",
")",
"cmdlist",
"=",
"shlex",
".",
"split",
"(",
"cmd",
")",
"commits",
"=",
"s... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._write_commits_to_release_notes | writes commits to the releasenotes file by appending to the end | versioner.py | def _write_commits_to_release_notes(self):
"""
writes commits to the releasenotes file by appending to the end
"""
with open(self.release_file, 'a') as out:
out.write("==========\n{}\n".format(self.tag))
for commit in self.commits:
try:
... | def _write_commits_to_release_notes(self):
"""
writes commits to the releasenotes file by appending to the end
"""
with open(self.release_file, 'a') as out:
out.write("==========\n{}\n".format(self.tag))
for commit in self.commits:
try:
... | [
"writes",
"commits",
"to",
"the",
"releasenotes",
"file",
"by",
"appending",
"to",
"the",
"end"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L145-L157 | [
"def",
"_write_commits_to_release_notes",
"(",
"self",
")",
":",
"with",
"open",
"(",
"self",
".",
"release_file",
",",
"'a'",
")",
"as",
"out",
":",
"out",
".",
"write",
"(",
"\"==========\\n{}\\n\"",
".",
"format",
"(",
"self",
".",
"tag",
")",
")",
"f... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._write_new_tag_to_init | Write version to __init__.py by editing in place | versioner.py | def _write_new_tag_to_init(self):
"""
Write version to __init__.py by editing in place
"""
for line in fileinput.input(self.init_file, inplace=1):
if line.strip().startswith("__version__"):
line = "__version__ = \"" + self.tag + "\""
print(line.str... | def _write_new_tag_to_init(self):
"""
Write version to __init__.py by editing in place
"""
for line in fileinput.input(self.init_file, inplace=1):
if line.strip().startswith("__version__"):
line = "__version__ = \"" + self.tag + "\""
print(line.str... | [
"Write",
"version",
"to",
"__init__",
".",
"py",
"by",
"editing",
"in",
"place"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L161-L168 | [
"def",
"_write_new_tag_to_init",
"(",
"self",
")",
":",
"for",
"line",
"in",
"fileinput",
".",
"input",
"(",
"self",
".",
"init_file",
",",
"inplace",
"=",
"1",
")",
":",
"if",
"line",
".",
"strip",
"(",
")",
".",
"startswith",
"(",
"\"__version__\"",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._write_branch_and_tag_to_meta_yaml | Write branch and tag to meta.yaml by editing in place | versioner.py | def _write_branch_and_tag_to_meta_yaml(self):
"""
Write branch and tag to meta.yaml by editing in place
"""
## set the branch to pull source from
with open(self.meta_yaml.replace("meta", "template"), 'r') as infile:
dat = infile.read()
newdat = dat.format(... | def _write_branch_and_tag_to_meta_yaml(self):
"""
Write branch and tag to meta.yaml by editing in place
"""
## set the branch to pull source from
with open(self.meta_yaml.replace("meta", "template"), 'r') as infile:
dat = infile.read()
newdat = dat.format(... | [
"Write",
"branch",
"and",
"tag",
"to",
"meta",
".",
"yaml",
"by",
"editing",
"in",
"place"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L172-L182 | [
"def",
"_write_branch_and_tag_to_meta_yaml",
"(",
"self",
")",
":",
"## set the branch to pull source from",
"with",
"open",
"(",
"self",
".",
"meta_yaml",
".",
"replace",
"(",
"\"meta\"",
",",
"\"template\"",
")",
",",
"'r'",
")",
"as",
"infile",
":",
"dat",
"=... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._revert_tag_in_init | Write version to __init__.py by editing in place | versioner.py | def _revert_tag_in_init(self):
"""
Write version to __init__.py by editing in place
"""
for line in fileinput.input(self.init_file, inplace=1):
if line.strip().startswith("__version__"):
line = "__version__ = \"" + self.init_version + "\""
print(li... | def _revert_tag_in_init(self):
"""
Write version to __init__.py by editing in place
"""
for line in fileinput.input(self.init_file, inplace=1):
if line.strip().startswith("__version__"):
line = "__version__ = \"" + self.init_version + "\""
print(li... | [
"Write",
"version",
"to",
"__init__",
".",
"py",
"by",
"editing",
"in",
"place"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L199-L209 | [
"def",
"_revert_tag_in_init",
"(",
"self",
")",
":",
"for",
"line",
"in",
"fileinput",
".",
"input",
"(",
"self",
".",
"init_file",
",",
"inplace",
"=",
"1",
")",
":",
"if",
"line",
".",
"strip",
"(",
")",
".",
"startswith",
"(",
"\"__version__\"",
")"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version._push_new_tag_to_git | tags a new release and pushes to origin/master | versioner.py | def _push_new_tag_to_git(self):
"""
tags a new release and pushes to origin/master
"""
print("Pushing new version to git")
## stage the releasefile and initfileb
subprocess.call(["git", "add", self.release_file])
subprocess.call(["git", "add", self.in... | def _push_new_tag_to_git(self):
"""
tags a new release and pushes to origin/master
"""
print("Pushing new version to git")
## stage the releasefile and initfileb
subprocess.call(["git", "add", self.release_file])
subprocess.call(["git", "add", self.in... | [
"tags",
"a",
"new",
"release",
"and",
"pushes",
"to",
"origin",
"/",
"master"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L216-L238 | [
"def",
"_push_new_tag_to_git",
"(",
"self",
")",
":",
"print",
"(",
"\"Pushing new version to git\"",
")",
"## stage the releasefile and initfileb",
"subprocess",
".",
"call",
"(",
"[",
"\"git\"",
",",
"\"add\"",
",",
"self",
".",
"release_file",
"]",
")",
"subproce... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Version.build_conda_packages | Run the Linux build and use converter to build OSX | versioner.py | def build_conda_packages(self):
"""
Run the Linux build and use converter to build OSX
"""
## check if update is necessary
#if self.nversion == self.pversion:
# raise SystemExit("Exited: new version == existing version")
## tmp dir
bldir = "./tmp-bld"
... | def build_conda_packages(self):
"""
Run the Linux build and use converter to build OSX
"""
## check if update is necessary
#if self.nversion == self.pversion:
# raise SystemExit("Exited: new version == existing version")
## tmp dir
bldir = "./tmp-bld"
... | [
"Run",
"the",
"Linux",
"build",
"and",
"use",
"converter",
"to",
"build",
"OSX"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L247-L285 | [
"def",
"build_conda_packages",
"(",
"self",
")",
":",
"## check if update is necessary",
"#if self.nversion == self.pversion:",
"# raise SystemExit(\"Exited: new version == existing version\")",
"## tmp dir",
"bldir",
"=",
"\"./tmp-bld\"",
"if",
"not",
"os",
".",
"path",
".",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | get_span_row_count | Gets the number of rows included in a span
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
rows : int
The number of rows included in the span
Example
-------
Consider this table::
+--------+--... | dashtable/dashutils/get_span_row_count.py | def get_span_row_count(span):
"""
Gets the number of rows included in a span
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
rows : int
The number of rows included in the span
Example
-------
C... | def get_span_row_count(span):
"""
Gets the number of rows included in a span
Parameters
----------
span : list of lists of int
The [row, column] pairs that make up the span
Returns
-------
rows : int
The number of rows included in the span
Example
-------
C... | [
"Gets",
"the",
"number",
"of",
"rows",
"included",
"in",
"a",
"span"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_row_count.py#L1-L41 | [
"def",
"get_span_row_count",
"(",
"span",
")",
":",
"rows",
"=",
"1",
"first_row",
"=",
"span",
"[",
"0",
"]",
"[",
"0",
"]",
"for",
"i",
"in",
"range",
"(",
"len",
"(",
"span",
")",
")",
":",
"if",
"span",
"[",
"i",
"]",
"[",
"0",
"]",
">",
... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | asarray | Convert ``x`` into a ``numpy.ndarray``. | dynts/utils/section.py | def asarray(x, dtype=None):
'''Convert ``x`` into a ``numpy.ndarray``.'''
iterable = scalarasiter(x)
if isinstance(iterable, ndarray):
return iterable
else:
if not hasattr(iterable, '__len__'):
iterable = list(iterable)
if dtype == object_type:
a ... | def asarray(x, dtype=None):
'''Convert ``x`` into a ``numpy.ndarray``.'''
iterable = scalarasiter(x)
if isinstance(iterable, ndarray):
return iterable
else:
if not hasattr(iterable, '__len__'):
iterable = list(iterable)
if dtype == object_type:
a ... | [
"Convert",
"x",
"into",
"a",
"numpy",
".",
"ndarray",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L21-L35 | [
"def",
"asarray",
"(",
"x",
",",
"dtype",
"=",
"None",
")",
":",
"iterable",
"=",
"scalarasiter",
"(",
"x",
")",
"if",
"isinstance",
"(",
"iterable",
",",
"ndarray",
")",
":",
"return",
"iterable",
"else",
":",
"if",
"not",
"hasattr",
"(",
"iterable",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | ascolumn | Convert ``x`` into a ``column``-type ``numpy.ndarray``. | dynts/utils/section.py | def ascolumn(x, dtype = None):
'''Convert ``x`` into a ``column``-type ``numpy.ndarray``.'''
x = asarray(x, dtype)
return x if len(x.shape) >= 2 else x.reshape(len(x),1) | def ascolumn(x, dtype = None):
'''Convert ``x`` into a ``column``-type ``numpy.ndarray``.'''
x = asarray(x, dtype)
return x if len(x.shape) >= 2 else x.reshape(len(x),1) | [
"Convert",
"x",
"into",
"a",
"column",
"-",
"type",
"numpy",
".",
"ndarray",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L38-L41 | [
"def",
"ascolumn",
"(",
"x",
",",
"dtype",
"=",
"None",
")",
":",
"x",
"=",
"asarray",
"(",
"x",
",",
"dtype",
")",
"return",
"x",
"if",
"len",
"(",
"x",
".",
"shape",
")",
">=",
"2",
"else",
"x",
".",
"reshape",
"(",
"len",
"(",
"x",
")",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | multis_2_mono | Converts each multiline string in a table to single line.
Parameters
----------
table : list of list of str
A list of rows containing strings
Returns
-------
table : list of lists of str | dashtable/dashutils/multis_2_mono.py | def multis_2_mono(table):
"""
Converts each multiline string in a table to single line.
Parameters
----------
table : list of list of str
A list of rows containing strings
Returns
-------
table : list of lists of str
"""
for row in range(len(table)):
for column ... | def multis_2_mono(table):
"""
Converts each multiline string in a table to single line.
Parameters
----------
table : list of list of str
A list of rows containing strings
Returns
-------
table : list of lists of str
"""
for row in range(len(table)):
for column ... | [
"Converts",
"each",
"multiline",
"string",
"in",
"a",
"table",
"to",
"single",
"line",
"."
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/multis_2_mono.py#L1-L18 | [
"def",
"multis_2_mono",
"(",
"table",
")",
":",
"for",
"row",
"in",
"range",
"(",
"len",
"(",
"table",
")",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
")",
":",
"table",
"[",
"row",
"]",
"[",
"colu... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | get_html_row_count | Get the number of rows | dashtable/html2data/get_html_row_count.py | def get_html_row_count(spans):
"""Get the number of rows"""
if spans == []:
return 0
row_counts = {}
for span in spans:
span = sorted(span)
try:
row_counts[str(span[0][1])] += get_span_row_count(span)
except KeyError:
row_counts[str(span[0][1])] =... | def get_html_row_count(spans):
"""Get the number of rows"""
if spans == []:
return 0
row_counts = {}
for span in spans:
span = sorted(span)
try:
row_counts[str(span[0][1])] += get_span_row_count(span)
except KeyError:
row_counts[str(span[0][1])] =... | [
"Get",
"the",
"number",
"of",
"rows"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/get_html_row_count.py#L4-L18 | [
"def",
"get_html_row_count",
"(",
"spans",
")",
":",
"if",
"spans",
"==",
"[",
"]",
":",
"return",
"0",
"row_counts",
"=",
"{",
"}",
"for",
"span",
"in",
"spans",
":",
"span",
"=",
"sorted",
"(",
"span",
")",
"try",
":",
"row_counts",
"[",
"str",
"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | levenshtein_distance | Computes the Levenshtein distance.
[Reference]: https://en.wikipedia.org/wiki/Levenshtein_distance
[Article]: Levenshtein, Vladimir I. (February 1966). "Binary codes capable of correcting deletions,
insertions,and reversals". Soviet Physics Doklady 10 (8): 707–710.
[Implementation]: https://en.wiki... | pyphonetics/distance_metrics/levenshtein.py | def levenshtein_distance(word1, word2):
"""
Computes the Levenshtein distance.
[Reference]: https://en.wikipedia.org/wiki/Levenshtein_distance
[Article]: Levenshtein, Vladimir I. (February 1966). "Binary codes capable of correcting deletions,
insertions,and reversals". Soviet Physics Doklady 10... | def levenshtein_distance(word1, word2):
"""
Computes the Levenshtein distance.
[Reference]: https://en.wikipedia.org/wiki/Levenshtein_distance
[Article]: Levenshtein, Vladimir I. (February 1966). "Binary codes capable of correcting deletions,
insertions,and reversals". Soviet Physics Doklady 10... | [
"Computes",
"the",
"Levenshtein",
"distance",
"."
] | Lilykos/pyphonetics | python | https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/distance_metrics/levenshtein.py#L1-L29 | [
"def",
"levenshtein_distance",
"(",
"word1",
",",
"word2",
")",
":",
"if",
"len",
"(",
"word1",
")",
"<",
"len",
"(",
"word2",
")",
":",
"return",
"levenshtein_distance",
"(",
"word2",
",",
"word1",
")",
"if",
"len",
"(",
"word2",
")",
"==",
"0",
":"... | 7f55cccc1135e6015520a895eb6859318a4b6111 |
train | better_ts_function | Decorator which check if timeseries has a better
implementation of the function. | dynts/api/tsfunctions.py | def better_ts_function(f):
'''Decorator which check if timeseries has a better
implementation of the function.'''
fname = f.__name__
def _(ts, *args, **kwargs):
func = getattr(ts, fname, None)
if func:
return func(*args, **kwargs)
else:
return f(ts... | def better_ts_function(f):
'''Decorator which check if timeseries has a better
implementation of the function.'''
fname = f.__name__
def _(ts, *args, **kwargs):
func = getattr(ts, fname, None)
if func:
return func(*args, **kwargs)
else:
return f(ts... | [
"Decorator",
"which",
"check",
"if",
"timeseries",
"has",
"a",
"better",
"implementation",
"of",
"the",
"function",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L4-L18 | [
"def",
"better_ts_function",
"(",
"f",
")",
":",
"fname",
"=",
"f",
".",
"__name__",
"def",
"_",
"(",
"ts",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"func",
"=",
"getattr",
"(",
"ts",
",",
"fname",
",",
"None",
")",
"if",
"func",
":... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | zscore | Rolling Z-Score statistics.
The Z-score is more formally known as ``standardised residuals``.
To calculate the standardised residuals of a data set,
the average value and the standard deviation of the data value
have to be estimated.
.. math::
z = \frac{x - \mu(x)}{\sigma(x)} | dynts/api/tsfunctions.py | def zscore(ts, **kwargs):
'''Rolling Z-Score statistics.
The Z-score is more formally known as ``standardised residuals``.
To calculate the standardised residuals of a data set,
the average value and the standard deviation of the data value
have to be estimated.
.. math::
z = ... | def zscore(ts, **kwargs):
'''Rolling Z-Score statistics.
The Z-score is more formally known as ``standardised residuals``.
To calculate the standardised residuals of a data set,
the average value and the standard deviation of the data value
have to be estimated.
.. math::
z = ... | [
"Rolling",
"Z",
"-",
"Score",
"statistics",
".",
"The",
"Z",
"-",
"score",
"is",
"more",
"formally",
"known",
"as",
"standardised",
"residuals",
".",
"To",
"calculate",
"the",
"standardised",
"residuals",
"of",
"a",
"data",
"set",
"the",
"average",
"value",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L22-L39 | [
"def",
"zscore",
"(",
"ts",
",",
"*",
"*",
"kwargs",
")",
":",
"m",
"=",
"ts",
".",
"rollmean",
"(",
"*",
"*",
"kwargs",
")",
"s",
"=",
"ts",
".",
"rollstddev",
"(",
"*",
"*",
"kwargs",
")",
"result",
"=",
"(",
"ts",
"-",
"m",
")",
"/",
"s"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | prange | Rolling Percentage range.
Value between 0 and 1 indicating the position in the rolling range. | dynts/api/tsfunctions.py | def prange(ts, **kwargs):
'''Rolling Percentage range.
Value between 0 and 1 indicating the position in the rolling range.
'''
mi = ts.rollmin(**kwargs)
ma = ts.rollmax(**kwargs)
return (ts - mi)/(ma - mi) | def prange(ts, **kwargs):
'''Rolling Percentage range.
Value between 0 and 1 indicating the position in the rolling range.
'''
mi = ts.rollmin(**kwargs)
ma = ts.rollmax(**kwargs)
return (ts - mi)/(ma - mi) | [
"Rolling",
"Percentage",
"range",
".",
"Value",
"between",
"0",
"and",
"1",
"indicating",
"the",
"position",
"in",
"the",
"rolling",
"range",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L43-L50 | [
"def",
"prange",
"(",
"ts",
",",
"*",
"*",
"kwargs",
")",
":",
"mi",
"=",
"ts",
".",
"rollmin",
"(",
"*",
"*",
"kwargs",
")",
"ma",
"=",
"ts",
".",
"rollmax",
"(",
"*",
"*",
"kwargs",
")",
"return",
"(",
"ts",
"-",
"mi",
")",
"/",
"(",
"ma"... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | bindata | data must be numeric list with a len above 20
This function counts the number of data points in a reduced array | dynts/lib/fallback/maths.py | def bindata(data, maxbins = 30, reduction = 0.1):
'''
data must be numeric list with a len above 20
This function counts the number of data points in a reduced array
'''
tole = 0.01
N = len(data)
assert N > 20
vmin = min(data)
vmax = max(data)
DV = vmax - vmin
tol = tole*DV
vmax += t... | def bindata(data, maxbins = 30, reduction = 0.1):
'''
data must be numeric list with a len above 20
This function counts the number of data points in a reduced array
'''
tole = 0.01
N = len(data)
assert N > 20
vmin = min(data)
vmax = max(data)
DV = vmax - vmin
tol = tole*DV
vmax += t... | [
"data",
"must",
"be",
"numeric",
"list",
"with",
"a",
"len",
"above",
"20",
"This",
"function",
"counts",
"the",
"number",
"of",
"data",
"points",
"in",
"a",
"reduced",
"array"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/maths.py#L3-L33 | [
"def",
"bindata",
"(",
"data",
",",
"maxbins",
"=",
"30",
",",
"reduction",
"=",
"0.1",
")",
":",
"tole",
"=",
"0.01",
"N",
"=",
"len",
"(",
"data",
")",
"assert",
"N",
">",
"20",
"vmin",
"=",
"min",
"(",
"data",
")",
"vmax",
"=",
"max",
"(",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | binOp | Combines the values from two map objects using the indx values
using the op operator. In situations where there is a missing value
it will use the callable function handle_missing | dynts/api/operators.py | def binOp(op, indx, amap, bmap, fill_vec):
'''
Combines the values from two map objects using the indx values
using the op operator. In situations where there is a missing value
it will use the callable function handle_missing
'''
def op_or_missing(id):
va = amap.get(id, None)
... | def binOp(op, indx, amap, bmap, fill_vec):
'''
Combines the values from two map objects using the indx values
using the op operator. In situations where there is a missing value
it will use the callable function handle_missing
'''
def op_or_missing(id):
va = amap.get(id, None)
... | [
"Combines",
"the",
"values",
"from",
"two",
"map",
"objects",
"using",
"the",
"indx",
"values",
"using",
"the",
"op",
"operator",
".",
"In",
"situations",
"where",
"there",
"is",
"a",
"missing",
"value",
"it",
"will",
"use",
"the",
"callable",
"function",
... | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L22-L44 | [
"def",
"binOp",
"(",
"op",
",",
"indx",
",",
"amap",
",",
"bmap",
",",
"fill_vec",
")",
":",
"def",
"op_or_missing",
"(",
"id",
")",
":",
"va",
"=",
"amap",
".",
"get",
"(",
"id",
",",
"None",
")",
"vb",
"=",
"bmap",
".",
"get",
"(",
"id",
",... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | _toVec | takes a single value and creates a vecotor / matrix with that value filled
in it | dynts/api/operators.py | def _toVec(shape, val):
'''
takes a single value and creates a vecotor / matrix with that value filled
in it
'''
mat = np.empty(shape)
mat.fill(val)
return mat | def _toVec(shape, val):
'''
takes a single value and creates a vecotor / matrix with that value filled
in it
'''
mat = np.empty(shape)
mat.fill(val)
return mat | [
"takes",
"a",
"single",
"value",
"and",
"creates",
"a",
"vecotor",
"/",
"matrix",
"with",
"that",
"value",
"filled",
"in",
"it"
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L65-L72 | [
"def",
"_toVec",
"(",
"shape",
",",
"val",
")",
":",
"mat",
"=",
"np",
".",
"empty",
"(",
"shape",
")",
"mat",
".",
"fill",
"(",
"val",
")",
"return",
"mat"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | center_line | Add leading & trailing space to text to center it within an allowed
width
Parameters
----------
space : int
The maximum character width allowed for the text. If the length
of text is more than this value, no space will be added.\
line : str
The text that will be centered.
... | dashtable/dashutils/center_line.py | def center_line(space, line):
"""
Add leading & trailing space to text to center it within an allowed
width
Parameters
----------
space : int
The maximum character width allowed for the text. If the length
of text is more than this value, no space will be added.\
line : str
... | def center_line(space, line):
"""
Add leading & trailing space to text to center it within an allowed
width
Parameters
----------
space : int
The maximum character width allowed for the text. If the length
of text is more than this value, no space will be added.\
line : str
... | [
"Add",
"leading",
"&",
"trailing",
"space",
"to",
"text",
"to",
"center",
"it",
"within",
"an",
"allowed",
"width"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/center_line.py#L4-L32 | [
"def",
"center_line",
"(",
"space",
",",
"line",
")",
":",
"line",
"=",
"line",
".",
"strip",
"(",
")",
"left_length",
"=",
"math",
".",
"floor",
"(",
"(",
"space",
"-",
"len",
"(",
"line",
")",
")",
"/",
"2",
")",
"right_length",
"=",
"math",
".... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | FunctionRegistry.register | Register a function in the function registry.
The function will be automatically instantiated if not already an
instance. | dynts/dsl/functions/registry.py | def register(self, function):
"""Register a function in the function registry.
The function will be automatically instantiated if not already an
instance.
"""
function = inspect.isclass(function) and function() or function
name = function.name
self[name] = ... | def register(self, function):
"""Register a function in the function registry.
The function will be automatically instantiated if not already an
instance.
"""
function = inspect.isclass(function) and function() or function
name = function.name
self[name] = ... | [
"Register",
"a",
"function",
"in",
"the",
"function",
"registry",
".",
"The",
"function",
"will",
"be",
"automatically",
"instantiated",
"if",
"not",
"already",
"an",
"instance",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L6-L13 | [
"def",
"register",
"(",
"self",
",",
"function",
")",
":",
"function",
"=",
"inspect",
".",
"isclass",
"(",
"function",
")",
"and",
"function",
"(",
")",
"or",
"function",
"name",
"=",
"function",
".",
"name",
"self",
"[",
"name",
"]",
"=",
"function"
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | FunctionRegistry.unregister | Unregister function by name. | dynts/dsl/functions/registry.py | def unregister(self, name):
"""Unregister function by name.
"""
try:
name = name.name
except AttributeError:
pass
return self.pop(name,None) | def unregister(self, name):
"""Unregister function by name.
"""
try:
name = name.name
except AttributeError:
pass
return self.pop(name,None) | [
"Unregister",
"function",
"by",
"name",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L15-L22 | [
"def",
"unregister",
"(",
"self",
",",
"name",
")",
":",
"try",
":",
"name",
"=",
"name",
".",
"name",
"except",
"AttributeError",
":",
"pass",
"return",
"self",
".",
"pop",
"(",
"name",
",",
"None",
")"
] | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | row_includes_spans | Determine if there are spans within a row
Parameters
----------
table : list of lists of str
row : int
spans : list of lists of lists of int
Returns
-------
bool
Whether or not a table's row includes spans | dashtable/data2simplerst/row_includes_spans.py | def row_includes_spans(table, row, spans):
"""
Determine if there are spans within a row
Parameters
----------
table : list of lists of str
row : int
spans : list of lists of lists of int
Returns
-------
bool
Whether or not a table's row includes spans
"""
for c... | def row_includes_spans(table, row, spans):
"""
Determine if there are spans within a row
Parameters
----------
table : list of lists of str
row : int
spans : list of lists of lists of int
Returns
-------
bool
Whether or not a table's row includes spans
"""
for c... | [
"Determine",
"if",
"there",
"are",
"spans",
"within",
"a",
"row"
] | doakey3/DashTable | python | https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2simplerst/row_includes_spans.py#L1-L20 | [
"def",
"row_includes_spans",
"(",
"table",
",",
"row",
",",
"spans",
")",
":",
"for",
"column",
"in",
"range",
"(",
"len",
"(",
"table",
"[",
"row",
"]",
")",
")",
":",
"for",
"span",
"in",
"spans",
":",
"if",
"[",
"row",
",",
"column",
"]",
"in"... | 744cfb6a717fa75a8092c83ebcd49b2668023681 |
train | _setup_states | Create a StateList object from a 'states' Workflow attribute. | src/xworkflows/base.py | def _setup_states(state_definitions, prev=()):
"""Create a StateList object from a 'states' Workflow attribute."""
states = list(prev)
for state_def in state_definitions:
if len(state_def) != 2:
raise TypeError(
"The 'state' attribute of a workflow should be "
... | def _setup_states(state_definitions, prev=()):
"""Create a StateList object from a 'states' Workflow attribute."""
states = list(prev)
for state_def in state_definitions:
if len(state_def) != 2:
raise TypeError(
"The 'state' attribute of a workflow should be "
... | [
"Create",
"a",
"StateList",
"object",
"from",
"a",
"states",
"Workflow",
"attribute",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L165-L181 | [
"def",
"_setup_states",
"(",
"state_definitions",
",",
"prev",
"=",
"(",
")",
")",
":",
"states",
"=",
"list",
"(",
"prev",
")",
"for",
"state_def",
"in",
"state_definitions",
":",
"if",
"len",
"(",
"state_def",
")",
"!=",
"2",
":",
"raise",
"TypeError",... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | _setup_transitions | Create a TransitionList object from a 'transitions' Workflow attribute.
Args:
tdef: list of transition definitions
states (StateList): already parsed state definitions.
prev (TransitionList): transition definitions from a parent.
Returns:
TransitionList: the list of transitions... | src/xworkflows/base.py | def _setup_transitions(tdef, states, prev=()):
"""Create a TransitionList object from a 'transitions' Workflow attribute.
Args:
tdef: list of transition definitions
states (StateList): already parsed state definitions.
prev (TransitionList): transition definitions from a parent.
Re... | def _setup_transitions(tdef, states, prev=()):
"""Create a TransitionList object from a 'transitions' Workflow attribute.
Args:
tdef: list of transition definitions
states (StateList): already parsed state definitions.
prev (TransitionList): transition definitions from a parent.
Re... | [
"Create",
"a",
"TransitionList",
"object",
"from",
"a",
"transitions",
"Workflow",
"attribute",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L184-L215 | [
"def",
"_setup_transitions",
"(",
"tdef",
",",
"states",
",",
"prev",
"=",
"(",
")",
")",
":",
"trs",
"=",
"list",
"(",
"prev",
")",
"for",
"transition",
"in",
"tdef",
":",
"if",
"len",
"(",
"transition",
")",
"==",
"3",
":",
"(",
"name",
",",
"s... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | transition | Decorator to declare a function as a transition implementation. | src/xworkflows/base.py | def transition(trname='', field='', check=None, before=None, after=None):
"""Decorator to declare a function as a transition implementation."""
if is_callable(trname):
raise ValueError(
"The @transition decorator should be called as "
"@transition(['transition_name'], **kwargs)")... | def transition(trname='', field='', check=None, before=None, after=None):
"""Decorator to declare a function as a transition implementation."""
if is_callable(trname):
raise ValueError(
"The @transition decorator should be called as "
"@transition(['transition_name'], **kwargs)")... | [
"Decorator",
"to",
"declare",
"a",
"function",
"as",
"a",
"transition",
"implementation",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L516-L529 | [
"def",
"transition",
"(",
"trname",
"=",
"''",
",",
"field",
"=",
"''",
",",
"check",
"=",
"None",
",",
"before",
"=",
"None",
",",
"after",
"=",
"None",
")",
":",
"if",
"is_callable",
"(",
"trname",
")",
":",
"raise",
"ValueError",
"(",
"\"The @tran... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | _make_hook_dict | Ensure the given function has a xworkflows_hook attribute.
That attribute has the following structure:
>>> {
... 'before': [('state', <TransitionHook>), ...],
... } | src/xworkflows/base.py | def _make_hook_dict(fun):
"""Ensure the given function has a xworkflows_hook attribute.
That attribute has the following structure:
>>> {
... 'before': [('state', <TransitionHook>), ...],
... }
"""
if not hasattr(fun, 'xworkflows_hook'):
fun.xworkflows_hook = {
HOOK_... | def _make_hook_dict(fun):
"""Ensure the given function has a xworkflows_hook attribute.
That attribute has the following structure:
>>> {
... 'before': [('state', <TransitionHook>), ...],
... }
"""
if not hasattr(fun, 'xworkflows_hook'):
fun.xworkflows_hook = {
HOOK_... | [
"Ensure",
"the",
"given",
"function",
"has",
"a",
"xworkflows_hook",
"attribute",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L532-L548 | [
"def",
"_make_hook_dict",
"(",
"fun",
")",
":",
"if",
"not",
"hasattr",
"(",
"fun",
",",
"'xworkflows_hook'",
")",
":",
"fun",
".",
"xworkflows_hook",
"=",
"{",
"HOOK_BEFORE",
":",
"[",
"]",
",",
"HOOK_AFTER",
":",
"[",
"]",
",",
"HOOK_CHECK",
":",
"["... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | Hook._match_state | Checks whether a given State matches self.names. | src/xworkflows/base.py | def _match_state(self, state):
"""Checks whether a given State matches self.names."""
return (self.names == '*'
or state in self.names
or state.name in self.names) | def _match_state(self, state):
"""Checks whether a given State matches self.names."""
return (self.names == '*'
or state in self.names
or state.name in self.names) | [
"Checks",
"whether",
"a",
"given",
"State",
"matches",
"self",
".",
"names",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L256-L260 | [
"def",
"_match_state",
"(",
"self",
",",
"state",
")",
":",
"return",
"(",
"self",
".",
"names",
"==",
"'*'",
"or",
"state",
"in",
"self",
".",
"names",
"or",
"state",
".",
"name",
"in",
"self",
".",
"names",
")"
] | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | Hook._match_transition | Checks whether a given Transition matches self.names. | src/xworkflows/base.py | def _match_transition(self, transition):
"""Checks whether a given Transition matches self.names."""
return (self.names == '*'
or transition in self.names
or transition.name in self.names) | def _match_transition(self, transition):
"""Checks whether a given Transition matches self.names."""
return (self.names == '*'
or transition in self.names
or transition.name in self.names) | [
"Checks",
"whether",
"a",
"given",
"Transition",
"matches",
"self",
".",
"names",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L262-L266 | [
"def",
"_match_transition",
"(",
"self",
",",
"transition",
")",
":",
"return",
"(",
"self",
".",
"names",
"==",
"'*'",
"or",
"transition",
"in",
"self",
".",
"names",
"or",
"transition",
".",
"name",
"in",
"self",
".",
"names",
")"
] | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | Hook.applies_to | Whether this hook applies to the given transition/state.
Args:
transition (Transition): the transition to check
from_state (State or None): the state to check. If absent, the check
is 'might this hook apply to the related transition, given a
valid source ... | src/xworkflows/base.py | def applies_to(self, transition, from_state=None):
"""Whether this hook applies to the given transition/state.
Args:
transition (Transition): the transition to check
from_state (State or None): the state to check. If absent, the check
is 'might this hook apply to... | def applies_to(self, transition, from_state=None):
"""Whether this hook applies to the given transition/state.
Args:
transition (Transition): the transition to check
from_state (State or None): the state to check. If absent, the check
is 'might this hook apply to... | [
"Whether",
"this",
"hook",
"applies",
"to",
"the",
"given",
"transition",
"/",
"state",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L268-L288 | [
"def",
"applies_to",
"(",
"self",
",",
"transition",
",",
"from_state",
"=",
"None",
")",
":",
"if",
"'*'",
"in",
"self",
".",
"names",
":",
"return",
"True",
"elif",
"self",
".",
"kind",
"in",
"(",
"HOOK_BEFORE",
",",
"HOOK_AFTER",
",",
"HOOK_CHECK",
... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationWrapper._pre_transition_checks | Run the pre-transition checks. | src/xworkflows/base.py | def _pre_transition_checks(self):
"""Run the pre-transition checks."""
current_state = getattr(self.instance, self.field_name)
if current_state not in self.transition.source:
raise InvalidTransitionError(
"Transition '%s' isn't available from state '%s'." %
... | def _pre_transition_checks(self):
"""Run the pre-transition checks."""
current_state = getattr(self.instance, self.field_name)
if current_state not in self.transition.source:
raise InvalidTransitionError(
"Transition '%s' isn't available from state '%s'." %
... | [
"Run",
"the",
"pre",
"-",
"transition",
"checks",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L363-L375 | [
"def",
"_pre_transition_checks",
"(",
"self",
")",
":",
"current_state",
"=",
"getattr",
"(",
"self",
".",
"instance",
",",
"self",
".",
"field_name",
")",
"if",
"current_state",
"not",
"in",
"self",
".",
"transition",
".",
"source",
":",
"raise",
"InvalidTr... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationWrapper._filter_hooks | Filter a list of hooks, keeping only applicable ones. | src/xworkflows/base.py | def _filter_hooks(self, *hook_kinds):
"""Filter a list of hooks, keeping only applicable ones."""
hooks = sum((self.hooks.get(kind, []) for kind in hook_kinds), [])
return sorted(hook for hook in hooks
if hook.applies_to(self.transition, self.current_state)) | def _filter_hooks(self, *hook_kinds):
"""Filter a list of hooks, keeping only applicable ones."""
hooks = sum((self.hooks.get(kind, []) for kind in hook_kinds), [])
return sorted(hook for hook in hooks
if hook.applies_to(self.transition, self.current_state)) | [
"Filter",
"a",
"list",
"of",
"hooks",
"keeping",
"only",
"applicable",
"ones",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L377-L381 | [
"def",
"_filter_hooks",
"(",
"self",
",",
"*",
"hook_kinds",
")",
":",
"hooks",
"=",
"sum",
"(",
"(",
"self",
".",
"hooks",
".",
"get",
"(",
"kind",
",",
"[",
"]",
")",
"for",
"kind",
"in",
"hook_kinds",
")",
",",
"[",
"]",
")",
"return",
"sorted... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationWrapper._post_transition | Performs post-transition actions. | src/xworkflows/base.py | def _post_transition(self, result, *args, **kwargs):
"""Performs post-transition actions."""
for hook in self._filter_hooks(HOOK_AFTER, HOOK_ON_ENTER):
hook(self.instance, result, *args, **kwargs) | def _post_transition(self, result, *args, **kwargs):
"""Performs post-transition actions."""
for hook in self._filter_hooks(HOOK_AFTER, HOOK_ON_ENTER):
hook(self.instance, result, *args, **kwargs) | [
"Performs",
"post",
"-",
"transition",
"actions",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L395-L398 | [
"def",
"_post_transition",
"(",
"self",
",",
"result",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"for",
"hook",
"in",
"self",
".",
"_filter_hooks",
"(",
"HOOK_AFTER",
",",
"HOOK_ON_ENTER",
")",
":",
"hook",
"(",
"self",
".",
"instance",
",",... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.load_parent_implems | Import previously defined implementations.
Args:
parent_implems (ImplementationList): List of implementations defined
in a parent class. | src/xworkflows/base.py | def load_parent_implems(self, parent_implems):
"""Import previously defined implementations.
Args:
parent_implems (ImplementationList): List of implementations defined
in a parent class.
"""
for trname, attr, implem in parent_implems.get_custom_implementation... | def load_parent_implems(self, parent_implems):
"""Import previously defined implementations.
Args:
parent_implems (ImplementationList): List of implementations defined
in a parent class.
"""
for trname, attr, implem in parent_implems.get_custom_implementation... | [
"Import",
"previously",
"defined",
"implementations",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L664-L674 | [
"def",
"load_parent_implems",
"(",
"self",
",",
"parent_implems",
")",
":",
"for",
"trname",
",",
"attr",
",",
"implem",
"in",
"parent_implems",
".",
"get_custom_implementations",
"(",
")",
":",
"self",
".",
"implementations",
"[",
"trname",
"]",
"=",
"implem"... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.add_implem | Add an implementation.
Args:
transition (Transition): the transition for which the implementation
is added
attribute (str): the name of the attribute where the implementation
will be available
function (callable): the actual implementation fun... | src/xworkflows/base.py | def add_implem(self, transition, attribute, function, **kwargs):
"""Add an implementation.
Args:
transition (Transition): the transition for which the implementation
is added
attribute (str): the name of the attribute where the implementation
will... | def add_implem(self, transition, attribute, function, **kwargs):
"""Add an implementation.
Args:
transition (Transition): the transition for which the implementation
is added
attribute (str): the name of the attribute where the implementation
will... | [
"Add",
"an",
"implementation",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L676-L695 | [
"def",
"add_implem",
"(",
"self",
",",
"transition",
",",
"attribute",
",",
"function",
",",
"*",
"*",
"kwargs",
")",
":",
"implem",
"=",
"ImplementationProperty",
"(",
"field_name",
"=",
"self",
".",
"state_field",
",",
"transition",
"=",
"transition",
",",... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.should_collect | Decide whether a given value should be collected. | src/xworkflows/base.py | def should_collect(self, value):
"""Decide whether a given value should be collected."""
return (
# decorated with @transition
isinstance(value, TransitionWrapper)
# Relates to a compatible transition
and value.trname in self.workflow.transitions
... | def should_collect(self, value):
"""Decide whether a given value should be collected."""
return (
# decorated with @transition
isinstance(value, TransitionWrapper)
# Relates to a compatible transition
and value.trname in self.workflow.transitions
... | [
"Decide",
"whether",
"a",
"given",
"value",
"should",
"be",
"collected",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L697-L705 | [
"def",
"should_collect",
"(",
"self",
",",
"value",
")",
":",
"return",
"(",
"# decorated with @transition",
"isinstance",
"(",
"value",
",",
"TransitionWrapper",
")",
"# Relates to a compatible transition",
"and",
"value",
".",
"trname",
"in",
"self",
".",
"workflo... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.collect | Collect the implementations from a given attributes dict. | src/xworkflows/base.py | def collect(self, attrs):
"""Collect the implementations from a given attributes dict."""
for name, value in attrs.items():
if self.should_collect(value):
transition = self.workflow.transitions[value.trname]
if (
value.trname in self.... | def collect(self, attrs):
"""Collect the implementations from a given attributes dict."""
for name, value in attrs.items():
if self.should_collect(value):
transition = self.workflow.transitions[value.trname]
if (
value.trname in self.... | [
"Collect",
"the",
"implementations",
"from",
"a",
"given",
"attributes",
"dict",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L707-L732 | [
"def",
"collect",
"(",
"self",
",",
"attrs",
")",
":",
"for",
"name",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"self",
".",
"should_collect",
"(",
"value",
")",
":",
"transition",
"=",
"self",
".",
"workflow",
".",
"transitions... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.get_custom_implementations | Retrieve a list of cutom implementations.
Yields:
(str, str, ImplementationProperty) tuples: The name of the attribute
an implementation lives at, the name of the related transition,
and the related implementation. | src/xworkflows/base.py | def get_custom_implementations(self):
"""Retrieve a list of cutom implementations.
Yields:
(str, str, ImplementationProperty) tuples: The name of the attribute
an implementation lives at, the name of the related transition,
and the related implementation.
... | def get_custom_implementations(self):
"""Retrieve a list of cutom implementations.
Yields:
(str, str, ImplementationProperty) tuples: The name of the attribute
an implementation lives at, the name of the related transition,
and the related implementation.
... | [
"Retrieve",
"a",
"list",
"of",
"cutom",
"implementations",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L734-L745 | [
"def",
"get_custom_implementations",
"(",
"self",
")",
":",
"for",
"trname",
"in",
"self",
".",
"custom_implems",
":",
"attr",
"=",
"self",
".",
"transitions_at",
"[",
"trname",
"]",
"implem",
"=",
"self",
".",
"implementations",
"[",
"trname",
"]",
"yield",... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.register_function_hooks | Looks at an object method and registers it for relevent transitions. | src/xworkflows/base.py | def register_function_hooks(self, func):
"""Looks at an object method and registers it for relevent transitions."""
for hook_kind, hooks in func.xworkflows_hook.items():
for field_name, hook in hooks:
if field_name and field_name != self.state_field:
conti... | def register_function_hooks(self, func):
"""Looks at an object method and registers it for relevent transitions."""
for hook_kind, hooks in func.xworkflows_hook.items():
for field_name, hook in hooks:
if field_name and field_name != self.state_field:
conti... | [
"Looks",
"at",
"an",
"object",
"method",
"and",
"registers",
"it",
"for",
"relevent",
"transitions",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L757-L766 | [
"def",
"register_function_hooks",
"(",
"self",
",",
"func",
")",
":",
"for",
"hook_kind",
",",
"hooks",
"in",
"func",
".",
"xworkflows_hook",
".",
"items",
"(",
")",
":",
"for",
"field_name",
",",
"hook",
"in",
"hooks",
":",
"if",
"field_name",
"and",
"f... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList._may_override | Checks whether an ImplementationProperty may override an attribute. | src/xworkflows/base.py | def _may_override(self, implem, other):
"""Checks whether an ImplementationProperty may override an attribute."""
if isinstance(other, ImplementationProperty):
# Overriding another custom implementation for the same transition
# and field
return (other.transition == i... | def _may_override(self, implem, other):
"""Checks whether an ImplementationProperty may override an attribute."""
if isinstance(other, ImplementationProperty):
# Overriding another custom implementation for the same transition
# and field
return (other.transition == i... | [
"Checks",
"whether",
"an",
"ImplementationProperty",
"may",
"override",
"an",
"attribute",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L768-L783 | [
"def",
"_may_override",
"(",
"self",
",",
"implem",
",",
"other",
")",
":",
"if",
"isinstance",
"(",
"other",
",",
"ImplementationProperty",
")",
":",
"# Overriding another custom implementation for the same transition",
"# and field",
"return",
"(",
"other",
".",
"tr... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.fill_attrs | Update the 'attrs' dict with generated ImplementationProperty. | src/xworkflows/base.py | def fill_attrs(self, attrs):
"""Update the 'attrs' dict with generated ImplementationProperty."""
for trname, attrname in self.transitions_at.items():
implem = self.implementations[trname]
if attrname in attrs:
conflicting = attrs[attrname]
if no... | def fill_attrs(self, attrs):
"""Update the 'attrs' dict with generated ImplementationProperty."""
for trname, attrname in self.transitions_at.items():
implem = self.implementations[trname]
if attrname in attrs:
conflicting = attrs[attrname]
if no... | [
"Update",
"the",
"attrs",
"dict",
"with",
"generated",
"ImplementationProperty",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L785-L799 | [
"def",
"fill_attrs",
"(",
"self",
",",
"attrs",
")",
":",
"for",
"trname",
",",
"attrname",
"in",
"self",
".",
"transitions_at",
".",
"items",
"(",
")",
":",
"implem",
"=",
"self",
".",
"implementations",
"[",
"trname",
"]",
"if",
"attrname",
"in",
"at... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | ImplementationList.transform | Perform all actions on a given attribute dict. | src/xworkflows/base.py | def transform(self, attrs):
"""Perform all actions on a given attribute dict."""
self.collect(attrs)
self.add_missing_implementations()
self.fill_attrs(attrs) | def transform(self, attrs):
"""Perform all actions on a given attribute dict."""
self.collect(attrs)
self.add_missing_implementations()
self.fill_attrs(attrs) | [
"Perform",
"all",
"actions",
"on",
"a",
"given",
"attribute",
"dict",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L801-L805 | [
"def",
"transform",
"(",
"self",
",",
"attrs",
")",
":",
"self",
".",
"collect",
"(",
"attrs",
")",
"self",
".",
"add_missing_implementations",
"(",
")",
"self",
".",
"fill_attrs",
"(",
"attrs",
")"
] | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | BaseWorkflow.log_transition | Log a transition.
Args:
transition (Transition): the name of the performed transition
from_state (State): the source state
instance (object): the modified object
Kwargs:
Any passed when calling the transition | src/xworkflows/base.py | def log_transition(self, transition, from_state, instance, *args, **kwargs):
"""Log a transition.
Args:
transition (Transition): the name of the performed transition
from_state (State): the source state
instance (object): the modified object
Kwargs:
... | def log_transition(self, transition, from_state, instance, *args, **kwargs):
"""Log a transition.
Args:
transition (Transition): the name of the performed transition
from_state (State): the source state
instance (object): the modified object
Kwargs:
... | [
"Log",
"a",
"transition",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L850-L869 | [
"def",
"log_transition",
"(",
"self",
",",
"transition",
",",
"from_state",
",",
"instance",
",",
"*",
"args",
",",
"*",
"*",
"kwargs",
")",
":",
"logger",
"=",
"logging",
".",
"getLogger",
"(",
"'xworkflows.transitions'",
")",
"try",
":",
"instance_repr",
... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | WorkflowEnabledMeta._add_workflow | Attach a workflow to the attribute list (create a StateProperty). | src/xworkflows/base.py | def _add_workflow(mcs, field_name, state_field, attrs):
"""Attach a workflow to the attribute list (create a StateProperty)."""
attrs[field_name] = StateProperty(state_field.workflow, field_name) | def _add_workflow(mcs, field_name, state_field, attrs):
"""Attach a workflow to the attribute list (create a StateProperty)."""
attrs[field_name] = StateProperty(state_field.workflow, field_name) | [
"Attach",
"a",
"workflow",
"to",
"the",
"attribute",
"list",
"(",
"create",
"a",
"StateProperty",
")",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L988-L990 | [
"def",
"_add_workflow",
"(",
"mcs",
",",
"field_name",
",",
"state_field",
",",
"attrs",
")",
":",
"attrs",
"[",
"field_name",
"]",
"=",
"StateProperty",
"(",
"state_field",
".",
"workflow",
",",
"field_name",
")"
] | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | WorkflowEnabledMeta._find_workflows | Finds all occurrences of a workflow in the attributes definitions.
Returns:
dict(str => StateField): maps an attribute name to a StateField
describing the related Workflow. | src/xworkflows/base.py | def _find_workflows(mcs, attrs):
"""Finds all occurrences of a workflow in the attributes definitions.
Returns:
dict(str => StateField): maps an attribute name to a StateField
describing the related Workflow.
"""
workflows = {}
for attribute, value in... | def _find_workflows(mcs, attrs):
"""Finds all occurrences of a workflow in the attributes definitions.
Returns:
dict(str => StateField): maps an attribute name to a StateField
describing the related Workflow.
"""
workflows = {}
for attribute, value in... | [
"Finds",
"all",
"occurrences",
"of",
"a",
"workflow",
"in",
"the",
"attributes",
"definitions",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L993-L1004 | [
"def",
"_find_workflows",
"(",
"mcs",
",",
"attrs",
")",
":",
"workflows",
"=",
"{",
"}",
"for",
"attribute",
",",
"value",
"in",
"attrs",
".",
"items",
"(",
")",
":",
"if",
"isinstance",
"(",
"value",
",",
"Workflow",
")",
":",
"workflows",
"[",
"at... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | WorkflowEnabledMeta._add_transitions | Collect and enhance transition definitions to a workflow.
Modifies the 'attrs' dict in-place.
Args:
field_name (str): name of the field transitions should update
workflow (Workflow): workflow we're working on
attrs (dict): dictionary of attributes to be updated.
... | src/xworkflows/base.py | def _add_transitions(mcs, field_name, workflow, attrs, implems=None):
"""Collect and enhance transition definitions to a workflow.
Modifies the 'attrs' dict in-place.
Args:
field_name (str): name of the field transitions should update
workflow (Workflow): workflow we're... | def _add_transitions(mcs, field_name, workflow, attrs, implems=None):
"""Collect and enhance transition definitions to a workflow.
Modifies the 'attrs' dict in-place.
Args:
field_name (str): name of the field transitions should update
workflow (Workflow): workflow we're... | [
"Collect",
"and",
"enhance",
"transition",
"definitions",
"to",
"a",
"workflow",
"."
] | rbarrois/xworkflows | python | https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L1007-L1027 | [
"def",
"_add_transitions",
"(",
"mcs",
",",
"field_name",
",",
"workflow",
",",
"attrs",
",",
"implems",
"=",
"None",
")",
":",
"new_implems",
"=",
"ImplementationList",
"(",
"field_name",
",",
"workflow",
")",
"if",
"implems",
":",
"new_implems",
".",
"load... | 4a94b04ba83cb43f61d4b0f7db6964a667c86b5b |
train | Coords.update | Updates cartesian coordinates for drawing tree graph | toytree/Coords.py | def update(self):
"Updates cartesian coordinates for drawing tree graph"
# get new shape and clear for attrs
self.edges = np.zeros((self.ttree.nnodes - 1, 2), dtype=int)
self.verts = np.zeros((self.ttree.nnodes, 2), dtype=float)
self.lines = []
self.coords =... | def update(self):
"Updates cartesian coordinates for drawing tree graph"
# get new shape and clear for attrs
self.edges = np.zeros((self.ttree.nnodes - 1, 2), dtype=int)
self.verts = np.zeros((self.ttree.nnodes, 2), dtype=float)
self.lines = []
self.coords =... | [
"Updates",
"cartesian",
"coordinates",
"for",
"drawing",
"tree",
"graph"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L40-L53 | [
"def",
"update",
"(",
"self",
")",
":",
"# get new shape and clear for attrs",
"self",
".",
"edges",
"=",
"np",
".",
"zeros",
"(",
"(",
"self",
".",
"ttree",
".",
"nnodes",
"-",
"1",
",",
"2",
")",
",",
"dtype",
"=",
"int",
")",
"self",
".",
"verts",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Coords.update_idxs | set root idx highest, tip idxs lowest ordered as ladderized | toytree/Coords.py | def update_idxs(self):
"set root idx highest, tip idxs lowest ordered as ladderized"
# internal nodes: root is highest idx
idx = self.ttree.nnodes - 1
for node in self.ttree.treenode.traverse("levelorder"):
if not node.is_leaf():
node.add_feature("idx", idx)
... | def update_idxs(self):
"set root idx highest, tip idxs lowest ordered as ladderized"
# internal nodes: root is highest idx
idx = self.ttree.nnodes - 1
for node in self.ttree.treenode.traverse("levelorder"):
if not node.is_leaf():
node.add_feature("idx", idx)
... | [
"set",
"root",
"idx",
"highest",
"tip",
"idxs",
"lowest",
"ordered",
"as",
"ladderized"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L56-L72 | [
"def",
"update_idxs",
"(",
"self",
")",
":",
"# internal nodes: root is highest idx",
"idx",
"=",
"self",
".",
"ttree",
".",
"nnodes",
"-",
"1",
"for",
"node",
"in",
"self",
".",
"ttree",
".",
"treenode",
".",
"traverse",
"(",
"\"levelorder\"",
")",
":",
"... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Coords.update_fixed_order | after pruning fixed order needs update to match new nnodes/ntips. | toytree/Coords.py | def update_fixed_order(self):
"after pruning fixed order needs update to match new nnodes/ntips."
# set tips order if fixing for multi-tree plotting (default None)
fixed_order = self.ttree._fixed_order
self.ttree_fixed_order = None
self.ttree_fixed_idx = list(range(self.ttree.nti... | def update_fixed_order(self):
"after pruning fixed order needs update to match new nnodes/ntips."
# set tips order if fixing for multi-tree plotting (default None)
fixed_order = self.ttree._fixed_order
self.ttree_fixed_order = None
self.ttree_fixed_idx = list(range(self.ttree.nti... | [
"after",
"pruning",
"fixed",
"order",
"needs",
"update",
"to",
"match",
"new",
"nnodes",
"/",
"ntips",
"."
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L75-L88 | [
"def",
"update_fixed_order",
"(",
"self",
")",
":",
"# set tips order if fixing for multi-tree plotting (default None)",
"fixed_order",
"=",
"self",
".",
"ttree",
".",
"_fixed_order",
"self",
".",
"ttree_fixed_order",
"=",
"None",
"self",
".",
"ttree_fixed_idx",
"=",
"l... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Coords.assign_vertices | Sets .edges, .verts for node positions.
X and Y positions here refer to base assumption that tree is right
facing, reorient_coordinates() will handle re-translating this. | toytree/Coords.py | def assign_vertices(self):
"""
Sets .edges, .verts for node positions.
X and Y positions here refer to base assumption that tree is right
facing, reorient_coordinates() will handle re-translating this.
"""
# shortname
uselen = bool(self.ttree.style.use_e... | def assign_vertices(self):
"""
Sets .edges, .verts for node positions.
X and Y positions here refer to base assumption that tree is right
facing, reorient_coordinates() will handle re-translating this.
"""
# shortname
uselen = bool(self.ttree.style.use_e... | [
"Sets",
".",
"edges",
".",
"verts",
"for",
"node",
"positions",
".",
"X",
"and",
"Y",
"positions",
"here",
"refer",
"to",
"base",
"assumption",
"that",
"tree",
"is",
"right",
"facing",
"reorient_coordinates",
"()",
"will",
"handle",
"re",
"-",
"translating",... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L91-L150 | [
"def",
"assign_vertices",
"(",
"self",
")",
":",
"# shortname ",
"uselen",
"=",
"bool",
"(",
"self",
".",
"ttree",
".",
"style",
".",
"use_edge_lengths",
")",
"# postorder: children then parents (nidxs from 0 up)",
"# store edge array for connecting child nodes to parent node... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Coords.reorient_coordinates | Returns a modified .verts array with new coordinates for nodes.
This does not need to modify .edges. The order of nodes, and therefore
of verts rows is still the same because it is still based on the tree
branching order (ladderized usually). | toytree/Coords.py | def reorient_coordinates(self):
"""
Returns a modified .verts array with new coordinates for nodes.
This does not need to modify .edges. The order of nodes, and therefore
of verts rows is still the same because it is still based on the tree
branching order (ladderized usually). ... | def reorient_coordinates(self):
"""
Returns a modified .verts array with new coordinates for nodes.
This does not need to modify .edges. The order of nodes, and therefore
of verts rows is still the same because it is still based on the tree
branching order (ladderized usually). ... | [
"Returns",
"a",
"modified",
".",
"verts",
"array",
"with",
"new",
"coordinates",
"for",
"nodes",
".",
"This",
"does",
"not",
"need",
"to",
"modify",
".",
"edges",
".",
"The",
"order",
"of",
"nodes",
"and",
"therefore",
"of",
"verts",
"rows",
"is",
"still... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L252-L287 | [
"def",
"reorient_coordinates",
"(",
"self",
")",
":",
"# if tree is empty then bail out",
"if",
"len",
"(",
"self",
".",
"ttree",
")",
"<",
"2",
":",
"return",
"# down is the default orientation",
"# down-facing tips align at y=0, first ladderized tip at x=0",
"if",
"self",... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | tsiterator | An iterator of timeseries as tuples. | dynts/formatters/base.py | def tsiterator(ts, dateconverter=None, desc=None,
clean=False, start_value=None, **kwargs):
'''An iterator of timeseries as tuples.'''
dateconverter = dateconverter or default_converter
yield ['Date'] + ts.names()
if clean == 'full':
for dt, value in full_clean(ts, dateconverter, ... | def tsiterator(ts, dateconverter=None, desc=None,
clean=False, start_value=None, **kwargs):
'''An iterator of timeseries as tuples.'''
dateconverter = dateconverter or default_converter
yield ['Date'] + ts.names()
if clean == 'full':
for dt, value in full_clean(ts, dateconverter, ... | [
"An",
"iterator",
"of",
"timeseries",
"as",
"tuples",
"."
] | quantmind/dynts | python | https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/formatters/base.py#L23-L36 | [
"def",
"tsiterator",
"(",
"ts",
",",
"dateconverter",
"=",
"None",
",",
"desc",
"=",
"None",
",",
"clean",
"=",
"False",
",",
"start_value",
"=",
"None",
",",
"*",
"*",
"kwargs",
")",
":",
"dateconverter",
"=",
"dateconverter",
"or",
"default_converter",
... | 21ac57c648bfec402fa6b1fe569496cf098fb5e8 |
train | Drawing.set_baselines | Modify coords to shift tree position for x,y baseline arguments. This
is useful for arrangeing trees onto a Canvas with other plots, but
still sharing a common cartesian axes coordinates. | toytree/Drawing.py | def set_baselines(self):
"""
Modify coords to shift tree position for x,y baseline arguments. This
is useful for arrangeing trees onto a Canvas with other plots, but
still sharing a common cartesian axes coordinates.
"""
if self.style.xbaseline:
if self.styl... | def set_baselines(self):
"""
Modify coords to shift tree position for x,y baseline arguments. This
is useful for arrangeing trees onto a Canvas with other plots, but
still sharing a common cartesian axes coordinates.
"""
if self.style.xbaseline:
if self.styl... | [
"Modify",
"coords",
"to",
"shift",
"tree",
"position",
"for",
"x",
"y",
"baseline",
"arguments",
".",
"This",
"is",
"useful",
"for",
"arrangeing",
"trees",
"onto",
"a",
"Canvas",
"with",
"other",
"plots",
"but",
"still",
"sharing",
"a",
"common",
"cartesian"... | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L73-L85 | [
"def",
"set_baselines",
"(",
"self",
")",
":",
"if",
"self",
".",
"style",
".",
"xbaseline",
":",
"if",
"self",
".",
"style",
".",
"orient",
"in",
"(",
"\"up\"",
",",
"\"down\"",
")",
":",
"self",
".",
"coords",
".",
"coords",
"[",
":",
",",
"0",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.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/Drawing.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
xpos = self.ttree.get_tip_coordinates('x')
... | 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
xpos = self.ttree.get_tip_coordinates('x')
... | [
"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/Drawing.py#L90-L132 | [
"def",
"add_tip_labels_to_axes",
"(",
"self",
")",
":",
"# get tip-coords and replace if using fixed_order",
"xpos",
"=",
"self",
".",
"ttree",
".",
"get_tip_coordinates",
"(",
"'x'",
")",
"ypos",
"=",
"self",
".",
"ttree",
".",
"get_tip_coordinates",
"(",
"'y'",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.add_tip_lines_to_axes | add lines to connect tips to zero axis for tip_labels_align=True | toytree/Drawing.py | def add_tip_lines_to_axes(self):
"add lines to connect tips to zero axis for tip_labels_align=True"
# get tip-coords and align-coords from verts
xpos, ypos, aedges, averts = self.get_tip_label_coords()
if self.style.tip_labels_align:
self.axes.graph(
aedges,... | def add_tip_lines_to_axes(self):
"add lines to connect tips to zero axis for tip_labels_align=True"
# get tip-coords and align-coords from verts
xpos, ypos, aedges, averts = self.get_tip_label_coords()
if self.style.tip_labels_align:
self.axes.graph(
aedges,... | [
"add",
"lines",
"to",
"connect",
"tips",
"to",
"zero",
"axis",
"for",
"tip_labels_align",
"=",
"True"
] | eaton-lab/toytree | python | https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L135-L147 | [
"def",
"add_tip_lines_to_axes",
"(",
"self",
")",
":",
"# get tip-coords and align-coords from verts",
"xpos",
",",
"ypos",
",",
"aedges",
",",
"averts",
"=",
"self",
".",
"get_tip_label_coords",
"(",
")",
"if",
"self",
".",
"style",
".",
"tip_labels_align",
":",
... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
train | Drawing.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/Drawing.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/Drawing.py#L150-L176 | [
"def",
"fit_tip_labels",
"(",
"self",
")",
":",
"# user entered values",
"#if self.style.axes.x_domain_max or self.style.axes.y_domain_min:",
"# self.axes.x.domain.max = self.style.axes.x_domain_max",
"# self.axes.y.domain.min = self.style.axes.y_domain_min ",
"# IF USE WANTS TO... | 0347ed2098acc5f707fadf52a0ecd411a6d1859c |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.