repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
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", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/multis_2_mono.py#L1-L18
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" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/get_html_row_count.py#L4-L18
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", "." ]
train
https://github.com/Lilykos/pyphonetics/blob/7f55cccc1135e6015520a895eb6859318a4b6111/pyphonetics/distance_metrics/levenshtein.py#L1-L29
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", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L4-L18
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", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L22-L39
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", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/tsfunctions.py#L43-L50
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" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/lib/fallback/maths.py#L3-L33
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", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L22-L44
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" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/operators.py#L65-L72
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" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/center_line.py#L4-L32
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", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L6-L13
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", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/functions/registry.py#L15-L22
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" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2simplerst/row_includes_spans.py#L1-L20
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L165-L181
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L184-L215
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L516-L529
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L532-L548
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L256-L260
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L262-L266
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L268-L288
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L363-L375
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", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L377-L381
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationWrapper._post_transition
def _post_transition(self, result, *args, **kwargs): """Performs post-transition actions.""" for hook in self._filter_hooks(HOOK_AFTER, HOOK_ON_ENTER): hook(self.instance, result, *args, **kwargs)
python
def _post_transition(self, result, *args, **kwargs): """Performs post-transition actions.""" for hook in self._filter_hooks(HOOK_AFTER, HOOK_ON_ENTER): hook(self.instance, result, *args, **kwargs)
[ "def", "_post_transition", "(", "self", ",", "result", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "for", "hook", "in", "self", ".", "_filter_hooks", "(", "HOOK_AFTER", ",", "HOOK_ON_ENTER", ")", ":", "hook", "(", "self", ".", "instance", ",",...
Performs post-transition actions.
[ "Performs", "post", "-", "transition", "actions", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L395-L398
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.load_parent_implems
def load_parent_implems(self, parent_implems): """Import previously defined implementations. Args: parent_implems (ImplementationList): List of implementations defined in a parent class. """ for trname, attr, implem in parent_implems.get_custom_implementation...
python
def load_parent_implems(self, parent_implems): """Import previously defined implementations. Args: parent_implems (ImplementationList): List of implementations defined in a parent class. """ for trname, attr, implem in parent_implems.get_custom_implementation...
[ "def", "load_parent_implems", "(", "self", ",", "parent_implems", ")", ":", "for", "trname", ",", "attr", ",", "implem", "in", "parent_implems", ".", "get_custom_implementations", "(", ")", ":", "self", ".", "implementations", "[", "trname", "]", "=", "implem"...
Import previously defined implementations. Args: parent_implems (ImplementationList): List of implementations defined in a parent class.
[ "Import", "previously", "defined", "implementations", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L664-L674
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.add_implem
def add_implem(self, transition, attribute, function, **kwargs): """Add an implementation. Args: transition (Transition): the transition for which the implementation is added attribute (str): the name of the attribute where the implementation will...
python
def add_implem(self, transition, attribute, function, **kwargs): """Add an implementation. Args: transition (Transition): the transition for which the implementation is added attribute (str): the name of the attribute where the implementation will...
[ "def", "add_implem", "(", "self", ",", "transition", ",", "attribute", ",", "function", ",", "*", "*", "kwargs", ")", ":", "implem", "=", "ImplementationProperty", "(", "field_name", "=", "self", ".", "state_field", ",", "transition", "=", "transition", ",",...
Add an implementation. Args: transition (Transition): the transition for which the implementation is added attribute (str): the name of the attribute where the implementation will be available function (callable): the actual implementation fun...
[ "Add", "an", "implementation", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L676-L695
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.should_collect
def should_collect(self, value): """Decide whether a given value should be collected.""" return ( # decorated with @transition isinstance(value, TransitionWrapper) # Relates to a compatible transition and value.trname in self.workflow.transitions ...
python
def should_collect(self, value): """Decide whether a given value should be collected.""" return ( # decorated with @transition isinstance(value, TransitionWrapper) # Relates to a compatible transition and value.trname in self.workflow.transitions ...
[ "def", "should_collect", "(", "self", ",", "value", ")", ":", "return", "(", "# decorated with @transition", "isinstance", "(", "value", ",", "TransitionWrapper", ")", "# Relates to a compatible transition", "and", "value", ".", "trname", "in", "self", ".", "workflo...
Decide whether a given value should be collected.
[ "Decide", "whether", "a", "given", "value", "should", "be", "collected", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L697-L705
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.collect
def collect(self, attrs): """Collect the implementations from a given attributes dict.""" for name, value in attrs.items(): if self.should_collect(value): transition = self.workflow.transitions[value.trname] if ( value.trname in self....
python
def collect(self, attrs): """Collect the implementations from a given attributes dict.""" for name, value in attrs.items(): if self.should_collect(value): transition = self.workflow.transitions[value.trname] if ( value.trname in self....
[ "def", "collect", "(", "self", ",", "attrs", ")", ":", "for", "name", ",", "value", "in", "attrs", ".", "items", "(", ")", ":", "if", "self", ".", "should_collect", "(", "value", ")", ":", "transition", "=", "self", ".", "workflow", ".", "transitions...
Collect the implementations from a given attributes dict.
[ "Collect", "the", "implementations", "from", "a", "given", "attributes", "dict", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L707-L732
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.get_custom_implementations
def get_custom_implementations(self): """Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation. ...
python
def get_custom_implementations(self): """Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation. ...
[ "def", "get_custom_implementations", "(", "self", ")", ":", "for", "trname", "in", "self", ".", "custom_implems", ":", "attr", "=", "self", ".", "transitions_at", "[", "trname", "]", "implem", "=", "self", ".", "implementations", "[", "trname", "]", "yield",...
Retrieve a list of cutom implementations. Yields: (str, str, ImplementationProperty) tuples: The name of the attribute an implementation lives at, the name of the related transition, and the related implementation.
[ "Retrieve", "a", "list", "of", "cutom", "implementations", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L734-L745
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.register_function_hooks
def register_function_hooks(self, func): """Looks at an object method and registers it for relevent transitions.""" for hook_kind, hooks in func.xworkflows_hook.items(): for field_name, hook in hooks: if field_name and field_name != self.state_field: conti...
python
def register_function_hooks(self, func): """Looks at an object method and registers it for relevent transitions.""" for hook_kind, hooks in func.xworkflows_hook.items(): for field_name, hook in hooks: if field_name and field_name != self.state_field: conti...
[ "def", "register_function_hooks", "(", "self", ",", "func", ")", ":", "for", "hook_kind", ",", "hooks", "in", "func", ".", "xworkflows_hook", ".", "items", "(", ")", ":", "for", "field_name", ",", "hook", "in", "hooks", ":", "if", "field_name", "and", "f...
Looks at an object method and registers it for relevent transitions.
[ "Looks", "at", "an", "object", "method", "and", "registers", "it", "for", "relevent", "transitions", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L757-L766
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList._may_override
def _may_override(self, implem, other): """Checks whether an ImplementationProperty may override an attribute.""" if isinstance(other, ImplementationProperty): # Overriding another custom implementation for the same transition # and field return (other.transition == i...
python
def _may_override(self, implem, other): """Checks whether an ImplementationProperty may override an attribute.""" if isinstance(other, ImplementationProperty): # Overriding another custom implementation for the same transition # and field return (other.transition == i...
[ "def", "_may_override", "(", "self", ",", "implem", ",", "other", ")", ":", "if", "isinstance", "(", "other", ",", "ImplementationProperty", ")", ":", "# Overriding another custom implementation for the same transition", "# and field", "return", "(", "other", ".", "tr...
Checks whether an ImplementationProperty may override an attribute.
[ "Checks", "whether", "an", "ImplementationProperty", "may", "override", "an", "attribute", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L768-L783
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.fill_attrs
def fill_attrs(self, attrs): """Update the 'attrs' dict with generated ImplementationProperty.""" for trname, attrname in self.transitions_at.items(): implem = self.implementations[trname] if attrname in attrs: conflicting = attrs[attrname] if no...
python
def fill_attrs(self, attrs): """Update the 'attrs' dict with generated ImplementationProperty.""" for trname, attrname in self.transitions_at.items(): implem = self.implementations[trname] if attrname in attrs: conflicting = attrs[attrname] if no...
[ "def", "fill_attrs", "(", "self", ",", "attrs", ")", ":", "for", "trname", ",", "attrname", "in", "self", ".", "transitions_at", ".", "items", "(", ")", ":", "implem", "=", "self", ".", "implementations", "[", "trname", "]", "if", "attrname", "in", "at...
Update the 'attrs' dict with generated ImplementationProperty.
[ "Update", "the", "attrs", "dict", "with", "generated", "ImplementationProperty", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L785-L799
rbarrois/xworkflows
src/xworkflows/base.py
ImplementationList.transform
def transform(self, attrs): """Perform all actions on a given attribute dict.""" self.collect(attrs) self.add_missing_implementations() self.fill_attrs(attrs)
python
def transform(self, attrs): """Perform all actions on a given attribute dict.""" self.collect(attrs) self.add_missing_implementations() self.fill_attrs(attrs)
[ "def", "transform", "(", "self", ",", "attrs", ")", ":", "self", ".", "collect", "(", "attrs", ")", "self", ".", "add_missing_implementations", "(", ")", "self", ".", "fill_attrs", "(", "attrs", ")" ]
Perform all actions on a given attribute dict.
[ "Perform", "all", "actions", "on", "a", "given", "attribute", "dict", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L801-L805
rbarrois/xworkflows
src/xworkflows/base.py
BaseWorkflow.log_transition
def log_transition(self, transition, from_state, instance, *args, **kwargs): """Log a transition. Args: transition (Transition): the name of the performed transition from_state (State): the source state instance (object): the modified object Kwargs: ...
python
def log_transition(self, transition, from_state, instance, *args, **kwargs): """Log a transition. Args: transition (Transition): the name of the performed transition from_state (State): the source state instance (object): the modified object Kwargs: ...
[ "def", "log_transition", "(", "self", ",", "transition", ",", "from_state", ",", "instance", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "logger", "=", "logging", ".", "getLogger", "(", "'xworkflows.transitions'", ")", "try", ":", "instance_repr", ...
Log a transition. Args: transition (Transition): the name of the performed transition from_state (State): the source state instance (object): the modified object Kwargs: Any passed when calling the transition
[ "Log", "a", "transition", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L850-L869
rbarrois/xworkflows
src/xworkflows/base.py
WorkflowEnabledMeta._add_workflow
def _add_workflow(mcs, field_name, state_field, attrs): """Attach a workflow to the attribute list (create a StateProperty).""" attrs[field_name] = StateProperty(state_field.workflow, field_name)
python
def _add_workflow(mcs, field_name, state_field, attrs): """Attach a workflow to the attribute list (create a StateProperty).""" attrs[field_name] = StateProperty(state_field.workflow, field_name)
[ "def", "_add_workflow", "(", "mcs", ",", "field_name", ",", "state_field", ",", "attrs", ")", ":", "attrs", "[", "field_name", "]", "=", "StateProperty", "(", "state_field", ".", "workflow", ",", "field_name", ")" ]
Attach a workflow to the attribute list (create a StateProperty).
[ "Attach", "a", "workflow", "to", "the", "attribute", "list", "(", "create", "a", "StateProperty", ")", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L988-L990
rbarrois/xworkflows
src/xworkflows/base.py
WorkflowEnabledMeta._find_workflows
def _find_workflows(mcs, attrs): """Finds all occurrences of a workflow in the attributes definitions. Returns: dict(str => StateField): maps an attribute name to a StateField describing the related Workflow. """ workflows = {} for attribute, value in...
python
def _find_workflows(mcs, attrs): """Finds all occurrences of a workflow in the attributes definitions. Returns: dict(str => StateField): maps an attribute name to a StateField describing the related Workflow. """ workflows = {} for attribute, value in...
[ "def", "_find_workflows", "(", "mcs", ",", "attrs", ")", ":", "workflows", "=", "{", "}", "for", "attribute", ",", "value", "in", "attrs", ".", "items", "(", ")", ":", "if", "isinstance", "(", "value", ",", "Workflow", ")", ":", "workflows", "[", "at...
Finds all occurrences of a workflow in the attributes definitions. Returns: dict(str => StateField): maps an attribute name to a StateField describing the related Workflow.
[ "Finds", "all", "occurrences", "of", "a", "workflow", "in", "the", "attributes", "definitions", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L993-L1004
rbarrois/xworkflows
src/xworkflows/base.py
WorkflowEnabledMeta._add_transitions
def _add_transitions(mcs, field_name, workflow, attrs, implems=None): """Collect and enhance transition definitions to a workflow. Modifies the 'attrs' dict in-place. Args: field_name (str): name of the field transitions should update workflow (Workflow): workflow we're...
python
def _add_transitions(mcs, field_name, workflow, attrs, implems=None): """Collect and enhance transition definitions to a workflow. Modifies the 'attrs' dict in-place. Args: field_name (str): name of the field transitions should update workflow (Workflow): workflow we're...
[ "def", "_add_transitions", "(", "mcs", ",", "field_name", ",", "workflow", ",", "attrs", ",", "implems", "=", "None", ")", ":", "new_implems", "=", "ImplementationList", "(", "field_name", ",", "workflow", ")", "if", "implems", ":", "new_implems", ".", "load...
Collect and enhance transition definitions to a workflow. Modifies the 'attrs' dict in-place. Args: field_name (str): name of the field transitions should update workflow (Workflow): workflow we're working on attrs (dict): dictionary of attributes to be updated. ...
[ "Collect", "and", "enhance", "transition", "definitions", "to", "a", "workflow", "." ]
train
https://github.com/rbarrois/xworkflows/blob/4a94b04ba83cb43f61d4b0f7db6964a667c86b5b/src/xworkflows/base.py#L1007-L1027
eaton-lab/toytree
toytree/Coords.py
Coords.update
def update(self): "Updates cartesian coordinates for drawing tree graph" # get new shape and clear for attrs self.edges = np.zeros((self.ttree.nnodes - 1, 2), dtype=int) self.verts = np.zeros((self.ttree.nnodes, 2), dtype=float) self.lines = [] self.coords =...
python
def update(self): "Updates cartesian coordinates for drawing tree graph" # get new shape and clear for attrs self.edges = np.zeros((self.ttree.nnodes - 1, 2), dtype=int) self.verts = np.zeros((self.ttree.nnodes, 2), dtype=float) self.lines = [] self.coords =...
[ "def", "update", "(", "self", ")", ":", "# get new shape and clear for attrs", "self", ".", "edges", "=", "np", ".", "zeros", "(", "(", "self", ".", "ttree", ".", "nnodes", "-", "1", ",", "2", ")", ",", "dtype", "=", "int", ")", "self", ".", "verts",...
Updates cartesian coordinates for drawing tree graph
[ "Updates", "cartesian", "coordinates", "for", "drawing", "tree", "graph" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L40-L53
eaton-lab/toytree
toytree/Coords.py
Coords.update_idxs
def update_idxs(self): "set root idx highest, tip idxs lowest ordered as ladderized" # internal nodes: root is highest idx idx = self.ttree.nnodes - 1 for node in self.ttree.treenode.traverse("levelorder"): if not node.is_leaf(): node.add_feature("idx", idx) ...
python
def update_idxs(self): "set root idx highest, tip idxs lowest ordered as ladderized" # internal nodes: root is highest idx idx = self.ttree.nnodes - 1 for node in self.ttree.treenode.traverse("levelorder"): if not node.is_leaf(): node.add_feature("idx", idx) ...
[ "def", "update_idxs", "(", "self", ")", ":", "# internal nodes: root is highest idx", "idx", "=", "self", ".", "ttree", ".", "nnodes", "-", "1", "for", "node", "in", "self", ".", "ttree", ".", "treenode", ".", "traverse", "(", "\"levelorder\"", ")", ":", "...
set root idx highest, tip idxs lowest ordered as ladderized
[ "set", "root", "idx", "highest", "tip", "idxs", "lowest", "ordered", "as", "ladderized" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L56-L72
eaton-lab/toytree
toytree/Coords.py
Coords.update_fixed_order
def update_fixed_order(self): "after pruning fixed order needs update to match new nnodes/ntips." # set tips order if fixing for multi-tree plotting (default None) fixed_order = self.ttree._fixed_order self.ttree_fixed_order = None self.ttree_fixed_idx = list(range(self.ttree.nti...
python
def update_fixed_order(self): "after pruning fixed order needs update to match new nnodes/ntips." # set tips order if fixing for multi-tree plotting (default None) fixed_order = self.ttree._fixed_order self.ttree_fixed_order = None self.ttree_fixed_idx = list(range(self.ttree.nti...
[ "def", "update_fixed_order", "(", "self", ")", ":", "# set tips order if fixing for multi-tree plotting (default None)", "fixed_order", "=", "self", ".", "ttree", ".", "_fixed_order", "self", ".", "ttree_fixed_order", "=", "None", "self", ".", "ttree_fixed_idx", "=", "l...
after pruning fixed order needs update to match new nnodes/ntips.
[ "after", "pruning", "fixed", "order", "needs", "update", "to", "match", "new", "nnodes", "/", "ntips", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L75-L88
eaton-lab/toytree
toytree/Coords.py
Coords.assign_vertices
def assign_vertices(self): """ Sets .edges, .verts for node positions. X and Y positions here refer to base assumption that tree is right facing, reorient_coordinates() will handle re-translating this. """ # shortname uselen = bool(self.ttree.style.use_e...
python
def assign_vertices(self): """ Sets .edges, .verts for node positions. X and Y positions here refer to base assumption that tree is right facing, reorient_coordinates() will handle re-translating this. """ # shortname uselen = bool(self.ttree.style.use_e...
[ "def", "assign_vertices", "(", "self", ")", ":", "# shortname ", "uselen", "=", "bool", "(", "self", ".", "ttree", ".", "style", ".", "use_edge_lengths", ")", "# postorder: children then parents (nidxs from 0 up)", "# store edge array for connecting child nodes to parent node...
Sets .edges, .verts for node positions. X and Y positions here refer to base assumption that tree is right facing, reorient_coordinates() will handle re-translating this.
[ "Sets", ".", "edges", ".", "verts", "for", "node", "positions", ".", "X", "and", "Y", "positions", "here", "refer", "to", "base", "assumption", "that", "tree", "is", "right", "facing", "reorient_coordinates", "()", "will", "handle", "re", "-", "translating",...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L91-L150
eaton-lab/toytree
toytree/Coords.py
Coords.reorient_coordinates
def reorient_coordinates(self): """ Returns a modified .verts array with new coordinates for nodes. This does not need to modify .edges. The order of nodes, and therefore of verts rows is still the same because it is still based on the tree branching order (ladderized usually). ...
python
def reorient_coordinates(self): """ Returns a modified .verts array with new coordinates for nodes. This does not need to modify .edges. The order of nodes, and therefore of verts rows is still the same because it is still based on the tree branching order (ladderized usually). ...
[ "def", "reorient_coordinates", "(", "self", ")", ":", "# if tree is empty then bail out", "if", "len", "(", "self", ".", "ttree", ")", "<", "2", ":", "return", "# down is the default orientation", "# down-facing tips align at y=0, first ladderized tip at x=0", "if", "self",...
Returns a modified .verts array with new coordinates for nodes. This does not need to modify .edges. The order of nodes, and therefore of verts rows is still the same because it is still based on the tree branching order (ladderized usually).
[ "Returns", "a", "modified", ".", "verts", "array", "with", "new", "coordinates", "for", "nodes", ".", "This", "does", "not", "need", "to", "modify", ".", "edges", ".", "The", "order", "of", "nodes", "and", "therefore", "of", "verts", "rows", "is", "still...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Coords.py#L252-L287
quantmind/dynts
dynts/formatters/base.py
tsiterator
def tsiterator(ts, dateconverter=None, desc=None, clean=False, start_value=None, **kwargs): '''An iterator of timeseries as tuples.''' dateconverter = dateconverter or default_converter yield ['Date'] + ts.names() if clean == 'full': for dt, value in full_clean(ts, dateconverter, ...
python
def tsiterator(ts, dateconverter=None, desc=None, clean=False, start_value=None, **kwargs): '''An iterator of timeseries as tuples.''' dateconverter = dateconverter or default_converter yield ['Date'] + ts.names() if clean == 'full': for dt, value in full_clean(ts, dateconverter, ...
[ "def", "tsiterator", "(", "ts", ",", "dateconverter", "=", "None", ",", "desc", "=", "None", ",", "clean", "=", "False", ",", "start_value", "=", "None", ",", "*", "*", "kwargs", ")", ":", "dateconverter", "=", "dateconverter", "or", "default_converter", ...
An iterator of timeseries as tuples.
[ "An", "iterator", "of", "timeseries", "as", "tuples", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/formatters/base.py#L23-L36
eaton-lab/toytree
toytree/Drawing.py
Drawing.set_baselines
def set_baselines(self): """ Modify coords to shift tree position for x,y baseline arguments. This is useful for arrangeing trees onto a Canvas with other plots, but still sharing a common cartesian axes coordinates. """ if self.style.xbaseline: if self.styl...
python
def set_baselines(self): """ Modify coords to shift tree position for x,y baseline arguments. This is useful for arrangeing trees onto a Canvas with other plots, but still sharing a common cartesian axes coordinates. """ if self.style.xbaseline: if self.styl...
[ "def", "set_baselines", "(", "self", ")", ":", "if", "self", ".", "style", ".", "xbaseline", ":", "if", "self", ".", "style", ".", "orient", "in", "(", "\"up\"", ",", "\"down\"", ")", ":", "self", ".", "coords", ".", "coords", "[", ":", ",", "0", ...
Modify coords to shift tree position for x,y baseline arguments. This is useful for arrangeing trees onto a Canvas with other plots, but still sharing a common cartesian axes coordinates.
[ "Modify", "coords", "to", "shift", "tree", "position", "for", "x", "y", "baseline", "arguments", ".", "This", "is", "useful", "for", "arrangeing", "trees", "onto", "a", "Canvas", "with", "other", "plots", "but", "still", "sharing", "a", "common", "cartesian"...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L73-L85
eaton-lab/toytree
toytree/Drawing.py
Drawing.add_tip_labels_to_axes
def add_tip_labels_to_axes(self): """ Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting. """ # get tip-coords and replace if using fixed_order xpos = self.ttree.get_tip_coordinates('x') ...
python
def add_tip_labels_to_axes(self): """ Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting. """ # get tip-coords and replace if using fixed_order xpos = self.ttree.get_tip_coordinates('x') ...
[ "def", "add_tip_labels_to_axes", "(", "self", ")", ":", "# get tip-coords and replace if using fixed_order", "xpos", "=", "self", ".", "ttree", ".", "get_tip_coordinates", "(", "'x'", ")", "ypos", "=", "self", ".", "ttree", ".", "get_tip_coordinates", "(", "'y'", ...
Add text offset from tips of tree with correction for orientation, and fixed_order which is usually used in multitree plotting.
[ "Add", "text", "offset", "from", "tips", "of", "tree", "with", "correction", "for", "orientation", "and", "fixed_order", "which", "is", "usually", "used", "in", "multitree", "plotting", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L90-L132
eaton-lab/toytree
toytree/Drawing.py
Drawing.add_tip_lines_to_axes
def add_tip_lines_to_axes(self): "add lines to connect tips to zero axis for tip_labels_align=True" # get tip-coords and align-coords from verts xpos, ypos, aedges, averts = self.get_tip_label_coords() if self.style.tip_labels_align: self.axes.graph( aedges,...
python
def add_tip_lines_to_axes(self): "add lines to connect tips to zero axis for tip_labels_align=True" # get tip-coords and align-coords from verts xpos, ypos, aedges, averts = self.get_tip_label_coords() if self.style.tip_labels_align: self.axes.graph( aedges,...
[ "def", "add_tip_lines_to_axes", "(", "self", ")", ":", "# get tip-coords and align-coords from verts", "xpos", ",", "ypos", ",", "aedges", ",", "averts", "=", "self", ".", "get_tip_label_coords", "(", ")", "if", "self", ".", "style", ".", "tip_labels_align", ":", ...
add lines to connect tips to zero axis for tip_labels_align=True
[ "add", "lines", "to", "connect", "tips", "to", "zero", "axis", "for", "tip_labels_align", "=", "True" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L135-L147
eaton-lab/toytree
toytree/Drawing.py
Drawing.fit_tip_labels
def fit_tip_labels(self): """ Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. I...
python
def fit_tip_labels(self): """ Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. I...
[ "def", "fit_tip_labels", "(", "self", ")", ":", "# user entered values", "#if self.style.axes.x_domain_max or self.style.axes.y_domain_min:", "# self.axes.x.domain.max = self.style.axes.x_domain_max", "# self.axes.y.domain.min = self.style.axes.y_domain_min ", "# IF USE WANTS TO...
Modifies display range to ensure tip labels fit. This is a bit hackish still. The problem is that the 'extents' range of the rendered text is totally correct. So we add a little buffer here. Should add for user to be able to modify this if needed. If not using edge lengths then need to ...
[ "Modifies", "display", "range", "to", "ensure", "tip", "labels", "fit", ".", "This", "is", "a", "bit", "hackish", "still", ".", "The", "problem", "is", "that", "the", "extents", "range", "of", "the", "rendered", "text", "is", "totally", "correct", ".", "...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L150-L176
eaton-lab/toytree
toytree/Drawing.py
Drawing.assign_node_colors_and_style
def assign_node_colors_and_style(self): """ Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a list...
python
def assign_node_colors_and_style(self): """ Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a list...
[ "def", "assign_node_colors_and_style", "(", "self", ")", ":", "# SET node_colors and POP node_style.fill", "colors", "=", "self", ".", "style", ".", "node_colors", "style", "=", "self", ".", "style", ".", "node_style", "if", "colors", "is", "None", ":", "if", "s...
Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a list of colors to pass to Drawing.node_colors which is ...
[ "Resolve", "conflict", "of", "node_color", "and", "node_style", "[", "fill", "]", "args", "which", "are", "redundant", ".", "Default", "is", "node_style", ".", "fill", "unless", "user", "entered", "node_color", ".", "To", "enter", "multiple", "colors", "user",...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L180-L236
eaton-lab/toytree
toytree/Drawing.py
Drawing.assign_node_labels_and_sizes
def assign_node_labels_and_sizes(self): "assign features of nodes to be plotted based on user kwargs" # shorthand nvals = self.ttree.get_node_values() # False == Hide nodes and labels unless user entered size if self.style.node_labels is False: self.node_labels = [...
python
def assign_node_labels_and_sizes(self): "assign features of nodes to be plotted based on user kwargs" # shorthand nvals = self.ttree.get_node_values() # False == Hide nodes and labels unless user entered size if self.style.node_labels is False: self.node_labels = [...
[ "def", "assign_node_labels_and_sizes", "(", "self", ")", ":", "# shorthand", "nvals", "=", "self", ".", "ttree", ".", "get_node_values", "(", ")", "# False == Hide nodes and labels unless user entered size ", "if", "self", ".", "style", ".", "node_labels", "is", "Fals...
assign features of nodes to be plotted based on user kwargs
[ "assign", "features", "of", "nodes", "to", "be", "plotted", "based", "on", "user", "kwargs" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L240-L311
eaton-lab/toytree
toytree/Drawing.py
Drawing.assign_tip_labels_and_colors
def assign_tip_labels_and_colors(self): "assign tip labels based on user provided kwargs" # COLOR # tip color overrides tipstyle.fill if self.style.tip_labels_colors: #if self.style.tip_labels_style.fill: # self.style.tip_labels_style.fill = None if...
python
def assign_tip_labels_and_colors(self): "assign tip labels based on user provided kwargs" # COLOR # tip color overrides tipstyle.fill if self.style.tip_labels_colors: #if self.style.tip_labels_style.fill: # self.style.tip_labels_style.fill = None if...
[ "def", "assign_tip_labels_and_colors", "(", "self", ")", ":", "# COLOR", "# tip color overrides tipstyle.fill", "if", "self", ".", "style", ".", "tip_labels_colors", ":", "#if self.style.tip_labels_style.fill:", "# self.style.tip_labels_style.fill = None", "if", "self", ".",...
assign tip labels based on user provided kwargs
[ "assign", "tip", "labels", "based", "on", "user", "provided", "kwargs" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L314-L349
eaton-lab/toytree
toytree/Drawing.py
Drawing.assign_edge_colors_and_widths
def assign_edge_colors_and_widths(self): """ Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a lis...
python
def assign_edge_colors_and_widths(self): """ Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a lis...
[ "def", "assign_edge_colors_and_widths", "(", "self", ")", ":", "# node_color overrides fill. Tricky to catch cuz it can be many types.", "# SET edge_widths and POP edge_style.stroke-width", "if", "self", ".", "style", ".", "edge_widths", "is", "None", ":", "if", "not", "self", ...
Resolve conflict of 'node_color' and 'node_style['fill'] args which are redundant. Default is node_style.fill unless user entered node_color. To enter multiple colors user must use node_color not style fill. Either way, we build a list of colors to pass to Drawing.node_colors which is ...
[ "Resolve", "conflict", "of", "node_color", "and", "node_style", "[", "fill", "]", "args", "which", "are", "redundant", ".", "Default", "is", "node_style", ".", "fill", "unless", "user", "entered", "node_color", ".", "To", "enter", "multiple", "colors", "user",...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L352-L421
eaton-lab/toytree
toytree/Drawing.py
Drawing.add_nodes_to_axes
def add_nodes_to_axes(self): """ Creates a new marker for every node from idx indexes and lists of node_values, node_colors, node_sizes, node_style, node_labels_style. Pulls from node_color and adds to a copy of the style dict for each node to create marker. Node_color...
python
def add_nodes_to_axes(self): """ Creates a new marker for every node from idx indexes and lists of node_values, node_colors, node_sizes, node_style, node_labels_style. Pulls from node_color and adds to a copy of the style dict for each node to create marker. Node_color...
[ "def", "add_nodes_to_axes", "(", "self", ")", ":", "# bail out if not any visible nodes (e.g., none w/ size>0)", "if", "all", "(", "[", "i", "==", "\"\"", "for", "i", "in", "self", ".", "node_labels", "]", ")", ":", "return", "# build markers for each node.", "marks...
Creates a new marker for every node from idx indexes and lists of node_values, node_colors, node_sizes, node_style, node_labels_style. Pulls from node_color and adds to a copy of the style dict for each node to create marker. Node_colors has priority to overwrite node_style['fill']
[ "Creates", "a", "new", "marker", "for", "every", "node", "from", "idx", "indexes", "and", "lists", "of", "node_values", "node_colors", "node_sizes", "node_style", "node_labels_style", ".", "Pulls", "from", "node_color", "and", "adds", "to", "a", "copy", "of", ...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L504-L566
eaton-lab/toytree
toytree/Drawing.py
Drawing.get_tip_label_coords
def get_tip_label_coords(self): """ Get starting position of tip labels text based on locations of the leaf nodes on the tree and style offset and align options. Node positions are found using the .verts attribute of coords and is already oriented for the tree face direction. ...
python
def get_tip_label_coords(self): """ Get starting position of tip labels text based on locations of the leaf nodes on the tree and style offset and align options. Node positions are found using the .verts attribute of coords and is already oriented for the tree face direction. ...
[ "def", "get_tip_label_coords", "(", "self", ")", ":", "# number of tips", "ns", "=", "self", ".", "ttree", ".", "ntips", "# x-coordinate of tips assuming down-face", "tip_xpos", "=", "self", ".", "coords", ".", "verts", "[", ":", "ns", ",", "0", "]", "tip_ypos...
Get starting position of tip labels text based on locations of the leaf nodes on the tree and style offset and align options. Node positions are found using the .verts attribute of coords and is already oriented for the tree face direction.
[ "Get", "starting", "position", "of", "tip", "labels", "text", "based", "on", "locations", "of", "the", "leaf", "nodes", "on", "the", "tree", "and", "style", "offset", "and", "align", "options", ".", "Node", "positions", "are", "found", "using", "the", ".",...
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L624-L665
eaton-lab/toytree
toytree/Drawing.py
Drawing.get_dims_from_tree_size
def get_dims_from_tree_size(self): "Calculate reasonable canvas height and width for tree given N tips" ntips = len(self.ttree) if self.style.orient in ("right", "left"): # height is long tip-wise dimension if not self.style.height: self.style.height = ma...
python
def get_dims_from_tree_size(self): "Calculate reasonable canvas height and width for tree given N tips" ntips = len(self.ttree) if self.style.orient in ("right", "left"): # height is long tip-wise dimension if not self.style.height: self.style.height = ma...
[ "def", "get_dims_from_tree_size", "(", "self", ")", ":", "ntips", "=", "len", "(", "self", ".", "ttree", ")", "if", "self", ".", "style", ".", "orient", "in", "(", "\"right\"", ",", "\"left\"", ")", ":", "# height is long tip-wise dimension", "if", "not", ...
Calculate reasonable canvas height and width for tree given N tips
[ "Calculate", "reasonable", "canvas", "height", "and", "width", "for", "tree", "given", "N", "tips" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/Drawing.py#L693-L707
doakey3/DashTable
dashtable/data2rst/cell/get_longest_line_length.py
get_longest_line_length
def get_longest_line_length(text): """Get the length longest line in a paragraph""" lines = text.split("\n") length = 0 for i in range(len(lines)): if len(lines[i]) > length: length = len(lines[i]) return length
python
def get_longest_line_length(text): """Get the length longest line in a paragraph""" lines = text.split("\n") length = 0 for i in range(len(lines)): if len(lines[i]) > length: length = len(lines[i]) return length
[ "def", "get_longest_line_length", "(", "text", ")", ":", "lines", "=", "text", ".", "split", "(", "\"\\n\"", ")", "length", "=", "0", "for", "i", "in", "range", "(", "len", "(", "lines", ")", ")", ":", "if", "len", "(", "lines", "[", "i", "]", ")...
Get the length longest line in a paragraph
[ "Get", "the", "length", "longest", "line", "in", "a", "paragraph" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/cell/get_longest_line_length.py#L1-L10
quantmind/dynts
dynts/utils/numbers.py
isnumeric
def isnumeric(obj): ''' Return true if obj is a numeric value ''' from decimal import Decimal if type(obj) == Decimal: return True else: try: float(obj) except: return False return True
python
def isnumeric(obj): ''' Return true if obj is a numeric value ''' from decimal import Decimal if type(obj) == Decimal: return True else: try: float(obj) except: return False return True
[ "def", "isnumeric", "(", "obj", ")", ":", "from", "decimal", "import", "Decimal", "if", "type", "(", "obj", ")", "==", "Decimal", ":", "return", "True", "else", ":", "try", ":", "float", "(", "obj", ")", "except", ":", "return", "False", "return", "T...
Return true if obj is a numeric value
[ "Return", "true", "if", "obj", "is", "a", "numeric", "value" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/numbers.py#L10-L22
quantmind/dynts
dynts/utils/numbers.py
significant_format
def significant_format(number, decimal_sep='.', thousand_sep=',', n=3): """Format a number according to a given number of significant figures. """ str_number = significant(number, n) # sign if float(number) < 0: sign = '-' else: sign = '' if str_number[0] == '-':...
python
def significant_format(number, decimal_sep='.', thousand_sep=',', n=3): """Format a number according to a given number of significant figures. """ str_number = significant(number, n) # sign if float(number) < 0: sign = '-' else: sign = '' if str_number[0] == '-':...
[ "def", "significant_format", "(", "number", ",", "decimal_sep", "=", "'.'", ",", "thousand_sep", "=", "','", ",", "n", "=", "3", ")", ":", "str_number", "=", "significant", "(", "number", ",", "n", ")", "# sign\r", "if", "float", "(", "number", ")", "<...
Format a number according to a given number of significant figures.
[ "Format", "a", "number", "according", "to", "a", "given", "number", "of", "significant", "figures", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/numbers.py#L34-L60
PierreRaybaut/formlayout
formlayout.py
to_text_string
def to_text_string(obj, encoding=None): """Convert `obj` to (unicode) text string""" if PY2: # Python 2 if encoding is None: return unicode(obj) else: return unicode(obj, encoding) else: # Python 3 if encoding is None: return str(ob...
python
def to_text_string(obj, encoding=None): """Convert `obj` to (unicode) text string""" if PY2: # Python 2 if encoding is None: return unicode(obj) else: return unicode(obj, encoding) else: # Python 3 if encoding is None: return str(ob...
[ "def", "to_text_string", "(", "obj", ",", "encoding", "=", "None", ")", ":", "if", "PY2", ":", "# Python 2", "if", "encoding", "is", "None", ":", "return", "unicode", "(", "obj", ")", "else", ":", "return", "unicode", "(", "obj", ",", "encoding", ")", ...
Convert `obj` to (unicode) text string
[ "Convert", "obj", "to", "(", "unicode", ")", "text", "string" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L134-L150
PierreRaybaut/formlayout
formlayout.py
text_to_qcolor
def text_to_qcolor(text): """ Create a QColor from specified string Avoid warning from Qt when an invalid QColor is instantiated """ color = QColor() if not is_string(text): # testing for QString (PyQt API#1) text = str(text) if not is_text_string(text): return color if t...
python
def text_to_qcolor(text): """ Create a QColor from specified string Avoid warning from Qt when an invalid QColor is instantiated """ color = QColor() if not is_string(text): # testing for QString (PyQt API#1) text = str(text) if not is_text_string(text): return color if t...
[ "def", "text_to_qcolor", "(", "text", ")", ":", "color", "=", "QColor", "(", ")", "if", "not", "is_string", "(", "text", ")", ":", "# testing for QString (PyQt API#1)", "text", "=", "str", "(", "text", ")", "if", "not", "is_text_string", "(", "text", ")", ...
Create a QColor from specified string Avoid warning from Qt when an invalid QColor is instantiated
[ "Create", "a", "QColor", "from", "specified", "string", "Avoid", "warning", "from", "Qt", "when", "an", "invalid", "QColor", "is", "instantiated" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L194-L212
PierreRaybaut/formlayout
formlayout.py
tuple_to_qfont
def tuple_to_qfont(tup): """ Create a QFont from tuple: (family [string], size [int], italic [bool], bold [bool]) """ if not isinstance(tup, tuple) or len(tup) != 4 \ or not is_text_string(tup[0]) \ or not isinstance(tup[1], int) \ or not isinstance(tup[2], bool) \ or...
python
def tuple_to_qfont(tup): """ Create a QFont from tuple: (family [string], size [int], italic [bool], bold [bool]) """ if not isinstance(tup, tuple) or len(tup) != 4 \ or not is_text_string(tup[0]) \ or not isinstance(tup[1], int) \ or not isinstance(tup[2], bool) \ or...
[ "def", "tuple_to_qfont", "(", "tup", ")", ":", "if", "not", "isinstance", "(", "tup", ",", "tuple", ")", "or", "len", "(", "tup", ")", "!=", "4", "or", "not", "is_text_string", "(", "tup", "[", "0", "]", ")", "or", "not", "isinstance", "(", "tup", ...
Create a QFont from tuple: (family [string], size [int], italic [bool], bold [bool])
[ "Create", "a", "QFont", "from", "tuple", ":", "(", "family", "[", "string", "]", "size", "[", "int", "]", "italic", "[", "bool", "]", "bold", "[", "bool", "]", ")" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L423-L440
PierreRaybaut/formlayout
formlayout.py
fedit
def fedit(data, title="", comment="", icon=None, parent=None, apply=None, ok=True, cancel=True, result='list', outfile=None, type='form', scrollbar=False, background_color=None, widget_color=None): """ Create form dialog and return result (if Cancel button is pressed, return None) :...
python
def fedit(data, title="", comment="", icon=None, parent=None, apply=None, ok=True, cancel=True, result='list', outfile=None, type='form', scrollbar=False, background_color=None, widget_color=None): """ Create form dialog and return result (if Cancel button is pressed, return None) :...
[ "def", "fedit", "(", "data", ",", "title", "=", "\"\"", ",", "comment", "=", "\"\"", ",", "icon", "=", "None", ",", "parent", "=", "None", ",", "apply", "=", "None", ",", "ok", "=", "True", ",", "cancel", "=", "True", ",", "result", "=", "'list'"...
Create form dialog and return result (if Cancel button is pressed, return None) :param tuple data: datalist, datagroup (see below) :param str title: form title :param str comment: header comment :param QIcon icon: dialog box icon :param QWidget parent: parent widget :param str ok: customize...
[ "Create", "form", "dialog", "and", "return", "result", "(", "if", "Cancel", "button", "is", "pressed", "return", "None", ")" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L1190-L1266
PierreRaybaut/formlayout
formlayout.py
FormWidget.get_dialog
def get_dialog(self): """Return FormDialog instance""" dialog = self.parent() while not isinstance(dialog, QDialog): dialog = dialog.parent() return dialog
python
def get_dialog(self): """Return FormDialog instance""" dialog = self.parent() while not isinstance(dialog, QDialog): dialog = dialog.parent() return dialog
[ "def", "get_dialog", "(", "self", ")", ":", "dialog", "=", "self", ".", "parent", "(", ")", "while", "not", "isinstance", "(", "dialog", ",", "QDialog", ")", ":", "dialog", "=", "dialog", ".", "parent", "(", ")", "return", "dialog" ]
Return FormDialog instance
[ "Return", "FormDialog", "instance" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L548-L553
PierreRaybaut/formlayout
formlayout.py
FormDialog.get
def get(self): """Return form result""" # It is import to avoid accessing Qt C++ object as it has probably # already been destroyed, due to the Qt.WA_DeleteOnClose attribute if self.outfile: if self.result in ['list', 'dict', 'OrderedDict']: fd = open(self.out...
python
def get(self): """Return form result""" # It is import to avoid accessing Qt C++ object as it has probably # already been destroyed, due to the Qt.WA_DeleteOnClose attribute if self.outfile: if self.result in ['list', 'dict', 'OrderedDict']: fd = open(self.out...
[ "def", "get", "(", "self", ")", ":", "# It is import to avoid accessing Qt C++ object as it has probably", "# already been destroyed, due to the Qt.WA_DeleteOnClose attribute", "if", "self", ".", "outfile", ":", "if", "self", ".", "result", "in", "[", "'list'", ",", "'dict'...
Return form result
[ "Return", "form", "result" ]
train
https://github.com/PierreRaybaut/formlayout/blob/832a0ef7a5c1c4a3205ffd94ccd41d7c833cb6f0/formlayout.py#L1168-L1187
quantmind/dynts
dynts/api/timeseries.py
ts_merge
def ts_merge(series): '''Merge timeseries into a new :class:`~.TimeSeries` instance. :parameter series: an iterable over :class:`~.TimeSeries`. ''' series = iter(series) ts = next(series) return ts.merge(series)
python
def ts_merge(series): '''Merge timeseries into a new :class:`~.TimeSeries` instance. :parameter series: an iterable over :class:`~.TimeSeries`. ''' series = iter(series) ts = next(series) return ts.merge(series)
[ "def", "ts_merge", "(", "series", ")", ":", "series", "=", "iter", "(", "series", ")", "ts", "=", "next", "(", "series", ")", "return", "ts", ".", "merge", "(", "series", ")" ]
Merge timeseries into a new :class:`~.TimeSeries` instance. :parameter series: an iterable over :class:`~.TimeSeries`.
[ "Merge", "timeseries", "into", "a", "new", ":", "class", ":", "~", ".", "TimeSeries", "instance", ".", ":", "parameter", "series", ":", "an", "iterable", "over", ":", "class", ":", "~", ".", "TimeSeries", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L31-L38
quantmind/dynts
dynts/api/timeseries.py
ts_bin_op
def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None): '''Entry point for any arithmetic type function performed on a timeseries and/or a scalar. op_name - name of the function to be performed ts1, ts2 - timeseries or scalars that the function is to performed over all - whether all d...
python
def ts_bin_op(op_name, ts1, ts2, all=True, fill=None, name=None): '''Entry point for any arithmetic type function performed on a timeseries and/or a scalar. op_name - name of the function to be performed ts1, ts2 - timeseries or scalars that the function is to performed over all - whether all d...
[ "def", "ts_bin_op", "(", "op_name", ",", "ts1", ",", "ts2", ",", "all", "=", "True", ",", "fill", "=", "None", ",", "name", "=", "None", ")", ":", "op", "=", "op_get", "(", "op_name", ")", "fill", "=", "fill", "if", "fill", "is", "not", "None", ...
Entry point for any arithmetic type function performed on a timeseries and/or a scalar. op_name - name of the function to be performed ts1, ts2 - timeseries or scalars that the function is to performed over all - whether all dates should be included in the result fill - the value that should be...
[ "Entry", "point", "for", "any", "arithmetic", "type", "function", "performed", "on", "a", "timeseries", "and", "/", "or", "a", "scalar", ".", "op_name", "-", "name", "of", "the", "function", "to", "be", "performed", "ts1", "ts2", "-", "timeseries", "or", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L41-L72
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.getalgo
def getalgo(self, operation, name): '''Return the algorithm for *operation* named *name*''' if operation not in self._algorithms: raise NotAvailable('{0} not registered.'.format(operation)) oper = self._algorithms[operation] try: return oper[name] e...
python
def getalgo(self, operation, name): '''Return the algorithm for *operation* named *name*''' if operation not in self._algorithms: raise NotAvailable('{0} not registered.'.format(operation)) oper = self._algorithms[operation] try: return oper[name] e...
[ "def", "getalgo", "(", "self", ",", "operation", ",", "name", ")", ":", "if", "operation", "not", "in", "self", ".", "_algorithms", ":", "raise", "NotAvailable", "(", "'{0} not registered.'", ".", "format", "(", "operation", ")", ")", "oper", "=", "self", ...
Return the algorithm for *operation* named *name*
[ "Return", "the", "algorithm", "for", "*", "operation", "*", "named", "*", "name", "*" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L119-L128
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.dates
def dates(self, desc=None): '''Returns an iterable over ``datetime.date`` instances in the timeseries.''' c = self.dateinverse for key in self.keys(desc=desc): yield c(key)
python
def dates(self, desc=None): '''Returns an iterable over ``datetime.date`` instances in the timeseries.''' c = self.dateinverse for key in self.keys(desc=desc): yield c(key)
[ "def", "dates", "(", "self", ",", "desc", "=", "None", ")", ":", "c", "=", "self", ".", "dateinverse", "for", "key", "in", "self", ".", "keys", "(", "desc", "=", "desc", ")", ":", "yield", "c", "(", "key", ")" ]
Returns an iterable over ``datetime.date`` instances in the timeseries.
[ "Returns", "an", "iterable", "over", "datetime", ".", "date", "instances", "in", "the", "timeseries", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L150-L155
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.items
def items(self, desc=None, start_value=None, shift_by=None): '''Returns a python ``generator`` which can be used to iterate over :func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values` returning a two dimensional tuple ``(date,value)`` in each iteration. Similar t...
python
def items(self, desc=None, start_value=None, shift_by=None): '''Returns a python ``generator`` which can be used to iterate over :func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values` returning a two dimensional tuple ``(date,value)`` in each iteration. Similar t...
[ "def", "items", "(", "self", ",", "desc", "=", "None", ",", "start_value", "=", "None", ",", "shift_by", "=", "None", ")", ":", "if", "self", ":", "if", "shift_by", "is", "None", "and", "start_value", "is", "not", "None", ":", "for", "cross", "in", ...
Returns a python ``generator`` which can be used to iterate over :func:`dynts.TimeSeries.dates` and :func:`dynts.TimeSeries.values` returning a two dimensional tuple ``(date,value)`` in each iteration. Similar to the python dictionary items function. :parameter de...
[ "Returns", "a", "python", "generator", "which", "can", "be", "used", "to", "iterate", "over", ":", "func", ":", "dynts", ".", "TimeSeries", ".", "dates", "and", ":", "func", ":", "dynts", ".", "TimeSeries", ".", "values", "returning", "a", "two", "dimens...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L170-L209
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.series
def series(self): '''Generator of single series data (no dates are included).''' data = self.values() if len(data): for c in range(self.count()): yield data[:, c] else: raise StopIteration
python
def series(self): '''Generator of single series data (no dates are included).''' data = self.values() if len(data): for c in range(self.count()): yield data[:, c] else: raise StopIteration
[ "def", "series", "(", "self", ")", ":", "data", "=", "self", ".", "values", "(", ")", "if", "len", "(", "data", ")", ":", "for", "c", "in", "range", "(", "self", ".", "count", "(", ")", ")", ":", "yield", "data", "[", ":", ",", "c", "]", "e...
Generator of single series data (no dates are included).
[ "Generator", "of", "single", "series", "data", "(", "no", "dates", "are", "included", ")", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L211-L218
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.named_series
def named_series(self, ordering=None): '''Generator of tuples with name and serie data.''' series = self.series() if ordering: series = list(series) todo = dict(((n, idx) for idx, n in enumerate(self.names()))) for name in ordering: if n...
python
def named_series(self, ordering=None): '''Generator of tuples with name and serie data.''' series = self.series() if ordering: series = list(series) todo = dict(((n, idx) for idx, n in enumerate(self.names()))) for name in ordering: if n...
[ "def", "named_series", "(", "self", ",", "ordering", "=", "None", ")", ":", "series", "=", "self", ".", "series", "(", ")", "if", "ordering", ":", "series", "=", "list", "(", "series", ")", "todo", "=", "dict", "(", "(", "(", "n", ",", "idx", ")"...
Generator of tuples with name and serie data.
[ "Generator", "of", "tuples", "with", "name", "and", "serie", "data", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L220-L235
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.clone
def clone(self, date=None, data=None, name=None): '''Create a clone of timeseries''' name = name or self.name data = data if data is not None else self.values() ts = self.__class__(name) ts._dtype = self._dtype if date is None: # dates not provided ...
python
def clone(self, date=None, data=None, name=None): '''Create a clone of timeseries''' name = name or self.name data = data if data is not None else self.values() ts = self.__class__(name) ts._dtype = self._dtype if date is None: # dates not provided ...
[ "def", "clone", "(", "self", ",", "date", "=", "None", ",", "data", "=", "None", ",", "name", "=", "None", ")", ":", "name", "=", "name", "or", "self", ".", "name", "data", "=", "data", "if", "data", "is", "not", "None", "else", "self", ".", "v...
Create a clone of timeseries
[ "Create", "a", "clone", "of", "timeseries" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L286-L297
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.reduce
def reduce(self, size, method='simple', **kwargs): '''Trim :class:`Timeseries` to a new *size* using the algorithm *method*. If *size* is greater or equal than len(self) it does nothing.''' if size >= len(self): return self return self.getalgo('reduce', method)(self, size, **kwa...
python
def reduce(self, size, method='simple', **kwargs): '''Trim :class:`Timeseries` to a new *size* using the algorithm *method*. If *size* is greater or equal than len(self) it does nothing.''' if size >= len(self): return self return self.getalgo('reduce', method)(self, size, **kwa...
[ "def", "reduce", "(", "self", ",", "size", ",", "method", "=", "'simple'", ",", "*", "*", "kwargs", ")", ":", "if", "size", ">=", "len", "(", "self", ")", ":", "return", "self", "return", "self", ".", "getalgo", "(", "'reduce'", ",", "method", ")",...
Trim :class:`Timeseries` to a new *size* using the algorithm *method*. If *size* is greater or equal than len(self) it does nothing.
[ "Trim", ":", "class", ":", "Timeseries", "to", "a", "new", "*", "size", "*", "using", "the", "algorithm", "*", "method", "*", ".", "If", "*", "size", "*", "is", "greater", "or", "equal", "than", "len", "(", "self", ")", "it", "does", "nothing", "."...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L299-L304
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.clean
def clean(self, algorithm=None): '''Create a new :class:`TimeSeries` with missing data removed or replaced by the *algorithm* provided''' # all dates original_dates = list(self.dates()) series = [] all_dates = set() for serie in self.series(): dstart, ...
python
def clean(self, algorithm=None): '''Create a new :class:`TimeSeries` with missing data removed or replaced by the *algorithm* provided''' # all dates original_dates = list(self.dates()) series = [] all_dates = set() for serie in self.series(): dstart, ...
[ "def", "clean", "(", "self", ",", "algorithm", "=", "None", ")", ":", "# all dates\r", "original_dates", "=", "list", "(", "self", ".", "dates", "(", ")", ")", "series", "=", "[", "]", "all_dates", "=", "set", "(", ")", "for", "serie", "in", "self", ...
Create a new :class:`TimeSeries` with missing data removed or replaced by the *algorithm* provided
[ "Create", "a", "new", ":", "class", ":", "TimeSeries", "with", "missing", "data", "removed", "or", "replaced", "by", "the", "*", "algorithm", "*", "provided" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L306-L356
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.isconsistent
def isconsistent(self): '''Check if the timeseries is consistent''' for dt1, dt0 in laggeddates(self): if dt1 <= dt0: return False return True
python
def isconsistent(self): '''Check if the timeseries is consistent''' for dt1, dt0 in laggeddates(self): if dt1 <= dt0: return False return True
[ "def", "isconsistent", "(", "self", ")", ":", "for", "dt1", ",", "dt0", "in", "laggeddates", "(", "self", ")", ":", "if", "dt1", "<=", "dt0", ":", "return", "False", "return", "True" ]
Check if the timeseries is consistent
[ "Check", "if", "the", "timeseries", "is", "consistent" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L394-L399
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.var
def var(self, ddof=0): '''Calculate variance of timeseries. Return a vector containing the variances of each series in the timeseries. :parameter ddof: delta degree of freedom, the divisor used in the calculation is given by ``N - ddof`` where ``N`` represents the length ...
python
def var(self, ddof=0): '''Calculate variance of timeseries. Return a vector containing the variances of each series in the timeseries. :parameter ddof: delta degree of freedom, the divisor used in the calculation is given by ``N - ddof`` where ``N`` represents the length ...
[ "def", "var", "(", "self", ",", "ddof", "=", "0", ")", ":", "N", "=", "len", "(", "self", ")", "if", "N", ":", "v", "=", "self", ".", "values", "(", ")", "mu", "=", "sum", "(", "v", ")", "return", "(", "sum", "(", "v", "*", "v", ")", "-...
Calculate variance of timeseries. Return a vector containing the variances of each series in the timeseries. :parameter ddof: delta degree of freedom, the divisor used in the calculation is given by ``N - ddof`` where ``N`` represents the length of timeseries. Default ``0``. ....
[ "Calculate", "variance", "of", "timeseries", ".", "Return", "a", "vector", "containing", "the", "variances", "of", "each", "series", "in", "the", "timeseries", ".", ":", "parameter", "ddof", ":", "delta", "degree", "of", "freedom", "the", "divisor", "used", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L461-L479
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.sd
def sd(self): '''Calculate standard deviation of timeseries''' v = self.var() if len(v): return np.sqrt(v) else: return None
python
def sd(self): '''Calculate standard deviation of timeseries''' v = self.var() if len(v): return np.sqrt(v) else: return None
[ "def", "sd", "(", "self", ")", ":", "v", "=", "self", ".", "var", "(", ")", "if", "len", "(", "v", ")", ":", "return", "np", ".", "sqrt", "(", "v", ")", "else", ":", "return", "None" ]
Calculate standard deviation of timeseries
[ "Calculate", "standard", "deviation", "of", "timeseries" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L481-L487
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.apply
def apply(self, func, window=None, bycolumn=True, align=None, **kwargs): '''Apply function ``func`` to the timeseries. :keyword func: string indicating function to apply :keyword window: Rolling window, If not defined ``func`` is applied on the whole dataset. Default ``None``. ...
python
def apply(self, func, window=None, bycolumn=True, align=None, **kwargs): '''Apply function ``func`` to the timeseries. :keyword func: string indicating function to apply :keyword window: Rolling window, If not defined ``func`` is applied on the whole dataset. Default ``None``. ...
[ "def", "apply", "(", "self", ",", "func", ",", "window", "=", "None", ",", "bycolumn", "=", "True", ",", "align", "=", "None", ",", "*", "*", "kwargs", ")", ":", "N", "=", "len", "(", "self", ")", "window", "=", "window", "or", "N", "self", "."...
Apply function ``func`` to the timeseries. :keyword func: string indicating function to apply :keyword window: Rolling window, If not defined ``func`` is applied on the whole dataset. Default ``None``. :keyword bycolumn: If ``True``, function ``func`` is applied on ...
[ "Apply", "function", "func", "to", "the", "timeseries", ".", ":", "keyword", "func", ":", "string", "indicating", "function", "to", "apply", ":", "keyword", "window", ":", "Rolling", "window", "If", "not", "defined", "func", "is", "applied", "on", "the", "...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L489-L510
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.rollapply
def rollapply(self, func, window=20, **kwargs): '''A generic :ref:`rolling function <rolling-function>` for function *func*. Same construct as :meth:`dynts.TimeSeries.apply` but with default ``window`` set to ``20``. ''' return self.apply(func, window=window, **kwar...
python
def rollapply(self, func, window=20, **kwargs): '''A generic :ref:`rolling function <rolling-function>` for function *func*. Same construct as :meth:`dynts.TimeSeries.apply` but with default ``window`` set to ``20``. ''' return self.apply(func, window=window, **kwar...
[ "def", "rollapply", "(", "self", ",", "func", ",", "window", "=", "20", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "apply", "(", "func", ",", "window", "=", "window", ",", "*", "*", "kwargs", ")" ]
A generic :ref:`rolling function <rolling-function>` for function *func*. Same construct as :meth:`dynts.TimeSeries.apply` but with default ``window`` set to ``20``.
[ "A", "generic", ":", "ref", ":", "rolling", "function", "<rolling", "-", "function", ">", "for", "function", "*", "func", "*", ".", "Same", "construct", "as", ":", "meth", ":", "dynts", ".", "TimeSeries", ".", "apply", "but", "with", "default", "window",...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L512-L518
quantmind/dynts
dynts/api/timeseries.py
TimeSeries.rollsd
def rollsd(self, scale=1, **kwargs): '''A :ref:`rolling function <rolling-function>` for stadard-deviation values: Same as:: self.rollapply('sd', **kwargs) ''' ts = self.rollapply('sd', **kwargs) if scale != 1: ts *= scale return...
python
def rollsd(self, scale=1, **kwargs): '''A :ref:`rolling function <rolling-function>` for stadard-deviation values: Same as:: self.rollapply('sd', **kwargs) ''' ts = self.rollapply('sd', **kwargs) if scale != 1: ts *= scale return...
[ "def", "rollsd", "(", "self", ",", "scale", "=", "1", ",", "*", "*", "kwargs", ")", ":", "ts", "=", "self", ".", "rollapply", "(", "'sd'", ",", "*", "*", "kwargs", ")", "if", "scale", "!=", "1", ":", "ts", "*=", "scale", "return", "ts" ]
A :ref:`rolling function <rolling-function>` for stadard-deviation values: Same as:: self.rollapply('sd', **kwargs)
[ "A", ":", "ref", ":", "rolling", "function", "<rolling", "-", "function", ">", "for", "stadard", "-", "deviation", "values", ":", "Same", "as", "::", "self", ".", "rollapply", "(", "sd", "**", "kwargs", ")" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/timeseries.py#L552-L562
quantmind/dynts
dynts/dsl/ast/base.py
Expr.unwind
def unwind(self, values, backend, **kwargs): '''Unwind expression by applying *values* to the abstract nodes. The ``kwargs`` dictionary can contain data which can be used to override values ''' if not hasattr(self, "_unwind_value"): self._unwind_value = self._...
python
def unwind(self, values, backend, **kwargs): '''Unwind expression by applying *values* to the abstract nodes. The ``kwargs`` dictionary can contain data which can be used to override values ''' if not hasattr(self, "_unwind_value"): self._unwind_value = self._...
[ "def", "unwind", "(", "self", ",", "values", ",", "backend", ",", "*", "*", "kwargs", ")", ":", "if", "not", "hasattr", "(", "self", ",", "\"_unwind_value\"", ")", ":", "self", ".", "_unwind_value", "=", "self", ".", "_unwind", "(", "values", ",", "b...
Unwind expression by applying *values* to the abstract nodes. The ``kwargs`` dictionary can contain data which can be used to override values
[ "Unwind", "expression", "by", "applying", "*", "values", "*", "to", "the", "abstract", "nodes", ".", "The", "kwargs", "dictionary", "can", "contain", "data", "which", "can", "be", "used", "to", "override", "values" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/ast/base.py#L43-L51
quantmind/dynts
dynts/dsl/ast/base.py
MultiExpression.removeduplicates
def removeduplicates(self, entries = None): ''' Loop over children a remove duplicate entries. @return - a list of removed entries ''' removed = [] if entries == None: entries = {} new_children = [] for c in self.children: ...
python
def removeduplicates(self, entries = None): ''' Loop over children a remove duplicate entries. @return - a list of removed entries ''' removed = [] if entries == None: entries = {} new_children = [] for c in self.children: ...
[ "def", "removeduplicates", "(", "self", ",", "entries", "=", "None", ")", ":", "removed", "=", "[", "]", "if", "entries", "==", "None", ":", "entries", "=", "{", "}", "new_children", "=", "[", "]", "for", "c", "in", "self", ".", "children", ":", "c...
Loop over children a remove duplicate entries. @return - a list of removed entries
[ "Loop", "over", "children", "a", "remove", "duplicate", "entries", "." ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/ast/base.py#L209-L231
doakey3/DashTable
dashtable/html2md.py
html2md
def html2md(html_string): """ Convert a string or html file to a markdown table string. Parameters ---------- html_string : str Either the html string, or the filepath to the html Returns ------- str The html table converted to a Markdown table Notes ----- ...
python
def html2md(html_string): """ Convert a string or html file to a markdown table string. Parameters ---------- html_string : str Either the html string, or the filepath to the html Returns ------- str The html table converted to a Markdown table Notes ----- ...
[ "def", "html2md", "(", "html_string", ")", ":", "if", "os", ".", "path", ".", "isfile", "(", "html_string", ")", ":", "file", "=", "open", "(", "html_string", ",", "'r'", ",", "encoding", "=", "'utf-8'", ")", "lines", "=", "file", ".", "readlines", "...
Convert a string or html file to a markdown table string. Parameters ---------- html_string : str Either the html string, or the filepath to the html Returns ------- str The html table converted to a Markdown table Notes ----- This function requires BeautifulSoup_ ...
[ "Convert", "a", "string", "or", "html", "file", "to", "a", "markdown", "table", "string", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2md.py#L6-L70
doakey3/DashTable
dashtable/data2rst/table_cells_2_spans.py
table_cells_2_spans
def table_cells_2_spans(table, spans): """ Converts the table to a list of spans, for consistency. This method combines the table data with the span data into a single, more consistent type. Any normal cell will become a span of just 1 column and 1 row. Parameters ---------- table : li...
python
def table_cells_2_spans(table, spans): """ Converts the table to a list of spans, for consistency. This method combines the table data with the span data into a single, more consistent type. Any normal cell will become a span of just 1 column and 1 row. Parameters ---------- table : li...
[ "def", "table_cells_2_spans", "(", "table", ",", "spans", ")", ":", "new_spans", "=", "[", "]", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", "for", "column", "in", "range", "(", "len", "(", "table", "[", "row", "]", ")", ...
Converts the table to a list of spans, for consistency. This method combines the table data with the span data into a single, more consistent type. Any normal cell will become a span of just 1 column and 1 row. Parameters ---------- table : list of lists of str spans : list of lists of int...
[ "Converts", "the", "table", "to", "a", "list", "of", "spans", "for", "consistency", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/data2rst/table_cells_2_spans.py#L4-L34
quantmind/dynts
dynts/backends/r/base.py
RTS.keys
def keys(self, desc = None): '''numpy asarray does not copy data''' res = asarray(self.rc('index')) if desc == True: return reversed(res) else: return res
python
def keys(self, desc = None): '''numpy asarray does not copy data''' res = asarray(self.rc('index')) if desc == True: return reversed(res) else: return res
[ "def", "keys", "(", "self", ",", "desc", "=", "None", ")", ":", "res", "=", "asarray", "(", "self", ".", "rc", "(", "'index'", ")", ")", "if", "desc", "==", "True", ":", "return", "reversed", "(", "res", ")", "else", ":", "return", "res" ]
numpy asarray does not copy data
[ "numpy", "asarray", "does", "not", "copy", "data" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L54-L60
quantmind/dynts
dynts/backends/r/base.py
RTS.values
def values(self, desc = None): '''numpy asarray does not copy data''' if self._ts: res = asarray(self._ts) if desc == True: return reversed(res) else: return res else: return ndarray([0,0])
python
def values(self, desc = None): '''numpy asarray does not copy data''' if self._ts: res = asarray(self._ts) if desc == True: return reversed(res) else: return res else: return ndarray([0,0])
[ "def", "values", "(", "self", ",", "desc", "=", "None", ")", ":", "if", "self", ".", "_ts", ":", "res", "=", "asarray", "(", "self", ".", "_ts", ")", "if", "desc", "==", "True", ":", "return", "reversed", "(", "res", ")", "else", ":", "return", ...
numpy asarray does not copy data
[ "numpy", "asarray", "does", "not", "copy", "data" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L62-L71
quantmind/dynts
dynts/backends/r/base.py
RTS.rcts
def rcts(self, command, *args, **kwargs): '''General function for applying a rolling R function to a timeserie''' cls = self.__class__ name = kwargs.pop('name','') date = kwargs.pop('date',None) data = kwargs.pop('data',None) kwargs.pop('bycolumn',None) ts ...
python
def rcts(self, command, *args, **kwargs): '''General function for applying a rolling R function to a timeserie''' cls = self.__class__ name = kwargs.pop('name','') date = kwargs.pop('date',None) data = kwargs.pop('data',None) kwargs.pop('bycolumn',None) ts ...
[ "def", "rcts", "(", "self", ",", "command", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "cls", "=", "self", ".", "__class__", "name", "=", "kwargs", ".", "pop", "(", "'name'", ",", "''", ")", "date", "=", "kwargs", ".", "pop", "(", "'d...
General function for applying a rolling R function to a timeserie
[ "General", "function", "for", "applying", "a", "rolling", "R", "function", "to", "a", "timeserie" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/backends/r/base.py#L117-L126
doakey3/DashTable
dashtable/html2data/get_html_column_count.py
get_html_column_count
def get_html_column_count(html_string): """ Gets the number of columns in an html table. Paramters --------- html_string : str Returns ------- int The number of columns in the table """ try: from bs4 import BeautifulSoup except ImportError: print("ER...
python
def get_html_column_count(html_string): """ Gets the number of columns in an html table. Paramters --------- html_string : str Returns ------- int The number of columns in the table """ try: from bs4 import BeautifulSoup except ImportError: print("ER...
[ "def", "get_html_column_count", "(", "html_string", ")", ":", "try", ":", "from", "bs4", "import", "BeautifulSoup", "except", "ImportError", ":", "print", "(", "\"ERROR: You must have BeautifulSoup to use html2data\"", ")", "return", "soup", "=", "BeautifulSoup", "(", ...
Gets the number of columns in an html table. Paramters --------- html_string : str Returns ------- int The number of columns in the table
[ "Gets", "the", "number", "of", "columns", "in", "an", "html", "table", "." ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/html2data/get_html_column_count.py#L1-L47
doakey3/DashTable
dashtable/dashutils/add_cushions.py
add_cushions
def add_cushions(table): """ Add space to start and end of each string in a list of lists Parameters ---------- table : list of lists of str A table of rows of strings. For example:: [ ['dog', 'cat', 'bicycle'], ['mouse', trumpet', ''] ...
python
def add_cushions(table): """ Add space to start and end of each string in a list of lists Parameters ---------- table : list of lists of str A table of rows of strings. For example:: [ ['dog', 'cat', 'bicycle'], ['mouse', trumpet', ''] ...
[ "def", "add_cushions", "(", "table", ")", ":", "for", "row", "in", "range", "(", "len", "(", "table", ")", ")", ":", "for", "column", "in", "range", "(", "len", "(", "table", "[", "row", "]", ")", ")", ":", "lines", "=", "table", "[", "row", "]...
Add space to start and end of each string in a list of lists Parameters ---------- table : list of lists of str A table of rows of strings. For example:: [ ['dog', 'cat', 'bicycle'], ['mouse', trumpet', ''] ] Returns ------- tabl...
[ "Add", "space", "to", "start", "and", "end", "of", "each", "string", "in", "a", "list", "of", "lists" ]
train
https://github.com/doakey3/DashTable/blob/744cfb6a717fa75a8092c83ebcd49b2668023681/dashtable/dashutils/add_cushions.py#L1-L48
quantmind/dynts
dynts/api/roll.py
rollsingle
def rollsingle(self, func, window=20, name=None, fallback=False, align='right', **kwargs): '''Efficient rolling window calculation for min, max type functions ''' rname = 'roll_{0}'.format(func) if fallback: rfunc = getattr(lib.fallback, rname) else: rfunc = getattr(li...
python
def rollsingle(self, func, window=20, name=None, fallback=False, align='right', **kwargs): '''Efficient rolling window calculation for min, max type functions ''' rname = 'roll_{0}'.format(func) if fallback: rfunc = getattr(lib.fallback, rname) else: rfunc = getattr(li...
[ "def", "rollsingle", "(", "self", ",", "func", ",", "window", "=", "20", ",", "name", "=", "None", ",", "fallback", "=", "False", ",", "align", "=", "'right'", ",", "*", "*", "kwargs", ")", ":", "rname", "=", "'roll_{0}'", ".", "format", "(", "func...
Efficient rolling window calculation for min, max type functions
[ "Efficient", "rolling", "window", "calculation", "for", "min", "max", "type", "functions" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/api/roll.py#L8-L27
quantmind/dynts
dynts/utils/wrappers.py
asbtree.find_ge
def find_ge(self, dt): '''Building block of all searches. Find the index corresponding to the leftmost value greater or equal to *dt*. If *dt* is greater than the :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound` exception will raise. *dt* must be a python datetime.date instance.'...
python
def find_ge(self, dt): '''Building block of all searches. Find the index corresponding to the leftmost value greater or equal to *dt*. If *dt* is greater than the :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound` exception will raise. *dt* must be a python datetime.date instance.'...
[ "def", "find_ge", "(", "self", ",", "dt", ")", ":", "i", "=", "bisect_left", "(", "self", ".", "dates", ",", "dt", ")", "if", "i", "!=", "len", "(", "self", ".", "dates", ")", ":", "return", "i", "raise", "RightOutOfBound" ]
Building block of all searches. Find the index corresponding to the leftmost value greater or equal to *dt*. If *dt* is greater than the :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.RightOutOfBound` exception will raise. *dt* must be a python datetime.date instance.
[ "Building", "block", "of", "all", "searches", ".", "Find", "the", "index", "corresponding", "to", "the", "leftmost", "value", "greater", "or", "equal", "to", "*", "dt", "*", ".", "If", "*", "dt", "*", "is", "greater", "than", "the", ":", "func", ":", ...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/wrappers.py#L77-L88
quantmind/dynts
dynts/utils/wrappers.py
asbtree.find_le
def find_le(self, dt): '''Find the index corresponding to the rightmost value less than or equal to *dt*. If *dt* is less than :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.LeftOutOfBound` exception will raise. *dt* must be a python datetime.date instance.''' i = bisect_right(self.dat...
python
def find_le(self, dt): '''Find the index corresponding to the rightmost value less than or equal to *dt*. If *dt* is less than :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.LeftOutOfBound` exception will raise. *dt* must be a python datetime.date instance.''' i = bisect_right(self.dat...
[ "def", "find_le", "(", "self", ",", "dt", ")", ":", "i", "=", "bisect_right", "(", "self", ".", "dates", ",", "dt", ")", "if", "i", ":", "return", "i", "-", "1", "raise", "LeftOutOfBound" ]
Find the index corresponding to the rightmost value less than or equal to *dt*. If *dt* is less than :func:`dynts.TimeSeries.end` a :class:`dynts.exceptions.LeftOutOfBound` exception will raise. *dt* must be a python datetime.date instance.
[ "Find", "the", "index", "corresponding", "to", "the", "rightmost", "value", "less", "than", "or", "equal", "to", "*", "dt", "*", ".", "If", "*", "dt", "*", "is", "less", "than", ":", "func", ":", "dynts", ".", "TimeSeries", ".", "end", "a", ":", "c...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/utils/wrappers.py#L90-L101
inveniosoftware/invenio-db
invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py
upgrade
def upgrade(): """Update database.""" op.create_table( 'transaction', sa.Column('issued_at', sa.DateTime(), nullable=True), sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('remote_addr', sa.String(length=50), nullable=True), ) op.create_primary_key('pk_transac...
python
def upgrade(): """Update database.""" op.create_table( 'transaction', sa.Column('issued_at', sa.DateTime(), nullable=True), sa.Column('id', sa.BigInteger(), nullable=False), sa.Column('remote_addr', sa.String(length=50), nullable=True), ) op.create_primary_key('pk_transac...
[ "def", "upgrade", "(", ")", ":", "op", ".", "create_table", "(", "'transaction'", ",", "sa", ".", "Column", "(", "'issued_at'", ",", "sa", ".", "DateTime", "(", ")", ",", "nullable", "=", "True", ")", ",", "sa", ".", "Column", "(", "'id'", ",", "sa...
Update database.
[ "Update", "database", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py#L23-L33
inveniosoftware/invenio-db
invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py
downgrade
def downgrade(): """Downgrade database.""" op.drop_table('transaction') if op._proxy.migration_context.dialect.supports_sequences: op.execute(DropSequence(Sequence('transaction_id_seq')))
python
def downgrade(): """Downgrade database.""" op.drop_table('transaction') if op._proxy.migration_context.dialect.supports_sequences: op.execute(DropSequence(Sequence('transaction_id_seq')))
[ "def", "downgrade", "(", ")", ":", "op", ".", "drop_table", "(", "'transaction'", ")", "if", "op", ".", "_proxy", ".", "migration_context", ".", "dialect", ".", "supports_sequences", ":", "op", ".", "execute", "(", "DropSequence", "(", "Sequence", "(", "'t...
Downgrade database.
[ "Downgrade", "database", "." ]
train
https://github.com/inveniosoftware/invenio-db/blob/9009a4cf79574083e129909cf3d2656568550184/invenio_db/alembic/dbdbc1b19cf2_create_transaction_table.py#L36-L40
quantmind/dynts
dynts/dsl/rules.py
Rules.t_NUMBER
def t_NUMBER(self, t): r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?' try: sv = t.value v = float(sv) iv = int(v) t.value = (iv if iv == v else v, sv) except ValueError: print("Number %s is too large!" % t.value) ...
python
def t_NUMBER(self, t): r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?' try: sv = t.value v = float(sv) iv = int(v) t.value = (iv if iv == v else v, sv) except ValueError: print("Number %s is too large!" % t.value) ...
[ "def", "t_NUMBER", "(", "self", ",", "t", ")", ":", "try", ":", "sv", "=", "t", ".", "value", "v", "=", "float", "(", "sv", ")", "iv", "=", "int", "(", "v", ")", "t", ".", "value", "=", "(", "iv", "if", "iv", "==", "v", "else", "v", ",", ...
r'([0-9]+\.?[0-9]*|\.[0-9]+)([eE](\+|-)?[0-9]+)?
[ "r", "(", "[", "0", "-", "9", "]", "+", "\\", ".", "?", "[", "0", "-", "9", "]", "*", "|", "\\", ".", "[", "0", "-", "9", "]", "+", ")", "(", "[", "eE", "]", "(", "\\", "+", "|", "-", ")", "?", "[", "0", "-", "9", "]", "+", ")",...
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/rules.py#L64-L74
quantmind/dynts
dynts/dsl/rules.py
Rules.t_ID
def t_ID(self, t): r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]*' res = self.oper.get(t.value, None) # Check for reserved words if res is None: res = t.value.upper() if res == 'FALSE': t.type = 'BOOL' t.value = False elif res == '...
python
def t_ID(self, t): r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]*' res = self.oper.get(t.value, None) # Check for reserved words if res is None: res = t.value.upper() if res == 'FALSE': t.type = 'BOOL' t.value = False elif res == '...
[ "def", "t_ID", "(", "self", ",", "t", ")", ":", "res", "=", "self", ".", "oper", ".", "get", "(", "t", ".", "value", ",", "None", ")", "# Check for reserved words\r", "if", "res", "is", "None", ":", "res", "=", "t", ".", "value", ".", "upper", "(...
r'`[^`]*`|[a-zA-Z_][a-zA-Z_0-9:@]*
[ "r", "[", "^", "]", "*", "|", "[", "a", "-", "zA", "-", "Z_", "]", "[", "a", "-", "zA", "-", "Z_0", "-", "9", ":" ]
train
https://github.com/quantmind/dynts/blob/21ac57c648bfec402fa6b1fe569496cf098fb5e8/dynts/dsl/rules.py#L76-L92
eaton-lab/toytree
toytree/newick.py
read_newick
def read_newick(newick, root_node=None, format=0): """ Reads a newick tree from either a string or a file, and returns an ETE tree structure. A previously existent node object can be passed as the root of the tree, which means that all its new children will belong to the same class as the root...
python
def read_newick(newick, root_node=None, format=0): """ Reads a newick tree from either a string or a file, and returns an ETE tree structure. A previously existent node object can be passed as the root of the tree, which means that all its new children will belong to the same class as the root...
[ "def", "read_newick", "(", "newick", ",", "root_node", "=", "None", ",", "format", "=", "0", ")", ":", "## check newick type as a string or filepath, Toytree parses urls to str's", "if", "isinstance", "(", "newick", ",", "six", ".", "string_types", ")", ":", "if", ...
Reads a newick tree from either a string or a file, and returns an ETE tree structure. A previously existent node object can be passed as the root of the tree, which means that all its new children will belong to the same class as the root (This allows to work with custom TreeNode objects). You ca...
[ "Reads", "a", "newick", "tree", "from", "either", "a", "string", "or", "a", "file", "and", "returns", "an", "ETE", "tree", "structure", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L162-L197
eaton-lab/toytree
toytree/newick.py
_read_newick_from_string
def _read_newick_from_string(nw, root_node, matcher, formatcode): """ Reads a newick string in the New Hampshire format. """ if nw.count('(') != nw.count(')'): raise NewickError('Parentheses do not match. Broken tree structure?') # white spaces and separators are removed nw = re.sub("[\n\r\t]+"...
python
def _read_newick_from_string(nw, root_node, matcher, formatcode): """ Reads a newick string in the New Hampshire format. """ if nw.count('(') != nw.count(')'): raise NewickError('Parentheses do not match. Broken tree structure?') # white spaces and separators are removed nw = re.sub("[\n\r\t]+"...
[ "def", "_read_newick_from_string", "(", "nw", ",", "root_node", ",", "matcher", ",", "formatcode", ")", ":", "if", "nw", ".", "count", "(", "'('", ")", "!=", "nw", ".", "count", "(", "')'", ")", ":", "raise", "NewickError", "(", "'Parentheses do not match....
Reads a newick string in the New Hampshire format.
[ "Reads", "a", "newick", "string", "in", "the", "New", "Hampshire", "format", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L201-L250
eaton-lab/toytree
toytree/newick.py
_parse_extra_features
def _parse_extra_features(node, NHX_string): """ Reads node's extra data form its NHX string. NHX uses this format: [&&NHX:prop1=value1:prop2=value2] """ NHX_string = NHX_string.replace("[&&NHX:", "") NHX_string = NHX_string.replace("]", "") for field in NHX_string.split(":"): try...
python
def _parse_extra_features(node, NHX_string): """ Reads node's extra data form its NHX string. NHX uses this format: [&&NHX:prop1=value1:prop2=value2] """ NHX_string = NHX_string.replace("[&&NHX:", "") NHX_string = NHX_string.replace("]", "") for field in NHX_string.split(":"): try...
[ "def", "_parse_extra_features", "(", "node", ",", "NHX_string", ")", ":", "NHX_string", "=", "NHX_string", ".", "replace", "(", "\"[&&NHX:\"", ",", "\"\"", ")", "NHX_string", "=", "NHX_string", ".", "replace", "(", "\"]\"", ",", "\"\"", ")", "for", "field", ...
Reads node's extra data form its NHX string. NHX uses this format: [&&NHX:prop1=value1:prop2=value2]
[ "Reads", "node", "s", "extra", "data", "form", "its", "NHX", "string", ".", "NHX", "uses", "this", "format", ":", "[", "&&NHX", ":", "prop1", "=", "value1", ":", "prop2", "=", "value2", "]" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L254-L266
eaton-lab/toytree
toytree/newick.py
compile_matchers
def compile_matchers(formatcode): """ Tests newick string against format types? and makes a re.compile """ matchers = {} for node_type in ["leaf", "single", "internal"]: if node_type == "leaf" or node_type == "single": container1 = NW_FORMAT[formatcode][0][0] containe...
python
def compile_matchers(formatcode): """ Tests newick string against format types? and makes a re.compile """ matchers = {} for node_type in ["leaf", "single", "internal"]: if node_type == "leaf" or node_type == "single": container1 = NW_FORMAT[formatcode][0][0] containe...
[ "def", "compile_matchers", "(", "formatcode", ")", ":", "matchers", "=", "{", "}", "for", "node_type", "in", "[", "\"leaf\"", ",", "\"single\"", ",", "\"internal\"", "]", ":", "if", "node_type", "==", "\"leaf\"", "or", "node_type", "==", "\"single\"", ":", ...
Tests newick string against format types? and makes a re.compile
[ "Tests", "newick", "string", "against", "format", "types?", "and", "makes", "a", "re", ".", "compile" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L271-L315
eaton-lab/toytree
toytree/newick.py
_read_node_data
def _read_node_data(subnw, current_node, node_type, matcher, formatcode): """ Reads a leaf node from a subpart of the original newicktree """ if node_type == "leaf" or node_type == "single": if node_type == "leaf": node = current_node.add_child() else: node = cu...
python
def _read_node_data(subnw, current_node, node_type, matcher, formatcode): """ Reads a leaf node from a subpart of the original newicktree """ if node_type == "leaf" or node_type == "single": if node_type == "leaf": node = current_node.add_child() else: node = cu...
[ "def", "_read_node_data", "(", "subnw", ",", "current_node", ",", "node_type", ",", "matcher", ",", "formatcode", ")", ":", "if", "node_type", "==", "\"leaf\"", "or", "node_type", "==", "\"single\"", ":", "if", "node_type", "==", "\"leaf\"", ":", "node", "="...
Reads a leaf node from a subpart of the original newicktree
[ "Reads", "a", "leaf", "node", "from", "a", "subpart", "of", "the", "original", "newicktree" ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L319-L358
eaton-lab/toytree
toytree/newick.py
write_newick
def write_newick(rootnode, features=None, format=1, format_root_node=True, is_leaf_fn=None, dist_formatter=None, support_formatter=None, name_formatter=None): """ Iteratively export a tree structure and returns its NHX representation. """ newick = [] leaf = is_leaf_fn if...
python
def write_newick(rootnode, features=None, format=1, format_root_node=True, is_leaf_fn=None, dist_formatter=None, support_formatter=None, name_formatter=None): """ Iteratively export a tree structure and returns its NHX representation. """ newick = [] leaf = is_leaf_fn if...
[ "def", "write_newick", "(", "rootnode", ",", "features", "=", "None", ",", "format", "=", "1", ",", "format_root_node", "=", "True", ",", "is_leaf_fn", "=", "None", ",", "dist_formatter", "=", "None", ",", "support_formatter", "=", "None", ",", "name_formatt...
Iteratively export a tree structure and returns its NHX representation.
[ "Iteratively", "export", "a", "tree", "structure", "and", "returns", "its", "NHX", "representation", "." ]
train
https://github.com/eaton-lab/toytree/blob/0347ed2098acc5f707fadf52a0ecd411a6d1859c/toytree/newick.py#L362-L401