repo
stringlengths
7
55
path
stringlengths
4
127
func_name
stringlengths
1
88
original_string
stringlengths
75
19.8k
language
stringclasses
1 value
code
stringlengths
75
19.8k
code_tokens
list
docstring
stringlengths
3
17.3k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
87
242
partition
stringclasses
1 value
LogicalDash/LiSE
ELiDE/ELiDE/stores.py
munge_source
def munge_source(v): """Take Python source code, return a pair of its parameters and the rest of it dedented""" lines = v.split('\n') if not lines: return tuple(), '' firstline = lines[0].lstrip() while firstline == '' or firstline[0] == '@': del lines[0] firstline = lines[0]...
python
def munge_source(v): """Take Python source code, return a pair of its parameters and the rest of it dedented""" lines = v.split('\n') if not lines: return tuple(), '' firstline = lines[0].lstrip() while firstline == '' or firstline[0] == '@': del lines[0] firstline = lines[0]...
[ "def", "munge_source", "(", "v", ")", ":", "lines", "=", "v", ".", "split", "(", "'\\n'", ")", "if", "not", "lines", ":", "return", "tuple", "(", ")", ",", "''", "firstline", "=", "lines", "[", "0", "]", ".", "lstrip", "(", ")", "while", "firstli...
Take Python source code, return a pair of its parameters and the rest of it dedented
[ "Take", "Python", "source", "code", "return", "a", "pair", "of", "its", "parameters", "and", "the", "rest", "of", "it", "dedented" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/stores.py#L440-L461
train
LogicalDash/LiSE
ELiDE/ELiDE/stores.py
StoreList.redata
def redata(self, *args, **kwargs): """Update my ``data`` to match what's in my ``store``""" select_name = kwargs.get('select_name') if not self.store: Clock.schedule_once(self.redata) return self.data = list(map(self.munge, enumerate(self._iter_keys()))) i...
python
def redata(self, *args, **kwargs): """Update my ``data`` to match what's in my ``store``""" select_name = kwargs.get('select_name') if not self.store: Clock.schedule_once(self.redata) return self.data = list(map(self.munge, enumerate(self._iter_keys()))) i...
[ "def", "redata", "(", "self", ",", "*", "args", ",", "**", "kwargs", ")", ":", "select_name", "=", "kwargs", ".", "get", "(", "'select_name'", ")", "if", "not", "self", ".", "store", ":", "Clock", ".", "schedule_once", "(", "self", ".", "redata", ")"...
Update my ``data`` to match what's in my ``store``
[ "Update", "my", "data", "to", "match", "what", "s", "in", "my", "store" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/stores.py#L133-L141
train
LogicalDash/LiSE
ELiDE/ELiDE/stores.py
StoreList.select_name
def select_name(self, name, *args): """Select an item by its name, highlighting""" self.boxl.select_node(self._name2i[name])
python
def select_name(self, name, *args): """Select an item by its name, highlighting""" self.boxl.select_node(self._name2i[name])
[ "def", "select_name", "(", "self", ",", "name", ",", "*", "args", ")", ":", "self", ".", "boxl", ".", "select_node", "(", "self", ".", "_name2i", "[", "name", "]", ")" ]
Select an item by its name, highlighting
[ "Select", "an", "item", "by", "its", "name", "highlighting" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/stores.py#L148-L150
train
LogicalDash/LiSE
ELiDE/ELiDE/stores.py
Editor.save
def save(self, *args): """Put text in my store, return True if it changed""" if self.name_wid is None or self.store is None: Logger.debug("{}: Not saving, missing name_wid or store".format(type(self).__name__)) return if not (self.name_wid.text or self.name_wid.hint_text)...
python
def save(self, *args): """Put text in my store, return True if it changed""" if self.name_wid is None or self.store is None: Logger.debug("{}: Not saving, missing name_wid or store".format(type(self).__name__)) return if not (self.name_wid.text or self.name_wid.hint_text)...
[ "def", "save", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "name_wid", "is", "None", "or", "self", ".", "store", "is", "None", ":", "Logger", ".", "debug", "(", "\"{}: Not saving, missing name_wid or store\"", ".", "format", "(", "type", ...
Put text in my store, return True if it changed
[ "Put", "text", "in", "my", "store", "return", "True", "if", "it", "changed" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/stores.py#L213-L256
train
LogicalDash/LiSE
ELiDE/ELiDE/stores.py
Editor.delete
def delete(self, *args): """Remove the currently selected item from my store""" key = self.name_wid.text or self.name_wid.hint_text if not hasattr(self.store, key): # TODO feedback about missing key return delattr(self.store, key) try: return m...
python
def delete(self, *args): """Remove the currently selected item from my store""" key = self.name_wid.text or self.name_wid.hint_text if not hasattr(self.store, key): # TODO feedback about missing key return delattr(self.store, key) try: return m...
[ "def", "delete", "(", "self", ",", "*", "args", ")", ":", "key", "=", "self", ".", "name_wid", ".", "text", "or", "self", ".", "name_wid", ".", "hint_text", "if", "not", "hasattr", "(", "self", ".", "store", ",", "key", ")", ":", "return", "delattr...
Remove the currently selected item from my store
[ "Remove", "the", "currently", "selected", "item", "from", "my", "store" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/stores.py#L258-L268
train
LogicalDash/LiSE
ELiDE/ELiDE/dialog.py
DialogLayout.advance_dialog
def advance_dialog(self, *args): """Try to display the next dialog described in my ``todo``.""" self.clear_widgets() try: self._update_dialog(self.todo[self.idx]) except IndexError: pass
python
def advance_dialog(self, *args): """Try to display the next dialog described in my ``todo``.""" self.clear_widgets() try: self._update_dialog(self.todo[self.idx]) except IndexError: pass
[ "def", "advance_dialog", "(", "self", ",", "*", "args", ")", ":", "self", ".", "clear_widgets", "(", ")", "try", ":", "self", ".", "_update_dialog", "(", "self", ".", "todo", "[", "self", ".", "idx", "]", ")", "except", "IndexError", ":", "pass" ]
Try to display the next dialog described in my ``todo``.
[ "Try", "to", "display", "the", "next", "dialog", "described", "in", "my", "todo", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/dialog.py#L186-L192
train
LogicalDash/LiSE
ELiDE/ELiDE/dialog.py
DialogLayout.ok
def ok(self, *args, cb=None): """Clear dialog widgets, call ``cb`` if provided, and advance the dialog queue""" self.clear_widgets() if cb: cb() self.idx += 1 self.advance_dialog()
python
def ok(self, *args, cb=None): """Clear dialog widgets, call ``cb`` if provided, and advance the dialog queue""" self.clear_widgets() if cb: cb() self.idx += 1 self.advance_dialog()
[ "def", "ok", "(", "self", ",", "*", "args", ",", "cb", "=", "None", ")", ":", "self", ".", "clear_widgets", "(", ")", "if", "cb", ":", "cb", "(", ")", "self", ".", "idx", "+=", "1", "self", ".", "advance_dialog", "(", ")" ]
Clear dialog widgets, call ``cb`` if provided, and advance the dialog queue
[ "Clear", "dialog", "widgets", "call", "cb", "if", "provided", "and", "advance", "the", "dialog", "queue" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/dialog.py#L233-L239
train
niemasd/TreeSwift
treeswift/Node.py
Node.add_child
def add_child(self, child): '''Add child to ``Node`` object Args: ``child`` (``Node``): The child ``Node`` to be added ''' if not isinstance(child, Node): raise TypeError("child must be a Node") self.children.append(child); child.parent = self
python
def add_child(self, child): '''Add child to ``Node`` object Args: ``child`` (``Node``): The child ``Node`` to be added ''' if not isinstance(child, Node): raise TypeError("child must be a Node") self.children.append(child); child.parent = self
[ "def", "add_child", "(", "self", ",", "child", ")", ":", "if", "not", "isinstance", "(", "child", ",", "Node", ")", ":", "raise", "TypeError", "(", "\"child must be a Node\"", ")", "self", ".", "children", ".", "append", "(", "child", ")", "child", ".", ...
Add child to ``Node`` object Args: ``child`` (``Node``): The child ``Node`` to be added
[ "Add", "child", "to", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L60-L68
train
niemasd/TreeSwift
treeswift/Node.py
Node.contract
def contract(self): '''Contract this ``Node`` by directly connecting its children to its parent''' if self.is_root(): return for c in self.children: if self.edge_length is not None and c.edge_length is not None: c.edge_length += self.edge_length ...
python
def contract(self): '''Contract this ``Node`` by directly connecting its children to its parent''' if self.is_root(): return for c in self.children: if self.edge_length is not None and c.edge_length is not None: c.edge_length += self.edge_length ...
[ "def", "contract", "(", "self", ")", ":", "if", "self", ".", "is_root", "(", ")", ":", "return", "for", "c", "in", "self", ".", "children", ":", "if", "self", ".", "edge_length", "is", "not", "None", "and", "c", ".", "edge_length", "is", "not", "No...
Contract this ``Node`` by directly connecting its children to its parent
[ "Contract", "this", "Node", "by", "directly", "connecting", "its", "children", "to", "its", "parent" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L78-L86
train
niemasd/TreeSwift
treeswift/Node.py
Node.newick
def newick(self): '''Newick string conversion starting at this ``Node`` object Returns: ``str``: Newick string conversion starting at this ``Node`` object ''' node_to_str = dict() for node in self.traverse_postorder(): if node.is_leaf(): i...
python
def newick(self): '''Newick string conversion starting at this ``Node`` object Returns: ``str``: Newick string conversion starting at this ``Node`` object ''' node_to_str = dict() for node in self.traverse_postorder(): if node.is_leaf(): i...
[ "def", "newick", "(", "self", ")", ":", "node_to_str", "=", "dict", "(", ")", "for", "node", "in", "self", ".", "traverse_postorder", "(", ")", ":", "if", "node", ".", "is_leaf", "(", ")", ":", "if", "node", ".", "label", "is", "None", ":", "node_t...
Newick string conversion starting at this ``Node`` object Returns: ``str``: Newick string conversion starting at this ``Node`` object
[ "Newick", "string", "conversion", "starting", "at", "this", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L128-L160
train
niemasd/TreeSwift
treeswift/Node.py
Node.remove_child
def remove_child(self, child): '''Remove child from ``Node`` object Args: ``child`` (``Node``): The child to remove ''' if not isinstance(child, Node): raise TypeError("child must be a Node") try: self.children.remove(child); child.parent = No...
python
def remove_child(self, child): '''Remove child from ``Node`` object Args: ``child`` (``Node``): The child to remove ''' if not isinstance(child, Node): raise TypeError("child must be a Node") try: self.children.remove(child); child.parent = No...
[ "def", "remove_child", "(", "self", ",", "child", ")", ":", "if", "not", "isinstance", "(", "child", ",", "Node", ")", ":", "raise", "TypeError", "(", "\"child must be a Node\"", ")", "try", ":", "self", ".", "children", ".", "remove", "(", "child", ")",...
Remove child from ``Node`` object Args: ``child`` (``Node``): The child to remove
[ "Remove", "child", "from", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L170-L181
train
niemasd/TreeSwift
treeswift/Node.py
Node.resolve_polytomies
def resolve_polytomies(self): '''Arbitrarily resolve polytomies below this ``Node`` with 0-lengthed edges.''' q = deque(); q.append(self) while len(q) != 0: node = q.popleft() while len(node.children) > 2: c1 = node.children.pop(); c2 = node.children.pop()...
python
def resolve_polytomies(self): '''Arbitrarily resolve polytomies below this ``Node`` with 0-lengthed edges.''' q = deque(); q.append(self) while len(q) != 0: node = q.popleft() while len(node.children) > 2: c1 = node.children.pop(); c2 = node.children.pop()...
[ "def", "resolve_polytomies", "(", "self", ")", ":", "q", "=", "deque", "(", ")", "q", ".", "append", "(", "self", ")", "while", "len", "(", "q", ")", "!=", "0", ":", "node", "=", "q", ".", "popleft", "(", ")", "while", "len", "(", "node", ".", ...
Arbitrarily resolve polytomies below this ``Node`` with 0-lengthed edges.
[ "Arbitrarily", "resolve", "polytomies", "below", "this", "Node", "with", "0", "-", "lengthed", "edges", "." ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L183-L192
train
niemasd/TreeSwift
treeswift/Node.py
Node.set_parent
def set_parent(self, parent): '''Set the parent of this ``Node`` object. Use this carefully, otherwise you may damage the structure of this ``Tree`` object. Args: ``Node``: The new parent of this ``Node`` ''' if not isinstance(parent, Node): raise TypeError("pare...
python
def set_parent(self, parent): '''Set the parent of this ``Node`` object. Use this carefully, otherwise you may damage the structure of this ``Tree`` object. Args: ``Node``: The new parent of this ``Node`` ''' if not isinstance(parent, Node): raise TypeError("pare...
[ "def", "set_parent", "(", "self", ",", "parent", ")", ":", "if", "not", "isinstance", "(", "parent", ",", "Node", ")", ":", "raise", "TypeError", "(", "\"parent must be a Node\"", ")", "self", ".", "parent", "=", "parent" ]
Set the parent of this ``Node`` object. Use this carefully, otherwise you may damage the structure of this ``Tree`` object. Args: ``Node``: The new parent of this ``Node``
[ "Set", "the", "parent", "of", "this", "Node", "object", ".", "Use", "this", "carefully", "otherwise", "you", "may", "damage", "the", "structure", "of", "this", "Tree", "object", "." ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L213-L221
train
niemasd/TreeSwift
treeswift/Node.py
Node.traverse_ancestors
def traverse_ancestors(self, include_self=True): '''Traverse over the ancestors of this ``Node`` Args: ``include_self`` (``bool``): ``True`` to include self in the traversal, otherwise ``False`` ''' if not isinstance(include_self, bool): raise TypeError("include_...
python
def traverse_ancestors(self, include_self=True): '''Traverse over the ancestors of this ``Node`` Args: ``include_self`` (``bool``): ``True`` to include self in the traversal, otherwise ``False`` ''' if not isinstance(include_self, bool): raise TypeError("include_...
[ "def", "traverse_ancestors", "(", "self", ",", "include_self", "=", "True", ")", ":", "if", "not", "isinstance", "(", "include_self", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"include_self must be a bool\"", ")", "if", "include_self", ":", "c", "=",...
Traverse over the ancestors of this ``Node`` Args: ``include_self`` (``bool``): ``True`` to include self in the traversal, otherwise ``False``
[ "Traverse", "over", "the", "ancestors", "of", "this", "Node" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L223-L236
train
niemasd/TreeSwift
treeswift/Node.py
Node.traverse_inorder
def traverse_inorder(self, leaves=True, internal=True): '''Perform an inorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``...
python
def traverse_inorder(self, leaves=True, internal=True): '''Perform an inorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``...
[ "def", "traverse_inorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "c", "=", "self", "s", "=", "deque", "(", ")", "done", "=", "False", "while", "not", "done", ":", "if", "c", "is", "None", ":", "if", "len...
Perform an inorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "an", "inorder", "traversal", "starting", "at", "this", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L263-L293
train
niemasd/TreeSwift
treeswift/Node.py
Node.traverse_levelorder
def traverse_levelorder(self, leaves=True, internal=True): '''Perform a levelorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``Fa...
python
def traverse_levelorder(self, leaves=True, internal=True): '''Perform a levelorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``Fa...
[ "def", "traverse_levelorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "q", "=", "deque", "(", ")", "q", ".", "append", "(", "self", ")", "while", "len", "(", "q", ")", "!=", "0", ":", "n", "=", "q", ".",...
Perform a levelorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "a", "levelorder", "traversal", "starting", "at", "this", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L305-L318
train
niemasd/TreeSwift
treeswift/Node.py
Node.traverse_postorder
def traverse_postorder(self, leaves=True, internal=True): '''Perform a postorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``Fals...
python
def traverse_postorder(self, leaves=True, internal=True): '''Perform a postorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``Fals...
[ "def", "traverse_postorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "s1", "=", "deque", "(", ")", "s2", "=", "deque", "(", ")", "s1", ".", "append", "(", "self", ")", "while", "len", "(", "s1", ")", "!=",...
Perform a postorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "a", "postorder", "traversal", "starting", "at", "this", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L320-L334
train
niemasd/TreeSwift
treeswift/Node.py
Node.traverse_preorder
def traverse_preorder(self, leaves=True, internal=True): '''Perform a preorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`...
python
def traverse_preorder(self, leaves=True, internal=True): '''Perform a preorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`...
[ "def", "traverse_preorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "s", "=", "deque", "(", ")", "s", ".", "append", "(", "self", ")", "while", "len", "(", "s", ")", "!=", "0", ":", "n", "=", "s", ".", ...
Perform a preorder traversal starting at this ``Node`` object Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "a", "preorder", "traversal", "starting", "at", "this", "Node", "object" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Node.py#L336-L349
train
piglei/uwsgi-sloth
uwsgi_sloth/structures.py
ValuesAggregation.merge_with
def merge_with(self, other): """Merge this ``ValuesAggregation`` with another one""" result = ValuesAggregation() result.total = self.total + other.total result.count = self.count + other.count result.min = min(self.min, other.min) result.max = max(self.max, other.max) ...
python
def merge_with(self, other): """Merge this ``ValuesAggregation`` with another one""" result = ValuesAggregation() result.total = self.total + other.total result.count = self.count + other.count result.min = min(self.min, other.min) result.max = max(self.max, other.max) ...
[ "def", "merge_with", "(", "self", ",", "other", ")", ":", "result", "=", "ValuesAggregation", "(", ")", "result", ".", "total", "=", "self", ".", "total", "+", "other", ".", "total", "result", ".", "count", "=", "self", ".", "count", "+", "other", "....
Merge this ``ValuesAggregation`` with another one
[ "Merge", "this", "ValuesAggregation", "with", "another", "one" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/structures.py#L35-L42
train
piglei/uwsgi-sloth
uwsgi_sloth/utils.py
parse_url_rules
def parse_url_rules(urls_fp): """URL rules from given fp""" url_rules = [] for line in urls_fp: re_url = line.strip() if re_url: url_rules.append({'str': re_url, 're': re.compile(re_url)}) return url_rules
python
def parse_url_rules(urls_fp): """URL rules from given fp""" url_rules = [] for line in urls_fp: re_url = line.strip() if re_url: url_rules.append({'str': re_url, 're': re.compile(re_url)}) return url_rules
[ "def", "parse_url_rules", "(", "urls_fp", ")", ":", "url_rules", "=", "[", "]", "for", "line", "in", "urls_fp", ":", "re_url", "=", "line", ".", "strip", "(", ")", "if", "re_url", ":", "url_rules", ".", "append", "(", "{", "'str'", ":", "re_url", ","...
URL rules from given fp
[ "URL", "rules", "from", "given", "fp" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/utils.py#L5-L12
train
piglei/uwsgi-sloth
uwsgi_sloth/utils.py
force_bytes
def force_bytes(s, encoding='utf-8', errors='strict'): """A function turns "s" into bytes object, similar to django.utils.encoding.force_bytes """ # Handle the common case first for performance reasons. if isinstance(s, bytes): if encoding == 'utf-8': return s else: ...
python
def force_bytes(s, encoding='utf-8', errors='strict'): """A function turns "s" into bytes object, similar to django.utils.encoding.force_bytes """ # Handle the common case first for performance reasons. if isinstance(s, bytes): if encoding == 'utf-8': return s else: ...
[ "def", "force_bytes", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "isinstance", "(", "s", ",", "bytes", ")", ":", "if", "encoding", "==", "'utf-8'", ":", "return", "s", "else", ":", "return", "s", ".", ...
A function turns "s" into bytes object, similar to django.utils.encoding.force_bytes
[ "A", "function", "turns", "s", "into", "bytes", "object", "similar", "to", "django", ".", "utils", ".", "encoding", ".", "force_bytes" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/utils.py#L25-L35
train
piglei/uwsgi-sloth
uwsgi_sloth/utils.py
force_text
def force_text(s, encoding='utf-8', errors='strict'): """A function turns "s" into text type, similar to django.utils.encoding.force_text """ if issubclass(type(s), str): return s try: if isinstance(s, bytes): s = str(s, encoding, errors) else: s = str(s)...
python
def force_text(s, encoding='utf-8', errors='strict'): """A function turns "s" into text type, similar to django.utils.encoding.force_text """ if issubclass(type(s), str): return s try: if isinstance(s, bytes): s = str(s, encoding, errors) else: s = str(s)...
[ "def", "force_text", "(", "s", ",", "encoding", "=", "'utf-8'", ",", "errors", "=", "'strict'", ")", ":", "if", "issubclass", "(", "type", "(", "s", ")", ",", "str", ")", ":", "return", "s", "try", ":", "if", "isinstance", "(", "s", ",", "bytes", ...
A function turns "s" into text type, similar to django.utils.encoding.force_text
[ "A", "function", "turns", "s", "into", "text", "type", "similar", "to", "django", ".", "utils", ".", "encoding", ".", "force_text" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/utils.py#L38-L50
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_XRef
def set_XRef(self, X=None, indtX=None, indtXlamb=None): """ Reset the reference X Useful if to replace channel indices by a time-vraying quantity e.g.: distance to the magnetic axis """ out = self._checkformat_inputs_XRef(X=X, indtX=indtX, ...
python
def set_XRef(self, X=None, indtX=None, indtXlamb=None): """ Reset the reference X Useful if to replace channel indices by a time-vraying quantity e.g.: distance to the magnetic axis """ out = self._checkformat_inputs_XRef(X=X, indtX=indtX, ...
[ "def", "set_XRef", "(", "self", ",", "X", "=", "None", ",", "indtX", "=", "None", ",", "indtXlamb", "=", "None", ")", ":", "out", "=", "self", ".", "_checkformat_inputs_XRef", "(", "X", "=", "X", ",", "indtX", "=", "indtX", ",", "indXlamb", "=", "i...
Reset the reference X Useful if to replace channel indices by a time-vraying quantity e.g.: distance to the magnetic axis
[ "Reset", "the", "reference", "X" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L888-L902
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_indt
def set_dtreat_indt(self, t=None, indt=None): """ Store the desired index array for the time vector If an array of indices (refering to self.ddataRef['t'] is not provided, uses self.select_t(t=t) to produce it """ lC = [indt is not None, t is not None] if all(lC): ...
python
def set_dtreat_indt(self, t=None, indt=None): """ Store the desired index array for the time vector If an array of indices (refering to self.ddataRef['t'] is not provided, uses self.select_t(t=t) to produce it """ lC = [indt is not None, t is not None] if all(lC): ...
[ "def", "set_dtreat_indt", "(", "self", ",", "t", "=", "None", ",", "indt", "=", "None", ")", ":", "lC", "=", "[", "indt", "is", "not", "None", ",", "t", "is", "not", "None", "]", "if", "all", "(", "lC", ")", ":", "msg", "=", "\"Please provide eit...
Store the desired index array for the time vector If an array of indices (refering to self.ddataRef['t'] is not provided, uses self.select_t(t=t) to produce it
[ "Store", "the", "desired", "index", "array", "for", "the", "time", "vector" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L904-L921
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_indch
def set_dtreat_indch(self, indch=None): """ Store the desired index array for the channels If None => all channels Must be a 1d array """ if indch is not None: indch = np.asarray(indch) assert indch.ndim==1 indch = _format_ind(indch, n=self._ddat...
python
def set_dtreat_indch(self, indch=None): """ Store the desired index array for the channels If None => all channels Must be a 1d array """ if indch is not None: indch = np.asarray(indch) assert indch.ndim==1 indch = _format_ind(indch, n=self._ddat...
[ "def", "set_dtreat_indch", "(", "self", ",", "indch", "=", "None", ")", ":", "if", "indch", "is", "not", "None", ":", "indch", "=", "np", ".", "asarray", "(", "indch", ")", "assert", "indch", ".", "ndim", "==", "1", "indch", "=", "_format_ind", "(", ...
Store the desired index array for the channels If None => all channels Must be a 1d array
[ "Store", "the", "desired", "index", "array", "for", "the", "channels" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L923-L935
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_indlamb
def set_dtreat_indlamb(self, indlamb=None): """ Store the desired index array for the wavelength If None => all wavelengths Must be a 1d array """ if not self._isSpectral(): msg = "The wavelength can only be set with DataSpectral object !" raise Exceptio...
python
def set_dtreat_indlamb(self, indlamb=None): """ Store the desired index array for the wavelength If None => all wavelengths Must be a 1d array """ if not self._isSpectral(): msg = "The wavelength can only be set with DataSpectral object !" raise Exceptio...
[ "def", "set_dtreat_indlamb", "(", "self", ",", "indlamb", "=", "None", ")", ":", "if", "not", "self", ".", "_isSpectral", "(", ")", ":", "msg", "=", "\"The wavelength can only be set with DataSpectral object !\"", "raise", "Exception", "(", "msg", ")", "if", "in...
Store the desired index array for the wavelength If None => all wavelengths Must be a 1d array
[ "Store", "the", "desired", "index", "array", "for", "the", "wavelength" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L937-L952
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_interp_indt
def set_dtreat_interp_indt(self, indt=None): """ Set the indices of the times for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices => interpolate data at these times for all channels - A dict with: ...
python
def set_dtreat_interp_indt(self, indt=None): """ Set the indices of the times for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices => interpolate data at these times for all channels - A dict with: ...
[ "def", "set_dtreat_interp_indt", "(", "self", ",", "indt", "=", "None", ")", ":", "lC", "=", "[", "indt", "is", "None", ",", "type", "(", "indt", ")", "in", "[", "np", ".", "ndarray", ",", "list", "]", ",", "type", "(", "indt", ")", "is", "dict",...
Set the indices of the times for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices => interpolate data at these times for all channels - A dict with: * keys = int indices of channels * valu...
[ "Set", "the", "indices", "of", "the", "times", "for", "which", "to", "interpolate", "data" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L998-L1024
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_interp_indch
def set_dtreat_interp_indch(self, indch=None): """ Set the indices of the channels for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices of channels => interpolate data at these channels for all times - A dict wit...
python
def set_dtreat_interp_indch(self, indch=None): """ Set the indices of the channels for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices of channels => interpolate data at these channels for all times - A dict wit...
[ "def", "set_dtreat_interp_indch", "(", "self", ",", "indch", "=", "None", ")", ":", "lC", "=", "[", "indch", "is", "None", ",", "type", "(", "indch", ")", "in", "[", "np", ".", "ndarray", ",", "list", "]", ",", "type", "(", "indch", ")", "is", "d...
Set the indices of the channels for which to interpolate data The index can be provided as: - A 1d np.ndarray of boolean or int indices of channels => interpolate data at these channels for all times - A dict with: * keys = int indices of times ...
[ "Set", "the", "indices", "of", "the", "channels", "for", "which", "to", "interpolate", "data" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1026-L1052
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_dfit
def set_dtreat_dfit(self, dfit=None): """ Set the fitting dictionnary A dict contaning all parameters for fitting the data Valid dict content includes: - 'type': str 'fft': A fourier filtering 'svd': A svd filtering """ warnings.war...
python
def set_dtreat_dfit(self, dfit=None): """ Set the fitting dictionnary A dict contaning all parameters for fitting the data Valid dict content includes: - 'type': str 'fft': A fourier filtering 'svd': A svd filtering """ warnings.war...
[ "def", "set_dtreat_dfit", "(", "self", ",", "dfit", "=", "None", ")", ":", "warnings", ".", "warn", "(", "\"Not implemented yet !, dfit forced to None\"", ")", "dfit", "=", "None", "assert", "dfit", "is", "None", "or", "isinstance", "(", "dfit", ",", "dict", ...
Set the fitting dictionnary A dict contaning all parameters for fitting the data Valid dict content includes: - 'type': str 'fft': A fourier filtering 'svd': A svd filtering
[ "Set", "the", "fitting", "dictionnary" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1054-L1073
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_interpt
def set_dtreat_interpt(self, t=None): """ Set the time vector on which to interpolate the data """ if t is not None: t = np.unique(np.asarray(t, dtype=float).ravel()) self._dtreat['interp-t'] = t
python
def set_dtreat_interpt(self, t=None): """ Set the time vector on which to interpolate the data """ if t is not None: t = np.unique(np.asarray(t, dtype=float).ravel()) self._dtreat['interp-t'] = t
[ "def", "set_dtreat_interpt", "(", "self", ",", "t", "=", "None", ")", ":", "if", "t", "is", "not", "None", ":", "t", "=", "np", ".", "unique", "(", "np", ".", "asarray", "(", "t", ",", "dtype", "=", "float", ")", ".", "ravel", "(", ")", ")", ...
Set the time vector on which to interpolate the data
[ "Set", "the", "time", "vector", "on", "which", "to", "interpolate", "the", "data" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1075-L1079
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.set_dtreat_order
def set_dtreat_order(self, order=None): """ Set the order in which the data treatment should be performed Provide an ordered list of keywords indicating the order in which you wish the data treatment steps to be performed. Each keyword corresponds to a step. Available steps are...
python
def set_dtreat_order(self, order=None): """ Set the order in which the data treatment should be performed Provide an ordered list of keywords indicating the order in which you wish the data treatment steps to be performed. Each keyword corresponds to a step. Available steps are...
[ "def", "set_dtreat_order", "(", "self", ",", "order", "=", "None", ")", ":", "if", "order", "is", "None", ":", "order", "=", "list", "(", "self", ".", "_ddef", "[", "'dtreat'", "]", "[", "'order'", "]", ")", "assert", "type", "(", "order", ")", "is...
Set the order in which the data treatment should be performed Provide an ordered list of keywords indicating the order in which you wish the data treatment steps to be performed. Each keyword corresponds to a step. Available steps are (in default order): - 'mask' : ...
[ "Set", "the", "order", "in", "which", "the", "data", "treatment", "should", "be", "performed" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1208-L1238
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.clear_ddata
def clear_ddata(self): """ Clear the working copy of data Harmless, as it preserves the reference copy and the treatment dict Use only to free some memory """ self._ddata = dict.fromkeys(self._get_keys_ddata()) self._ddata['uptodate'] = False
python
def clear_ddata(self): """ Clear the working copy of data Harmless, as it preserves the reference copy and the treatment dict Use only to free some memory """ self._ddata = dict.fromkeys(self._get_keys_ddata()) self._ddata['uptodate'] = False
[ "def", "clear_ddata", "(", "self", ")", ":", "self", ".", "_ddata", "=", "dict", ".", "fromkeys", "(", "self", ".", "_get_keys_ddata", "(", ")", ")", "self", ".", "_ddata", "[", "'uptodate'", "]", "=", "False" ]
Clear the working copy of data Harmless, as it preserves the reference copy and the treatment dict Use only to free some memory
[ "Clear", "the", "working", "copy", "of", "data" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1341-L1349
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.dchans
def dchans(self, key=None): """ Return the dchans updated with indch Return a dict with all keys if key=None """ if self._dtreat['indch'] is None or np.all(self._dtreat['indch']): dch = dict(self._dchans) if key is None else self._dchans[key] else: dch =...
python
def dchans(self, key=None): """ Return the dchans updated with indch Return a dict with all keys if key=None """ if self._dtreat['indch'] is None or np.all(self._dtreat['indch']): dch = dict(self._dchans) if key is None else self._dchans[key] else: dch =...
[ "def", "dchans", "(", "self", ",", "key", "=", "None", ")", ":", "if", "self", ".", "_dtreat", "[", "'indch'", "]", "is", "None", "or", "np", ".", "all", "(", "self", ".", "_dtreat", "[", "'indch'", "]", ")", ":", "dch", "=", "dict", "(", "self...
Return the dchans updated with indch Return a dict with all keys if key=None
[ "Return", "the", "dchans", "updated", "with", "indch" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1369-L1391
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.select_t
def select_t(self, t=None, out=bool): """ Return a time index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['t'] Parameters ---------- t : None / float / np.ndarray / list / tuple ...
python
def select_t(self, t=None, out=bool): """ Return a time index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['t'] Parameters ---------- t : None / float / np.ndarray / list / tuple ...
[ "def", "select_t", "(", "self", ",", "t", "=", "None", ",", "out", "=", "bool", ")", ":", "assert", "out", "in", "[", "bool", ",", "int", "]", "ind", "=", "_select_ind", "(", "t", ",", "self", ".", "_ddataRef", "[", "'t'", "]", ",", "self", "."...
Return a time index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['t'] Parameters ---------- t : None / float / np.ndarray / list / tuple The time values to be selected: ...
[ "Return", "a", "time", "index", "array" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1398-L1428
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.select_lamb
def select_lamb(self, lamb=None, out=bool): """ Return a wavelength index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['lamb'] Parameters ---------- lamb : None / float / np.ndarray...
python
def select_lamb(self, lamb=None, out=bool): """ Return a wavelength index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['lamb'] Parameters ---------- lamb : None / float / np.ndarray...
[ "def", "select_lamb", "(", "self", ",", "lamb", "=", "None", ",", "out", "=", "bool", ")", ":", "if", "not", "self", ".", "_isSpectral", "(", ")", ":", "msg", "=", "\"\"", "raise", "Exception", "(", "msg", ")", "assert", "out", "in", "[", "bool", ...
Return a wavelength index array Return a boolean or integer index array, hereafter called 'ind' The array refers to the reference time vector self.ddataRef['lamb'] Parameters ---------- lamb : None / float / np.ndarray / list / tuple The time values to be select...
[ "Return", "a", "wavelength", "index", "array" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1545-L1578
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.plot
def plot(self, key=None, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=3, lls=None, lct=None, lcch=None, lclbd=None, cbck=None, inct=[1,10], incX=[1,5], inclbd=[1,10],...
python
def plot(self, key=None, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=3, lls=None, lct=None, lcch=None, lclbd=None, cbck=None, inct=[1,10], incX=[1,5], inclbd=[1,10],...
[ "def", "plot", "(", "self", ",", "key", "=", "None", ",", "cmap", "=", "None", ",", "ms", "=", "4", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ",", "vmin_map", "=", "None", ",", "vmax_map", "=", "None", ",", "cmap_map", "=", "None", ",...
Plot the data content in a generic interactive figure
[ "Plot", "the", "data", "content", "in", "a", "generic", "interactive", "figure" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1582-L1605
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.plot_compare
def plot_compare(self, lD, key=None, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=3, lls=None, lct=None, lcch=None, lclbd=None, cbck=None, ...
python
def plot_compare(self, lD, key=None, cmap=None, ms=4, vmin=None, vmax=None, vmin_map=None, vmax_map=None, cmap_map=None, normt_map=False, ntMax=None, nchMax=None, nlbdMax=3, lls=None, lct=None, lcch=None, lclbd=None, cbck=None, ...
[ "def", "plot_compare", "(", "self", ",", "lD", ",", "key", "=", "None", ",", "cmap", "=", "None", ",", "ms", "=", "4", ",", "vmin", "=", "None", ",", "vmax", "=", "None", ",", "vmin_map", "=", "None", ",", "vmax_map", "=", "None", ",", "cmap_map"...
Plot several Data instances of the same diag Useful to compare : - the diag data for 2 different shots - experimental vs synthetic data for the same shot
[ "Plot", "several", "Data", "instances", "of", "the", "same", "diag" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1607-L1643
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.calc_spectrogram
def calc_spectrogram(self, fmin=None, method='scipy-fourier', deg=False, window='hann', detrend='linear', nperseg=None, noverlap=None, boundary='constant', padded=True, wave='morlet', warn=True):...
python
def calc_spectrogram(self, fmin=None, method='scipy-fourier', deg=False, window='hann', detrend='linear', nperseg=None, noverlap=None, boundary='constant', padded=True, wave='morlet', warn=True):...
[ "def", "calc_spectrogram", "(", "self", ",", "fmin", "=", "None", ",", "method", "=", "'scipy-fourier'", ",", "deg", "=", "False", ",", "window", "=", "'hann'", ",", "detrend", "=", "'linear'", ",", "nperseg", "=", "None", ",", "noverlap", "=", "None", ...
Return the power spectrum density for each channel The power spectrum density is computed with the chosen method Parameters ---------- fmin : None / float The minimum frequency of interest If None, set to 5/T, where T is the whole time interval Used...
[ "Return", "the", "power", "spectrum", "density", "for", "each", "channel" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1682-L1754
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.plot_spectrogram
def plot_spectrogram(self, fmin=None, fmax=None, method='scipy-fourier', deg=False, window='hann', detrend='linear', nperseg=None, noverlap=None, boundary='constant', padded=True, wave='morlet', ...
python
def plot_spectrogram(self, fmin=None, fmax=None, method='scipy-fourier', deg=False, window='hann', detrend='linear', nperseg=None, noverlap=None, boundary='constant', padded=True, wave='morlet', ...
[ "def", "plot_spectrogram", "(", "self", ",", "fmin", "=", "None", ",", "fmax", "=", "None", ",", "method", "=", "'scipy-fourier'", ",", "deg", "=", "False", ",", "window", "=", "'hann'", ",", "detrend", "=", "'linear'", ",", "nperseg", "=", "None", ","...
Plot the spectrogram of all channels with chosen method All non-plotting arguments are fed to self.calc_spectrogram() see self.calc_spectrogram? for details Parameters ---------- Return ------ kh : tofu.utils.HeyHandler The tofu KeyHandler object...
[ "Plot", "the", "spectrogram", "of", "all", "channels", "with", "chosen", "method" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1756-L1802
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.calc_svd
def calc_svd(self, lapack_driver='gesdd'): """ Return the SVD decomposition of data The input data np.ndarray shall be of dimension 2, with time as the first dimension, and the channels in the second Hence data should be of shape (nt, nch) Uses scipy.linalg.svd(), with:...
python
def calc_svd(self, lapack_driver='gesdd'): """ Return the SVD decomposition of data The input data np.ndarray shall be of dimension 2, with time as the first dimension, and the channels in the second Hence data should be of shape (nt, nch) Uses scipy.linalg.svd(), with:...
[ "def", "calc_svd", "(", "self", ",", "lapack_driver", "=", "'gesdd'", ")", ":", "if", "self", ".", "_isSpectral", "(", ")", ":", "msg", "=", "\"svd not implemented yet for spectral data class\"", "raise", "Exception", "(", "msg", ")", "chronos", ",", "s", ",",...
Return the SVD decomposition of data The input data np.ndarray shall be of dimension 2, with time as the first dimension, and the channels in the second Hence data should be of shape (nt, nch) Uses scipy.linalg.svd(), with: full_matrices = True compute_u...
[ "Return", "the", "SVD", "decomposition", "of", "data" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1804-L1839
train
ToFuProject/tofu
tofu/data/_core.py
DataAbstract.plot_svd
def plot_svd(self, lapack_driver='gesdd', modes=None, key=None, Bck=True, Lplot='In', cmap=None, vmin=None, vmax=None, cmap_topos=None, vmin_topos=None, vmax_topos=None, ntMax=None, nchMax=None, ms=4, inct=[1,10], incX=[1,5], incm=[1,5], ...
python
def plot_svd(self, lapack_driver='gesdd', modes=None, key=None, Bck=True, Lplot='In', cmap=None, vmin=None, vmax=None, cmap_topos=None, vmin_topos=None, vmax_topos=None, ntMax=None, nchMax=None, ms=4, inct=[1,10], incX=[1,5], incm=[1,5], ...
[ "def", "plot_svd", "(", "self", ",", "lapack_driver", "=", "'gesdd'", ",", "modes", "=", "None", ",", "key", "=", "None", ",", "Bck", "=", "True", ",", "Lplot", "=", "'In'", ",", "cmap", "=", "None", ",", "vmin", "=", "None", ",", "vmax", "=", "N...
Plot the chosen modes of the svd decomposition All modes will be plotted, the keyword 'modes' is only used to determine the reference modes for computing a common scale for vizualisation Runs self.calc_svd() and then plots the result in an interactive figure
[ "Plot", "the", "chosen", "modes", "of", "the", "svd", "decomposition" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L1841-L1878
train
ToFuProject/tofu
tofu/data/_core.py
DataSpectro.plot
def plot(self, key=None, invert=None, plotmethod='imshow', cmap=plt.cm.gray, ms=4, Max=None, fs=None, dmargin=None, wintit=None, draw=True, connect=True): """ Plot the data content in a predefined figure """ dax, KH = _plot.Data_plot(self, key=key, invert=invert, ...
python
def plot(self, key=None, invert=None, plotmethod='imshow', cmap=plt.cm.gray, ms=4, Max=None, fs=None, dmargin=None, wintit=None, draw=True, connect=True): """ Plot the data content in a predefined figure """ dax, KH = _plot.Data_plot(self, key=key, invert=invert, ...
[ "def", "plot", "(", "self", ",", "key", "=", "None", ",", "invert", "=", "None", ",", "plotmethod", "=", "'imshow'", ",", "cmap", "=", "plt", ".", "cm", ".", "gray", ",", "ms", "=", "4", ",", "Max", "=", "None", ",", "fs", "=", "None", ",", "...
Plot the data content in a predefined figure
[ "Plot", "the", "data", "content", "in", "a", "predefined", "figure" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_core.py#L2446-L2455
train
ToFuProject/tofu
tofu/geom/_comp.py
LOS_PRMin
def LOS_PRMin(Ds, dus, kPOut=None, Eps=1.e-12, Test=True): """ Compute the point on the LOS where the major radius is minimum """ if Test: assert Ds.ndim in [1,2] and 3 in Ds.shape and Ds.shape==dus.shape assert kPOut is None or (Ds.ndim==1 and not hasattr(kPOut,'__iter__')) or (Ds.ndim==2 and ...
python
def LOS_PRMin(Ds, dus, kPOut=None, Eps=1.e-12, Test=True): """ Compute the point on the LOS where the major radius is minimum """ if Test: assert Ds.ndim in [1,2] and 3 in Ds.shape and Ds.shape==dus.shape assert kPOut is None or (Ds.ndim==1 and not hasattr(kPOut,'__iter__')) or (Ds.ndim==2 and ...
[ "def", "LOS_PRMin", "(", "Ds", ",", "dus", ",", "kPOut", "=", "None", ",", "Eps", "=", "1.e-12", ",", "Test", "=", "True", ")", ":", "if", "Test", ":", "assert", "Ds", ".", "ndim", "in", "[", "1", ",", "2", "]", "and", "3", "in", "Ds", ".", ...
Compute the point on the LOS where the major radius is minimum
[ "Compute", "the", "point", "on", "the", "LOS", "where", "the", "major", "radius", "is", "minimum" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_comp.py#L306-L336
train
ToFuProject/tofu
tofu/geom/_comp.py
LOS_get_sample
def LOS_get_sample(D, u, dL, DL=None, dLMode='abs', method='sum', Test=True): """ Return the sampled line, with the specified method 'linspace': return the N+1 edges, including the first and last point 'sum' : return the N middle of the segments 'simps': return the N+1 egdes, where N has to be even (sc...
python
def LOS_get_sample(D, u, dL, DL=None, dLMode='abs', method='sum', Test=True): """ Return the sampled line, with the specified method 'linspace': return the N+1 edges, including the first and last point 'sum' : return the N middle of the segments 'simps': return the N+1 egdes, where N has to be even (sc...
[ "def", "LOS_get_sample", "(", "D", ",", "u", ",", "dL", ",", "DL", "=", "None", ",", "dLMode", "=", "'abs'", ",", "method", "=", "'sum'", ",", "Test", "=", "True", ")", ":", "if", "Test", ":", "assert", "all", "(", "[", "type", "(", "dd", ")", ...
Return the sampled line, with the specified method 'linspace': return the N+1 edges, including the first and last point 'sum' : return the N middle of the segments 'simps': return the N+1 egdes, where N has to be even (scipy.simpson requires an even number of intervals) 'romb' : return the N+1 edges, w...
[ "Return", "the", "sampled", "line", "with", "the", "specified", "method" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_comp.py#L426-L456
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.isInside
def isInside(self, pts, In='(X,Y,Z)'): """ Return an array of booleans indicating whether each point lies inside the Struct volume Tests for each point whether it lies inside the Struct object. The points coordinates can be provided in 2D or 3D You must specify which coordinate ...
python
def isInside(self, pts, In='(X,Y,Z)'): """ Return an array of booleans indicating whether each point lies inside the Struct volume Tests for each point whether it lies inside the Struct object. The points coordinates can be provided in 2D or 3D You must specify which coordinate ...
[ "def", "isInside", "(", "self", ",", "pts", ",", "In", "=", "'(X,Y,Z)'", ")", ":", "ind", "=", "_GG", ".", "_Ves_isInside", "(", "pts", ",", "self", ".", "Poly", ",", "Lim", "=", "self", ".", "Lim", ",", "nLim", "=", "self", ".", "_dgeom", "[", ...
Return an array of booleans indicating whether each point lies inside the Struct volume Tests for each point whether it lies inside the Struct object. The points coordinates can be provided in 2D or 3D You must specify which coordinate system is used with 'In' kwdarg. An array o...
[ "Return", "an", "array", "of", "booleans", "indicating", "whether", "each", "point", "lies", "inside", "the", "Struct", "volume" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L691-L718
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.get_InsideConvexPoly
def get_InsideConvexPoly(self, RelOff=_def.TorRelOff, ZLim='Def', Spline=True, Splprms=_def.TorSplprms, NP=_def.TorInsideNP, Plot=False, Test=True): """ Return a polygon that is a smaller and smoothed approximation of Ves.Poly, useful for excluding the d...
python
def get_InsideConvexPoly(self, RelOff=_def.TorRelOff, ZLim='Def', Spline=True, Splprms=_def.TorSplprms, NP=_def.TorInsideNP, Plot=False, Test=True): """ Return a polygon that is a smaller and smoothed approximation of Ves.Poly, useful for excluding the d...
[ "def", "get_InsideConvexPoly", "(", "self", ",", "RelOff", "=", "_def", ".", "TorRelOff", ",", "ZLim", "=", "'Def'", ",", "Spline", "=", "True", ",", "Splprms", "=", "_def", ".", "TorSplprms", ",", "NP", "=", "_def", ".", "TorInsideNP", ",", "Plot", "=...
Return a polygon that is a smaller and smoothed approximation of Ves.Poly, useful for excluding the divertor region in a Tokamak For some uses, it can be practical to approximate the polygon defining the Ves object (which can be non-convex, like with a divertor), by a simpler, sligthly smaller and convex polyg...
[ "Return", "a", "polygon", "that", "is", "a", "smaller", "and", "smoothed", "approximation", "of", "Ves", ".", "Poly", "useful", "for", "excluding", "the", "divertor", "region", "in", "a", "Tokamak" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L721-L758
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.get_sampleEdge
def get_sampleEdge(self, res, DS=None, resMode='abs', offsetIn=0.): """ Sample the polygon edges, with resolution res Sample each segment of the 2D polygon Sampling can be limited to a subdomain defined by DS """ pts, dlr, ind = _comp._Ves_get_sampleEdge(self.Poly, res, DS=DS, ...
python
def get_sampleEdge(self, res, DS=None, resMode='abs', offsetIn=0.): """ Sample the polygon edges, with resolution res Sample each segment of the 2D polygon Sampling can be limited to a subdomain defined by DS """ pts, dlr, ind = _comp._Ves_get_sampleEdge(self.Poly, res, DS=DS, ...
[ "def", "get_sampleEdge", "(", "self", ",", "res", ",", "DS", "=", "None", ",", "resMode", "=", "'abs'", ",", "offsetIn", "=", "0.", ")", ":", "pts", ",", "dlr", ",", "ind", "=", "_comp", ".", "_Ves_get_sampleEdge", "(", "self", ".", "Poly", ",", "r...
Sample the polygon edges, with resolution res Sample each segment of the 2D polygon Sampling can be limited to a subdomain defined by DS
[ "Sample", "the", "polygon", "edges", "with", "resolution", "res" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L760-L770
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.get_sampleCross
def get_sampleCross(self, res, DS=None, resMode='abs', ind=None): """ Sample, with resolution res, the 2D cross-section The sampling domain can be limited by DS or ind """ args = [self.Poly, self.dgeom['P1Min'][0], self.dgeom['P1Max'][0], self.dgeom['P2Min'][1], self.dge...
python
def get_sampleCross(self, res, DS=None, resMode='abs', ind=None): """ Sample, with resolution res, the 2D cross-section The sampling domain can be limited by DS or ind """ args = [self.Poly, self.dgeom['P1Min'][0], self.dgeom['P1Max'][0], self.dgeom['P2Min'][1], self.dge...
[ "def", "get_sampleCross", "(", "self", ",", "res", ",", "DS", "=", "None", ",", "resMode", "=", "'abs'", ",", "ind", "=", "None", ")", ":", "args", "=", "[", "self", ".", "Poly", ",", "self", ".", "dgeom", "[", "'P1Min'", "]", "[", "0", "]", ",...
Sample, with resolution res, the 2D cross-section The sampling domain can be limited by DS or ind
[ "Sample", "with", "resolution", "res", "the", "2D", "cross", "-", "section" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L772-L781
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.get_sampleS
def get_sampleS(self, res, DS=None, resMode='abs', ind=None, offsetIn=0., Out='(X,Y,Z)', Ind=None): """ Sample, with resolution res, the surface defined by DS or ind An optionnal offset perpendicular to the surface can be used (offsetIn>0 => inwards) Parameters ...
python
def get_sampleS(self, res, DS=None, resMode='abs', ind=None, offsetIn=0., Out='(X,Y,Z)', Ind=None): """ Sample, with resolution res, the surface defined by DS or ind An optionnal offset perpendicular to the surface can be used (offsetIn>0 => inwards) Parameters ...
[ "def", "get_sampleS", "(", "self", ",", "res", ",", "DS", "=", "None", ",", "resMode", "=", "'abs'", ",", "ind", "=", "None", ",", "offsetIn", "=", "0.", ",", "Out", "=", "'(X,Y,Z)'", ",", "Ind", "=", "None", ")", ":", "if", "Ind", "is", "not", ...
Sample, with resolution res, the surface defined by DS or ind An optionnal offset perpendicular to the surface can be used (offsetIn>0 => inwards) Parameters ---------- res : float / list of 2 floats Desired resolution of the surfacic sample fl...
[ "Sample", "with", "resolution", "res", "the", "surface", "defined", "by", "DS", "or", "ind" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L783-L855
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.get_sampleV
def get_sampleV(self, res, DV=None, resMode='abs', ind=None, Out='(X,Y,Z)'): """ Sample, with resolution res, the volume defined by DV or ind """ args = [self.Poly, self.dgeom['P1Min'][0], self.dgeom['P1Max'][0], self.dgeom['P2Min'][1], self.dgeom['P2Max'][1], res] kwdargs = dic...
python
def get_sampleV(self, res, DV=None, resMode='abs', ind=None, Out='(X,Y,Z)'): """ Sample, with resolution res, the volume defined by DV or ind """ args = [self.Poly, self.dgeom['P1Min'][0], self.dgeom['P1Max'][0], self.dgeom['P2Min'][1], self.dgeom['P2Max'][1], res] kwdargs = dic...
[ "def", "get_sampleV", "(", "self", ",", "res", ",", "DV", "=", "None", ",", "resMode", "=", "'abs'", ",", "ind", "=", "None", ",", "Out", "=", "'(X,Y,Z)'", ")", ":", "args", "=", "[", "self", ".", "Poly", ",", "self", ".", "dgeom", "[", "'P1Min'"...
Sample, with resolution res, the volume defined by DV or ind
[ "Sample", "with", "resolution", "res", "the", "volume", "defined", "by", "DV", "or", "ind" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L857-L865
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.plot
def plot(self, lax=None, proj='all', element='PIBsBvV', dP=None, dI=_def.TorId, dBs=_def.TorBsd, dBv=_def.TorBvd, dVect=_def.TorVind, dIHor=_def.TorITord, dBsHor=_def.TorBsTord, dBvHor=_def.TorBvTord, Lim=None, Nstep=_def.TorNTheta, dLeg=_def.TorLegd, indices=False, ...
python
def plot(self, lax=None, proj='all', element='PIBsBvV', dP=None, dI=_def.TorId, dBs=_def.TorBsd, dBv=_def.TorBvd, dVect=_def.TorVind, dIHor=_def.TorITord, dBsHor=_def.TorBsTord, dBvHor=_def.TorBvTord, Lim=None, Nstep=_def.TorNTheta, dLeg=_def.TorLegd, indices=False, ...
[ "def", "plot", "(", "self", ",", "lax", "=", "None", ",", "proj", "=", "'all'", ",", "element", "=", "'PIBsBvV'", ",", "dP", "=", "None", ",", "dI", "=", "_def", ".", "TorId", ",", "dBs", "=", "_def", ".", "TorBsd", ",", "dBv", "=", "_def", "."...
Plot the polygon defining the vessel, in chosen projection Generic method for plotting the Ves object The projections to be plotted, the elements to plot can be specified Dictionaries of properties for each elements can also be specified If an ax is not provided a default one is created...
[ "Plot", "the", "polygon", "defining", "the", "vessel", "in", "chosen", "projection" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L868-L943
train
ToFuProject/tofu
tofu/geom/_core.py
Struct.plot_sino
def plot_sino(self, ax=None, Ang=_def.LOSImpAng, AngUnit=_def.LOSImpAngUnit, Sketch=True, dP=None, dLeg=_def.TorLegd, draw=True, fs=None, wintit=None, Test=True): """ Plot the sinogram of the vessel polygon, by computing its envelopp in a cross-section, can ...
python
def plot_sino(self, ax=None, Ang=_def.LOSImpAng, AngUnit=_def.LOSImpAngUnit, Sketch=True, dP=None, dLeg=_def.TorLegd, draw=True, fs=None, wintit=None, Test=True): """ Plot the sinogram of the vessel polygon, by computing its envelopp in a cross-section, can ...
[ "def", "plot_sino", "(", "self", ",", "ax", "=", "None", ",", "Ang", "=", "_def", ".", "LOSImpAng", ",", "AngUnit", "=", "_def", ".", "LOSImpAngUnit", ",", "Sketch", "=", "True", ",", "dP", "=", "None", ",", "dLeg", "=", "_def", ".", "TorLegd", ","...
Plot the sinogram of the vessel polygon, by computing its envelopp in a cross-section, can also plot a 3D version of it The envelop of the polygon is computed using self.Sino_RefPt as a reference point in projection space, and plotted using the provided dictionary of properties. Optionaly a sma...
[ "Plot", "the", "sinogram", "of", "the", "vessel", "polygon", "by", "computing", "its", "envelopp", "in", "a", "cross", "-", "section", "can", "also", "plot", "a", "3D", "version", "of", "it" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L946-L1006
train
ToFuProject/tofu
tofu/geom/_core.py
Config.lStruct
def lStruct(self): """ Return the list of Struct that was used for creation As tofu objects or SavePath+SaveNames (according to strip status) """ lStruct = [] for k in self._dStruct['lorder']: k0, k1 = k.split('_') lStruct.append(self._dStruct['dObj'][k0]...
python
def lStruct(self): """ Return the list of Struct that was used for creation As tofu objects or SavePath+SaveNames (according to strip status) """ lStruct = [] for k in self._dStruct['lorder']: k0, k1 = k.split('_') lStruct.append(self._dStruct['dObj'][k0]...
[ "def", "lStruct", "(", "self", ")", ":", "lStruct", "=", "[", "]", "for", "k", "in", "self", ".", "_dStruct", "[", "'lorder'", "]", ":", "k0", ",", "k1", "=", "k", ".", "split", "(", "'_'", ")", "lStruct", ".", "append", "(", "self", ".", "_dSt...
Return the list of Struct that was used for creation As tofu objects or SavePath+SaveNames (according to strip status)
[ "Return", "the", "list", "of", "Struct", "that", "was", "used", "for", "creation" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L2049-L2058
train
ToFuProject/tofu
tofu/geom/_core.py
Config.lStructIn
def lStructIn(self): """ Return the list of StructIn contained in self.lStruct As tofu objects or SavePath+SaveNames (according to strip status) """ lStruct = [] for k in self._dStruct['lorder']: k0, k1 = k.split('_') if type(self._dStruct['dObj'][k0][k1]...
python
def lStructIn(self): """ Return the list of StructIn contained in self.lStruct As tofu objects or SavePath+SaveNames (according to strip status) """ lStruct = [] for k in self._dStruct['lorder']: k0, k1 = k.split('_') if type(self._dStruct['dObj'][k0][k1]...
[ "def", "lStructIn", "(", "self", ")", ":", "lStruct", "=", "[", "]", "for", "k", "in", "self", ".", "_dStruct", "[", "'lorder'", "]", ":", "k0", ",", "k1", "=", "k", ".", "split", "(", "'_'", ")", "if", "type", "(", "self", ".", "_dStruct", "["...
Return the list of StructIn contained in self.lStruct As tofu objects or SavePath+SaveNames (according to strip status)
[ "Return", "the", "list", "of", "StructIn", "contained", "in", "self", ".", "lStruct" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L2061-L2075
train
ToFuProject/tofu
tofu/geom/_core.py
Config.get_summary
def get_summary(self, verb=False, max_columns=100, width=1000): """ Summary description of the object content as a pandas DataFrame """ # Make sure the data is accessible msg = "The data is not accessible because self.strip(2) was used !" assert self._dstrip['strip']<2, msg # Bu...
python
def get_summary(self, verb=False, max_columns=100, width=1000): """ Summary description of the object content as a pandas DataFrame """ # Make sure the data is accessible msg = "The data is not accessible because self.strip(2) was used !" assert self._dstrip['strip']<2, msg # Bu...
[ "def", "get_summary", "(", "self", ",", "verb", "=", "False", ",", "max_columns", "=", "100", ",", "width", "=", "1000", ")", ":", "msg", "=", "\"The data is not accessible because self.strip(2) was used !\"", "assert", "self", ".", "_dstrip", "[", "'strip'", "]...
Summary description of the object content as a pandas DataFrame
[ "Summary", "description", "of", "the", "object", "content", "as", "a", "pandas", "DataFrame" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L2228-L2261
train
ToFuProject/tofu
tofu/geom/_core.py
Config.isInside
def isInside(self, pts, In='(X,Y,Z)', log='any'): """ Return a 2D array of bool Equivalent to applying isInside to each Struct Check self.lStruct[0].isInside? for details Arg log determines how Struct with multiple Limits are treated - 'all' : True only if pts belong to all...
python
def isInside(self, pts, In='(X,Y,Z)', log='any'): """ Return a 2D array of bool Equivalent to applying isInside to each Struct Check self.lStruct[0].isInside? for details Arg log determines how Struct with multiple Limits are treated - 'all' : True only if pts belong to all...
[ "def", "isInside", "(", "self", ",", "pts", ",", "In", "=", "'(X,Y,Z)'", ",", "log", "=", "'any'", ")", ":", "msg", "=", "\"Arg pts must be a 1D or 2D np.ndarray !\"", "assert", "isinstance", "(", "pts", ",", "np", ".", "ndarray", ")", "and", "pts", ".", ...
Return a 2D array of bool Equivalent to applying isInside to each Struct Check self.lStruct[0].isInside? for details Arg log determines how Struct with multiple Limits are treated - 'all' : True only if pts belong to all elements - 'any' : True if pts belong to any elem...
[ "Return", "a", "2D", "array", "of", "bool" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L2263-L2301
train
ToFuProject/tofu
tofu/geom/_core.py
Rays.get_sample
def get_sample(self, res, resMode='abs', DL=None, method='sum', ind=None, compact=False): """ Return a linear sampling of the LOS The LOS is sampled into a series a points and segments lengths The resolution (segments length) is <= res The sampling can be done accordin...
python
def get_sample(self, res, resMode='abs', DL=None, method='sum', ind=None, compact=False): """ Return a linear sampling of the LOS The LOS is sampled into a series a points and segments lengths The resolution (segments length) is <= res The sampling can be done accordin...
[ "def", "get_sample", "(", "self", ",", "res", ",", "resMode", "=", "'abs'", ",", "DL", "=", "None", ",", "method", "=", "'sum'", ",", "ind", "=", "None", ",", "compact", "=", "False", ")", ":", "ind", "=", "self", ".", "_check_indch", "(", "ind", ...
Return a linear sampling of the LOS The LOS is sampled into a series a points and segments lengths The resolution (segments length) is <= res The sampling can be done according to different methods It is possible to sample only a subset of the LOS Parameters ---------- ...
[ "Return", "a", "linear", "sampling", "of", "the", "LOS" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L3859-L3946
train
ToFuProject/tofu
tofu/geom/_core.py
Rays.calc_kInkOut_IsoFlux
def calc_kInkOut_IsoFlux(self, lPoly, lVIn=None, Lim=None, kInOut=True): """ Calculate the intersection points of each ray with each isoflux The isofluxes are provided as a list of 2D closed polygons The intersections are the inward and outward intersections ...
python
def calc_kInkOut_IsoFlux(self, lPoly, lVIn=None, Lim=None, kInOut=True): """ Calculate the intersection points of each ray with each isoflux The isofluxes are provided as a list of 2D closed polygons The intersections are the inward and outward intersections ...
[ "def", "calc_kInkOut_IsoFlux", "(", "self", ",", "lPoly", ",", "lVIn", "=", "None", ",", "Lim", "=", "None", ",", "kInOut", "=", "True", ")", ":", "nPoly", ",", "lPoly", ",", "lVIn", "=", "self", ".", "_kInOut_IsoFlux_inputs_usr", "(", "lPoly", ",", "l...
Calculate the intersection points of each ray with each isoflux The isofluxes are provided as a list of 2D closed polygons The intersections are the inward and outward intersections They are retruned as two np.ndarrays: kIn and kOut Each array contains the length parameter along the ra...
[ "Calculate", "the", "intersection", "points", "of", "each", "ray", "with", "each", "isoflux" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L4022-L4078
train
ToFuProject/tofu
tofu/geom/_core.py
Rays.get_touch_dict
def get_touch_dict(self, ind=None, out=bool): """ Get a dictionnary of Cls_Name struct with indices of Rays touching Only includes Struct object with compute = True (as returned by self.lStruct__computeInOut_computeInOut) Also return the associated colors If in is not None, ...
python
def get_touch_dict(self, ind=None, out=bool): """ Get a dictionnary of Cls_Name struct with indices of Rays touching Only includes Struct object with compute = True (as returned by self.lStruct__computeInOut_computeInOut) Also return the associated colors If in is not None, ...
[ "def", "get_touch_dict", "(", "self", ",", "ind", "=", "None", ",", "out", "=", "bool", ")", ":", "if", "self", ".", "config", "is", "None", ":", "msg", "=", "\"Config must be set in order to get touch dict !\"", "raise", "Exception", "(", "msg", ")", "dElt"...
Get a dictionnary of Cls_Name struct with indices of Rays touching Only includes Struct object with compute = True (as returned by self.lStruct__computeInOut_computeInOut) Also return the associated colors If in is not None, the indices for each Struct are split between: ...
[ "Get", "a", "dictionnary", "of", "Cls_Name", "struct", "with", "indices", "of", "Rays", "touching" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/_core.py#L4373-L4402
train
piglei/uwsgi-sloth
uwsgi_sloth/models.py
merge_urls_data_to
def merge_urls_data_to(to, food={}): """Merge urls data""" if not to: to.update(food) for url, data in food.items(): if url not in to: to[url] = data else: to[url] = to[url].merge_with(data)
python
def merge_urls_data_to(to, food={}): """Merge urls data""" if not to: to.update(food) for url, data in food.items(): if url not in to: to[url] = data else: to[url] = to[url].merge_with(data)
[ "def", "merge_urls_data_to", "(", "to", ",", "food", "=", "{", "}", ")", ":", "if", "not", "to", ":", "to", ".", "update", "(", "food", ")", "for", "url", ",", "data", "in", "food", ".", "items", "(", ")", ":", "if", "url", "not", "in", "to", ...
Merge urls data
[ "Merge", "urls", "data" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/models.py#L53-L62
train
piglei/uwsgi-sloth
uwsgi_sloth/models.py
merge_requests_data_to
def merge_requests_data_to(to, food={}): """Merge a small analyzed result to a big one, this function will modify the original ``to``""" if not to: to.update(food) to['requests_counter']['normal'] += food['requests_counter']['normal'] to['requests_counter']['slow'] += food['requests_counte...
python
def merge_requests_data_to(to, food={}): """Merge a small analyzed result to a big one, this function will modify the original ``to``""" if not to: to.update(food) to['requests_counter']['normal'] += food['requests_counter']['normal'] to['requests_counter']['slow'] += food['requests_counte...
[ "def", "merge_requests_data_to", "(", "to", ",", "food", "=", "{", "}", ")", ":", "if", "not", "to", ":", "to", ".", "update", "(", "food", ")", "to", "[", "'requests_counter'", "]", "[", "'normal'", "]", "+=", "food", "[", "'requests_counter'", "]", ...
Merge a small analyzed result to a big one, this function will modify the original ``to``
[ "Merge", "a", "small", "analyzed", "result", "to", "a", "big", "one", "this", "function", "will", "modify", "the", "original", "to" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/models.py#L65-L84
train
piglei/uwsgi-sloth
uwsgi_sloth/analyzer.py
format_data
def format_data(raw_data, limit_per_url_group=LIMIT_PER_URL_GROUP, limit_url_groups=LIMIT_URL_GROUPS): """Fomat data from LogAnalyzer for render purpose""" data = copy.deepcopy(raw_data) for k, v in list(data['data_details'].items()): # Only reserve first ``limit_per_url_group`` items v['url...
python
def format_data(raw_data, limit_per_url_group=LIMIT_PER_URL_GROUP, limit_url_groups=LIMIT_URL_GROUPS): """Fomat data from LogAnalyzer for render purpose""" data = copy.deepcopy(raw_data) for k, v in list(data['data_details'].items()): # Only reserve first ``limit_per_url_group`` items v['url...
[ "def", "format_data", "(", "raw_data", ",", "limit_per_url_group", "=", "LIMIT_PER_URL_GROUP", ",", "limit_url_groups", "=", "LIMIT_URL_GROUPS", ")", ":", "data", "=", "copy", ".", "deepcopy", "(", "raw_data", ")", "for", "k", ",", "v", "in", "list", "(", "d...
Fomat data from LogAnalyzer for render purpose
[ "Fomat", "data", "from", "LogAnalyzer", "for", "render", "purpose" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/analyzer.py#L221-L242
train
piglei/uwsgi-sloth
uwsgi_sloth/analyzer.py
URLClassifier.classify
def classify(self, url_path): """Classify an url""" for dict_api_url in self.user_defined_rules: api_url = dict_api_url['str'] re_api_url = dict_api_url['re'] if re_api_url.match(url_path[1:]): return api_url return self.RE_SIMPLIFY_URL.sub(r'...
python
def classify(self, url_path): """Classify an url""" for dict_api_url in self.user_defined_rules: api_url = dict_api_url['str'] re_api_url = dict_api_url['re'] if re_api_url.match(url_path[1:]): return api_url return self.RE_SIMPLIFY_URL.sub(r'...
[ "def", "classify", "(", "self", ",", "url_path", ")", ":", "for", "dict_api_url", "in", "self", ".", "user_defined_rules", ":", "api_url", "=", "dict_api_url", "[", "'str'", "]", "re_api_url", "=", "dict_api_url", "[", "'re'", "]", "if", "re_api_url", ".", ...
Classify an url
[ "Classify", "an", "url" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/analyzer.py#L69-L77
train
daveoncode/pyvaru
pyvaru/__init__.py
ValidationResult.annotate_rule_violation
def annotate_rule_violation(self, rule: ValidationRule) -> None: """ Takes note of a rule validation failure by collecting its error message. :param rule: Rule that failed validation. :type rule: ValidationRule :return: None """ if self.errors.get(rule.label) is ...
python
def annotate_rule_violation(self, rule: ValidationRule) -> None: """ Takes note of a rule validation failure by collecting its error message. :param rule: Rule that failed validation. :type rule: ValidationRule :return: None """ if self.errors.get(rule.label) is ...
[ "def", "annotate_rule_violation", "(", "self", ",", "rule", ":", "ValidationRule", ")", "->", "None", ":", "if", "self", ".", "errors", ".", "get", "(", "rule", ".", "label", ")", "is", "None", ":", "self", ".", "errors", "[", "rule", ".", "label", "...
Takes note of a rule validation failure by collecting its error message. :param rule: Rule that failed validation. :type rule: ValidationRule :return: None
[ "Takes", "note", "of", "a", "rule", "validation", "failure", "by", "collecting", "its", "error", "message", "." ]
78ad9c55d44aef1f24028b2c83e7de12f2698abb
https://github.com/daveoncode/pyvaru/blob/78ad9c55d44aef1f24028b2c83e7de12f2698abb/pyvaru/__init__.py#L187-L197
train
ToFuProject/tofu
tofu/pathfile.py
get_PolyFromPolyFileObj
def get_PolyFromPolyFileObj(PolyFileObj, SavePathInp=None, units='m', comments='#', skiprows=0, shape0=2): """ Return a polygon as a np.ndarray, extracted from a txt file or from a ToFu object, with appropriate units Useful for :meth:`tofu.plugins.AUG.Ves._create()` Parameters ---------- PolyFileO...
python
def get_PolyFromPolyFileObj(PolyFileObj, SavePathInp=None, units='m', comments='#', skiprows=0, shape0=2): """ Return a polygon as a np.ndarray, extracted from a txt file or from a ToFu object, with appropriate units Useful for :meth:`tofu.plugins.AUG.Ves._create()` Parameters ---------- PolyFileO...
[ "def", "get_PolyFromPolyFileObj", "(", "PolyFileObj", ",", "SavePathInp", "=", "None", ",", "units", "=", "'m'", ",", "comments", "=", "'#'", ",", "skiprows", "=", "0", ",", "shape0", "=", "2", ")", ":", "assert", "type", "(", "PolyFileObj", ")", "in", ...
Return a polygon as a np.ndarray, extracted from a txt file or from a ToFu object, with appropriate units Useful for :meth:`tofu.plugins.AUG.Ves._create()` Parameters ---------- PolyFileObj : str / :mod:`tofu.geom` object / np.ndarray The source where the polygon is to be found, either: ...
[ "Return", "a", "polygon", "as", "a", "np", ".", "ndarray", "extracted", "from", "a", "txt", "file", "or", "from", "a", "ToFu", "object", "with", "appropriate", "units" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L73-L121
train
ToFuProject/tofu
tofu/pathfile.py
CheckSameObj
def CheckSameObj(obj0, obj1, LFields=None): """ Check if two variables are the same instance of a ToFu class Checks a list of attributes, provided by LField Parameters ---------- obj0 : tofu object A variable refering to a ToFu object of any class obj1 : tofu object A...
python
def CheckSameObj(obj0, obj1, LFields=None): """ Check if two variables are the same instance of a ToFu class Checks a list of attributes, provided by LField Parameters ---------- obj0 : tofu object A variable refering to a ToFu object of any class obj1 : tofu object A...
[ "def", "CheckSameObj", "(", "obj0", ",", "obj1", ",", "LFields", "=", "None", ")", ":", "A", "=", "True", "if", "LField", "is", "not", "None", "and", "obj0", ".", "__class__", "==", "obj1", ".", "__class__", ":", "assert", "type", "(", "LFields", ")"...
Check if two variables are the same instance of a ToFu class Checks a list of attributes, provided by LField Parameters ---------- obj0 : tofu object A variable refering to a ToFu object of any class obj1 : tofu object A variable refering to a ToFu object of the same clas...
[ "Check", "if", "two", "variables", "are", "the", "same", "instance", "of", "a", "ToFu", "class" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L525-L564
train
ToFuProject/tofu
tofu/pathfile.py
Save_Generic
def Save_Generic(obj, SaveName=None, Path='./', Mode='npz', compressed=False, Print=True): """ Save a ToFu object under file name SaveName, in folder Path ToFu provides built-in saving and loading functions for ToFu objects. There is now only one saving mode: - 'npz': saves a dict ...
python
def Save_Generic(obj, SaveName=None, Path='./', Mode='npz', compressed=False, Print=True): """ Save a ToFu object under file name SaveName, in folder Path ToFu provides built-in saving and loading functions for ToFu objects. There is now only one saving mode: - 'npz': saves a dict ...
[ "def", "Save_Generic", "(", "obj", ",", "SaveName", "=", "None", ",", "Path", "=", "'./'", ",", "Mode", "=", "'npz'", ",", "compressed", "=", "False", ",", "Print", "=", "True", ")", ":", "assert", "type", "(", "obj", ".", "__class__", ")", "is", "...
Save a ToFu object under file name SaveName, in folder Path ToFu provides built-in saving and loading functions for ToFu objects. There is now only one saving mode: - 'npz': saves a dict of key attributes using :meth:`numpy.savez` Good practices are: - save :class:`~tofu.geom.Ves` and :cla...
[ "Save", "a", "ToFu", "object", "under", "file", "name", "SaveName", "in", "folder", "Path" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L904-L954
train
ToFuProject/tofu
tofu/pathfile.py
Open
def Open(pathfileext=None, shot=None, t=None, Dt=None, Mesh=None, Deg=None, Deriv=None, Sep=True, Pos=True, OutPath=None, ReplacePath=None, Ves=None, out='full', Verb=False, Print=True): """ Open a ToFu object saved file This generic open function identifies the required loading rout...
python
def Open(pathfileext=None, shot=None, t=None, Dt=None, Mesh=None, Deg=None, Deriv=None, Sep=True, Pos=True, OutPath=None, ReplacePath=None, Ves=None, out='full', Verb=False, Print=True): """ Open a ToFu object saved file This generic open function identifies the required loading rout...
[ "def", "Open", "(", "pathfileext", "=", "None", ",", "shot", "=", "None", ",", "t", "=", "None", ",", "Dt", "=", "None", ",", "Mesh", "=", "None", ",", "Deg", "=", "None", ",", "Deriv", "=", "None", ",", "Sep", "=", "True", ",", "Pos", "=", "...
Open a ToFu object saved file This generic open function identifies the required loading routine by detecting how the object was saved from the file name extension. Also, it uses :meth:`~tofu.pathfile.FindSolFile()` to identify the relevant file in case key criteria such as shot, Deg... are provided instead of...
[ "Open", "a", "ToFu", "object", "saved", "file" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L1176-L1224
train
ToFuProject/tofu
tofu/pathfile.py
ID.set_LObj
def set_LObj(self,LObj=None): """ Set the LObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). LObj does this: it stores the ID (as dict) of ...
python
def set_LObj(self,LObj=None): """ Set the LObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). LObj does this: it stores the ID (as dict) of ...
[ "def", "set_LObj", "(", "self", ",", "LObj", "=", "None", ")", ":", "self", ".", "_LObj", "=", "{", "}", "if", "LObj", "is", "not", "None", ":", "if", "type", "(", "LObj", ")", "is", "not", "list", ":", "LObj", "=", "[", "LObj", "]", "for", "...
Set the LObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). LObj does this: it stores the ID (as dict) of all objects depended on. Paramete...
[ "Set", "the", "LObj", "attribute", "storing", "objects", "the", "instance", "depends", "on" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L346-L372
train
ToFuProject/tofu
tofu/pathfile.py
ID.set_USRdict
def set_USRdict(self,USRdict={}): """ Set the USRdict, containing user-defined info about the instance Useful for arbitrary info (e.g.: manufacturing date, material...) Parameters ---------- USRdict : dict A user-defined dictionary containing info about the instan...
python
def set_USRdict(self,USRdict={}): """ Set the USRdict, containing user-defined info about the instance Useful for arbitrary info (e.g.: manufacturing date, material...) Parameters ---------- USRdict : dict A user-defined dictionary containing info about the instan...
[ "def", "set_USRdict", "(", "self", ",", "USRdict", "=", "{", "}", ")", ":", "self", ".", "_check_inputs", "(", "USRdict", "=", "USRdict", ")", "self", ".", "_USRdict", "=", "USRdict" ]
Set the USRdict, containing user-defined info about the instance Useful for arbitrary info (e.g.: manufacturing date, material...) Parameters ---------- USRdict : dict A user-defined dictionary containing info about the instance
[ "Set", "the", "USRdict", "containing", "user", "-", "defined", "info", "about", "the", "instance" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/pathfile.py#L374-L386
train
ToFuProject/tofu
tofu/geom/utils.py
create_config
def create_config(case=None, Exp='Dummy', Type='Tor', Lim=None, Bump_posextent=[np.pi/4., np.pi/4], R=2.4, r=1., elong=0., Dshape=0., divlow=True, divup=True, nP=200, out='object', SavePath='./'): """ Create easily a tofu.geom.Config object ...
python
def create_config(case=None, Exp='Dummy', Type='Tor', Lim=None, Bump_posextent=[np.pi/4., np.pi/4], R=2.4, r=1., elong=0., Dshape=0., divlow=True, divup=True, nP=200, out='object', SavePath='./'): """ Create easily a tofu.geom.Config object ...
[ "def", "create_config", "(", "case", "=", "None", ",", "Exp", "=", "'Dummy'", ",", "Type", "=", "'Tor'", ",", "Lim", "=", "None", ",", "Bump_posextent", "=", "[", "np", ".", "pi", "/", "4.", ",", "np", ".", "pi", "/", "4", "]", ",", "R", "=", ...
Create easily a tofu.geom.Config object In tofu, a Config (short for geometrical configuration) refers to the 3D geometry of a fusion device. It includes, at least, a simple 2D polygon describing the first wall of the fusion chamber, and can also include other structural elements (tiles, limiters.....
[ "Create", "easily", "a", "tofu", ".", "geom", ".", "Config", "object" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/geom/utils.py#L690-L771
train
piglei/uwsgi-sloth
uwsgi_sloth/commands/analyze.py
analyze_log
def analyze_log(fp, configs, url_rules): """Analyze log file""" url_classifier = URLClassifier(url_rules) analyzer = LogAnalyzer(url_classifier=url_classifier, min_msecs=configs.min_msecs) for line in fp: analyzer.analyze_line(line) return analyzer.get_data()
python
def analyze_log(fp, configs, url_rules): """Analyze log file""" url_classifier = URLClassifier(url_rules) analyzer = LogAnalyzer(url_classifier=url_classifier, min_msecs=configs.min_msecs) for line in fp: analyzer.analyze_line(line) return analyzer.get_data()
[ "def", "analyze_log", "(", "fp", ",", "configs", ",", "url_rules", ")", ":", "url_classifier", "=", "URLClassifier", "(", "url_rules", ")", "analyzer", "=", "LogAnalyzer", "(", "url_classifier", "=", "url_classifier", ",", "min_msecs", "=", "configs", ".", "mi...
Analyze log file
[ "Analyze", "log", "file" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/commands/analyze.py#L15-L21
train
ToFuProject/tofu
tofu/data/_comp.py
_spectrogram_scipy_fourier
def _spectrogram_scipy_fourier(data, fs, nt, nch, fmin=None, window=('tukey', 0.25), deg=False, nperseg=None, noverlap=None, detrend='linear', stft=False, boundary='constant', padded=True, warn=Tr...
python
def _spectrogram_scipy_fourier(data, fs, nt, nch, fmin=None, window=('tukey', 0.25), deg=False, nperseg=None, noverlap=None, detrend='linear', stft=False, boundary='constant', padded=True, warn=Tr...
[ "def", "_spectrogram_scipy_fourier", "(", "data", ",", "fs", ",", "nt", ",", "nch", ",", "fmin", "=", "None", ",", "window", "=", "(", "'tukey'", ",", "0.25", ")", ",", "deg", "=", "False", ",", "nperseg", "=", "None", ",", "noverlap", "=", "None", ...
Return a spectrogram for each channel, and a common frequency vector The min frequency of interest fmin fixes the nb. of pt. per seg. (if None) The number of overlapping points is set to nperseg-1 if None The choice of the window type is a trade-off between: Spectral resolution between similar freq...
[ "Return", "a", "spectrogram", "for", "each", "channel", "and", "a", "common", "frequency", "vector" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_comp.py#L70-L130
train
ToFuProject/tofu
tofu/data/_comp.py
filter_svd
def filter_svd(data, lapack_driver='gesdd', modes=[]): """ Return the svd-filtered signal using only the selected mode Provide the indices of the modes desired """ # Check input modes = np.asarray(modes,dtype=int) assert modes.ndim==1 assert modes.size>=1, "No modes selected !" u, s, ...
python
def filter_svd(data, lapack_driver='gesdd', modes=[]): """ Return the svd-filtered signal using only the selected mode Provide the indices of the modes desired """ # Check input modes = np.asarray(modes,dtype=int) assert modes.ndim==1 assert modes.size>=1, "No modes selected !" u, s, ...
[ "def", "filter_svd", "(", "data", ",", "lapack_driver", "=", "'gesdd'", ",", "modes", "=", "[", "]", ")", ":", "modes", "=", "np", ".", "asarray", "(", "modes", ",", "dtype", "=", "int", ")", "assert", "modes", ".", "ndim", "==", "1", "assert", "mo...
Return the svd-filtered signal using only the selected mode Provide the indices of the modes desired
[ "Return", "the", "svd", "-", "filtered", "signal", "using", "only", "the", "selected", "mode" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/data/_comp.py#L351-L370
train
piglei/uwsgi-sloth
uwsgi_sloth/commands/start.py
HTMLRender.render_requests_data_to_html
def render_requests_data_to_html(self, data, file_name, context={}): """Render to HTML file""" file_path = os.path.join(self.html_dir, file_name) logger.info('Rendering HTML file %s...' % file_path) data = format_data(data) data.update(context) data.update(domain=self.dom...
python
def render_requests_data_to_html(self, data, file_name, context={}): """Render to HTML file""" file_path = os.path.join(self.html_dir, file_name) logger.info('Rendering HTML file %s...' % file_path) data = format_data(data) data.update(context) data.update(domain=self.dom...
[ "def", "render_requests_data_to_html", "(", "self", ",", "data", ",", "file_name", ",", "context", "=", "{", "}", ")", ":", "file_path", "=", "os", ".", "path", ".", "join", "(", "self", ".", "html_dir", ",", "file_name", ")", "logger", ".", "info", "(...
Render to HTML file
[ "Render", "to", "HTML", "file" ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/commands/start.py#L26-L34
train
ToFuProject/tofu
tofu/utils.py
get_figuresize
def get_figuresize(fs, fsdef=(12,6), orient='landscape', method='xrandr'): """ Generic function to return figure size in inches Useful for str-based flags such as: - 'a4' : use orient='portrait' or 'landscape' - 'full': to get screen size use meth...
python
def get_figuresize(fs, fsdef=(12,6), orient='landscape', method='xrandr'): """ Generic function to return figure size in inches Useful for str-based flags such as: - 'a4' : use orient='portrait' or 'landscape' - 'full': to get screen size use meth...
[ "def", "get_figuresize", "(", "fs", ",", "fsdef", "=", "(", "12", ",", "6", ")", ",", "orient", "=", "'landscape'", ",", "method", "=", "'xrandr'", ")", ":", "assert", "fs", "is", "None", "or", "type", "(", "fs", ")", "in", "[", "str", ",", "tupl...
Generic function to return figure size in inches Useful for str-based flags such as: - 'a4' : use orient='portrait' or 'landscape' - 'full': to get screen size use method='xrandr' (recommended), as 'xdpyinfo' tends to be wrong
[ "Generic", "function", "to", "return", "figure", "size", "in", "inches" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L79-L119
train
ToFuProject/tofu
tofu/utils.py
_set_arrayorder
def _set_arrayorder(obj, arrayorder='C'): """ Set the memory order of all np.ndarrays in a tofu object """ msg = "Arg arrayorder must be in ['C','F']" assert arrayorder in ['C','F'], msg d = obj.to_dict(strip=-1) account = {'Success':[], 'Failed':[]} for k, v in d.items(): if type(v) is...
python
def _set_arrayorder(obj, arrayorder='C'): """ Set the memory order of all np.ndarrays in a tofu object """ msg = "Arg arrayorder must be in ['C','F']" assert arrayorder in ['C','F'], msg d = obj.to_dict(strip=-1) account = {'Success':[], 'Failed':[]} for k, v in d.items(): if type(v) is...
[ "def", "_set_arrayorder", "(", "obj", ",", "arrayorder", "=", "'C'", ")", ":", "msg", "=", "\"Arg arrayorder must be in ['C','F']\"", "assert", "arrayorder", "in", "[", "'C'", ",", "'F'", "]", ",", "msg", "d", "=", "obj", ".", "to_dict", "(", "strip", "=",...
Set the memory order of all np.ndarrays in a tofu object
[ "Set", "the", "memory", "order", "of", "all", "np", ".", "ndarrays", "in", "a", "tofu", "object" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L214-L233
train
ToFuProject/tofu
tofu/utils.py
save
def save(obj, path=None, name=None, sep=_sep, deep=False, mode='npz', strip=None, compressed=False, verb=True, return_pfe=False): """ Save the ToFu object ToFu provides built-in saving and loading functions for ToFu objects. Specifying saving path ad name is optional (defaults recommended) The...
python
def save(obj, path=None, name=None, sep=_sep, deep=False, mode='npz', strip=None, compressed=False, verb=True, return_pfe=False): """ Save the ToFu object ToFu provides built-in saving and loading functions for ToFu objects. Specifying saving path ad name is optional (defaults recommended) The...
[ "def", "save", "(", "obj", ",", "path", "=", "None", ",", "name", "=", "None", ",", "sep", "=", "_sep", ",", "deep", "=", "False", ",", "mode", "=", "'npz'", ",", "strip", "=", "None", ",", "compressed", "=", "False", ",", "verb", "=", "True", ...
Save the ToFu object ToFu provides built-in saving and loading functions for ToFu objects. Specifying saving path ad name is optional (defaults recommended) The mode refers to the file format Good practices are: - save all struct objects Parameters ---------- obj : ToFuObjec...
[ "Save", "the", "ToFu", "object" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L241-L328
train
ToFuProject/tofu
tofu/utils.py
load
def load(name, path=None, strip=None, verb=True): """ Load a tofu object file Can load from .npz or .txt files In future versions, will also load from .mat The file must have been saved with tofu (i.e.: must be tofu-formatted) The associated tofu object will be created and returned Pa...
python
def load(name, path=None, strip=None, verb=True): """ Load a tofu object file Can load from .npz or .txt files In future versions, will also load from .mat The file must have been saved with tofu (i.e.: must be tofu-formatted) The associated tofu object will be created and returned Pa...
[ "def", "load", "(", "name", ",", "path", "=", "None", ",", "strip", "=", "None", ",", "verb", "=", "True", ")", ":", "lmodes", "=", "[", "'.npz'", ",", "'.mat'", ",", "'.txt'", "]", "name", ",", "mode", ",", "pfe", "=", "_filefind", "(", "name", ...
Load a tofu object file Can load from .npz or .txt files In future versions, will also load from .mat The file must have been saved with tofu (i.e.: must be tofu-formatted) The associated tofu object will be created and returned Parameters ---------- name: str Name of the fi...
[ "Load", "a", "tofu", "object", "file" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L442-L487
train
ToFuProject/tofu
tofu/utils.py
ToFuObjectBase.to_dict
def to_dict(self, strip=None, sep=_sep, deep='ref'): """ Return a flat dict view of the object's attributes Useful for: * displaying all attributes * saving to file * exchaning data with non-tofu libraries Parameters ---------- strip : in...
python
def to_dict(self, strip=None, sep=_sep, deep='ref'): """ Return a flat dict view of the object's attributes Useful for: * displaying all attributes * saving to file * exchaning data with non-tofu libraries Parameters ---------- strip : in...
[ "def", "to_dict", "(", "self", ",", "strip", "=", "None", ",", "sep", "=", "_sep", ",", "deep", "=", "'ref'", ")", ":", "if", "deep", "not", "in", "[", "'ref'", ",", "'copy'", ",", "'dict'", "]", ":", "msg", "=", "\"Arg deep must be a flag in ['ref','c...
Return a flat dict view of the object's attributes Useful for: * displaying all attributes * saving to file * exchaning data with non-tofu libraries Parameters ---------- strip : int Flag indicating how stripped the object should be ...
[ "Return", "a", "flat", "dict", "view", "of", "the", "object", "s", "attributes" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L826-L886
train
ToFuProject/tofu
tofu/utils.py
ToFuObjectBase.from_dict
def from_dict(self, fd, sep=_sep, strip=None): """ Populate the instances attributes using an input dict The input dict must be properly formatted In practice it should be the return output of a similar class to_dict() Parameters ---------- fd : dict The ...
python
def from_dict(self, fd, sep=_sep, strip=None): """ Populate the instances attributes using an input dict The input dict must be properly formatted In practice it should be the return output of a similar class to_dict() Parameters ---------- fd : dict The ...
[ "def", "from_dict", "(", "self", ",", "fd", ",", "sep", "=", "_sep", ",", "strip", "=", "None", ")", ":", "self", ".", "_reset", "(", ")", "dd", "=", "reshape_dict", "(", "fd", ")", "self", ".", "_from_dict", "(", "dd", ")", "self", ".", "_dstrip...
Populate the instances attributes using an input dict The input dict must be properly formatted In practice it should be the return output of a similar class to_dict() Parameters ---------- fd : dict The properly formatted ditionnary from which to read the attrib...
[ "Populate", "the", "instances", "attributes", "using", "an", "input", "dict" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L892-L923
train
ToFuProject/tofu
tofu/utils.py
ToFuObjectBase.copy
def copy(self, strip=None, deep='ref'): """ Return another instance of the object, with the same attributes If deep=True, all attributes themselves are also copies """ dd = self.to_dict(strip=strip, deep=deep) return self.__class__(fromdict=dd)
python
def copy(self, strip=None, deep='ref'): """ Return another instance of the object, with the same attributes If deep=True, all attributes themselves are also copies """ dd = self.to_dict(strip=strip, deep=deep) return self.__class__(fromdict=dd)
[ "def", "copy", "(", "self", ",", "strip", "=", "None", ",", "deep", "=", "'ref'", ")", ":", "dd", "=", "self", ".", "to_dict", "(", "strip", "=", "strip", ",", "deep", "=", "deep", ")", "return", "self", ".", "__class__", "(", "fromdict", "=", "d...
Return another instance of the object, with the same attributes If deep=True, all attributes themselves are also copies
[ "Return", "another", "instance", "of", "the", "object", "with", "the", "same", "attributes" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L925-L931
train
ToFuProject/tofu
tofu/utils.py
ID.set_lObj
def set_lObj(self, lObj=None): """ Set the lObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). lObj does this: it stores the ID (as dict) of...
python
def set_lObj(self, lObj=None): """ Set the lObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). lObj does this: it stores the ID (as dict) of...
[ "def", "set_lObj", "(", "self", ",", "lObj", "=", "None", ")", ":", "if", "self", ".", "lObj", "is", "None", "and", "lObj", "is", "not", "None", ":", "self", ".", "_dall", "[", "'lObj'", "]", "=", "{", "}", "if", "lObj", "is", "not", "None", ":...
Set the lObj attribute, storing objects the instance depends on For example: A Detect object depends on a vessel and some apertures That link between should be stored somewhere (for saving/loading). lObj does this: it stores the ID (as dict) of all objects depended on. Paramete...
[ "Set", "the", "lObj", "attribute", "storing", "objects", "the", "instance", "depends", "on" ]
39d6b2e7ced9e13666572dfd37e19403f1d6ff8d
https://github.com/ToFuProject/tofu/blob/39d6b2e7ced9e13666572dfd37e19403f1d6ff8d/tofu/utils.py#L1587-L1614
train
piglei/uwsgi-sloth
uwsgi_sloth/tailer.py
Tailer.seek_line_forward
def seek_line_forward(self): """\ Searches forward from the current file position for a line terminator and seeks to the charachter after it. """ pos = start_pos = self.file.tell() bytes_read, read_str = self.read(self.read_size) start = 0 if bytes_read ...
python
def seek_line_forward(self): """\ Searches forward from the current file position for a line terminator and seeks to the charachter after it. """ pos = start_pos = self.file.tell() bytes_read, read_str = self.read(self.read_size) start = 0 if bytes_read ...
[ "def", "seek_line_forward", "(", "self", ")", ":", "pos", "=", "start_pos", "=", "self", ".", "file", ".", "tell", "(", ")", "bytes_read", ",", "read_str", "=", "self", ".", "read", "(", "self", ".", "read_size", ")", "start", "=", "0", "if", "bytes_...
\ Searches forward from the current file position for a line terminator and seeks to the charachter after it.
[ "\\", "Searches", "forward", "from", "the", "current", "file", "position", "for", "a", "line", "terminator", "and", "seeks", "to", "the", "charachter", "after", "it", "." ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/tailer.py#L53-L81
train
piglei/uwsgi-sloth
uwsgi_sloth/tailer.py
Tailer.seek_line
def seek_line(self): """\ Searches backwards from the current file position for a line terminator and seeks to the charachter after it. """ pos = end_pos = self.file.tell() read_size = self.read_size if pos > read_size: pos -= read_size else: ...
python
def seek_line(self): """\ Searches backwards from the current file position for a line terminator and seeks to the charachter after it. """ pos = end_pos = self.file.tell() read_size = self.read_size if pos > read_size: pos -= read_size else: ...
[ "def", "seek_line", "(", "self", ")", ":", "pos", "=", "end_pos", "=", "self", ".", "file", ".", "tell", "(", ")", "read_size", "=", "self", ".", "read_size", "if", "pos", ">", "read_size", ":", "pos", "-=", "read_size", "else", ":", "pos", "=", "0...
\ Searches backwards from the current file position for a line terminator and seeks to the charachter after it.
[ "\\", "Searches", "backwards", "from", "the", "current", "file", "position", "for", "a", "line", "terminator", "and", "seeks", "to", "the", "charachter", "after", "it", "." ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/tailer.py#L83-L128
train
piglei/uwsgi-sloth
uwsgi_sloth/tailer.py
Tailer.tail
def tail(self, lines=10): """\ Return the last lines of the file. """ self.seek_end() end_pos = self.file.tell() for i in range(lines): if not self.seek_line(): break data = self.file.read(end_pos - self.file.tell() - 1) if da...
python
def tail(self, lines=10): """\ Return the last lines of the file. """ self.seek_end() end_pos = self.file.tell() for i in range(lines): if not self.seek_line(): break data = self.file.read(end_pos - self.file.tell() - 1) if da...
[ "def", "tail", "(", "self", ",", "lines", "=", "10", ")", ":", "self", ".", "seek_end", "(", ")", "end_pos", "=", "self", ".", "file", ".", "tell", "(", ")", "for", "i", "in", "range", "(", "lines", ")", ":", "if", "not", "self", ".", "seek_lin...
\ Return the last lines of the file.
[ "\\", "Return", "the", "last", "lines", "of", "the", "file", "." ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/tailer.py#L130-L145
train
piglei/uwsgi-sloth
uwsgi_sloth/tailer.py
Tailer.head
def head(self, lines=10): """\ Return the top lines of the file. """ self.seek(0) for i in range(lines): if not self.seek_line_forward(): break end_pos = self.file.tell() self.seek(0) data = self.file.read(end_pos...
python
def head(self, lines=10): """\ Return the top lines of the file. """ self.seek(0) for i in range(lines): if not self.seek_line_forward(): break end_pos = self.file.tell() self.seek(0) data = self.file.read(end_pos...
[ "def", "head", "(", "self", ",", "lines", "=", "10", ")", ":", "self", ".", "seek", "(", "0", ")", "for", "i", "in", "range", "(", "lines", ")", ":", "if", "not", "self", ".", "seek_line_forward", "(", ")", ":", "break", "end_pos", "=", "self", ...
\ Return the top lines of the file.
[ "\\", "Return", "the", "top", "lines", "of", "the", "file", "." ]
2834ac5ed17d89ca5f19151c649ac610f6f37bd1
https://github.com/piglei/uwsgi-sloth/blob/2834ac5ed17d89ca5f19151c649ac610f6f37bd1/uwsgi_sloth/tailer.py#L147-L165
train
rodricios/eatiht
eatiht/v2.py
get_html_tree
def get_html_tree(filename_url_or_filelike): """From some file path, input stream, or URL, construct and return an HTML tree. """ try: handler = ( HTTPSHandler if filename_url_or_filelike.lower().startswith('https') else HTTPHandler ) ...
python
def get_html_tree(filename_url_or_filelike): """From some file path, input stream, or URL, construct and return an HTML tree. """ try: handler = ( HTTPSHandler if filename_url_or_filelike.lower().startswith('https') else HTTPHandler ) ...
[ "def", "get_html_tree", "(", "filename_url_or_filelike", ")", ":", "try", ":", "handler", "=", "(", "HTTPSHandler", "if", "filename_url_or_filelike", ".", "lower", "(", ")", ".", "startswith", "(", "'https'", ")", "else", "HTTPHandler", ")", "cj", "=", "Cookie...
From some file path, input stream, or URL, construct and return an HTML tree.
[ "From", "some", "file", "path", "input", "stream", "or", "URL", "construct", "and", "return", "an", "HTML", "tree", "." ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/v2.py#L113-L158
train
rodricios/eatiht
eatiht/v2.py
calc_across_paths_textnodes
def calc_across_paths_textnodes(paths_nodes, dbg=False): """Given a list of parent paths tupled with children textnodes, plus initialized feature values, we calculate the total and average string length of the parent's children textnodes. """ # for (path, [textnodes], # num. of...
python
def calc_across_paths_textnodes(paths_nodes, dbg=False): """Given a list of parent paths tupled with children textnodes, plus initialized feature values, we calculate the total and average string length of the parent's children textnodes. """ # for (path, [textnodes], # num. of...
[ "def", "calc_across_paths_textnodes", "(", "paths_nodes", ",", "dbg", "=", "False", ")", ":", "for", "path_nodes", "in", "paths_nodes", ":", "cnt", "=", "len", "(", "path_nodes", "[", "1", "]", "[", "0", "]", ")", "ttl", "=", "sum", "(", "[", "len", ...
Given a list of parent paths tupled with children textnodes, plus initialized feature values, we calculate the total and average string length of the parent's children textnodes.
[ "Given", "a", "list", "of", "parent", "paths", "tupled", "with", "children", "textnodes", "plus", "initialized", "feature", "values", "we", "calculate", "the", "total", "and", "average", "string", "length", "of", "the", "parent", "s", "children", "textnodes", ...
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/v2.py#L194-L211
train
rodricios/eatiht
eatiht/v2.py
extract
def extract(filename_url_or_filelike): """A more precise algorithm over the original eatiht algorithm """ pars_tnodes = get_parent_xpaths_and_textnodes(filename_url_or_filelike) #[iterable, cardinality, ttl across iterable, avg across iterable.]) calc_across_paths_textnodes(pars_tnodes) ...
python
def extract(filename_url_or_filelike): """A more precise algorithm over the original eatiht algorithm """ pars_tnodes = get_parent_xpaths_and_textnodes(filename_url_or_filelike) #[iterable, cardinality, ttl across iterable, avg across iterable.]) calc_across_paths_textnodes(pars_tnodes) ...
[ "def", "extract", "(", "filename_url_or_filelike", ")", ":", "pars_tnodes", "=", "get_parent_xpaths_and_textnodes", "(", "filename_url_or_filelike", ")", "calc_across_paths_textnodes", "(", "pars_tnodes", ")", "avg", ",", "_", ",", "_", "=", "calc_avgstrlen_pathstextnodes...
A more precise algorithm over the original eatiht algorithm
[ "A", "more", "precise", "algorithm", "over", "the", "original", "eatiht", "algorithm" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/v2.py#L253-L275
train
rodricios/eatiht
eatiht/etv2.py
extract
def extract(filename_url_filelike_or_htmlstring): """An "improved" algorithm over the original eatiht algorithm """ html_tree = get_html_tree(filename_url_filelike_or_htmlstring) subtrees = get_textnode_subtrees(html_tree) #[iterable, cardinality, ttl across iterable, avg across iterable.]) ...
python
def extract(filename_url_filelike_or_htmlstring): """An "improved" algorithm over the original eatiht algorithm """ html_tree = get_html_tree(filename_url_filelike_or_htmlstring) subtrees = get_textnode_subtrees(html_tree) #[iterable, cardinality, ttl across iterable, avg across iterable.]) ...
[ "def", "extract", "(", "filename_url_filelike_or_htmlstring", ")", ":", "html_tree", "=", "get_html_tree", "(", "filename_url_filelike_or_htmlstring", ")", "subtrees", "=", "get_textnode_subtrees", "(", "html_tree", ")", "avg", ",", "_", ",", "_", "=", "calcavg_avgstr...
An "improved" algorithm over the original eatiht algorithm
[ "An", "improved", "algorithm", "over", "the", "original", "eatiht", "algorithm" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/etv2.py#L238-L262
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeSubTree.__learn_oneself
def __learn_oneself(self): """calculate cardinality, total and average string length""" if not self.__parent_path or not self.__text_nodes: raise Exception("This error occurred because the step constructor\ had insufficient textnodes or it had empty string\ ...
python
def __learn_oneself(self): """calculate cardinality, total and average string length""" if not self.__parent_path or not self.__text_nodes: raise Exception("This error occurred because the step constructor\ had insufficient textnodes or it had empty string\ ...
[ "def", "__learn_oneself", "(", "self", ")", ":", "if", "not", "self", ".", "__parent_path", "or", "not", "self", ".", "__text_nodes", ":", "raise", "Exception", "(", "\"This error occurred because the step constructor\\\r had insufficient textnodes ...
calculate cardinality, total and average string length
[ "calculate", "cardinality", "total", "and", "average", "string", "length" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L161-L174
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeTree.__make_tree
def __make_tree(self): """Build a tree using lxml.html.builder and our subtrees""" # create div with "container" class div = E.DIV(E.CLASS("container")) # append header with title div.append(E.H2(self.__title)) # next, iterate through subtrees appending each t...
python
def __make_tree(self): """Build a tree using lxml.html.builder and our subtrees""" # create div with "container" class div = E.DIV(E.CLASS("container")) # append header with title div.append(E.H2(self.__title)) # next, iterate through subtrees appending each t...
[ "def", "__make_tree", "(", "self", ")", ":", "div", "=", "E", ".", "DIV", "(", "E", ".", "CLASS", "(", "\"container\"", ")", ")", "div", ".", "append", "(", "E", ".", "H2", "(", "self", ".", "__title", ")", ")", "for", "subtree", "in", "self", ...
Build a tree using lxml.html.builder and our subtrees
[ "Build", "a", "tree", "using", "lxml", ".", "html", ".", "builder", "and", "our", "subtrees" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L228-L250
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeTree.get_html
def get_html(self): """Generates if need be and returns a simpler html document with text""" if self.__htmltree is not None: return self.__htmltree else: self.__make_tree() return self.__htmltree
python
def get_html(self): """Generates if need be and returns a simpler html document with text""" if self.__htmltree is not None: return self.__htmltree else: self.__make_tree() return self.__htmltree
[ "def", "get_html", "(", "self", ")", ":", "if", "self", ".", "__htmltree", "is", "not", "None", ":", "return", "self", ".", "__htmltree", "else", ":", "self", ".", "__make_tree", "(", ")", "return", "self", ".", "__htmltree" ]
Generates if need be and returns a simpler html document with text
[ "Generates", "if", "need", "be", "and", "returns", "a", "simpler", "html", "document", "with", "text" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L252-L258
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeTree.get_html_string
def get_html_string(self): """Generates if need be and returns a simpler html string with extracted text""" if self.__htmltree is not None: return htmltostring(self.__htmltree) else: self.__make_tree() return htmltostring(self.__htmltree)
python
def get_html_string(self): """Generates if need be and returns a simpler html string with extracted text""" if self.__htmltree is not None: return htmltostring(self.__htmltree) else: self.__make_tree() return htmltostring(self.__htmltree)
[ "def", "get_html_string", "(", "self", ")", ":", "if", "self", ".", "__htmltree", "is", "not", "None", ":", "return", "htmltostring", "(", "self", ".", "__htmltree", ")", "else", ":", "self", ".", "__make_tree", "(", ")", "return", "htmltostring", "(", "...
Generates if need be and returns a simpler html string with extracted text
[ "Generates", "if", "need", "be", "and", "returns", "a", "simpler", "html", "string", "with", "extracted", "text" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L260-L267
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeTree.get_text
def get_text(self): """Return all joined text from each subtree""" if self.__fulltext: return self.__fulltext else: self.__fulltext = "\n\n".join(text.get_text() for text in self.__subtrees) return self.__fullte...
python
def get_text(self): """Return all joined text from each subtree""" if self.__fulltext: return self.__fulltext else: self.__fulltext = "\n\n".join(text.get_text() for text in self.__subtrees) return self.__fullte...
[ "def", "get_text", "(", "self", ")", ":", "if", "self", ".", "__fulltext", ":", "return", "self", ".", "__fulltext", "else", ":", "self", ".", "__fulltext", "=", "\"\\n\\n\"", ".", "join", "(", "text", ".", "get_text", "(", ")", "for", "text", "in", ...
Return all joined text from each subtree
[ "Return", "all", "joined", "text", "from", "each", "subtree" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L269-L276
train
rodricios/eatiht
eatiht/eatiht_trees.py
TextNodeTree.bootstrapify
def bootstrapify(self): """Add bootstrap cdn to headers of html""" if self.__htmltree is None: #raise Exception("HtmlTree has not been made yet") self.__make_tree() # add bootstrap cdn to head self.__htmltree.find('head').append( E.LINK(rel="s...
python
def bootstrapify(self): """Add bootstrap cdn to headers of html""" if self.__htmltree is None: #raise Exception("HtmlTree has not been made yet") self.__make_tree() # add bootstrap cdn to head self.__htmltree.find('head').append( E.LINK(rel="s...
[ "def", "bootstrapify", "(", "self", ")", ":", "if", "self", ".", "__htmltree", "is", "None", ":", "self", ".", "__make_tree", "(", ")", "self", ".", "__htmltree", ".", "find", "(", "'head'", ")", ".", "append", "(", "E", ".", "LINK", "(", "rel", "=...
Add bootstrap cdn to headers of html
[ "Add", "bootstrap", "cdn", "to", "headers", "of", "html" ]
7341c46327cfe7e0c9f226ef5e9808975c4d43da
https://github.com/rodricios/eatiht/blob/7341c46327cfe7e0c9f226ef5e9808975c4d43da/eatiht/eatiht_trees.py#L280-L300
train
markokr/rarfile
dumprar.py
rar3_type
def rar3_type(btype): """RAR3 type code as string.""" if btype < rf.RAR_BLOCK_MARK or btype > rf.RAR_BLOCK_ENDARC: return "*UNKNOWN*" return block_strs[btype - rf.RAR_BLOCK_MARK]
python
def rar3_type(btype): """RAR3 type code as string.""" if btype < rf.RAR_BLOCK_MARK or btype > rf.RAR_BLOCK_ENDARC: return "*UNKNOWN*" return block_strs[btype - rf.RAR_BLOCK_MARK]
[ "def", "rar3_type", "(", "btype", ")", ":", "if", "btype", "<", "rf", ".", "RAR_BLOCK_MARK", "or", "btype", ">", "rf", ".", "RAR_BLOCK_ENDARC", ":", "return", "\"*UNKNOWN*\"", "return", "block_strs", "[", "btype", "-", "rf", ".", "RAR_BLOCK_MARK", "]" ]
RAR3 type code as string.
[ "RAR3", "type", "code", "as", "string", "." ]
2704344e8d7a1658c96c8ed8f449d7ba01bedea3
https://github.com/markokr/rarfile/blob/2704344e8d7a1658c96c8ed8f449d7ba01bedea3/dumprar.py#L44-L48
train
markokr/rarfile
dumprar.py
xprint
def xprint(m, *args): """Print string to stdout. Format unicode safely. """ if sys.hexversion < 0x3000000: m = m.decode('utf8') if args: m = m % args if sys.hexversion < 0x3000000: m = m.encode('utf8') sys.stdout.write(m) sys.stdout.write('\n')
python
def xprint(m, *args): """Print string to stdout. Format unicode safely. """ if sys.hexversion < 0x3000000: m = m.decode('utf8') if args: m = m % args if sys.hexversion < 0x3000000: m = m.encode('utf8') sys.stdout.write(m) sys.stdout.write('\n')
[ "def", "xprint", "(", "m", ",", "*", "args", ")", ":", "if", "sys", ".", "hexversion", "<", "0x3000000", ":", "m", "=", "m", ".", "decode", "(", "'utf8'", ")", "if", "args", ":", "m", "=", "m", "%", "args", "if", "sys", ".", "hexversion", "<", ...
Print string to stdout. Format unicode safely.
[ "Print", "string", "to", "stdout", "." ]
2704344e8d7a1658c96c8ed8f449d7ba01bedea3
https://github.com/markokr/rarfile/blob/2704344e8d7a1658c96c8ed8f449d7ba01bedea3/dumprar.py#L154-L166
train
markokr/rarfile
dumprar.py
render_flags
def render_flags(flags, bit_list): """Show bit names. """ res = [] known = 0 for bit in bit_list: known = known | bit[0] if flags & bit[0]: res.append(bit[1]) unknown = flags & ~known n = 0 while unknown: if unknown & 1: res.append("UNK_%04...
python
def render_flags(flags, bit_list): """Show bit names. """ res = [] known = 0 for bit in bit_list: known = known | bit[0] if flags & bit[0]: res.append(bit[1]) unknown = flags & ~known n = 0 while unknown: if unknown & 1: res.append("UNK_%04...
[ "def", "render_flags", "(", "flags", ",", "bit_list", ")", ":", "res", "=", "[", "]", "known", "=", "0", "for", "bit", "in", "bit_list", ":", "known", "=", "known", "|", "bit", "[", "0", "]", "if", "flags", "&", "bit", "[", "0", "]", ":", "res"...
Show bit names.
[ "Show", "bit", "names", "." ]
2704344e8d7a1658c96c8ed8f449d7ba01bedea3
https://github.com/markokr/rarfile/blob/2704344e8d7a1658c96c8ed8f449d7ba01bedea3/dumprar.py#L169-L189
train