repo
stringlengths
7
55
path
stringlengths
4
223
func_name
stringlengths
1
134
original_string
stringlengths
75
104k
language
stringclasses
1 value
code
stringlengths
75
104k
code_tokens
listlengths
19
28.4k
docstring
stringlengths
1
46.9k
docstring_tokens
listlengths
1
1.97k
sha
stringlengths
40
40
url
stringlengths
87
315
partition
stringclasses
1 value
doakey3/DashTable
dashtable/html2data/restructify/add_links.py
add_links
def add_links(converted_text, html): """ Add the links to the bottom of the text """ soup = BeautifulSoup(html, 'html.parser') link_exceptions = [ 'footnote-reference', 'fn-backref', 'citation-reference' ] footnotes = {} citations = {} backrefs = {} lin...
python
def add_links(converted_text, html): """ Add the links to the bottom of the text """ soup = BeautifulSoup(html, 'html.parser') link_exceptions = [ 'footnote-reference', 'fn-backref', 'citation-reference' ] footnotes = {} citations = {} backrefs = {} lin...
[ "def", "add_links", "(", "converted_text", ",", "html", ")", ":", "soup", "=", "BeautifulSoup", "(", "html", ",", "'html.parser'", ")", "link_exceptions", "=", "[", "'footnote-reference'", ",", "'fn-backref'", ",", "'citation-reference'", "]", "footnotes", "=", ...
Add the links to the bottom of the text
[ "Add", "the", "links", "to", "the", "bottom", "of", "the", "text" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/restructify/add_links.py#L5-L65
train
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.load
def load(self, providers, symbols, start, end, logger, backend, **kwargs): '''Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword lo...
python
def load(self, providers, symbols, start, end, logger, backend, **kwargs): '''Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword lo...
[ "def", "load", "(", "self", ",", "providers", ",", "symbols", ",", "start", ",", "end", ",", "logger", ",", "backend", ",", "*", "*", "kwargs", ")", ":", "# Preconditioning on dates\r", "logger", "=", "logger", "or", "logging", ".", "getLogger", "(", "se...
Load symbols data. :keyword providers: Dictionary of registered data providers. :keyword symbols: list of symbols to load. :keyword start: start date. :keyword end: end date. :keyword logger: instance of :class:`logging.Logger` or ``None``. :keyword backend: :clas...
[ "Load", "symbols", "data", ".", ":", "keyword", "providers", ":", "Dictionary", "of", "registered", "data", "providers", ".", ":", "keyword", "symbols", ":", "list", "of", "symbols", "to", "load", ".", ":", "keyword", "start", ":", "start", "date", ".", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L90-L133
train
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.dates
def dates(self, start, end): '''Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *star...
python
def dates(self, start, end): '''Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *star...
[ "def", "dates", "(", "self", ",", "start", ",", "end", ")", ":", "td", "=", "date", ".", "today", "(", ")", "end", "=", "safetodate", "(", "end", ")", "or", "td", "end", "=", "end", "if", "end", "<=", "td", "else", "td", "start", "=", "safetoda...
Internal function which perform pre-conditioning on dates: :keyword start: start date. :keyword end: end date. This function makes sure the *start* and *end* date are consistent. It *never fails* and always return a two-element tuple containing *start*, *end* with *start* less or equal *end* and *end* never a...
[ "Internal", "function", "which", "perform", "pre", "-", "conditioning", "on", "dates", ":", ":", "keyword", "start", ":", "start", "date", ".", ":", "keyword", "end", ":", "end", "date", ".", "This", "function", "makes", "sure", "the", "*", "start", "*",...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L135-L153
train
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.parse_symbol
def parse_symbol(self, symbol, providers): '''Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data....
python
def parse_symbol(self, symbol, providers): '''Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data....
[ "def", "parse_symbol", "(", "self", ",", "symbol", ",", "providers", ")", ":", "separator", "=", "settings", ".", "field_separator", "symbol", "=", "str", "(", "symbol", ")", "bits", "=", "symbol", ".", "split", "(", "separator", ")", "pnames", "=", "pro...
Parse a symbol to obtain information regarding ticker, field and provider. Must return an instance of :attr:`symboldata`. :keyword symbol: string associated with market data to load. :keyword providers: dictionary of :class:`dynts.data.DataProvider` instances av...
[ "Parse", "a", "symbol", "to", "obtain", "information", "regarding", "ticker", "field", "and", "provider", ".", "Must", "return", "an", "instance", "of", ":", "attr", ":", "symboldata", ".", ":", "keyword", "symbol", ":", "string", "associated", "with", "mark...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L155-L210
train
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.symbol_for_ticker
def symbol_for_ticker(self, ticker, field, provider, providers): '''Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.''' provider = provider or settings.default_provider if provider: pro...
python
def symbol_for_ticker(self, ticker, field, provider, providers): '''Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.''' provider = provider or settings.default_provider if provider: pro...
[ "def", "symbol_for_ticker", "(", "self", ",", "ticker", ",", "field", ",", "provider", ",", "providers", ")", ":", "provider", "=", "provider", "or", "settings", ".", "default_provider", "if", "provider", ":", "provider", "=", "providers", ".", "get", "(", ...
Return an instance of *symboldata* containing information about the data provider, the data provider ticker name and the data provider field.
[ "Return", "an", "instance", "of", "*", "symboldata", "*", "containing", "information", "about", "the", "data", "provider", "the", "data", "provider", "ticker", "name", "and", "the", "data", "provider", "field", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L212-L219
train
quantmind/dynts
dynts/data/__init__.py
TimeSerieLoader.preprocess
def preprocess(self, ticker, start, end, logger, backend, **kwargs): '''Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(in...
python
def preprocess(self, ticker, start, end, logger, backend, **kwargs): '''Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(in...
[ "def", "preprocess", "(", "self", ",", "ticker", ",", "start", ",", "end", ",", "logger", ",", "backend", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "preprocessdata", "(", "intervals", "=", "(", "(", "start", ",", "end", ")", ",", ")...
Preprocess **hook**. This is first loading hook and it is **called before requesting data** from a dataprovider. It must return an instance of :attr:`TimeSerieLoader.preprocessdata`. By default it returns:: self.preprocessdata(intervals = ((start,end),)) It could be overritten to modify the intervals. If ...
[ "Preprocess", "**", "hook", "**", ".", "This", "is", "first", "loading", "hook", "and", "it", "is", "**", "called", "before", "requesting", "data", "**", "from", "a", "dataprovider", ".", "It", "must", "return", "an", "instance", "of", ":", "attr", ":", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L230-L244
train
quantmind/dynts
dynts/data/__init__.py
DataProviders.register
def register(self, provider): '''Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.''' if isinstance(provider,type): provider = provider() self[provider.code] = provider
python
def register(self, provider): '''Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.''' if isinstance(provider,type): provider = provider() self[provider.code] = provider
[ "def", "register", "(", "self", ",", "provider", ")", ":", "if", "isinstance", "(", "provider", ",", "type", ")", ":", "provider", "=", "provider", "(", ")", "self", "[", "provider", ".", "code", "]", "=", "provider" ]
Register a new data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.
[ "Register", "a", "new", "data", "provider", ".", "*", "provider", "*", "must", "be", "an", "instance", "of", "DataProvider", ".", "If", "provider", "name", "is", "already", "available", "it", "will", "be", "replaced", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L274-L279
train
quantmind/dynts
dynts/data/__init__.py
DataProviders.unregister
def unregister(self, provider): '''Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced. ''' if isinstance(provider, type): provider = provider() if isinstance...
python
def unregister(self, provider): '''Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced. ''' if isinstance(provider, type): provider = provider() if isinstance...
[ "def", "unregister", "(", "self", ",", "provider", ")", ":", "if", "isinstance", "(", "provider", ",", "type", ")", ":", "provider", "=", "provider", "(", ")", "if", "isinstance", "(", "provider", ",", "DataProvider", ")", ":", "provider", "=", "provider...
Unregister an existing data provider. *provider* must be an instance of DataProvider. If provider name is already available, it will be replaced.
[ "Unregister", "an", "existing", "data", "provider", ".", "*", "provider", "*", "must", "be", "an", "instance", "of", "DataProvider", ".", "If", "provider", "name", "is", "already", "available", "it", "will", "be", "replaced", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/data/__init__.py#L281-L291
train
quantmind/dynts
dynts/dsl/__init__.py
parse
def parse(timeseries_expression, method=None, functions=None, debug=False): '''Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is...
python
def parse(timeseries_expression, method=None, functions=None, debug=False): '''Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is...
[ "def", "parse", "(", "timeseries_expression", ",", "method", "=", "None", ",", "functions", "=", "None", ",", "debug", "=", "False", ")", ":", "if", "not", "parsefunc", ":", "raise", "ExpressionError", "(", "'Could not parse. No parser installed.'", ")", "functi...
Function for parsing :ref:`timeseries expressions <dsl-script>`. If succesful, it returns an instance of :class:`dynts.dsl.Expr` which can be used to to populate timeseries or scatters once data is available. Parsing is implemented using the ply_ module, an implementation of lex and yacc parsing t...
[ "Function", "for", "parsing", ":", "ref", ":", "timeseries", "expressions", "<dsl", "-", "script", ">", ".", "If", "succesful", "it", "returns", "an", "instance", "of", ":", "class", ":", "dynts", ".", "dsl", ".", "Expr", "which", "can", "be", "used", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/__init__.py#L18-L43
train
quantmind/dynts
dynts/dsl/__init__.py
evaluate
def evaluate(expression, start=None, end=None, loader=None, logger=None, backend=None, **kwargs): '''Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of ...
python
def evaluate(expression, start=None, end=None, loader=None, logger=None, backend=None, **kwargs): '''Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of ...
[ "def", "evaluate", "(", "expression", ",", "start", "=", "None", ",", "end", "=", "None", ",", "loader", "=", "None", ",", "logger", "=", "None", ",", "backend", "=", "None", ",", "*", "*", "kwargs", ")", ":", "if", "isinstance", "(", "expression", ...
Evaluate a timeseries ``expression`` into an instance of :class:`dynts.dsl.dslresult` which can be used to obtain timeseries and/or scatters. This is probably the most used function of the library. :parameter expression: A timeseries expression string or an instance of :class:`dynts.dsl.E...
[ "Evaluate", "a", "timeseries", "expression", "into", "an", "instance", "of", ":", "class", ":", "dynts", ".", "dsl", ".", "dslresult", "which", "can", "be", "used", "to", "obtain", "timeseries", "and", "/", "or", "scatters", ".", "This", "is", "probably", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/__init__.py#L46-L90
train
doakey3/DashTable
dashtable/grid2data/grid2data.py
grid2data
def grid2data(text): """ Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] p...
python
def grid2data(text): """ Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst table Returns ------- table : list of lists of str spans : list of lists of lists of int A span is a list of [row, column] p...
[ "def", "grid2data", "(", "text", ")", ":", "try", ":", "import", "docutils", ".", "statemachine", "import", "docutils", ".", "parsers", ".", "rst", ".", "tableparser", "except", "ImportError", ":", "print", "(", "\"ERROR: You must install the docutils library to use...
Convert Grid table to data (the kind used by Dashtable) Parameters ---------- text : str The text must be a valid rst 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 a group of ...
[ "Convert", "Grid", "table", "to", "data", "(", "the", "kind", "used", "by", "Dashtable", ")" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/grid2data/grid2data.py#L6-L108
train
eaton-lab/toytree
toytree/Multitree.py
MultiTree.get_consensus_tree
def get_consensus_tree(self, cutoff=0.0, best_tree=None): """ Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with suppor...
python
def get_consensus_tree(self, cutoff=0.0, best_tree=None): """ Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with suppor...
[ "def", "get_consensus_tree", "(", "self", ",", "cutoff", "=", "0.0", ",", "best_tree", "=", "None", ")", ":", "if", "best_tree", ":", "raise", "NotImplementedError", "(", "\"best_tree option not yet supported.\"", ")", "cons", "=", "ConsensusTree", "(", "self", ...
Returns an extended majority rule consensus tree as a Toytree object. Node labels include 'support' values showing the occurrence of clades in the consensus tree across trees in the input treelist. Clades with support below 'cutoff' are collapsed into polytomies. If you enter an option...
[ "Returns", "an", "extended", "majority", "rule", "consensus", "tree", "as", "a", "Toytree", "object", ".", "Node", "labels", "include", "support", "values", "showing", "the", "occurrence", "of", "clades", "in", "the", "consensus", "tree", "across", "trees", "i...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L172-L196
train
eaton-lab/toytree
toytree/Multitree.py
MultiTree.draw_tree_grid
def draw_tree_grid(self, nrows=None, ncols=None, start=0, fixed_order=False, shared_axis=False, **kwargs): """ Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): N...
python
def draw_tree_grid(self, nrows=None, ncols=None, start=0, fixed_order=False, shared_axis=False, **kwargs): """ Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): N...
[ "def", "draw_tree_grid", "(", "self", ",", "nrows", "=", "None", ",", "ncols", "=", "None", ",", "start", "=", "0", ",", "fixed_order", "=", "False", ",", "shared_axis", "=", "False", ",", "*", "*", "kwargs", ")", ":", "# return nothing if tree is empty", ...
Draw a slice of x*y trees into a x,y grid non-overlapping. Parameters: ----------- x (int): Number of grid cells in x dimension. Default=automatically set. y (int): Number of grid cells in y dimension. Default=automatically set. start (int): ...
[ "Draw", "a", "slice", "of", "x", "*", "y", "trees", "into", "a", "x", "y", "grid", "non", "-", "overlapping", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L201-L280
train
eaton-lab/toytree
toytree/Multitree.py
MultiTree.draw_cloud_tree
def draw_cloud_tree(self, axes=None, html=False, fixed_order=True, **kwargs): """ Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen ...
python
def draw_cloud_tree(self, axes=None, html=False, fixed_order=True, **kwargs): """ Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen ...
[ "def", "draw_cloud_tree", "(", "self", ",", "axes", "=", "None", ",", "html", "=", "False", ",", "fixed_order", "=", "True", ",", "*", "*", "kwargs", ")", ":", "# return nothing if tree is empty", "if", "not", "self", ".", "treelist", ":", "print", "(", ...
Draw a series of trees overlapping each other in coordinate space. The order of tip_labels is fixed in cloud trees so that trees with discordant relationships can be seen in conflict. To change the tip order use the 'fixed_order' argument in toytree.mtree() when creating the MultiTree o...
[ "Draw", "a", "series", "of", "trees", "overlapping", "each", "other", "in", "coordinate", "space", ".", "The", "order", "of", "tip_labels", "is", "fixed", "in", "cloud", "trees", "so", "that", "trees", "with", "discordant", "relationships", "can", "be", "see...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L283-L363
train
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.hash_trees
def hash_trees(self): "hash ladderized tree topologies" observed = {} for idx, tree in enumerate(self.treelist): nwk = tree.write(tree_format=9) hashed = md5(nwk.encode("utf-8")).hexdigest() if hashed not in observed: observed[hashed] = ...
python
def hash_trees(self): "hash ladderized tree topologies" observed = {} for idx, tree in enumerate(self.treelist): nwk = tree.write(tree_format=9) hashed = md5(nwk.encode("utf-8")).hexdigest() if hashed not in observed: observed[hashed] = ...
[ "def", "hash_trees", "(", "self", ")", ":", "observed", "=", "{", "}", "for", "idx", ",", "tree", "in", "enumerate", "(", "self", ".", "treelist", ")", ":", "nwk", "=", "tree", ".", "write", "(", "tree_format", "=", "9", ")", "hashed", "=", "md5", ...
hash ladderized tree topologies
[ "hash", "ladderized", "tree", "topologies" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L407-L418
train
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.find_clades
def find_clades(self): "Count clade occurrences." # index names from the first tree ndict = {j: i for i, j in enumerate(self.names)} namedict = {i: j for i, j in enumerate(self.names)} # store counts clade_counts = {} for tidx, ncopies in self.treedict.items(): ...
python
def find_clades(self): "Count clade occurrences." # index names from the first tree ndict = {j: i for i, j in enumerate(self.names)} namedict = {i: j for i, j in enumerate(self.names)} # store counts clade_counts = {} for tidx, ncopies in self.treedict.items(): ...
[ "def", "find_clades", "(", "self", ")", ":", "# index names from the first tree", "ndict", "=", "{", "j", ":", "i", "for", "i", ",", "j", "in", "enumerate", "(", "self", ".", "names", ")", "}", "namedict", "=", "{", "i", ":", "j", "for", "i", ",", ...
Count clade occurrences.
[ "Count", "clade", "occurrences", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L421-L462
train
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.filter_clades
def filter_clades(self): "Remove conflicting clades and those < cutoff to get majority rule" passed = [] carrs = np.array([list(i[0]) for i in self.clade_counts], dtype=int) freqs = np.array([i[1] for i in self.clade_counts]) for idx in range(carrs.shape[0]): conflic...
python
def filter_clades(self): "Remove conflicting clades and those < cutoff to get majority rule" passed = [] carrs = np.array([list(i[0]) for i in self.clade_counts], dtype=int) freqs = np.array([i[1] for i in self.clade_counts]) for idx in range(carrs.shape[0]): conflic...
[ "def", "filter_clades", "(", "self", ")", ":", "passed", "=", "[", "]", "carrs", "=", "np", ".", "array", "(", "[", "list", "(", "i", "[", "0", "]", ")", "for", "i", "in", "self", ".", "clade_counts", "]", ",", "dtype", "=", "int", ")", "freqs"...
Remove conflicting clades and those < cutoff to get majority rule
[ "Remove", "conflicting", "clades", "and", "those", "<", "cutoff", "to", "get", "majority", "rule" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L465-L492
train
eaton-lab/toytree
toytree/Multitree.py
ConsensusTree.build_trees
def build_trees(self): "Build an unrooted consensus tree from filtered clade counts." # storage nodes = {} idxarr = np.arange(len(self.fclade_counts[0][0])) queue = [] ## create dict of clade counts and set keys countdict = defaultdict(int) for clade, co...
python
def build_trees(self): "Build an unrooted consensus tree from filtered clade counts." # storage nodes = {} idxarr = np.arange(len(self.fclade_counts[0][0])) queue = [] ## create dict of clade counts and set keys countdict = defaultdict(int) for clade, co...
[ "def", "build_trees", "(", "self", ")", ":", "# storage", "nodes", "=", "{", "}", "idxarr", "=", "np", ".", "arange", "(", "len", "(", "self", ".", "fclade_counts", "[", "0", "]", "[", "0", "]", ")", ")", "queue", "=", "[", "]", "## create dict of ...
Build an unrooted consensus tree from filtered clade counts.
[ "Build", "an", "unrooted", "consensus", "tree", "from", "filtered", "clade", "counts", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Multitree.py#L495-L557
train
Lilykos/pyphonetics
pyphonetics/phonetics/phonetic_algorithm.py
PhoneticAlgorithm.sounds_like
def sounds_like(self, word1, word2): """Compare the phonetic representations of 2 words, and return a boolean value.""" return self.phonetics(word1) == self.phonetics(word2)
python
def sounds_like(self, word1, word2): """Compare the phonetic representations of 2 words, and return a boolean value.""" return self.phonetics(word1) == self.phonetics(word2)
[ "def", "sounds_like", "(", "self", ",", "word1", ",", "word2", ")", ":", "return", "self", ".", "phonetics", "(", "word1", ")", "==", "self", ".", "phonetics", "(", "word2", ")" ]
Compare the phonetic representations of 2 words, and return a boolean value.
[ "Compare", "the", "phonetic", "representations", "of", "2", "words", "and", "return", "a", "boolean", "value", "." ]
7f55cccc1135e6015520a895eb6859318a4b6111
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/phonetics/phonetic_algorithm.py#L20-L22
train
Lilykos/pyphonetics
pyphonetics/phonetics/phonetic_algorithm.py
PhoneticAlgorithm.distance
def distance(self, word1, word2, metric='levenshtein'): """Get the similarity of the words, using the supported distance metrics.""" if metric in self.distances: distance_func = self.distances[metric] return distance_func(self.phonetics(word1), self.phonetics(word2)) else...
python
def distance(self, word1, word2, metric='levenshtein'): """Get the similarity of the words, using the supported distance metrics.""" if metric in self.distances: distance_func = self.distances[metric] return distance_func(self.phonetics(word1), self.phonetics(word2)) else...
[ "def", "distance", "(", "self", ",", "word1", ",", "word2", ",", "metric", "=", "'levenshtein'", ")", ":", "if", "metric", "in", "self", ".", "distances", ":", "distance_func", "=", "self", ".", "distances", "[", "metric", "]", "return", "distance_func", ...
Get the similarity of the words, using the supported distance metrics.
[ "Get", "the", "similarity", "of", "the", "words", "using", "the", "supported", "distance", "metrics", "." ]
7f55cccc1135e6015520a895eb6859318a4b6111
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/phonetics/phonetic_algorithm.py#L24-L30
train
doakey3/DashTable
dashtable/data2rst/get_output_row_heights.py
get_output_row_heights
def get_output_row_heights(table, spans): """ Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table """ heigh...
python
def get_output_row_heights(table, spans): """ Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table """ heigh...
[ "def", "get_output_row_heights", "(", "table", ",", "spans", ")", ":", "heights", "=", "[", "]", "for", "row", "in", "table", ":", "heights", ".", "append", "(", "-", "1", ")", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", ...
Get the heights of the rows of the output table. Parameters ---------- table : list of lists of str spans : list of lists of int Returns ------- heights : list of int The heights of each row in the output table
[ "Get", "the", "heights", "of", "the", "rows", "of", "the", "output", "table", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/get_output_row_heights.py#L5-L53
train
quantmind/dynts
dynts/lib/fallback/operators.py
smedian
def smedian(olist,nobs): '''Generalised media for odd and even number of samples''' if nobs: rem = nobs % 2 midpoint = nobs // 2 me = olist[midpoint] if not rem: me = 0.5 * (me + olist[midpoint-1]) return me else: return NaN
python
def smedian(olist,nobs): '''Generalised media for odd and even number of samples''' if nobs: rem = nobs % 2 midpoint = nobs // 2 me = olist[midpoint] if not rem: me = 0.5 * (me + olist[midpoint-1]) return me else: return NaN
[ "def", "smedian", "(", "olist", ",", "nobs", ")", ":", "if", "nobs", ":", "rem", "=", "nobs", "%", "2", "midpoint", "=", "nobs", "//", "2", "me", "=", "olist", "[", "midpoint", "]", "if", "not", "rem", ":", "me", "=", "0.5", "*", "(", "me", "...
Generalised media for odd and even number of samples
[ "Generalised", "media", "for", "odd", "and", "even", "number", "of", "samples" ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L41-L51
train
quantmind/dynts
dynts/lib/fallback/operators.py
roll_mean
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
python
def roll_mean(input, window): '''Apply a rolling mean function to an array. This is a simple rolling aggregation.''' nobs, i, j, sum_x = 0,0,0,0. N = len(input) if window > N: raise ValueError('Out of bound') output = np.ndarray(N-window+1,dtype=input.dtype) for val in inpu...
[ "def", "roll_mean", "(", "input", ",", "window", ")", ":", "nobs", ",", "i", ",", "j", ",", "sum_x", "=", "0", ",", "0", ",", "0", ",", "0.", "N", "=", "len", "(", "input", ")", "if", "window", ">", "N", ":", "raise", "ValueError", "(", "'Out...
Apply a rolling mean function to an array. This is a simple rolling aggregation.
[ "Apply", "a", "rolling", "mean", "function", "to", "an", "array", ".", "This", "is", "a", "simple", "rolling", "aggregation", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L76-L107
train
quantmind/dynts
dynts/lib/fallback/operators.py
roll_sd
def roll_sd(input, window, scale = 1.0, ddof = 0): '''Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.''' nobs, i, j, sx, sxx = 0,0,0,0.,0. N = len(input) sqrt = np.sqrt if window > N: raise ValueError('Out of bound') ...
python
def roll_sd(input, window, scale = 1.0, ddof = 0): '''Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.''' nobs, i, j, sx, sxx = 0,0,0,0.,0. N = len(input) sqrt = np.sqrt if window > N: raise ValueError('Out of bound') ...
[ "def", "roll_sd", "(", "input", ",", "window", ",", "scale", "=", "1.0", ",", "ddof", "=", "0", ")", ":", "nobs", ",", "i", ",", "j", ",", "sx", ",", "sxx", "=", "0", ",", "0", ",", "0", ",", "0.", ",", "0.", "N", "=", "len", "(", "input"...
Apply a rolling standard deviation function to an array. This is a simple rolling aggregation of squared sums.
[ "Apply", "a", "rolling", "standard", "deviation", "function", "to", "an", "array", ".", "This", "is", "a", "simple", "rolling", "aggregation", "of", "squared", "sums", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/operators.py#L110-L148
train
doakey3/DashTable
dashtable/dashutils/check_span.py
check_span
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 ...
python
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", ")", ":", "if", "not", "type", "(", "span", ")", "is", "list", ":", "return", "\"Spans must be a list of lists\"", "for", "pair", "in", "span", ":", "if", "not", "type", "(", "pair", ")", "is", "list", ":...
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...
[ "Ensure", "the", "span", "is", "valid", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/check_span.py#L7-L81
train
doakey3/DashTable
dashtable/data2rst/merge_all_cells.py
merge_all_cells
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...
python
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", ")", ":", "current", "=", "0", "while", "len", "(", "cells", ")", ">", "1", ":", "count", "=", "0", "while", "count", "<", "len", "(", "cells", ")", ":", "cell1", "=", "cells", "[", "current", "]", "cell2", ...
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
[ "Loop", "through", "list", "of", "cells", "and", "piece", "them", "together", "one", "by", "one" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/merge_all_cells.py#L5-L44
train
eaton-lab/toytree
toytree/utils.py
bpp2newick
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...
python
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", ")", ":", "regex1", "=", "re", ".", "compile", "(", "r\" #[-+]?[0-9]*\\.?[0-9]*[:]\"", ")", "regex2", "=", "re", ".", "compile", "(", "r\" #[-+]?[0-9]*\\.?[0-9]*[;]\"", ")", "regex3", "=", "re", ".", "compile", "(", "r\":...
converts bpp newick format to normal newick
[ "converts", "bpp", "newick", "format", "to", "normal", "newick" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L396-L404
train
eaton-lab/toytree
toytree/utils.py
return_small_clade
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
python
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", ")", ":", "node", "=", "treenode", "while", "1", ":", "if", "node", ".", "children", ":", "c1", ",", "c2", "=", "node", ".", "children", "node", "=", "sorted", "(", "[", "c1", ",", "c2", "]", ",", "key"...
used to produce balanced trees, returns a tip node from the smaller clade
[ "used", "to", "produce", "balanced", "trees", "returns", "a", "tip", "node", "from", "the", "smaller", "clade" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L408-L416
train
eaton-lab/toytree
toytree/utils.py
fuzzy_match_tipnames
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...
python
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", ")", ":", "# require arguments", "if", "not", "any", "(", "[", "names", ",", "wildcard", ",", "regex", "]", ")...
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 ...
[ "Used", "in", "multiple", "internal", "functions", "(", "e", ".", "g", ".", ".", "root", "()", ")", "and", ".", "drop_tips", "()", ")", "to", "select", "an", "internal", "mrca", "node", "or", "multiple", "tipnames", "using", "fuzzy", "matching", "so", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L424-L497
train
eaton-lab/toytree
toytree/utils.py
TreeMod.node_scale_root_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 ...
python
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", ")", ":", "# make tree height = 1 * treeheight", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "_height", "=", "ctree", ".", "treenode", ".", "height", "for", "node", "i...
Returns a toytree copy with all nodes scaled so that the root height equals the value entered for treeheight.
[ "Returns", "a", "toytree", "copy", "with", "all", "nodes", "scaled", "so", "that", "the", "root", "height", "equals", "the", "value", "entered", "for", "treeheight", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L30-L41
train
eaton-lab/toytree
toytree/utils.py
TreeMod.node_slider
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...
python
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", ")", ":", "# 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", ...
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...
[ "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...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L44-L77
train
eaton-lab/toytree
toytree/utils.py
TreeMod.node_multiplier
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...
python
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", ")", ":", "random", ".", "seed", "(", "seed", ")", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "low", ",", "high", "=", "sorted", "(", ...
Returns a toytree copy with all nodes multiplied by a constant sampled uniformly between (multiplier, 1/multiplier).
[ "Returns", "a", "toytree", "copy", "with", "all", "nodes", "multiplied", "by", "a", "constant", "sampled", "uniformly", "between", "(", "multiplier", "1", "/", "multiplier", ")", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L80-L92
train
eaton-lab/toytree
toytree/utils.py
TreeMod.make_ultrametric
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...
python
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", ")", ":", "ctree", "=", "self", ".", "_ttree", ".", "copy", "(", ")", "if", "strategy", "==", "1", ":", "for", "node", "in", "ctree", ".", "treenode", ".", "traverse", "(", ")", ":"...
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 ...
[ "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", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L95-L115
train
eaton-lab/toytree
toytree/utils.py
RandomTree.coaltree
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. ...
python
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", ")", ":", "# seed generator", "random", ".", "seed", "(", "seed", ")", "# convert units", "coalunits", "=", "False", "if", "not", "ne", ":", "coalunits", "=", "True", "n...
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...
[ "Returns", "a", "coalescent", "tree", "with", "ntips", "samples", "and", "waiting", "times", "between", "coalescent", "events", "drawn", "from", "the", "kingman", "coalescent", ":", "(", "4N", ")", "/", "(", "k", "*", "(", "k", "-", "1", "))", "where", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L218-L275
train
eaton-lab/toytree
toytree/utils.py
RandomTree.unittree
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): ...
python
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", ")", ":", "# seed generator", "random", ".", "seed", "(", "seed", ")", "# generate tree with N tips.", "tmptree", "=", "TreeNode", "(", ")", "tmptree", ".", "populate",...
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...
[ "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"...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L279-L320
train
eaton-lab/toytree
toytree/utils.py
RandomTree.imbtree
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...
python
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", ")", ":", "rtree", "=", "toytree", ".", "tree", "(", ")", "rtree", ".", "treenode", ".", "add_child", "(", "name", "=", "\"0\"", ")", "rtree", ".", "treenode", ".", "add_child", "(", "nam...
Return an imbalanced (comb-like) tree topology.
[ "Return", "an", "imbalanced", "(", "comb", "-", "like", ")", "tree", "topology", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L324-L347
train
eaton-lab/toytree
toytree/utils.py
RandomTree.baltree
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...
python
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", ")", ":", "# require even number of tips", "if", "ntips", "%", "2", ":", "raise", "ToytreeError", "(", "\"balanced trees must have even number of tips.\"", ")", "# make first cherry", "rtree", "=", "toytre...
Returns a balanced tree topology.
[ "Returns", "a", "balanced", "tree", "topology", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/utils.py#L351-L389
train
doakey3/DashTable
dashtable/dashutils/get_span_char_height.py
get_span_char_height
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 ...
python
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", ")", ":", "start_row", "=", "span", "[", "0", "]", "[", "0", "]", "row_count", "=", "get_span_row_count", "(", "span", ")", "total_height", "=", "0", "for", "i", "in", "range", "(", "start_r...
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...
[ "Get", "the", "height", "of", "a", "span", "in", "the", "number", "of", "newlines", "it", "fills", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_char_height.py#L4-L28
train
doakey3/DashTable
dashtable/html2data/html2data.py
html2data
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,...
python
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", ")", ":", "spans", "=", "extract_spans", "(", "html_string", ")", "column_count", "=", "get_html_column_count", "(", "html_string", ")", "row_count", "=", "get_html_row_count", "(", "spans", ")", "count", "=", "0", "while"...
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 ...
[ "Convert", "an", "html", "table", "to", "a", "data", "table", "and", "spans", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/html2data.py#L7-L40
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.newick
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...
python
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", ")", ":", "# checks one of root's children for features and extra feats.", "if", "self", ".", "treenode", ".", "children", ":", "features", "=", "{", "\"name\"", ",", "\"dist\"", ",", "\"support\"", ",", ...
Returns newick represenation of the tree in its current state.
[ "Returns", "newick", "represenation", "of", "the", "tree", "in", "its", "current", "state", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L132-L140
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_edge_values
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...
python
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'", ")", ":", "elist", "=", "[", "]", "for", "cidx", "in", "self", ".", "_coords", ".", "edges", "[", ":", ",", "1", "]", ":", "node", "=", "self", ".", "treenode", ".", "search_nodes...
Returns edge values in the order they are plotted (see .get_edges())
[ "Returns", "edge", "values", "in", "the", "order", "they", "are", "plotted", "(", "see", ".", "get_edges", "()", ")" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L173-L183
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_edge_values_from_dict
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 ...
python
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", ")", ":", "# map node idxs to the order in which edges are plotted", "idxs", "=", "{", "j", ":", "i", "for", "(", "i", ",", "j", ")", "in", ...
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...
[ "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...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L186-L242
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_mrca_idx_from_tip_labels
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...
python
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", ")", ":", "if", "not", "any", "(", "[", "names", ",", "wildcard", ",", "regex", "]", ")", ":", "raise", "ToytreeErro...
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.
[ "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"...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L245-L255
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_node_values
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 ...
python
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", ",", ")", ":", "# access nodes in the order they will be plotted", "ndict", "=", "self", ".", "get_node_dict", "(", "return_internal...
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...
[ "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" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L268-L313
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_node_dict
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...
python
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", ")", ":", "if", "return_internal", ":", "if", "return_nodes", ":", "return", "{", "i", ".", "idx", ":", "i", "for", "i", "in", "self", ".", "t...
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...
[ "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", "()", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L316-L344
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_tip_coordinates
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...
python
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", ")", ":", "# get coordinates array", "coords", "=", "self", ".", "get_node_coordinates", "(", ")", "if", "axis", "==", "'x'", ":", "return", "coords", "[", ":", "self", ".", "ntips", ",",...
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.
[ "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...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L347-L360
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.get_tip_labels
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...
python
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", ")", ":", "if", "not", "idx", ":", "return", "self", ".", "treenode", ".", "get_leaf_names", "(", ")", "[", ":", ":", "-", "1", "]", "else", ":", "treenode", "=", "self", ".", "treenode...
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,...
[ "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...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L363-L386
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.is_bifurcating
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)) ...
python
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", ")", ":", "ctn1", "=", "-", "1", "+", "(", "2", "*", "len", "(", "self", ")", ")", "ctn2", "=", "-", "2", "+", "(", "2", "*", "len", "(", "self", ")", ")", "if", "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.
[ "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", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L403-L415
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.ladderize
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...
python
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", ")", ":", "nself", "=", "deepcopy", "(", "self", ")", "nself", ".", "treenode", ".", "ladderize", "(", "direction", "=", "direction", ")", "nself", ".", "_fixed_order", "=", "None", "nself", ...
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.
[ "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...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L420-L430
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.collapse_nodes
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) """...
python
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", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "for", "node", "in", "nself", ".", "treenode", ".", "traverse", "(", ")", ":", "if", "not", "no...
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", ".", ":" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L433-L447
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.drop_tips
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...
python
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", ")", ":", "# make a deepcopy of the tree", "nself", "=", "self", ".", "copy", "(", ")", "# return if nothing to drop", "if", "not", "any", ...
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...
[ "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", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L451-L489
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.rotate_node
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... ...
python
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,", ")", ":", "# make a copy", "revd", "=", "{", "j", ":", "i", "for", "(", "i", ...
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", "..." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L493-L542
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.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( ...
python
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", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "nself", ".", "treenode", ".", "resolve_polytomy", "(", "default_dist", "...
Returns a copy of the tree with all polytomies randomly resolved. Does not transform tree in-place.
[ "Returns", "a", "copy", "of", "the", "tree", "with", "all", "polytomies", "randomly", "resolved", ".", "Does", "not", "transform", "tree", "in", "-", "place", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L545-L560
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.unroot
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
python
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", ")", ":", "nself", "=", "self", ".", "copy", "(", ")", "nself", ".", "treenode", ".", "unroot", "(", ")", "nself", ".", "treenode", ".", "ladderize", "(", ")", "nself", ".", "_coords", ".", "update", "(", ")", "return"...
Returns a copy of the tree unrooted. Does not transform tree in-place.
[ "Returns", "a", "copy", "of", "the", "tree", "unrooted", ".", "Does", "not", "transform", "tree", "in", "-", "place", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L563-L571
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.root
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....
python
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", ")", ":", "# make a deepcopy of the tree", "nself", "=", "self", ".", "copy", "(", ")", "# get treenode of the common ancestor of selected tips", "try...
(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...
[ "(", "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"...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L574-L659
train
eaton-lab/toytree
toytree/Toytree.py
ToyTree.draw
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, ...
python
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_...
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)...
[ "Plot", "a", "Toytree", "tree", "returns", "a", "tuple", "of", "Toyplot", "(", "Canvas", "Axes", ")", "objects", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Toytree.py#L664-L823
train
doakey3/DashTable
dashtable/data2rst/cell/get_merge_direction.py
get_merge_direction
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" ...
python
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", ")", ":", "cell1_left", "=", "cell1", ".", "column", "cell1_right", "=", "cell1", ".", "column", "+", "cell1", ".", "column_count", "cell1_top", "=", "cell1", ".", "row", "cell1_bottom", "=", "cell1",...
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", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_merge_direction.py#L1-L74
train
eaton-lab/toytree
toytree/TreeParser.py
parse_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:", "") ...
python
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", ")", ":", "# store features", "ndict", "=", "{", "}", "# parse NHX or MB features", "if", "\"[&&NHX:\"", "in", "NHX_string", ":", "NHX_string", "=", "NHX_string", ".", "replace", "(", "\"[&&NHX:\"", ",", "\"\"", ")", "NHX_s...
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], ...
[ "NHX", "format", ":", "[", "&&NHX", ":", "prop1", "=", "value1", ":", "prop2", "=", "value2", "]", "MB", "format", ":", "((", "a", "[", "&Z", "=", "1", "Y", "=", "2", "]", "b", "[", "&Z", "=", "1", "Y", "=", "2", "]", ")", ":", "1", ".", ...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L586-L605
train
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.get_data_from_intree
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...
python
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 string: filename or data stream", "if", "isinstance", "(", "self", ".", "intree", ",", "(", "str", ",", "bytes", ")", ")", ":", "# strip it", "self", ".", "intree", "=", "self", ".", "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...
[ "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"...
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L196-L228
train
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.parse_nexus
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
python
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", ")", ":", "if", "self", ".", "data", "[", "0", "]", ".", "strip", "(", ")", ".", "upper", "(", ")", "==", "\"#NEXUS\"", ":", "nex", "=", "NexusParser", "(", "self", ".", "data", ")", "self", ".", "data", "=", ...
get newick data from NEXUS
[ "get", "newick", "data", "from", "NEXUS" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L231-L236
train
eaton-lab/toytree
toytree/TreeParser.py
TreeParser.get_treenodes
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_...
python
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", ")", ":", "if", "not", "self", ".", "multitree", ":", "# get TreeNodes from Newick", "extractor", "=", "Newick2TreeNode", "(", "self", ".", "data", "[", "0", "]", ".", "strip", "(", ")", ",", "fmt", "=", "self", ".", ...
test format of intree nex/nwk, extra features
[ "test", "format", "of", "intree", "nex", "/", "nwk", "extra", "features" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L239-L255
train
eaton-lab/toytree
toytree/TreeParser.py
Newick2TreeNode.newick_from_string
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...
python
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", ")", ":", "# split on parentheses to traverse hierarchical tree structure", "for", "chunk", "in", "self", ".", "data", ".", "split", "(", "\"(\"", ")", "[", "1", ":", "]", ":", "# add child to make this node a parent.", "self"...
Reads a newick string in the New Hampshire format.
[ "Reads", "a", "newick", "string", "in", "the", "New", "Hampshire", "format", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L319-L352
train
eaton-lab/toytree
toytree/TreeParser.py
NexusParser.extract_tree_block
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(...
python
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", ")", ":", "lines", "=", "iter", "(", "self", ".", "data", ")", "while", "1", ":", "try", ":", "line", "=", "next", "(", "lines", ")", ".", "strip", "(", ")", "except", "StopIteration", ":", "break", "# enter ...
iterate through data file to extract trees
[ "iterate", "through", "data", "file", "to", "extract", "trees" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/TreeParser.py#L422-L454
train
eaton-lab/toytree
versioner.py
parse_command_line
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...
python
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", "(", ")", ":", "## create the parser", "parser", "=", "argparse", ".", "ArgumentParser", "(", "formatter_class", "=", "argparse", ".", "RawDescriptionHelpFormatter", ",", "epilog", "=", "\"\"\"\n * Example command-line usage: \n\n ## push test b...
Parse CLI args.
[ "Parse", "CLI", "args", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L293-L354
train
eaton-lab/toytree
versioner.py
Version.get_git_status
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...
python
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", ")", ":", "## 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", ...
Gets git and init versions and commits since the init version
[ "Gets", "git", "and", "init", "versions", "and", "commits", "since", "the", "init", "version" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L39-L67
train
eaton-lab/toytree
versioner.py
Version.push_git_package
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() ...
python
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", ")", ":", "## 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
[ "if", "no", "conflicts", "then", "write", "new", "tag", "to" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L72-L92
train
eaton-lab/toytree
versioner.py
Version._pull_branch_from_origin
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]) ...
python
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", ")", ":", "try", ":", "## self.repo.git.pull()", "subprocess", ".", "check_call", "(", "[", "\"git\"", ",", "\"pull\"", ",", "\"origin\"", ",", "self", ".", "branch", "]", ")", "except", "Exception", "as", "inst"...
Pulls from origin/master, if you have unmerged conflicts it will raise an exception. You will need to resolve these.
[ "Pulls", "from", "origin", "/", "master", "if", "you", "have", "unmerged", "conflicts", "it", "will", "raise", "an", "exception", ".", "You", "will", "need", "to", "resolve", "these", "." ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L105-L117
train
eaton-lab/toytree
versioner.py
Version._get_init_release_tag
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)
python
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", ")", ":", "self", ".", "init_version", "=", "re", ".", "search", "(", "r\"^__version__ = ['\\\"]([^'\\\"]*)['\\\"]\"", ",", "open", "(", "self", ".", "init_file", ",", "\"r\"", ")", ".", "read", "(", ")", ",", "re...
parses init.py to get previous version
[ "parses", "init", ".", "py", "to", "get", "previous", "version" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L121-L127
train
eaton-lab/toytree
versioner.py
Version._get_log_commits
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...
python
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", ")", ":", "## check if update is necessary", "cmd", "=", "\"git log --pretty=oneline {}..\"", ".", "format", "(", "self", ".", "init_version", ")", "cmdlist", "=", "shlex", ".", "split", "(", "cmd", ")", "commits", "=", "s...
calls git log to complile a change list
[ "calls", "git", "log", "to", "complile", "a", "change", "list" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L131-L141
train
eaton-lab/toytree
versioner.py
Version._write_commits_to_release_notes
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: ...
python
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", ")", ":", "with", "open", "(", "self", ".", "release_file", ",", "'a'", ")", "as", "out", ":", "out", ".", "write", "(", "\"==========\\n{}\\n\"", ".", "format", "(", "self", ".", "tag", ")", ")", "f...
writes commits to the releasenotes file by appending to the end
[ "writes", "commits", "to", "the", "releasenotes", "file", "by", "appending", "to", "the", "end" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L145-L157
train
eaton-lab/toytree
versioner.py
Version._write_new_tag_to_init
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...
python
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", ")", ":", "for", "line", "in", "fileinput", ".", "input", "(", "self", ".", "init_file", ",", "inplace", "=", "1", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"__version__\"", ...
Write version to __init__.py by editing in place
[ "Write", "version", "to", "__init__", ".", "py", "by", "editing", "in", "place" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L161-L168
train
eaton-lab/toytree
versioner.py
Version._write_branch_and_tag_to_meta_yaml
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(...
python
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", ")", ":", "## set the branch to pull source from", "with", "open", "(", "self", ".", "meta_yaml", ".", "replace", "(", "\"meta\"", ",", "\"template\"", ")", ",", "'r'", ")", "as", "infile", ":", "dat", "=...
Write branch and tag to meta.yaml by editing in place
[ "Write", "branch", "and", "tag", "to", "meta", ".", "yaml", "by", "editing", "in", "place" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L172-L182
train
eaton-lab/toytree
versioner.py
Version._revert_tag_in_init
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...
python
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", ")", ":", "for", "line", "in", "fileinput", ".", "input", "(", "self", ".", "init_file", ",", "inplace", "=", "1", ")", ":", "if", "line", ".", "strip", "(", ")", ".", "startswith", "(", "\"__version__\"", ")"...
Write version to __init__.py by editing in place
[ "Write", "version", "to", "__init__", ".", "py", "by", "editing", "in", "place" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L199-L209
train
eaton-lab/toytree
versioner.py
Version._push_new_tag_to_git
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...
python
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", ")", ":", "print", "(", "\"Pushing new version to git\"", ")", "## stage the releasefile and initfileb", "subprocess", ".", "call", "(", "[", "\"git\"", ",", "\"add\"", ",", "self", ".", "release_file", "]", ")", "subproce...
tags a new release and pushes to origin/master
[ "tags", "a", "new", "release", "and", "pushes", "to", "origin", "/", "master" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L216-L238
train
eaton-lab/toytree
versioner.py
Version.build_conda_packages
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" ...
python
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", ")", ":", "## 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", ".", ...
Run the Linux build and use converter to build OSX
[ "Run", "the", "Linux", "build", "and", "use", "converter", "to", "build", "OSX" ]
0347ed2098acc5f707fadf52a0ecd411a6d1859c
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/versioner.py#L247-L285
train
doakey3/DashTable
dashtable/dashutils/get_span_row_count.py
get_span_row_count
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...
python
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", ")", ":", "rows", "=", "1", "first_row", "=", "span", "[", "0", "]", "[", "0", "]", "for", "i", "in", "range", "(", "len", "(", "span", ")", ")", ":", "if", "span", "[", "i", "]", "[", "0", "]", ">", ...
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:: +--------+--...
[ "Gets", "the", "number", "of", "rows", "included", "in", "a", "span" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/get_span_row_count.py#L1-L41
train
quantmind/dynts
dynts/utils/section.py
asarray
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 ...
python
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", ")", ":", "iterable", "=", "scalarasiter", "(", "x", ")", "if", "isinstance", "(", "iterable", ",", "ndarray", ")", ":", "return", "iterable", "else", ":", "if", "not", "hasattr", "(", "iterable", ...
Convert ``x`` into a ``numpy.ndarray``.
[ "Convert", "x", "into", "a", "numpy", ".", "ndarray", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L21-L35
train
quantmind/dynts
dynts/utils/section.py
ascolumn
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)
python
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", ")", ":", "x", "=", "asarray", "(", "x", ",", "dtype", ")", "return", "x", "if", "len", "(", "x", ".", "shape", ")", ">=", "2", "else", "x", ".", "reshape", "(", "len", "(", "x", ")", ...
Convert ``x`` into a ``column``-type ``numpy.ndarray``.
[ "Convert", "x", "into", "a", "column", "-", "type", "numpy", ".", "ndarray", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/section.py#L38-L41
train
doakey3/DashTable
dashtable/dashutils/multis_2_mono.py
multis_2_mono
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 ...
python
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", ")", ":", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", "for", "column", "in", "range", "(", "len", "(", "table", "[", "row", "]", ")", ")", ":", "table", "[", "row", "]", "[", "colu...
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
[ "Converts", "each", "multiline", "string", "in", "a", "table", "to", "single", "line", "." ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/multis_2_mono.py#L1-L18
train
doakey3/DashTable
dashtable/html2data/get_html_row_count.py
get_html_row_count
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])] =...
python
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", ")", ":", "if", "spans", "==", "[", "]", ":", "return", "0", "row_counts", "=", "{", "}", "for", "span", "in", "spans", ":", "span", "=", "sorted", "(", "span", ")", "try", ":", "row_counts", "[", "str", "...
Get the number of rows
[ "Get", "the", "number", "of", "rows" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/get_html_row_count.py#L4-L18
train
Lilykos/pyphonetics
pyphonetics/distance_metrics/levenshtein.py
levenshtein_distance
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...
python
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", ")", ":", "if", "len", "(", "word1", ")", "<", "len", "(", "word2", ")", ":", "return", "levenshtein_distance", "(", "word2", ",", "word1", ")", "if", "len", "(", "word2", ")", "==", "0", ":"...
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...
[ "Computes", "the", "Levenshtein", "distance", "." ]
7f55cccc1135e6015520a895eb6859318a4b6111
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/distance_metrics/levenshtein.py#L1-L29
train
quantmind/dynts
dynts/api/tsfunctions.py
better_ts_function
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...
python
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", ")", ":", "fname", "=", "f", ".", "__name__", "def", "_", "(", "ts", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "func", "=", "getattr", "(", "ts", ",", "fname", ",", "None", ")", "if", "func", ":...
Decorator which check if timeseries has a better implementation of the function.
[ "Decorator", "which", "check", "if", "timeseries", "has", "a", "better", "implementation", "of", "the", "function", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L4-L18
train
quantmind/dynts
dynts/api/tsfunctions.py
zscore
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 = ...
python
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", ")", ":", "m", "=", "ts", ".", "rollmean", "(", "*", "*", "kwargs", ")", "s", "=", "ts", ".", "rollstddev", "(", "*", "*", "kwargs", ")", "result", "=", "(", "ts", "-", "m", ")", "/", "s"...
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)}
[ "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", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L22-L39
train
quantmind/dynts
dynts/api/tsfunctions.py
prange
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)
python
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", ")", ":", "mi", "=", "ts", ".", "rollmin", "(", "*", "*", "kwargs", ")", "ma", "=", "ts", ".", "rollmax", "(", "*", "*", "kwargs", ")", "return", "(", "ts", "-", "mi", ")", "/", "(", "ma"...
Rolling Percentage range. Value between 0 and 1 indicating the position in the rolling range.
[ "Rolling", "Percentage", "range", ".", "Value", "between", "0", "and", "1", "indicating", "the", "position", "in", "the", "rolling", "range", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L43-L50
train
quantmind/dynts
dynts/lib/fallback/maths.py
bindata
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...
python
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", ")", ":", "tole", "=", "0.01", "N", "=", "len", "(", "data", ")", "assert", "N", ">", "20", "vmin", "=", "min", "(", "data", ")", "vmax", "=", "max", "(", ...
data must be numeric list with a len above 20 This function counts the number of data points in a reduced array
[ "data", "must", "be", "numeric", "list", "with", "a", "len", "above", "20", "This", "function", "counts", "the", "number", "of", "data", "points", "in", "a", "reduced", "array" ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/maths.py#L3-L33
train
quantmind/dynts
dynts/api/operators.py
binOp
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) ...
python
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", ")", ":", "def", "op_or_missing", "(", "id", ")", ":", "va", "=", "amap", ".", "get", "(", "id", ",", "None", ")", "vb", "=", "bmap", ".", "get", "(", "id", ",...
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
[ "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", ...
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L22-L44
train
quantmind/dynts
dynts/api/operators.py
_toVec
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
python
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", ")", ":", "mat", "=", "np", ".", "empty", "(", "shape", ")", "mat", ".", "fill", "(", "val", ")", "return", "mat" ]
takes a single value and creates a vecotor / matrix with that value filled in it
[ "takes", "a", "single", "value", "and", "creates", "a", "vecotor", "/", "matrix", "with", "that", "value", "filled", "in", "it" ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L65-L72
train
doakey3/DashTable
dashtable/dashutils/center_line.py
center_line
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 ...
python
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", ")", ":", "line", "=", "line", ".", "strip", "(", ")", "left_length", "=", "math", ".", "floor", "(", "(", "space", "-", "len", "(", "line", ")", ")", "/", "2", ")", "right_length", "=", "math", "....
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. ...
[ "Add", "leading", "&", "trailing", "space", "to", "text", "to", "center", "it", "within", "an", "allowed", "width" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/center_line.py#L4-L32
train
quantmind/dynts
dynts/dsl/functions/registry.py
FunctionRegistry.register
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] = ...
python
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", ")", ":", "function", "=", "inspect", ".", "isclass", "(", "function", ")", "and", "function", "(", ")", "or", "function", "name", "=", "function", ".", "name", "self", "[", "name", "]", "=", "function" ...
Register a function in the function registry. The function will be automatically instantiated if not already an instance.
[ "Register", "a", "function", "in", "the", "function", "registry", ".", "The", "function", "will", "be", "automatically", "instantiated", "if", "not", "already", "an", "instance", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L6-L13
train
quantmind/dynts
dynts/dsl/functions/registry.py
FunctionRegistry.unregister
def unregister(self, name): """Unregister function by name. """ try: name = name.name except AttributeError: pass return self.pop(name,None)
python
def unregister(self, name): """Unregister function by name. """ try: name = name.name except AttributeError: pass return self.pop(name,None)
[ "def", "unregister", "(", "self", ",", "name", ")", ":", "try", ":", "name", "=", "name", ".", "name", "except", "AttributeError", ":", "pass", "return", "self", ".", "pop", "(", "name", ",", "None", ")" ]
Unregister function by name.
[ "Unregister", "function", "by", "name", "." ]
21ac57c648bfec402fa6b1fe569496cf098fb5e8
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L15-L22
train
doakey3/DashTable
dashtable/data2simplerst/row_includes_spans.py
row_includes_spans
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...
python
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", ")", ":", "for", "column", "in", "range", "(", "len", "(", "table", "[", "row", "]", ")", ")", ":", "for", "span", "in", "spans", ":", "if", "[", "row", ",", "column", "]", "in"...
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
[ "Determine", "if", "there", "are", "spans", "within", "a", "row" ]
744cfb6a717fa75a8092c83ebcd49b2668023681
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2simplerst/row_includes_spans.py#L1-L20
train
rbarrois/xworkflows
src/xworkflows/base.py
_setup_states
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 " ...
python
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", "=", "(", ")", ")", ":", "states", "=", "list", "(", "prev", ")", "for", "state_def", "in", "state_definitions", ":", "if", "len", "(", "state_def", ")", "!=", "2", ":", "raise", "TypeError",...
Create a StateList object from a 'states' Workflow attribute.
[ "Create", "a", "StateList", "object", "from", "a", "states", "Workflow", "attribute", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L165-L181
train
rbarrois/xworkflows
src/xworkflows/base.py
_setup_transitions
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...
python
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", "=", "(", ")", ")", ":", "trs", "=", "list", "(", "prev", ")", "for", "transition", "in", "tdef", ":", "if", "len", "(", "transition", ")", "==", "3", ":", "(", "name", ",", "s...
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...
[ "Create", "a", "TransitionList", "object", "from", "a", "transitions", "Workflow", "attribute", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L184-L215
train
rbarrois/xworkflows
src/xworkflows/base.py
transition
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)")...
python
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", ")", ":", "if", "is_callable", "(", "trname", ")", ":", "raise", "ValueError", "(", "\"The @tran...
Decorator to declare a function as a transition implementation.
[ "Decorator", "to", "declare", "a", "function", "as", "a", "transition", "implementation", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L516-L529
train
rbarrois/xworkflows
src/xworkflows/base.py
_make_hook_dict
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_...
python
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", ")", ":", "if", "not", "hasattr", "(", "fun", ",", "'xworkflows_hook'", ")", ":", "fun", ".", "xworkflows_hook", "=", "{", "HOOK_BEFORE", ":", "[", "]", ",", "HOOK_AFTER", ":", "[", "]", ",", "HOOK_CHECK", ":", "["...
Ensure the given function has a xworkflows_hook attribute. That attribute has the following structure: >>> { ... 'before': [('state', <TransitionHook>), ...], ... }
[ "Ensure", "the", "given", "function", "has", "a", "xworkflows_hook", "attribute", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L532-L548
train
rbarrois/xworkflows
src/xworkflows/base.py
Hook._match_state
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)
python
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", ")", ":", "return", "(", "self", ".", "names", "==", "'*'", "or", "state", "in", "self", ".", "names", "or", "state", ".", "name", "in", "self", ".", "names", ")" ]
Checks whether a given State matches self.names.
[ "Checks", "whether", "a", "given", "State", "matches", "self", ".", "names", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L256-L260
train
rbarrois/xworkflows
src/xworkflows/base.py
Hook._match_transition
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)
python
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", ")", ":", "return", "(", "self", ".", "names", "==", "'*'", "or", "transition", "in", "self", ".", "names", "or", "transition", ".", "name", "in", "self", ".", "names", ")" ]
Checks whether a given Transition matches self.names.
[ "Checks", "whether", "a", "given", "Transition", "matches", "self", ".", "names", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L262-L266
train
rbarrois/xworkflows
src/xworkflows/base.py
Hook.applies_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...
python
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", ")", ":", "if", "'*'", "in", "self", ".", "names", ":", "return", "True", "elif", "self", ".", "kind", "in", "(", "HOOK_BEFORE", ",", "HOOK_AFTER", ",", "HOOK_CHECK", ...
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 ...
[ "Whether", "this", "hook", "applies", "to", "the", "given", "transition", "/", "state", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L268-L288
train
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationWrapper._pre_transition_checks
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'." % ...
python
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", ")", ":", "current_state", "=", "getattr", "(", "self", ".", "instance", ",", "self", ".", "field_name", ")", "if", "current_state", "not", "in", "self", ".", "transition", ".", "source", ":", "raise", "InvalidTr...
Run the pre-transition checks.
[ "Run", "the", "pre", "-", "transition", "checks", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L363-L375
train
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationWrapper._filter_hooks
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))
python
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", ")", ":", "hooks", "=", "sum", "(", "(", "self", ".", "hooks", ".", "get", "(", "kind", ",", "[", "]", ")", "for", "kind", "in", "hook_kinds", ")", ",", "[", "]", ")", "return", "sorted...
Filter a list of hooks, keeping only applicable ones.
[ "Filter", "a", "list", "of", "hooks", "keeping", "only", "applicable", "ones", "." ]
4a94b04ba83cb43f61d4b0f7db6964a667c86b5b
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L377-L381
train