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
niemasd/TreeSwift
treeswift/Tree.py
Tree.coalescence_times
def coalescence_times(self, backward=True): '''Generator over the times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False`` ''' if not isinstance(backward, bool): raise TypeEr...
python
def coalescence_times(self, backward=True): '''Generator over the times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False`` ''' if not isinstance(backward, bool): raise TypeEr...
[ "def", "coalescence_times", "(", "self", ",", "backward", "=", "True", ")", ":", "if", "not", "isinstance", "(", "backward", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"backward must be a bool\"", ")", "for", "dist", "in", "sorted", "(", "(", "d",...
Generator over the times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False``
[ "Generator", "over", "the", "times", "of", "successive", "coalescence", "events" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L100-L109
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.coalescence_waiting_times
def coalescence_waiting_times(self, backward=True): '''Generator over the waiting times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False`` ''' if not isinstance(backward, bool): ...
python
def coalescence_waiting_times(self, backward=True): '''Generator over the waiting times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False`` ''' if not isinstance(backward, bool): ...
[ "def", "coalescence_waiting_times", "(", "self", ",", "backward", "=", "True", ")", ":", "if", "not", "isinstance", "(", "backward", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"backward must be a bool\"", ")", "times", "=", "list", "(", ")", "lowest...
Generator over the waiting times of successive coalescence events Args: ``backward`` (``bool``): ``True`` to go backward in time (i.e., leaves to root), otherwise ``False``
[ "Generator", "over", "the", "waiting", "times", "of", "successive", "coalescence", "events" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L111-L128
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.colless
def colless(self, normalize='leaves'): '''Compute the Colless balance index of this ``Tree``. If the tree has polytomies, they will be randomly resolved Args: ``normalize`` (``str``): How to normalize the Colless index (if at all) * ``None`` to not normalize * ``"l...
python
def colless(self, normalize='leaves'): '''Compute the Colless balance index of this ``Tree``. If the tree has polytomies, they will be randomly resolved Args: ``normalize`` (``str``): How to normalize the Colless index (if at all) * ``None`` to not normalize * ``"l...
[ "def", "colless", "(", "self", ",", "normalize", "=", "'leaves'", ")", ":", "t_res", "=", "copy", "(", "self", ")", "t_res", ".", "resolve_polytomies", "(", ")", "leaves_below", "=", "dict", "(", ")", "n", "=", "0", "I", "=", "0", "for", "node", "i...
Compute the Colless balance index of this ``Tree``. If the tree has polytomies, they will be randomly resolved Args: ``normalize`` (``str``): How to normalize the Colless index (if at all) * ``None`` to not normalize * ``"leaves"`` to normalize by the number of leaves ...
[ "Compute", "the", "Colless", "balance", "index", "of", "this", "Tree", ".", "If", "the", "tree", "has", "polytomies", "they", "will", "be", "randomly", "resolved" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L152-L188
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.condense
def condense(self): '''If siblings have the same label, merge them. If they have edge lengths, the resulting ``Node`` will have the larger of the lengths''' self.resolve_polytomies(); labels_below = dict(); longest_leaf_dist = dict() for node in self.traverse_postorder(): if node.is_...
python
def condense(self): '''If siblings have the same label, merge them. If they have edge lengths, the resulting ``Node`` will have the larger of the lengths''' self.resolve_polytomies(); labels_below = dict(); longest_leaf_dist = dict() for node in self.traverse_postorder(): if node.is_...
[ "def", "condense", "(", "self", ")", ":", "self", ".", "resolve_polytomies", "(", ")", "labels_below", "=", "dict", "(", ")", "longest_leaf_dist", "=", "dict", "(", ")", "for", "node", "in", "self", ".", "traverse_postorder", "(", ")", ":", "if", "node",...
If siblings have the same label, merge them. If they have edge lengths, the resulting ``Node`` will have the larger of the lengths
[ "If", "siblings", "have", "the", "same", "label", "merge", "them", ".", "If", "they", "have", "edge", "lengths", "the", "resulting", "Node", "will", "have", "the", "larger", "of", "the", "lengths" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L190-L219
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.deroot
def deroot(self, label='OLDROOT'): '''If the tree has a root edge, drop the edge to be a child of the root node Args: ``label`` (``str``): The desired label of the new child ''' if self.root.edge_length is not None: self.root.add_child(Node(edge_length=self.root....
python
def deroot(self, label='OLDROOT'): '''If the tree has a root edge, drop the edge to be a child of the root node Args: ``label`` (``str``): The desired label of the new child ''' if self.root.edge_length is not None: self.root.add_child(Node(edge_length=self.root....
[ "def", "deroot", "(", "self", ",", "label", "=", "'OLDROOT'", ")", ":", "if", "self", ".", "root", ".", "edge_length", "is", "not", "None", ":", "self", ".", "root", ".", "add_child", "(", "Node", "(", "edge_length", "=", "self", ".", "root", ".", ...
If the tree has a root edge, drop the edge to be a child of the root node Args: ``label`` (``str``): The desired label of the new child
[ "If", "the", "tree", "has", "a", "root", "edge", "drop", "the", "edge", "to", "be", "a", "child", "of", "the", "root", "node" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L238-L246
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.distance_between
def distance_between(self, u, v): '''Return the distance between nodes ``u`` and ``v`` in this ``Tree`` Args: ``u`` (``Node``): Node ``u`` ``v`` (``Node``): Node ``v`` Returns: ``float``: The distance between nodes ``u`` and ``v`` ''' if not...
python
def distance_between(self, u, v): '''Return the distance between nodes ``u`` and ``v`` in this ``Tree`` Args: ``u`` (``Node``): Node ``u`` ``v`` (``Node``): Node ``v`` Returns: ``float``: The distance between nodes ``u`` and ``v`` ''' if not...
[ "def", "distance_between", "(", "self", ",", "u", ",", "v", ")", ":", "if", "not", "isinstance", "(", "u", ",", "Node", ")", ":", "raise", "TypeError", "(", "\"u must be a Node\"", ")", "if", "not", "isinstance", "(", "v", ",", "Node", ")", ":", "rai...
Return the distance between nodes ``u`` and ``v`` in this ``Tree`` Args: ``u`` (``Node``): Node ``u`` ``v`` (``Node``): Node ``v`` Returns: ``float``: The distance between nodes ``u`` and ``v``
[ "Return", "the", "distance", "between", "nodes", "u", "and", "v", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L265-L297
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.edge_length_sum
def edge_length_sum(self, terminal=True, internal=True): '''Compute the sum of all selected edge lengths in this ``Tree`` Args: ``terminal`` (``bool``): ``True`` to include terminal branches, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal branches, ot...
python
def edge_length_sum(self, terminal=True, internal=True): '''Compute the sum of all selected edge lengths in this ``Tree`` Args: ``terminal`` (``bool``): ``True`` to include terminal branches, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal branches, ot...
[ "def", "edge_length_sum", "(", "self", ",", "terminal", "=", "True", ",", "internal", "=", "True", ")", ":", "if", "not", "isinstance", "(", "terminal", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"leaves must be a bool\"", ")", "if", "not", "isins...
Compute the sum of all selected edge lengths in this ``Tree`` Args: ``terminal`` (``bool``): ``True`` to include terminal branches, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal branches, otherwise ``False`` Returns: ``float``: Sum of al...
[ "Compute", "the", "sum", "of", "all", "selected", "edge", "lengths", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L391-L406
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.extract_subtree
def extract_subtree(self, node): '''Return a copy of the subtree rooted at ``node`` Args: ``node`` (``Node``): The root of the desired subtree Returns: ``Tree``: A copy of the subtree rooted at ``node`` ''' if not isinstance(node, Node): rais...
python
def extract_subtree(self, node): '''Return a copy of the subtree rooted at ``node`` Args: ``node`` (``Node``): The root of the desired subtree Returns: ``Tree``: A copy of the subtree rooted at ``node`` ''' if not isinstance(node, Node): rais...
[ "def", "extract_subtree", "(", "self", ",", "node", ")", ":", "if", "not", "isinstance", "(", "node", ",", "Node", ")", ":", "raise", "TypeError", "(", "\"node must be a Node\"", ")", "r", "=", "self", ".", "root", "self", ".", "root", "=", "node", "o"...
Return a copy of the subtree rooted at ``node`` Args: ``node`` (``Node``): The root of the desired subtree Returns: ``Tree``: A copy of the subtree rooted at ``node``
[ "Return", "a", "copy", "of", "the", "subtree", "rooted", "at", "node" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L408-L419
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.extract_tree_without
def extract_tree_without(self, labels, suppress_unifurcations=True): '''Extract a copy of this ``Tree`` without the leaves labeled by the strings in ``labels`` Args: ``labels`` (``set``): Set of leaf labels to exclude ``suppress_unifurcations`` (``bool``): ``True`` to suppress ...
python
def extract_tree_without(self, labels, suppress_unifurcations=True): '''Extract a copy of this ``Tree`` without the leaves labeled by the strings in ``labels`` Args: ``labels`` (``set``): Set of leaf labels to exclude ``suppress_unifurcations`` (``bool``): ``True`` to suppress ...
[ "def", "extract_tree_without", "(", "self", ",", "labels", ",", "suppress_unifurcations", "=", "True", ")", ":", "return", "self", ".", "extract_tree", "(", "labels", ",", "True", ",", "suppress_unifurcations", ")" ]
Extract a copy of this ``Tree`` without the leaves labeled by the strings in ``labels`` Args: ``labels`` (``set``): Set of leaf labels to exclude ``suppress_unifurcations`` (``bool``): ``True`` to suppress unifurcations, otherwise ``False`` Returns: ``Tree``: Copy ...
[ "Extract", "a", "copy", "of", "this", "Tree", "without", "the", "leaves", "labeled", "by", "the", "strings", "in", "labels" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L451-L462
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.extract_tree_with
def extract_tree_with(self, labels, suppress_unifurcations=True): '''Extract a copy of this ``Tree`` with only the leaves labeled by the strings in ``labels`` Args: ``leaves`` (``set``): Set of leaf labels to include. ``suppress_unifurcations`` (``bool``): ``True`` to suppress ...
python
def extract_tree_with(self, labels, suppress_unifurcations=True): '''Extract a copy of this ``Tree`` with only the leaves labeled by the strings in ``labels`` Args: ``leaves`` (``set``): Set of leaf labels to include. ``suppress_unifurcations`` (``bool``): ``True`` to suppress ...
[ "def", "extract_tree_with", "(", "self", ",", "labels", ",", "suppress_unifurcations", "=", "True", ")", ":", "return", "self", ".", "extract_tree", "(", "labels", ",", "False", ",", "suppress_unifurcations", ")" ]
Extract a copy of this ``Tree`` with only the leaves labeled by the strings in ``labels`` Args: ``leaves`` (``set``): Set of leaf labels to include. ``suppress_unifurcations`` (``bool``): ``True`` to suppress unifurcations, otherwise ``False`` Returns: Tree: Copy o...
[ "Extract", "a", "copy", "of", "this", "Tree", "with", "only", "the", "leaves", "labeled", "by", "the", "strings", "in", "labels" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L464-L475
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.furthest_from_root
def furthest_from_root(self): '''Return the ``Node`` that is furthest from the root and the corresponding distance. Edges with no length will be considered to have a length of 0 Returns: ``tuple``: First value is the furthest ``Node`` from the root, and second value is the corresponding dis...
python
def furthest_from_root(self): '''Return the ``Node`` that is furthest from the root and the corresponding distance. Edges with no length will be considered to have a length of 0 Returns: ``tuple``: First value is the furthest ``Node`` from the root, and second value is the corresponding dis...
[ "def", "furthest_from_root", "(", "self", ")", ":", "best", "=", "(", "self", ".", "root", ",", "0", ")", "d", "=", "dict", "(", ")", "for", "node", "in", "self", ".", "traverse_preorder", "(", ")", ":", "if", "node", ".", "edge_length", "is", "Non...
Return the ``Node`` that is furthest from the root and the corresponding distance. Edges with no length will be considered to have a length of 0 Returns: ``tuple``: First value is the furthest ``Node`` from the root, and second value is the corresponding distance
[ "Return", "the", "Node", "that", "is", "furthest", "from", "the", "root", "and", "the", "corresponding", "distance", ".", "Edges", "with", "no", "length", "will", "be", "considered", "to", "have", "a", "length", "of", "0" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L477-L493
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.indent
def indent(self, space=4): '''Return an indented Newick string, just like ``nw_indent`` in Newick Utilities Args: ``space`` (``int``): The number of spaces a tab should equal Returns: ``str``: An indented Newick string ''' if not isinstance(space,int): ...
python
def indent(self, space=4): '''Return an indented Newick string, just like ``nw_indent`` in Newick Utilities Args: ``space`` (``int``): The number of spaces a tab should equal Returns: ``str``: An indented Newick string ''' if not isinstance(space,int): ...
[ "def", "indent", "(", "self", ",", "space", "=", "4", ")", ":", "if", "not", "isinstance", "(", "space", ",", "int", ")", ":", "raise", "TypeError", "(", "\"space must be an int\"", ")", "if", "space", "<", "0", ":", "raise", "ValueError", "(", "\"spac...
Return an indented Newick string, just like ``nw_indent`` in Newick Utilities Args: ``space`` (``int``): The number of spaces a tab should equal Returns: ``str``: An indented Newick string
[ "Return", "an", "indented", "Newick", "string", "just", "like", "nw_indent", "in", "Newick", "Utilities" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L525-L548
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.lineages_through_time
def lineages_through_time(self, present_day=None, show_plot=True, color='#000000', xmin=None, xmax=None, ymin=None, ymax=None, title=None, xlabel=None, ylabel=None): '''Compute the number of lineages through time. If seaborn is installed, a plot is shown as well Args: ``present_day`` (``flo...
python
def lineages_through_time(self, present_day=None, show_plot=True, color='#000000', xmin=None, xmax=None, ymin=None, ymax=None, title=None, xlabel=None, ylabel=None): '''Compute the number of lineages through time. If seaborn is installed, a plot is shown as well Args: ``present_day`` (``flo...
[ "def", "lineages_through_time", "(", "self", ",", "present_day", "=", "None", ",", "show_plot", "=", "True", ",", "color", "=", "'#000000'", ",", "xmin", "=", "None", ",", "xmax", "=", "None", ",", "ymin", "=", "None", ",", "ymax", "=", "None", ",", ...
Compute the number of lineages through time. If seaborn is installed, a plot is shown as well Args: ``present_day`` (``float``): The time of the furthest node from the root. If ``None``, the top of the tree will be placed at time 0 ``show_plot`` (``bool``): ``True`` to show the plot, o...
[ "Compute", "the", "number", "of", "lineages", "through", "time", ".", "If", "seaborn", "is", "installed", "a", "plot", "is", "shown", "as", "well" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L615-L686
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.newick
def newick(self): '''Output this ``Tree`` as a Newick string Returns: ``str``: Newick string of this ``Tree`` ''' if self.root.edge_length is None: suffix = ';' elif isinstance(self.root.edge_length,int): suffix = ':%d;' % self.root.edge_lengt...
python
def newick(self): '''Output this ``Tree`` as a Newick string Returns: ``str``: Newick string of this ``Tree`` ''' if self.root.edge_length is None: suffix = ';' elif isinstance(self.root.edge_length,int): suffix = ':%d;' % self.root.edge_lengt...
[ "def", "newick", "(", "self", ")", ":", "if", "self", ".", "root", ".", "edge_length", "is", "None", ":", "suffix", "=", "';'", "elif", "isinstance", "(", "self", ".", "root", ".", "edge_length", ",", "int", ")", ":", "suffix", "=", "':%d;'", "%", ...
Output this ``Tree`` as a Newick string Returns: ``str``: Newick string of this ``Tree``
[ "Output", "this", "Tree", "as", "a", "Newick", "string" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L738-L755
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.num_lineages_at
def num_lineages_at(self, distance): '''Returns the number of lineages of this ``Tree`` that exist ``distance`` away from the root Args: ``distance`` (``float``): The distance away from the root Returns: ``int``: The number of lineages that exist ``distance`` away from ...
python
def num_lineages_at(self, distance): '''Returns the number of lineages of this ``Tree`` that exist ``distance`` away from the root Args: ``distance`` (``float``): The distance away from the root Returns: ``int``: The number of lineages that exist ``distance`` away from ...
[ "def", "num_lineages_at", "(", "self", ",", "distance", ")", ":", "if", "not", "isinstance", "(", "distance", ",", "float", ")", "and", "not", "isinstance", "(", "distance", ",", "int", ")", ":", "raise", "TypeError", "(", "\"distance must be an int or a float...
Returns the number of lineages of this ``Tree`` that exist ``distance`` away from the root Args: ``distance`` (``float``): The distance away from the root Returns: ``int``: The number of lineages that exist ``distance`` away from the root
[ "Returns", "the", "number", "of", "lineages", "of", "this", "Tree", "that", "exist", "distance", "away", "from", "the", "root" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L757-L783
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.num_nodes
def num_nodes(self, leaves=True, internal=True): '''Compute the total number of selected nodes in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`` ...
python
def num_nodes(self, leaves=True, internal=True): '''Compute the total number of selected nodes in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`` ...
[ "def", "num_nodes", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "if", "not", "isinstance", "(", "leaves", ",", "bool", ")", ":", "raise", "TypeError", "(", "\"leaves must be a bool\"", ")", "if", "not", "isinstance", ...
Compute the total number of selected nodes in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False`` Returns: ``int``: The total number of selected ...
[ "Compute", "the", "total", "number", "of", "selected", "nodes", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L785-L804
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.rename_nodes
def rename_nodes(self, renaming_map): '''Rename nodes in this ``Tree`` Args: ``renaming_map`` (``dict``): A dictionary mapping old labels (keys) to new labels (values) ''' if not isinstance(renaming_map, dict): raise TypeError("renaming_map must be a dict") ...
python
def rename_nodes(self, renaming_map): '''Rename nodes in this ``Tree`` Args: ``renaming_map`` (``dict``): A dictionary mapping old labels (keys) to new labels (values) ''' if not isinstance(renaming_map, dict): raise TypeError("renaming_map must be a dict") ...
[ "def", "rename_nodes", "(", "self", ",", "renaming_map", ")", ":", "if", "not", "isinstance", "(", "renaming_map", ",", "dict", ")", ":", "raise", "TypeError", "(", "\"renaming_map must be a dict\"", ")", "for", "node", "in", "self", ".", "traverse_preorder", ...
Rename nodes in this ``Tree`` Args: ``renaming_map`` (``dict``): A dictionary mapping old labels (keys) to new labels (values)
[ "Rename", "nodes", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L890-L900
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.sackin
def sackin(self, normalize='leaves'): '''Compute the Sackin balance index of this ``Tree`` Args: ``normalize`` (``str``): How to normalize the Sackin index (if at all) * ``None`` to not normalize * ``"leaves"`` to normalize by the number of leaves * ``...
python
def sackin(self, normalize='leaves'): '''Compute the Sackin balance index of this ``Tree`` Args: ``normalize`` (``str``): How to normalize the Sackin index (if at all) * ``None`` to not normalize * ``"leaves"`` to normalize by the number of leaves * ``...
[ "def", "sackin", "(", "self", ",", "normalize", "=", "'leaves'", ")", ":", "num_nodes_from_root", "=", "dict", "(", ")", "sackin", "=", "0", "num_leaves", "=", "0", "for", "node", "in", "self", ".", "traverse_preorder", "(", ")", ":", "num_nodes_from_root"...
Compute the Sackin balance index of this ``Tree`` Args: ``normalize`` (``str``): How to normalize the Sackin index (if at all) * ``None`` to not normalize * ``"leaves"`` to normalize by the number of leaves * ``"yule"`` to normalize to the Yule model ...
[ "Compute", "the", "Sackin", "balance", "index", "of", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L947-L984
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.scale_edges
def scale_edges(self, multiplier): '''Multiply all edges in this ``Tree`` by ``multiplier``''' if not isinstance(multiplier,int) and not isinstance(multiplier,float): raise TypeError("multiplier must be an int or float") for node in self.traverse_preorder(): if node.edge_...
python
def scale_edges(self, multiplier): '''Multiply all edges in this ``Tree`` by ``multiplier``''' if not isinstance(multiplier,int) and not isinstance(multiplier,float): raise TypeError("multiplier must be an int or float") for node in self.traverse_preorder(): if node.edge_...
[ "def", "scale_edges", "(", "self", ",", "multiplier", ")", ":", "if", "not", "isinstance", "(", "multiplier", ",", "int", ")", "and", "not", "isinstance", "(", "multiplier", ",", "float", ")", ":", "raise", "TypeError", "(", "\"multiplier must be an int or flo...
Multiply all edges in this ``Tree`` by ``multiplier``
[ "Multiply", "all", "edges", "in", "this", "Tree", "by", "multiplier" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L986-L992
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.suppress_unifurcations
def suppress_unifurcations(self): '''Remove all nodes with only one child and directly attach child to parent''' q = deque(); q.append(self.root) while len(q) != 0: node = q.popleft() if len(node.children) != 1: q.extend(node.children); continue ...
python
def suppress_unifurcations(self): '''Remove all nodes with only one child and directly attach child to parent''' q = deque(); q.append(self.root) while len(q) != 0: node = q.popleft() if len(node.children) != 1: q.extend(node.children); continue ...
[ "def", "suppress_unifurcations", "(", "self", ")", ":", "q", "=", "deque", "(", ")", "q", ".", "append", "(", "self", ".", "root", ")", "while", "len", "(", "q", ")", "!=", "0", ":", "node", "=", "q", ".", "popleft", "(", ")", "if", "len", "(",...
Remove all nodes with only one child and directly attach child to parent
[ "Remove", "all", "nodes", "with", "only", "one", "child", "and", "directly", "attach", "child", "to", "parent" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L994-L1012
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.traverse_inorder
def traverse_inorder(self, leaves=True, internal=True): '''Perform an inorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise `...
python
def traverse_inorder(self, leaves=True, internal=True): '''Perform an inorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise `...
[ "def", "traverse_inorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "for", "node", "in", "self", ".", "root", ".", "traverse_inorder", "(", "leaves", "=", "leaves", ",", "internal", "=", "internal", ")", ":", "yi...
Perform an inorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "an", "inorder", "traversal", "of", "the", "Node", "objects", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L1014-L1023
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.traverse_levelorder
def traverse_levelorder(self, leaves=True, internal=True): '''Perform a levelorder traversal of the ``Node`` objects in this ``Tree``''' for node in self.root.traverse_levelorder(leaves=leaves, internal=internal): yield node
python
def traverse_levelorder(self, leaves=True, internal=True): '''Perform a levelorder traversal of the ``Node`` objects in this ``Tree``''' for node in self.root.traverse_levelorder(leaves=leaves, internal=internal): yield node
[ "def", "traverse_levelorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "for", "node", "in", "self", ".", "root", ".", "traverse_levelorder", "(", "leaves", "=", "leaves", ",", "internal", "=", "internal", ")", ":",...
Perform a levelorder traversal of the ``Node`` objects in this ``Tree``
[ "Perform", "a", "levelorder", "traversal", "of", "the", "Node", "objects", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L1035-L1038
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.traverse_postorder
def traverse_postorder(self, leaves=True, internal=True): '''Perform a postorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwis...
python
def traverse_postorder(self, leaves=True, internal=True): '''Perform a postorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwis...
[ "def", "traverse_postorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "for", "node", "in", "self", ".", "root", ".", "traverse_postorder", "(", "leaves", "=", "leaves", ",", "internal", "=", "internal", ")", ":", ...
Perform a postorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "a", "postorder", "traversal", "of", "the", "Node", "objects", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L1040-L1049
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.traverse_preorder
def traverse_preorder(self, leaves=True, internal=True): '''Perform a preorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ...
python
def traverse_preorder(self, leaves=True, internal=True): '''Perform a preorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ...
[ "def", "traverse_preorder", "(", "self", ",", "leaves", "=", "True", ",", "internal", "=", "True", ")", ":", "for", "node", "in", "self", ".", "root", ".", "traverse_preorder", "(", "leaves", "=", "leaves", ",", "internal", "=", "internal", ")", ":", "...
Perform a preorder traversal of the ``Node`` objects in this ``Tree`` Args: ``leaves`` (``bool``): ``True`` to include leaves, otherwise ``False`` ``internal`` (``bool``): ``True`` to include internal nodes, otherwise ``False``
[ "Perform", "a", "preorder", "traversal", "of", "the", "Node", "objects", "in", "this", "Tree" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L1051-L1060
train
niemasd/TreeSwift
treeswift/Tree.py
Tree.write_tree_newick
def write_tree_newick(self, filename, hide_rooted_prefix=False): '''Write this ``Tree`` to a Newick file Args: ``filename`` (``str``): Path to desired output file (plain-text or gzipped) ''' if not isinstance(filename, str): raise TypeError("filename must be a st...
python
def write_tree_newick(self, filename, hide_rooted_prefix=False): '''Write this ``Tree`` to a Newick file Args: ``filename`` (``str``): Path to desired output file (plain-text or gzipped) ''' if not isinstance(filename, str): raise TypeError("filename must be a st...
[ "def", "write_tree_newick", "(", "self", ",", "filename", ",", "hide_rooted_prefix", "=", "False", ")", ":", "if", "not", "isinstance", "(", "filename", ",", "str", ")", ":", "raise", "TypeError", "(", "\"filename must be a str\"", ")", "treestr", "=", "self",...
Write this ``Tree`` to a Newick file Args: ``filename`` (``str``): Path to desired output file (plain-text or gzipped)
[ "Write", "this", "Tree", "to", "a", "Newick", "file" ]
7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917
https://github.com/niemasd/TreeSwift/blob/7e0cbc770fcc2ee1194ef7c2a0ab9fb82f089917/treeswift/Tree.py#L1089-L1106
train
LogicalDash/LiSE
allegedb/allegedb/window.py
update_window
def update_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): """Iterate over a window of time in ``branchd`` and call ``updfun`` on the values""" if turn_from in branchd: # Not including the exact tick you started from because deltas are *changes* for past_state in branchd[turn_fr...
python
def update_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): """Iterate over a window of time in ``branchd`` and call ``updfun`` on the values""" if turn_from in branchd: # Not including the exact tick you started from because deltas are *changes* for past_state in branchd[turn_fr...
[ "def", "update_window", "(", "turn_from", ",", "tick_from", ",", "turn_to", ",", "tick_to", ",", "updfun", ",", "branchd", ")", ":", "if", "turn_from", "in", "branchd", ":", "for", "past_state", "in", "branchd", "[", "turn_from", "]", "[", "tick_from", "+"...
Iterate over a window of time in ``branchd`` and call ``updfun`` on the values
[ "Iterate", "over", "a", "window", "of", "time", "in", "branchd", "and", "call", "updfun", "on", "the", "values" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L46-L58
train
LogicalDash/LiSE
allegedb/allegedb/window.py
update_backward_window
def update_backward_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): """Iterate backward over a window of time in ``branchd`` and call ``updfun`` on the values""" if turn_from in branchd: for future_state in reversed(branchd[turn_from][:tick_from]): updfun(*future_state) ...
python
def update_backward_window(turn_from, tick_from, turn_to, tick_to, updfun, branchd): """Iterate backward over a window of time in ``branchd`` and call ``updfun`` on the values""" if turn_from in branchd: for future_state in reversed(branchd[turn_from][:tick_from]): updfun(*future_state) ...
[ "def", "update_backward_window", "(", "turn_from", ",", "tick_from", ",", "turn_to", ",", "tick_to", ",", "updfun", ",", "branchd", ")", ":", "if", "turn_from", "in", "branchd", ":", "for", "future_state", "in", "reversed", "(", "branchd", "[", "turn_from", ...
Iterate backward over a window of time in ``branchd`` and call ``updfun`` on the values
[ "Iterate", "backward", "over", "a", "window", "of", "time", "in", "branchd", "and", "call", "updfun", "on", "the", "values" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L61-L72
train
LogicalDash/LiSE
allegedb/allegedb/window.py
within_history
def within_history(rev, windowdict): """Return whether the windowdict has history at the revision.""" if not windowdict: return False begin = windowdict._past[0][0] if windowdict._past else \ windowdict._future[-1][0] end = windowdict._future[0][0] if windowdict._future else \ ...
python
def within_history(rev, windowdict): """Return whether the windowdict has history at the revision.""" if not windowdict: return False begin = windowdict._past[0][0] if windowdict._past else \ windowdict._future[-1][0] end = windowdict._future[0][0] if windowdict._future else \ ...
[ "def", "within_history", "(", "rev", ",", "windowdict", ")", ":", "if", "not", "windowdict", ":", "return", "False", "begin", "=", "windowdict", ".", "_past", "[", "0", "]", "[", "0", "]", "if", "windowdict", ".", "_past", "else", "windowdict", ".", "_...
Return whether the windowdict has history at the revision.
[ "Return", "whether", "the", "windowdict", "has", "history", "at", "the", "revision", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L83-L91
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.future
def future(self, rev=None): """Return a Mapping of items after the given revision. Default revision is the last one looked up. """ if rev is not None: self.seek(rev) return WindowDictFutureView(self._future)
python
def future(self, rev=None): """Return a Mapping of items after the given revision. Default revision is the last one looked up. """ if rev is not None: self.seek(rev) return WindowDictFutureView(self._future)
[ "def", "future", "(", "self", ",", "rev", "=", "None", ")", ":", "if", "rev", "is", "not", "None", ":", "self", ".", "seek", "(", "rev", ")", "return", "WindowDictFutureView", "(", "self", ".", "_future", ")" ]
Return a Mapping of items after the given revision. Default revision is the last one looked up.
[ "Return", "a", "Mapping", "of", "items", "after", "the", "given", "revision", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L429-L437
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.past
def past(self, rev=None): """Return a Mapping of items at or before the given revision. Default revision is the last one looked up. """ if rev is not None: self.seek(rev) return WindowDictPastView(self._past)
python
def past(self, rev=None): """Return a Mapping of items at or before the given revision. Default revision is the last one looked up. """ if rev is not None: self.seek(rev) return WindowDictPastView(self._past)
[ "def", "past", "(", "self", ",", "rev", "=", "None", ")", ":", "if", "rev", "is", "not", "None", ":", "self", ".", "seek", "(", "rev", ")", "return", "WindowDictPastView", "(", "self", ".", "_past", ")" ]
Return a Mapping of items at or before the given revision. Default revision is the last one looked up.
[ "Return", "a", "Mapping", "of", "items", "at", "or", "before", "the", "given", "revision", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L439-L447
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.seek
def seek(self, rev): """Arrange the caches to help look up the given revision.""" # TODO: binary search? Perhaps only when one or the other # stack is very large? if not self: return if type(rev) is not int: raise TypeError("rev must be int") past ...
python
def seek(self, rev): """Arrange the caches to help look up the given revision.""" # TODO: binary search? Perhaps only when one or the other # stack is very large? if not self: return if type(rev) is not int: raise TypeError("rev must be int") past ...
[ "def", "seek", "(", "self", ",", "rev", ")", ":", "if", "not", "self", ":", "return", "if", "type", "(", "rev", ")", "is", "not", "int", ":", "raise", "TypeError", "(", "\"rev must be int\"", ")", "past", "=", "self", ".", "_past", "future", "=", "...
Arrange the caches to help look up the given revision.
[ "Arrange", "the", "caches", "to", "help", "look", "up", "the", "given", "revision", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L450-L479
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.rev_before
def rev_before(self, rev: int) -> int: """Return the latest past rev on which the value changed.""" self.seek(rev) if self._past: return self._past[-1][0]
python
def rev_before(self, rev: int) -> int: """Return the latest past rev on which the value changed.""" self.seek(rev) if self._past: return self._past[-1][0]
[ "def", "rev_before", "(", "self", ",", "rev", ":", "int", ")", "->", "int", ":", "self", ".", "seek", "(", "rev", ")", "if", "self", ".", "_past", ":", "return", "self", ".", "_past", "[", "-", "1", "]", "[", "0", "]" ]
Return the latest past rev on which the value changed.
[ "Return", "the", "latest", "past", "rev", "on", "which", "the", "value", "changed", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L487-L491
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.rev_after
def rev_after(self, rev: int) -> int: """Return the earliest future rev on which the value will change.""" self.seek(rev) if self._future: return self._future[-1][0]
python
def rev_after(self, rev: int) -> int: """Return the earliest future rev on which the value will change.""" self.seek(rev) if self._future: return self._future[-1][0]
[ "def", "rev_after", "(", "self", ",", "rev", ":", "int", ")", "->", "int", ":", "self", ".", "seek", "(", "rev", ")", "if", "self", ".", "_future", ":", "return", "self", ".", "_future", "[", "-", "1", "]", "[", "0", "]" ]
Return the earliest future rev on which the value will change.
[ "Return", "the", "earliest", "future", "rev", "on", "which", "the", "value", "will", "change", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L493-L497
train
LogicalDash/LiSE
allegedb/allegedb/window.py
WindowDict.truncate
def truncate(self, rev: int) -> None: """Delete everything after the given revision.""" self.seek(rev) self._keys.difference_update(map(get0, self._future)) self._future = [] if not self._past: self._beginning = None
python
def truncate(self, rev: int) -> None: """Delete everything after the given revision.""" self.seek(rev) self._keys.difference_update(map(get0, self._future)) self._future = [] if not self._past: self._beginning = None
[ "def", "truncate", "(", "self", ",", "rev", ":", "int", ")", "->", "None", ":", "self", ".", "seek", "(", "rev", ")", "self", ".", "_keys", ".", "difference_update", "(", "map", "(", "get0", ",", "self", ".", "_future", ")", ")", "self", ".", "_f...
Delete everything after the given revision.
[ "Delete", "everything", "after", "the", "given", "revision", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/window.py#L499-L505
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.build_config
def build_config(self, config): """Set config defaults""" for sec in 'LiSE', 'ELiDE': config.adddefaultsection(sec) config.setdefaults( 'LiSE', { 'world': 'sqlite:///LiSEworld.db', 'language': 'eng', 'logfile': '...
python
def build_config(self, config): """Set config defaults""" for sec in 'LiSE', 'ELiDE': config.adddefaultsection(sec) config.setdefaults( 'LiSE', { 'world': 'sqlite:///LiSEworld.db', 'language': 'eng', 'logfile': '...
[ "def", "build_config", "(", "self", ",", "config", ")", ":", "for", "sec", "in", "'LiSE'", ",", "'ELiDE'", ":", "config", ".", "adddefaultsection", "(", "sec", ")", "config", ".", "setdefaults", "(", "'LiSE'", ",", "{", "'world'", ":", "'sqlite:///LiSEworl...
Set config defaults
[ "Set", "config", "defaults" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L121-L162
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.build
def build(self): """Make sure I can use the database, create the tables as needed, and return the root widget. """ self.icon = 'icon_24px.png' config = self.config Logger.debug( "ELiDEApp: starting with world {}, path {}".format( config['LiSE'...
python
def build(self): """Make sure I can use the database, create the tables as needed, and return the root widget. """ self.icon = 'icon_24px.png' config = self.config Logger.debug( "ELiDEApp: starting with world {}, path {}".format( config['LiSE'...
[ "def", "build", "(", "self", ")", ":", "self", ".", "icon", "=", "'icon_24px.png'", "config", "=", "self", ".", "config", "Logger", ".", "debug", "(", "\"ELiDEApp: starting with world {}, path {}\"", ".", "format", "(", "config", "[", "'LiSE'", "]", "[", "'w...
Make sure I can use the database, create the tables as needed, and return the root widget.
[ "Make", "sure", "I", "can", "use", "the", "database", "create", "the", "tables", "as", "needed", "and", "return", "the", "root", "widget", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L164-L191
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.on_pause
def on_pause(self): """Sync the database with the current state of the game.""" self.engine.commit() self.strings.save() self.funcs.save() self.config.write()
python
def on_pause(self): """Sync the database with the current state of the game.""" self.engine.commit() self.strings.save() self.funcs.save() self.config.write()
[ "def", "on_pause", "(", "self", ")", ":", "self", ".", "engine", ".", "commit", "(", ")", "self", ".", "strings", ".", "save", "(", ")", "self", ".", "funcs", ".", "save", "(", ")", "self", ".", "config", ".", "write", "(", ")" ]
Sync the database with the current state of the game.
[ "Sync", "the", "database", "with", "the", "current", "state", "of", "the", "game", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L370-L375
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.on_stop
def on_stop(self, *largs): """Sync the database, wrap up the game, and halt.""" self.strings.save() self.funcs.save() self.engine.commit() self.procman.shutdown() self.config.write()
python
def on_stop(self, *largs): """Sync the database, wrap up the game, and halt.""" self.strings.save() self.funcs.save() self.engine.commit() self.procman.shutdown() self.config.write()
[ "def", "on_stop", "(", "self", ",", "*", "largs", ")", ":", "self", ".", "strings", ".", "save", "(", ")", "self", ".", "funcs", ".", "save", "(", ")", "self", ".", "engine", ".", "commit", "(", ")", "self", ".", "procman", ".", "shutdown", "(", ...
Sync the database, wrap up the game, and halt.
[ "Sync", "the", "database", "wrap", "up", "the", "game", "and", "halt", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L377-L383
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.delete_selection
def delete_selection(self): """Delete both the selected widget and whatever it represents.""" selection = self.selection if selection is None: return if isinstance(selection, ArrowWidget): self.mainscreen.boardview.board.rm_arrow( selection.origin....
python
def delete_selection(self): """Delete both the selected widget and whatever it represents.""" selection = self.selection if selection is None: return if isinstance(selection, ArrowWidget): self.mainscreen.boardview.board.rm_arrow( selection.origin....
[ "def", "delete_selection", "(", "self", ")", ":", "selection", "=", "self", ".", "selection", "if", "selection", "is", "None", ":", "return", "if", "isinstance", "(", "selection", ",", "ArrowWidget", ")", ":", "self", ".", "mainscreen", ".", "boardview", "...
Delete both the selected widget and whatever it represents.
[ "Delete", "both", "the", "selected", "widget", "and", "whatever", "it", "represents", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L385-L403
train
LogicalDash/LiSE
ELiDE/ELiDE/app.py
ELiDEApp.new_board
def new_board(self, name): """Make a board for a character name, and switch to it.""" char = self.engine.character[name] board = Board(character=char) self.mainscreen.boards[name] = board self.character = char
python
def new_board(self, name): """Make a board for a character name, and switch to it.""" char = self.engine.character[name] board = Board(character=char) self.mainscreen.boards[name] = board self.character = char
[ "def", "new_board", "(", "self", ",", "name", ")", ":", "char", "=", "self", ".", "engine", ".", "character", "[", "name", "]", "board", "=", "Board", "(", "character", "=", "char", ")", "self", ".", "mainscreen", ".", "boards", "[", "name", "]", "...
Make a board for a character name, and switch to it.
[ "Make", "a", "board", "for", "a", "character", "name", "and", "switch", "to", "it", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/app.py#L405-L410
train
LogicalDash/LiSE
ELiDE/ELiDE/util.py
dummynum
def dummynum(character, name): """Count how many nodes there already are in the character whose name starts the same. """ num = 0 for nodename in character.node: nodename = str(nodename) if not nodename.startswith(name): continue try: nodenum = int(no...
python
def dummynum(character, name): """Count how many nodes there already are in the character whose name starts the same. """ num = 0 for nodename in character.node: nodename = str(nodename) if not nodename.startswith(name): continue try: nodenum = int(no...
[ "def", "dummynum", "(", "character", ",", "name", ")", ":", "num", "=", "0", "for", "nodename", "in", "character", ".", "node", ":", "nodename", "=", "str", "(", "nodename", ")", "if", "not", "nodename", ".", "startswith", "(", "name", ")", ":", "con...
Count how many nodes there already are in the character whose name starts the same.
[ "Count", "how", "many", "nodes", "there", "already", "are", "in", "the", "character", "whose", "name", "starts", "the", "same", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/util.py#L81-L96
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
lru_append
def lru_append(kc, lru, kckey, maxsize): """Delete old data from ``kc``, then add the new ``kckey``. :param kc: a three-layer keycache :param lru: an :class:`OrderedDict` with a key for each triple that should fill out ``kc``'s three layers :param kckey: a triple that indexes into ``kc``, which will be...
python
def lru_append(kc, lru, kckey, maxsize): """Delete old data from ``kc``, then add the new ``kckey``. :param kc: a three-layer keycache :param lru: an :class:`OrderedDict` with a key for each triple that should fill out ``kc``'s three layers :param kckey: a triple that indexes into ``kc``, which will be...
[ "def", "lru_append", "(", "kc", ",", "lru", ",", "kckey", ",", "maxsize", ")", ":", "if", "kckey", "in", "lru", ":", "return", "while", "len", "(", "lru", ")", ">=", "maxsize", ":", "(", "peb", ",", "turn", ",", "tick", ")", ",", "_", "=", "lru...
Delete old data from ``kc``, then add the new ``kckey``. :param kc: a three-layer keycache :param lru: an :class:`OrderedDict` with a key for each triple that should fill out ``kc``'s three layers :param kckey: a triple that indexes into ``kc``, which will be added to ``lru`` if needed :param maxsize: ...
[ "Delete", "old", "data", "from", "kc", "then", "add", "the", "new", "kckey", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L146-L172
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache.load
def load(self, data): """Add a bunch of data. Must be in chronological order. But it doesn't need to all be from the same branch, as long as each branch is chronological of itself. """ branches = defaultdict(list) for row in data: branches[row[-4]].append(ro...
python
def load(self, data): """Add a bunch of data. Must be in chronological order. But it doesn't need to all be from the same branch, as long as each branch is chronological of itself. """ branches = defaultdict(list) for row in data: branches[row[-4]].append(ro...
[ "def", "load", "(", "self", ",", "data", ")", ":", "branches", "=", "defaultdict", "(", "list", ")", "for", "row", "in", "data", ":", "branches", "[", "row", "[", "-", "4", "]", "]", ".", "append", "(", "row", ")", "childbranch", "=", "self", "."...
Add a bunch of data. Must be in chronological order. But it doesn't need to all be from the same branch, as long as each branch is chronological of itself.
[ "Add", "a", "bunch", "of", "data", ".", "Must", "be", "in", "chronological", "order", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L233-L254
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache._valcache_lookup
def _valcache_lookup(self, cache, branch, turn, tick): """Return the value at the given time in ``cache``""" if branch in cache: branc = cache[branch] try: if turn in branc and branc[turn].rev_gettable(tick): return branc[turn][tick] ...
python
def _valcache_lookup(self, cache, branch, turn, tick): """Return the value at the given time in ``cache``""" if branch in cache: branc = cache[branch] try: if turn in branc and branc[turn].rev_gettable(tick): return branc[turn][tick] ...
[ "def", "_valcache_lookup", "(", "self", ",", "cache", ",", "branch", ",", "turn", ",", "tick", ")", ":", "if", "branch", "in", "cache", ":", "branc", "=", "cache", "[", "branch", "]", "try", ":", "if", "turn", "in", "branc", "and", "branc", "[", "t...
Return the value at the given time in ``cache``
[ "Return", "the", "value", "at", "the", "given", "time", "in", "cache" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L256-L285
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache._get_keycache
def _get_keycache(self, parentity, branch, turn, tick, *, forward): """Get a frozenset of keys that exist in the entity at the moment. With ``forward=True``, enable an optimization that copies old key sets forward and updates them. """ lru_append(self.keycache, self._kc_lru, (p...
python
def _get_keycache(self, parentity, branch, turn, tick, *, forward): """Get a frozenset of keys that exist in the entity at the moment. With ``forward=True``, enable an optimization that copies old key sets forward and updates them. """ lru_append(self.keycache, self._kc_lru, (p...
[ "def", "_get_keycache", "(", "self", ",", "parentity", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", ")", ":", "lru_append", "(", "self", ".", "keycache", ",", "self", ".", "_kc_lru", ",", "(", "parentity", "+", "(", "branch", ",...
Get a frozenset of keys that exist in the entity at the moment. With ``forward=True``, enable an optimization that copies old key sets forward and updates them.
[ "Get", "a", "frozenset", "of", "keys", "that", "exist", "in", "the", "entity", "at", "the", "moment", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L388-L399
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache._update_keycache
def _update_keycache(self, *args, forward): """Add or remove a key in the set describing the keys that exist.""" entity, key, branch, turn, tick, value = args[-6:] parent = args[:-6] kc = self._get_keycache(parent + (entity,), branch, turn, tick, forward=forward) if value is None...
python
def _update_keycache(self, *args, forward): """Add or remove a key in the set describing the keys that exist.""" entity, key, branch, turn, tick, value = args[-6:] parent = args[:-6] kc = self._get_keycache(parent + (entity,), branch, turn, tick, forward=forward) if value is None...
[ "def", "_update_keycache", "(", "self", ",", "*", "args", ",", "forward", ")", ":", "entity", ",", "key", ",", "branch", ",", "turn", ",", "tick", ",", "value", "=", "args", "[", "-", "6", ":", "]", "parent", "=", "args", "[", ":", "-", "6", "]...
Add or remove a key in the set describing the keys that exist.
[ "Add", "or", "remove", "a", "key", "in", "the", "set", "describing", "the", "keys", "that", "exist", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L401-L410
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache.remove
def remove(self, branch, turn, tick): """Delete all data from a specific tick""" time_entity, parents, branches, keys, settings, presettings, remove_keycache, send = self._remove_stuff parent, entity, key = time_entity[branch, turn, tick] branchkey = parent + (entity, key) keykey...
python
def remove(self, branch, turn, tick): """Delete all data from a specific tick""" time_entity, parents, branches, keys, settings, presettings, remove_keycache, send = self._remove_stuff parent, entity, key = time_entity[branch, turn, tick] branchkey = parent + (entity, key) keykey...
[ "def", "remove", "(", "self", ",", "branch", ",", "turn", ",", "tick", ")", ":", "time_entity", ",", "parents", ",", "branches", ",", "keys", ",", "settings", ",", "presettings", ",", "remove_keycache", ",", "send", "=", "self", ".", "_remove_stuff", "pa...
Delete all data from a specific tick
[ "Delete", "all", "data", "from", "a", "specific", "tick" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L475-L550
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache._remove_keycache
def _remove_keycache(self, entity_branch, turn, tick): """Remove the future of a given entity from a branch in the keycache""" keycache = self.keycache if entity_branch in keycache: kc = keycache[entity_branch] if turn in kc: kcturn = kc[turn] ...
python
def _remove_keycache(self, entity_branch, turn, tick): """Remove the future of a given entity from a branch in the keycache""" keycache = self.keycache if entity_branch in keycache: kc = keycache[entity_branch] if turn in kc: kcturn = kc[turn] ...
[ "def", "_remove_keycache", "(", "self", ",", "entity_branch", ",", "turn", ",", "tick", ")", ":", "keycache", "=", "self", ".", "keycache", "if", "entity_branch", "in", "keycache", ":", "kc", "=", "keycache", "[", "entity_branch", "]", "if", "turn", "in", ...
Remove the future of a given entity from a branch in the keycache
[ "Remove", "the", "future", "of", "a", "given", "entity", "from", "a", "branch", "in", "the", "keycache" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L552-L566
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
Cache.count_entities_or_keys
def count_entities_or_keys(self, *args, forward=None): """Return the number of keys an entity has, if you specify an entity. Otherwise return the number of entities. """ if forward is None: forward = self.db._forward entity = args[:-3] branch, turn, tick = a...
python
def count_entities_or_keys(self, *args, forward=None): """Return the number of keys an entity has, if you specify an entity. Otherwise return the number of entities. """ if forward is None: forward = self.db._forward entity = args[:-3] branch, turn, tick = a...
[ "def", "count_entities_or_keys", "(", "self", ",", "*", "args", ",", "forward", "=", "None", ")", ":", "if", "forward", "is", "None", ":", "forward", "=", "self", ".", "db", ".", "_forward", "entity", "=", "args", "[", ":", "-", "3", "]", "branch", ...
Return the number of keys an entity has, if you specify an entity. Otherwise return the number of entities.
[ "Return", "the", "number", "of", "keys", "an", "entity", "has", "if", "you", "specify", "an", "entity", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L799-L811
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache._adds_dels_sucpred
def _adds_dels_sucpred(self, cache, branch, turn, tick, *, stoptime=None): """Take the successors or predecessors cache and get nodes added or deleted from it Operates like ``_get_adds_dels``. """ added = set() deleted = set() for node, nodes in cache.items(): ...
python
def _adds_dels_sucpred(self, cache, branch, turn, tick, *, stoptime=None): """Take the successors or predecessors cache and get nodes added or deleted from it Operates like ``_get_adds_dels``. """ added = set() deleted = set() for node, nodes in cache.items(): ...
[ "def", "_adds_dels_sucpred", "(", "self", ",", "cache", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "stoptime", "=", "None", ")", ":", "added", "=", "set", "(", ")", "deleted", "=", "set", "(", ")", "for", "node", ",", "nodes", "in", ...
Take the successors or predecessors cache and get nodes added or deleted from it Operates like ``_get_adds_dels``.
[ "Take", "the", "successors", "or", "predecessors", "cache", "and", "get", "nodes", "added", "or", "deleted", "from", "it" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L888-L902
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache._get_destcache
def _get_destcache(self, graph, orig, branch, turn, tick, *, forward): """Return a set of destination nodes succeeding ``orig``""" destcache, destcache_lru, get_keycachelike, successors, adds_dels_sucpred = self._get_destcache_stuff lru_append(destcache, destcache_lru, ((graph, orig, branch), tu...
python
def _get_destcache(self, graph, orig, branch, turn, tick, *, forward): """Return a set of destination nodes succeeding ``orig``""" destcache, destcache_lru, get_keycachelike, successors, adds_dels_sucpred = self._get_destcache_stuff lru_append(destcache, destcache_lru, ((graph, orig, branch), tu...
[ "def", "_get_destcache", "(", "self", ",", "graph", ",", "orig", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", ")", ":", "destcache", ",", "destcache_lru", ",", "get_keycachelike", ",", "successors", ",", "adds_dels_sucpred", "=", "sel...
Return a set of destination nodes succeeding ``orig``
[ "Return", "a", "set", "of", "destination", "nodes", "succeeding", "orig" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L904-L911
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache._get_origcache
def _get_origcache(self, graph, dest, branch, turn, tick, *, forward): """Return a set of origin nodes leading to ``dest``""" origcache, origcache_lru, get_keycachelike, predecessors, adds_dels_sucpred = self._get_origcache_stuff lru_append(origcache, origcache_lru, ((graph, dest, branch), turn,...
python
def _get_origcache(self, graph, dest, branch, turn, tick, *, forward): """Return a set of origin nodes leading to ``dest``""" origcache, origcache_lru, get_keycachelike, predecessors, adds_dels_sucpred = self._get_origcache_stuff lru_append(origcache, origcache_lru, ((graph, dest, branch), turn,...
[ "def", "_get_origcache", "(", "self", ",", "graph", ",", "dest", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", ")", ":", "origcache", ",", "origcache_lru", ",", "get_keycachelike", ",", "predecessors", ",", "adds_dels_sucpred", "=", "s...
Return a set of origin nodes leading to ``dest``
[ "Return", "a", "set", "of", "origin", "nodes", "leading", "to", "dest" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L913-L920
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache.iter_successors
def iter_successors(self, graph, orig, branch, turn, tick, *, forward=None): """Iterate over successors of a given origin node at a given time.""" if self.db._no_kc: yield from self._adds_dels_sucpred(self.successors[graph, orig], branch, turn, tick)[0] return if forward ...
python
def iter_successors(self, graph, orig, branch, turn, tick, *, forward=None): """Iterate over successors of a given origin node at a given time.""" if self.db._no_kc: yield from self._adds_dels_sucpred(self.successors[graph, orig], branch, turn, tick)[0] return if forward ...
[ "def", "iter_successors", "(", "self", ",", "graph", ",", "orig", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", "=", "None", ")", ":", "if", "self", ".", "db", ".", "_no_kc", ":", "yield", "from", "self", ".", "_adds_dels_sucpred...
Iterate over successors of a given origin node at a given time.
[ "Iterate", "over", "successors", "of", "a", "given", "origin", "node", "at", "a", "given", "time", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L922-L929
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache.iter_predecessors
def iter_predecessors(self, graph, dest, branch, turn, tick, *, forward=None): """Iterate over predecessors to a given destination node at a given time.""" if self.db._no_kc: yield from self._adds_dels_sucpred(self.predecessors[graph, dest], branch, turn, tick)[0] return ...
python
def iter_predecessors(self, graph, dest, branch, turn, tick, *, forward=None): """Iterate over predecessors to a given destination node at a given time.""" if self.db._no_kc: yield from self._adds_dels_sucpred(self.predecessors[graph, dest], branch, turn, tick)[0] return ...
[ "def", "iter_predecessors", "(", "self", ",", "graph", ",", "dest", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", "=", "None", ")", ":", "if", "self", ".", "db", ".", "_no_kc", ":", "yield", "from", "self", ".", "_adds_dels_sucpr...
Iterate over predecessors to a given destination node at a given time.
[ "Iterate", "over", "predecessors", "to", "a", "given", "destination", "node", "at", "a", "given", "time", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L931-L938
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache.has_successor
def has_successor(self, graph, orig, dest, branch, turn, tick, *, forward=None): """Return whether an edge connects the origin to the destination at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge. """ if forward is None...
python
def has_successor(self, graph, orig, dest, branch, turn, tick, *, forward=None): """Return whether an edge connects the origin to the destination at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge. """ if forward is None...
[ "def", "has_successor", "(", "self", ",", "graph", ",", "orig", ",", "dest", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", "=", "None", ")", ":", "if", "forward", "is", "None", ":", "forward", "=", "self", ".", "db", ".", "_f...
Return whether an edge connects the origin to the destination at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge.
[ "Return", "whether", "an", "edge", "connects", "the", "origin", "to", "the", "destination", "at", "the", "given", "time", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L956-L965
train
LogicalDash/LiSE
allegedb/allegedb/cache.py
EdgesCache.has_predecessor
def has_predecessor(self, graph, dest, orig, branch, turn, tick, *, forward=None): """Return whether an edge connects the destination to the origin at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge. """ if forward is No...
python
def has_predecessor(self, graph, dest, orig, branch, turn, tick, *, forward=None): """Return whether an edge connects the destination to the origin at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge. """ if forward is No...
[ "def", "has_predecessor", "(", "self", ",", "graph", ",", "dest", ",", "orig", ",", "branch", ",", "turn", ",", "tick", ",", "*", ",", "forward", "=", "None", ")", ":", "if", "forward", "is", "None", ":", "forward", "=", "self", ".", "db", ".", "...
Return whether an edge connects the destination to the origin at the given time. Doesn't require the edge's index, which makes it slower than retrieving a particular edge.
[ "Return", "whether", "an", "edge", "connects", "the", "destination", "to", "the", "origin", "at", "the", "given", "time", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/cache.py#L967-L976
train
LogicalDash/LiSE
ELiDE/ELiDE/board/spot.py
Spot.push_pos
def push_pos(self, *args): """Set my current position, expressed as proportions of the board's width and height, into the ``_x`` and ``_y`` keys of the entity in my ``proxy`` property, such that it will be recorded in the database. """ self.proxy['_x'] = self.x / self.bo...
python
def push_pos(self, *args): """Set my current position, expressed as proportions of the board's width and height, into the ``_x`` and ``_y`` keys of the entity in my ``proxy`` property, such that it will be recorded in the database. """ self.proxy['_x'] = self.x / self.bo...
[ "def", "push_pos", "(", "self", ",", "*", "args", ")", ":", "self", ".", "proxy", "[", "'_x'", "]", "=", "self", ".", "x", "/", "self", ".", "board", ".", "width", "self", ".", "proxy", "[", "'_y'", "]", "=", "self", ".", "y", "/", "self", "....
Set my current position, expressed as proportions of the board's width and height, into the ``_x`` and ``_y`` keys of the entity in my ``proxy`` property, such that it will be recorded in the database.
[ "Set", "my", "current", "position", "expressed", "as", "proportions", "of", "the", "board", "s", "width", "and", "height", "into", "the", "_x", "and", "_y", "keys", "of", "the", "entity", "in", "my", "proxy", "property", "such", "that", "it", "will", "be...
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/spot.py#L81-L89
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
convert_to_networkx_graph
def convert_to_networkx_graph(data, create_using=None, multigraph_input=False): """Convert an AllegedGraph to the corresponding NetworkX graph type.""" if isinstance(data, AllegedGraph): result = networkx.convert.from_dict_of_dicts( data.adj, create_using=create_using, ...
python
def convert_to_networkx_graph(data, create_using=None, multigraph_input=False): """Convert an AllegedGraph to the corresponding NetworkX graph type.""" if isinstance(data, AllegedGraph): result = networkx.convert.from_dict_of_dicts( data.adj, create_using=create_using, ...
[ "def", "convert_to_networkx_graph", "(", "data", ",", "create_using", "=", "None", ",", "multigraph_input", "=", "False", ")", ":", "if", "isinstance", "(", "data", ",", "AllegedGraph", ")", ":", "result", "=", "networkx", ".", "convert", ".", "from_dict_of_di...
Convert an AllegedGraph to the corresponding NetworkX graph type.
[ "Convert", "an", "AllegedGraph", "to", "the", "corresponding", "NetworkX", "graph", "type", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L32-L45
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
AllegedMapping.connect
def connect(self, func): """Arrange to call this function whenever something changes here. The arguments will be this object, the key changed, and the value set. """ l = _alleged_receivers[id(self)] if func not in l: l.append(func)
python
def connect(self, func): """Arrange to call this function whenever something changes here. The arguments will be this object, the key changed, and the value set. """ l = _alleged_receivers[id(self)] if func not in l: l.append(func)
[ "def", "connect", "(", "self", ",", "func", ")", ":", "l", "=", "_alleged_receivers", "[", "id", "(", "self", ")", "]", "if", "func", "not", "in", "l", ":", "l", ".", "append", "(", "func", ")" ]
Arrange to call this function whenever something changes here. The arguments will be this object, the key changed, and the value set.
[ "Arrange", "to", "call", "this", "function", "whenever", "something", "changes", "here", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L55-L63
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
AllegedMapping.disconnect
def disconnect(self, func): """No longer call the function when something changes here.""" if id(self) not in _alleged_receivers: return l = _alleged_receivers[id(self)] try: l.remove(func) except ValueError: return if not l: ...
python
def disconnect(self, func): """No longer call the function when something changes here.""" if id(self) not in _alleged_receivers: return l = _alleged_receivers[id(self)] try: l.remove(func) except ValueError: return if not l: ...
[ "def", "disconnect", "(", "self", ",", "func", ")", ":", "if", "id", "(", "self", ")", "not", "in", "_alleged_receivers", ":", "return", "l", "=", "_alleged_receivers", "[", "id", "(", "self", ")", "]", "try", ":", "l", ".", "remove", "(", "func", ...
No longer call the function when something changes here.
[ "No", "longer", "call", "the", "function", "when", "something", "changes", "here", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L65-L75
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
AllegedMapping.send
def send(self, sender, **kwargs): """Internal. Call connected functions.""" if id(self) not in _alleged_receivers: return for func in _alleged_receivers[id(self)]: func(sender, **kwargs)
python
def send(self, sender, **kwargs): """Internal. Call connected functions.""" if id(self) not in _alleged_receivers: return for func in _alleged_receivers[id(self)]: func(sender, **kwargs)
[ "def", "send", "(", "self", ",", "sender", ",", "**", "kwargs", ")", ":", "if", "id", "(", "self", ")", "not", "in", "_alleged_receivers", ":", "return", "for", "func", "in", "_alleged_receivers", "[", "id", "(", "self", ")", "]", ":", "func", "(", ...
Internal. Call connected functions.
[ "Internal", ".", "Call", "connected", "functions", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L77-L82
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
AllegedMapping.update
def update(self, other, **kwargs): """Version of ``update`` that doesn't clobber the database so much""" from itertools import chain if hasattr(other, 'items'): other = other.items() for (k, v) in chain(other, kwargs.items()): if ( k not in sel...
python
def update(self, other, **kwargs): """Version of ``update`` that doesn't clobber the database so much""" from itertools import chain if hasattr(other, 'items'): other = other.items() for (k, v) in chain(other, kwargs.items()): if ( k not in sel...
[ "def", "update", "(", "self", ",", "other", ",", "**", "kwargs", ")", ":", "from", "itertools", "import", "chain", "if", "hasattr", "(", "other", ",", "'items'", ")", ":", "other", "=", "other", ".", "items", "(", ")", "for", "(", "k", ",", "v", ...
Version of ``update`` that doesn't clobber the database so much
[ "Version", "of", "update", "that", "doesn", "t", "clobber", "the", "database", "so", "much" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L89-L99
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
AllegedGraph.clear
def clear(self): """Remove all nodes and edges from the graph. Unlike the regular networkx implementation, this does *not* remove the graph's name. But all the other graph, node, and edge attributes go away. """ self.adj.clear() self.node.clear() self.gr...
python
def clear(self): """Remove all nodes and edges from the graph. Unlike the regular networkx implementation, this does *not* remove the graph's name. But all the other graph, node, and edge attributes go away. """ self.adj.clear() self.node.clear() self.gr...
[ "def", "clear", "(", "self", ")", ":", "self", ".", "adj", ".", "clear", "(", ")", "self", ".", "node", ".", "clear", "(", ")", "self", ".", "graph", ".", "clear", "(", ")" ]
Remove all nodes and edges from the graph. Unlike the regular networkx implementation, this does *not* remove the graph's name. But all the other graph, node, and edge attributes go away.
[ "Remove", "all", "nodes", "and", "edges", "from", "the", "graph", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1297-L1307
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
DiGraph.remove_edges_from
def remove_edges_from(self, ebunch): """Version of remove_edges_from that's much like normal networkx but only deletes once, since the database doesn't keep separate adj and succ mappings """ for e in ebunch: (u, v) = e[:2] if u in self.succ and v in self...
python
def remove_edges_from(self, ebunch): """Version of remove_edges_from that's much like normal networkx but only deletes once, since the database doesn't keep separate adj and succ mappings """ for e in ebunch: (u, v) = e[:2] if u in self.succ and v in self...
[ "def", "remove_edges_from", "(", "self", ",", "ebunch", ")", ":", "for", "e", "in", "ebunch", ":", "(", "u", ",", "v", ")", "=", "e", "[", ":", "2", "]", "if", "u", "in", "self", ".", "succ", "and", "v", "in", "self", ".", "succ", "[", "u", ...
Version of remove_edges_from that's much like normal networkx but only deletes once, since the database doesn't keep separate adj and succ mappings
[ "Version", "of", "remove_edges_from", "that", "s", "much", "like", "normal", "networkx", "but", "only", "deletes", "once", "since", "the", "database", "doesn", "t", "keep", "separate", "adj", "and", "succ", "mappings" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1339-L1348
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
DiGraph.add_edge
def add_edge(self, u, v, attr_dict=None, **attr): """Version of add_edge that only writes to the database once""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise NetworkXErro...
python
def add_edge(self, u, v, attr_dict=None, **attr): """Version of add_edge that only writes to the database once""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise NetworkXErro...
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "attr_dict", "=", "None", ",", "**", "attr", ")", ":", "if", "attr_dict", "is", "None", ":", "attr_dict", "=", "attr", "else", ":", "try", ":", "attr_dict", ".", "update", "(", "attr", ")", ...
Version of add_edge that only writes to the database once
[ "Version", "of", "add_edge", "that", "only", "writes", "to", "the", "database", "once" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1350-L1373
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
DiGraph.add_edges_from
def add_edges_from(self, ebunch, attr_dict=None, **attr): """Version of add_edges_from that only writes to the database once""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: rais...
python
def add_edges_from(self, ebunch, attr_dict=None, **attr): """Version of add_edges_from that only writes to the database once""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: rais...
[ "def", "add_edges_from", "(", "self", ",", "ebunch", ",", "attr_dict", "=", "None", ",", "**", "attr", ")", ":", "if", "attr_dict", "is", "None", ":", "attr_dict", "=", "attr", "else", ":", "try", ":", "attr_dict", ".", "update", "(", "attr", ")", "e...
Version of add_edges_from that only writes to the database once
[ "Version", "of", "add_edges_from", "that", "only", "writes", "to", "the", "database", "once" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1375-L1407
train
LogicalDash/LiSE
allegedb/allegedb/graph.py
MultiDiGraph.add_edge
def add_edge(self, u, v, key=None, attr_dict=None, **attr): """Version of add_edge that only writes to the database once.""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise N...
python
def add_edge(self, u, v, key=None, attr_dict=None, **attr): """Version of add_edge that only writes to the database once.""" if attr_dict is None: attr_dict = attr else: try: attr_dict.update(attr) except AttributeError: raise N...
[ "def", "add_edge", "(", "self", ",", "u", ",", "v", ",", "key", "=", "None", ",", "attr_dict", "=", "None", ",", "**", "attr", ")", ":", "if", "attr_dict", "is", "None", ":", "attr_dict", "=", "attr", "else", ":", "try", ":", "attr_dict", ".", "u...
Version of add_edge that only writes to the database once.
[ "Version", "of", "add_edge", "that", "only", "writes", "to", "the", "database", "once", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/allegedb/allegedb/graph.py#L1462-L1493
train
LogicalDash/LiSE
LiSE/LiSE/place.py
Place.delete
def delete(self): """Remove myself from the world model immediately.""" super().delete() self.character.place.send(self.character.place, key=self.name, val=None)
python
def delete(self): """Remove myself from the world model immediately.""" super().delete() self.character.place.send(self.character.place, key=self.name, val=None)
[ "def", "delete", "(", "self", ")", ":", "super", "(", ")", ".", "delete", "(", ")", "self", ".", "character", ".", "place", ".", "send", "(", "self", ".", "character", ".", "place", ",", "key", "=", "self", ".", "name", ",", "val", "=", "None", ...
Remove myself from the world model immediately.
[ "Remove", "myself", "from", "the", "world", "model", "immediately", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/place.py#L49-L52
train
LogicalDash/LiSE
LiSE/LiSE/proxy.py
NodeMapProxy.patch
def patch(self, patch): """Change a bunch of node stats at once. This works similarly to ``update``, but only accepts a dict-like argument, and it recurses one level. The patch is sent to the LiSE core all at once, so this is faster than using ``update``, too. :param p...
python
def patch(self, patch): """Change a bunch of node stats at once. This works similarly to ``update``, but only accepts a dict-like argument, and it recurses one level. The patch is sent to the LiSE core all at once, so this is faster than using ``update``, too. :param p...
[ "def", "patch", "(", "self", ",", "patch", ")", ":", "self", ".", "engine", ".", "handle", "(", "'update_nodes'", ",", "char", "=", "self", ".", "character", ".", "name", ",", "patch", "=", "patch", ",", "block", "=", "False", ")", "for", "node", "...
Change a bunch of node stats at once. This works similarly to ``update``, but only accepts a dict-like argument, and it recurses one level. The patch is sent to the LiSE core all at once, so this is faster than using ``update``, too. :param patch: a dictionary. Keys are node n...
[ "Change", "a", "bunch", "of", "node", "stats", "at", "once", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/proxy.py#L580-L606
train
LogicalDash/LiSE
LiSE/LiSE/proxy.py
EngineProxy.handle
def handle(self, cmd=None, **kwargs): """Send a command to the LiSE core. The only positional argument should be the name of a method in :class:``EngineHandle``. All keyword arguments will be passed to it, with the exceptions of ``cb``, ``branching``, and ``silent``. Wi...
python
def handle(self, cmd=None, **kwargs): """Send a command to the LiSE core. The only positional argument should be the name of a method in :class:``EngineHandle``. All keyword arguments will be passed to it, with the exceptions of ``cb``, ``branching``, and ``silent``. Wi...
[ "def", "handle", "(", "self", ",", "cmd", "=", "None", ",", "**", "kwargs", ")", ":", "if", "'command'", "in", "kwargs", ":", "cmd", "=", "kwargs", "[", "'command'", "]", "elif", "cmd", ":", "kwargs", "[", "'command'", "]", "=", "cmd", "else", ":",...
Send a command to the LiSE core. The only positional argument should be the name of a method in :class:``EngineHandle``. All keyword arguments will be passed to it, with the exceptions of ``cb``, ``branching``, and ``silent``. With ``block=False``, don't wait for a result. ...
[ "Send", "a", "command", "to", "the", "LiSE", "core", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/proxy.py#L2154-L2229
train
LogicalDash/LiSE
LiSE/LiSE/proxy.py
EngineProxy.pull
def pull(self, chars='all', cb=None, block=True): """Update the state of all my proxy objects from the real objects.""" if block: deltas = self.handle('get_char_deltas', chars=chars) self._upd_caches(deltas) if cb: cb(deltas) else: ...
python
def pull(self, chars='all', cb=None, block=True): """Update the state of all my proxy objects from the real objects.""" if block: deltas = self.handle('get_char_deltas', chars=chars) self._upd_caches(deltas) if cb: cb(deltas) else: ...
[ "def", "pull", "(", "self", ",", "chars", "=", "'all'", ",", "cb", "=", "None", ",", "block", "=", "True", ")", ":", "if", "block", ":", "deltas", "=", "self", ".", "handle", "(", "'get_char_deltas'", ",", "chars", "=", "chars", ")", "self", ".", ...
Update the state of all my proxy objects from the real objects.
[ "Update", "the", "state", "of", "all", "my", "proxy", "objects", "from", "the", "real", "objects", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/proxy.py#L2345-L2353
train
LogicalDash/LiSE
LiSE/LiSE/proxy.py
EngineProxy.time_travel
def time_travel(self, branch, turn, tick=None, chars='all', cb=None, block=True): """Move to a different point in the timestream. Needs ``branch`` and ``turn`` arguments. The ``tick`` is optional; if unspecified, you'll travel to the last tick in the turn. May take a callback function ...
python
def time_travel(self, branch, turn, tick=None, chars='all', cb=None, block=True): """Move to a different point in the timestream. Needs ``branch`` and ``turn`` arguments. The ``tick`` is optional; if unspecified, you'll travel to the last tick in the turn. May take a callback function ...
[ "def", "time_travel", "(", "self", ",", "branch", ",", "turn", ",", "tick", "=", "None", ",", "chars", "=", "'all'", ",", "cb", "=", "None", ",", "block", "=", "True", ")", ":", "if", "cb", "and", "not", "chars", ":", "raise", "TypeError", "(", "...
Move to a different point in the timestream. Needs ``branch`` and ``turn`` arguments. The ``tick`` is optional; if unspecified, you'll travel to the last tick in the turn. May take a callback function ``cb``, which will receive a dictionary describing changes to the characters in ``cha...
[ "Move", "to", "a", "different", "point", "in", "the", "timestream", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/proxy.py#L2371-L2399
train
LogicalDash/LiSE
LiSE/LiSE/cache.py
NodeContentsCache.truncate_loc
def truncate_loc(self, character, location, branch, turn, tick): """Remove future data about a particular location Return True if I deleted anything, False otherwise. """ r = False branches_turns = self.branches[character, location][branch] branches_turns.truncate(turn)...
python
def truncate_loc(self, character, location, branch, turn, tick): """Remove future data about a particular location Return True if I deleted anything, False otherwise. """ r = False branches_turns = self.branches[character, location][branch] branches_turns.truncate(turn)...
[ "def", "truncate_loc", "(", "self", ",", "character", ",", "location", ",", "branch", ",", "turn", ",", "tick", ")", ":", "r", "=", "False", "branches_turns", "=", "self", ".", "branches", "[", "character", ",", "location", "]", "[", "branch", "]", "br...
Remove future data about a particular location Return True if I deleted anything, False otherwise.
[ "Remove", "future", "data", "about", "a", "particular", "location" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/cache.py#L635-L686
train
LogicalDash/LiSE
ELiDE/ELiDE/statcfg.py
StatScreen.new_stat
def new_stat(self): """Look at the key and value that the user has entered into the stat configurator, and set them on the currently selected entity. """ key = self.ids.newstatkey.text value = self.ids.newstatval.text if not (key and value): # TODO im...
python
def new_stat(self): """Look at the key and value that the user has entered into the stat configurator, and set them on the currently selected entity. """ key = self.ids.newstatkey.text value = self.ids.newstatval.text if not (key and value): # TODO im...
[ "def", "new_stat", "(", "self", ")", ":", "key", "=", "self", ".", "ids", ".", "newstatkey", ".", "text", "value", "=", "self", ".", "ids", ".", "newstatval", ".", "text", "if", "not", "(", "key", "and", "value", ")", ":", "return", "try", ":", "...
Look at the key and value that the user has entered into the stat configurator, and set them on the currently selected entity.
[ "Look", "at", "the", "key", "and", "value", "that", "the", "user", "has", "entered", "into", "the", "stat", "configurator", "and", "set", "them", "on", "the", "currently", "selected", "entity", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/statcfg.py#L212-L229
train
LogicalDash/LiSE
ELiDE/ELiDE/board/pawnspot.py
PawnSpot.on_touch_move
def on_touch_move(self, touch): """If I'm being dragged, move to follow the touch.""" if touch.grab_current is not self: return False self.center = touch.pos return True
python
def on_touch_move(self, touch): """If I'm being dragged, move to follow the touch.""" if touch.grab_current is not self: return False self.center = touch.pos return True
[ "def", "on_touch_move", "(", "self", ",", "touch", ")", ":", "if", "touch", ".", "grab_current", "is", "not", "self", ":", "return", "False", "self", ".", "center", "=", "touch", ".", "pos", "return", "True" ]
If I'm being dragged, move to follow the touch.
[ "If", "I", "m", "being", "dragged", "move", "to", "follow", "the", "touch", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/pawnspot.py#L84-L89
train
LogicalDash/LiSE
ELiDE/ELiDE/board/pawnspot.py
PawnSpot.finalize
def finalize(self, initial=True): """Call this after you've created all the PawnSpot you need and are ready to add them to the board.""" if getattr(self, '_finalized', False): return if ( self.proxy is None or not hasattr(self.proxy, 'name') ):...
python
def finalize(self, initial=True): """Call this after you've created all the PawnSpot you need and are ready to add them to the board.""" if getattr(self, '_finalized', False): return if ( self.proxy is None or not hasattr(self.proxy, 'name') ):...
[ "def", "finalize", "(", "self", ",", "initial", "=", "True", ")", ":", "if", "getattr", "(", "self", ",", "'_finalized'", ",", "False", ")", ":", "return", "if", "(", "self", ".", "proxy", "is", "None", "or", "not", "hasattr", "(", "self", ".", "pr...
Call this after you've created all the PawnSpot you need and are ready to add them to the board.
[ "Call", "this", "after", "you", "ve", "created", "all", "the", "PawnSpot", "you", "need", "and", "are", "ready", "to", "add", "them", "to", "the", "board", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/pawnspot.py#L91-L116
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
normalize_layout
def normalize_layout(l): """Make sure all the spots in a layout are where you can click. Returns a copy of the layout with all spot coordinates are normalized to within (0.0, 0.98). """ xs = [] ys = [] ks = [] for (k, (x, y)) in l.items(): xs.append(x) ys.append(y) ...
python
def normalize_layout(l): """Make sure all the spots in a layout are where you can click. Returns a copy of the layout with all spot coordinates are normalized to within (0.0, 0.98). """ xs = [] ys = [] ks = [] for (k, (x, y)) in l.items(): xs.append(x) ys.append(y) ...
[ "def", "normalize_layout", "(", "l", ")", ":", "xs", "=", "[", "]", "ys", "=", "[", "]", "ks", "=", "[", "]", "for", "(", "k", ",", "(", "x", ",", "y", ")", ")", "in", "l", ".", "items", "(", ")", ":", "xs", ".", "append", "(", "x", ")"...
Make sure all the spots in a layout are where you can click. Returns a copy of the layout with all spot coordinates are normalized to within (0.0, 0.98).
[ "Make", "sure", "all", "the", "spots", "in", "a", "layout", "are", "where", "you", "can", "click", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L44-L72
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.on_touch_down
def on_touch_down(self, touch): """Check for collisions and select an appropriate entity.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return if not self.collide_point(*touch.pos): return touch.push() touch.apply_transform_2d(self.to_loc...
python
def on_touch_down(self, touch): """Check for collisions and select an appropriate entity.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return if not self.collide_point(*touch.pos): return touch.push() touch.apply_transform_2d(self.to_loc...
[ "def", "on_touch_down", "(", "self", ",", "touch", ")", ":", "if", "hasattr", "(", "self", ",", "'_lasttouch'", ")", "and", "self", ".", "_lasttouch", "==", "touch", ":", "return", "if", "not", "self", ".", "collide_point", "(", "*", "touch", ".", "pos...
Check for collisions and select an appropriate entity.
[ "Check", "for", "collisions", "and", "select", "an", "appropriate", "entity", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L147-L201
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.on_touch_move
def on_touch_move(self, touch): """If an entity is selected, drag it.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return if self.app.selection in self.selection_candidates: self.selection_candidates.remove(self.app.selection) if self.app.select...
python
def on_touch_move(self, touch): """If an entity is selected, drag it.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return if self.app.selection in self.selection_candidates: self.selection_candidates.remove(self.app.selection) if self.app.select...
[ "def", "on_touch_move", "(", "self", ",", "touch", ")", ":", "if", "hasattr", "(", "self", ",", "'_lasttouch'", ")", "and", "self", ".", "_lasttouch", "==", "touch", ":", "return", "if", "self", ".", "app", ".", "selection", "in", "self", ".", "selecti...
If an entity is selected, drag it.
[ "If", "an", "entity", "is", "selected", "drag", "it", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L203-L221
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.portal_touch_up
def portal_touch_up(self, touch): """Try to create a portal between the spots the user chose.""" try: # If the touch ended upon a spot, and there isn't # already a portal between the origin and this # destination, create one. destspot = next(self.spots_at(...
python
def portal_touch_up(self, touch): """Try to create a portal between the spots the user chose.""" try: # If the touch ended upon a spot, and there isn't # already a portal between the origin and this # destination, create one. destspot = next(self.spots_at(...
[ "def", "portal_touch_up", "(", "self", ",", "touch", ")", ":", "try", ":", "destspot", "=", "next", "(", "self", ".", "spots_at", "(", "*", "touch", ".", "pos", ")", ")", "orig", "=", "self", ".", "origspot", ".", "proxy", "dest", "=", "destspot", ...
Try to create a portal between the spots the user chose.
[ "Try", "to", "create", "a", "portal", "between", "the", "spots", "the", "user", "chose", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L223-L265
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.on_touch_up
def on_touch_up(self, touch): """Delegate touch handling if possible, else select something.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return self._lasttouch = touch touch.push() touch.apply_transform_2d(self.to_local) if hasattr(self, 'p...
python
def on_touch_up(self, touch): """Delegate touch handling if possible, else select something.""" if hasattr(self, '_lasttouch') and self._lasttouch == touch: return self._lasttouch = touch touch.push() touch.apply_transform_2d(self.to_local) if hasattr(self, 'p...
[ "def", "on_touch_up", "(", "self", ",", "touch", ")", ":", "if", "hasattr", "(", "self", ",", "'_lasttouch'", ")", "and", "self", ".", "_lasttouch", "==", "touch", ":", "return", "self", ".", "_lasttouch", "=", "touch", "touch", ".", "push", "(", ")", ...
Delegate touch handling if possible, else select something.
[ "Delegate", "touch", "handling", "if", "possible", "else", "select", "something", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L267-L305
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.on_parent
def on_parent(self, *args): """Create some subwidgets and trigger the first update.""" if not self.parent or hasattr(self, '_parented'): return if not self.wallpaper_path: Logger.debug("Board: waiting for wallpaper_path") Clock.schedule_once(self.on_parent, 0)...
python
def on_parent(self, *args): """Create some subwidgets and trigger the first update.""" if not self.parent or hasattr(self, '_parented'): return if not self.wallpaper_path: Logger.debug("Board: waiting for wallpaper_path") Clock.schedule_once(self.on_parent, 0)...
[ "def", "on_parent", "(", "self", ",", "*", "args", ")", ":", "if", "not", "self", ".", "parent", "or", "hasattr", "(", "self", ",", "'_parented'", ")", ":", "return", "if", "not", "self", ".", "wallpaper_path", ":", "Logger", ".", "debug", "(", "\"Bo...
Create some subwidgets and trigger the first update.
[ "Create", "some", "subwidgets", "and", "trigger", "the", "first", "update", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L317-L339
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.update
def update(self, *args): """Force an update to match the current state of my character. This polls every element of the character, and therefore causes me to sync with the LiSE core for a long time. Avoid when possible. """ # remove widgets that don't represent anythin...
python
def update(self, *args): """Force an update to match the current state of my character. This polls every element of the character, and therefore causes me to sync with the LiSE core for a long time. Avoid when possible. """ # remove widgets that don't represent anythin...
[ "def", "update", "(", "self", ",", "*", "args", ")", ":", "Logger", ".", "debug", "(", "\"Board: updating\"", ")", "self", ".", "remove_absent_pawns", "(", ")", "self", ".", "remove_absent_spots", "(", ")", "self", ".", "remove_absent_arrows", "(", ")", "s...
Force an update to match the current state of my character. This polls every element of the character, and therefore causes me to sync with the LiSE core for a long time. Avoid when possible.
[ "Force", "an", "update", "to", "match", "the", "current", "state", "of", "my", "character", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L719-L739
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.update_from_delta
def update_from_delta(self, delta, *args): """Apply the changes described in the dict ``delta``.""" for (node, extant) in delta.get('nodes', {}).items(): if extant: if node in delta.get('node_val', {}) \ and 'location' in delta['node_val'][node]\ ...
python
def update_from_delta(self, delta, *args): """Apply the changes described in the dict ``delta``.""" for (node, extant) in delta.get('nodes', {}).items(): if extant: if node in delta.get('node_val', {}) \ and 'location' in delta['node_val'][node]\ ...
[ "def", "update_from_delta", "(", "self", ",", "delta", ",", "*", "args", ")", ":", "for", "(", "node", ",", "extant", ")", "in", "delta", ".", "get", "(", "'nodes'", ",", "{", "}", ")", ".", "items", "(", ")", ":", "if", "extant", ":", "if", "n...
Apply the changes described in the dict ``delta``.
[ "Apply", "the", "changes", "described", "in", "the", "dict", "delta", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L742-L787
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.arrows
def arrows(self): """Iterate over all my arrows.""" for o in self.arrow.values(): for arro in o.values(): yield arro
python
def arrows(self): """Iterate over all my arrows.""" for o in self.arrow.values(): for arro in o.values(): yield arro
[ "def", "arrows", "(", "self", ")", ":", "for", "o", "in", "self", ".", "arrow", ".", "values", "(", ")", ":", "for", "arro", "in", "o", ".", "values", "(", ")", ":", "yield", "arro" ]
Iterate over all my arrows.
[ "Iterate", "over", "all", "my", "arrows", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L846-L850
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.pawns_at
def pawns_at(self, x, y): """Iterate over pawns that collide the given point.""" for pawn in self.pawn.values(): if pawn.collide_point(x, y): yield pawn
python
def pawns_at(self, x, y): """Iterate over pawns that collide the given point.""" for pawn in self.pawn.values(): if pawn.collide_point(x, y): yield pawn
[ "def", "pawns_at", "(", "self", ",", "x", ",", "y", ")", ":", "for", "pawn", "in", "self", ".", "pawn", ".", "values", "(", ")", ":", "if", "pawn", ".", "collide_point", "(", "x", ",", "y", ")", ":", "yield", "pawn" ]
Iterate over pawns that collide the given point.
[ "Iterate", "over", "pawns", "that", "collide", "the", "given", "point", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L852-L856
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.spots_at
def spots_at(self, x, y): """Iterate over spots that collide the given point.""" for spot in self.spot.values(): if spot.collide_point(x, y): yield spot
python
def spots_at(self, x, y): """Iterate over spots that collide the given point.""" for spot in self.spot.values(): if spot.collide_point(x, y): yield spot
[ "def", "spots_at", "(", "self", ",", "x", ",", "y", ")", ":", "for", "spot", "in", "self", ".", "spot", ".", "values", "(", ")", ":", "if", "spot", ".", "collide_point", "(", "x", ",", "y", ")", ":", "yield", "spot" ]
Iterate over spots that collide the given point.
[ "Iterate", "over", "spots", "that", "collide", "the", "given", "point", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L858-L862
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
Board.arrows_at
def arrows_at(self, x, y): """Iterate over arrows that collide the given point.""" for arrow in self.arrows(): if arrow.collide_point(x, y): yield arrow
python
def arrows_at(self, x, y): """Iterate over arrows that collide the given point.""" for arrow in self.arrows(): if arrow.collide_point(x, y): yield arrow
[ "def", "arrows_at", "(", "self", ",", "x", ",", "y", ")", ":", "for", "arrow", "in", "self", ".", "arrows", "(", ")", ":", "if", "arrow", ".", "collide_point", "(", "x", ",", "y", ")", ":", "yield", "arrow" ]
Iterate over arrows that collide the given point.
[ "Iterate", "over", "arrows", "that", "collide", "the", "given", "point", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L864-L868
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
BoardScatterPlane.spot_from_dummy
def spot_from_dummy(self, dummy): """Make a real place and its spot from a dummy spot. Create a new :class:`board.Spot` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, position, and imagery of the provided dummy. """ (x, y) = self...
python
def spot_from_dummy(self, dummy): """Make a real place and its spot from a dummy spot. Create a new :class:`board.Spot` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, position, and imagery of the provided dummy. """ (x, y) = self...
[ "def", "spot_from_dummy", "(", "self", ",", "dummy", ")", ":", "(", "x", ",", "y", ")", "=", "self", ".", "to_local", "(", "*", "dummy", ".", "pos_up", ")", "x", "/=", "self", ".", "board", ".", "width", "y", "/=", "self", ".", "board", ".", "h...
Make a real place and its spot from a dummy spot. Create a new :class:`board.Spot` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, position, and imagery of the provided dummy.
[ "Make", "a", "real", "place", "and", "its", "spot", "from", "a", "dummy", "spot", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L879-L900
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
BoardScatterPlane.pawn_from_dummy
def pawn_from_dummy(self, dummy): """Make a real thing and its pawn from a dummy pawn. Create a new :class:`board.Pawn` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, location, and imagery of the provided dummy. """ dummy.pos = s...
python
def pawn_from_dummy(self, dummy): """Make a real thing and its pawn from a dummy pawn. Create a new :class:`board.Pawn` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, location, and imagery of the provided dummy. """ dummy.pos = s...
[ "def", "pawn_from_dummy", "(", "self", ",", "dummy", ")", ":", "dummy", ".", "pos", "=", "self", ".", "to_local", "(", "*", "dummy", ".", "pos", ")", "for", "spot", "in", "self", ".", "board", ".", "spotlayout", ".", "children", ":", "if", "spot", ...
Make a real thing and its pawn from a dummy pawn. Create a new :class:`board.Pawn` instance, along with the underlying :class:`LiSE.Place` instance, and give it the name, location, and imagery of the provided dummy.
[ "Make", "a", "real", "thing", "and", "its", "pawn", "from", "a", "dummy", "pawn", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L902-L926
train
LogicalDash/LiSE
ELiDE/ELiDE/board/board.py
BoardScatterPlane.arrow_from_wid
def arrow_from_wid(self, wid): """Make a real portal and its arrow from a dummy arrow. This doesn't handle touch events. It takes a widget as its argument: the one the user has been dragging to indicate where they want the arrow to go. Said widget ought to be invisible. It check...
python
def arrow_from_wid(self, wid): """Make a real portal and its arrow from a dummy arrow. This doesn't handle touch events. It takes a widget as its argument: the one the user has been dragging to indicate where they want the arrow to go. Said widget ought to be invisible. It check...
[ "def", "arrow_from_wid", "(", "self", ",", "wid", ")", ":", "for", "spot", "in", "self", ".", "board", ".", "spotlayout", ".", "children", ":", "if", "spot", ".", "collide_widget", "(", "wid", ")", ":", "whereto", "=", "spot", "break", "else", ":", "...
Make a real portal and its arrow from a dummy arrow. This doesn't handle touch events. It takes a widget as its argument: the one the user has been dragging to indicate where they want the arrow to go. Said widget ought to be invisible. It checks if the dummy arrow connects two real spo...
[ "Make", "a", "real", "portal", "and", "its", "arrow", "from", "a", "dummy", "arrow", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/board/board.py#L928-L952
train
LogicalDash/LiSE
LiSE/LiSE/util.py
sort_set
def sort_set(s): """Return a sorted list of the contents of a set This is intended to be used to iterate over world state, where you just need keys to be in some deterministic order, but the sort order should be obvious from the key. Non-strings come before strings and then tuples. Tuples compare elem...
python
def sort_set(s): """Return a sorted list of the contents of a set This is intended to be used to iterate over world state, where you just need keys to be in some deterministic order, but the sort order should be obvious from the key. Non-strings come before strings and then tuples. Tuples compare elem...
[ "def", "sort_set", "(", "s", ")", ":", "if", "not", "isinstance", "(", "s", ",", "Set", ")", ":", "raise", "TypeError", "(", "\"sets only\"", ")", "s", "=", "frozenset", "(", "s", ")", "if", "s", "not", "in", "_sort_set_memo", ":", "_sort_set_memo", ...
Return a sorted list of the contents of a set This is intended to be used to iterate over world state, where you just need keys to be in some deterministic order, but the sort order should be obvious from the key. Non-strings come before strings and then tuples. Tuples compare element-wise as normal. ...
[ "Return", "a", "sorted", "list", "of", "the", "contents", "of", "a", "set" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/util.py#L170-L187
train
LogicalDash/LiSE
LiSE/LiSE/portal.py
Portal.reciprocal
def reciprocal(self): """If there's another Portal connecting the same origin and destination that I do, but going the opposite way, return it. Else raise KeyError. """ try: return self.character.portal[self.dest][self.orig] except KeyError: raise...
python
def reciprocal(self): """If there's another Portal connecting the same origin and destination that I do, but going the opposite way, return it. Else raise KeyError. """ try: return self.character.portal[self.dest][self.orig] except KeyError: raise...
[ "def", "reciprocal", "(", "self", ")", ":", "try", ":", "return", "self", ".", "character", ".", "portal", "[", "self", ".", "dest", "]", "[", "self", ".", "orig", "]", "except", "KeyError", ":", "raise", "KeyError", "(", "\"This portal has no reciprocal\"...
If there's another Portal connecting the same origin and destination that I do, but going the opposite way, return it. Else raise KeyError.
[ "If", "there", "s", "another", "Portal", "connecting", "the", "same", "origin", "and", "destination", "that", "I", "do", "but", "going", "the", "opposite", "way", "return", "it", ".", "Else", "raise", "KeyError", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/portal.py#L197-L206
train
LogicalDash/LiSE
LiSE/LiSE/portal.py
Portal.update
def update(self, d): """Works like regular update, but only actually updates when the new value and the old value differ. This is necessary to prevent certain infinite loops. :arg d: a dictionary """ for (k, v) in d.items(): if k not in self or self[k] != v:...
python
def update(self, d): """Works like regular update, but only actually updates when the new value and the old value differ. This is necessary to prevent certain infinite loops. :arg d: a dictionary """ for (k, v) in d.items(): if k not in self or self[k] != v:...
[ "def", "update", "(", "self", ",", "d", ")", ":", "for", "(", "k", ",", "v", ")", "in", "d", ".", "items", "(", ")", ":", "if", "k", "not", "in", "self", "or", "self", "[", "k", "]", "!=", "v", ":", "self", "[", "k", "]", "=", "v" ]
Works like regular update, but only actually updates when the new value and the old value differ. This is necessary to prevent certain infinite loops. :arg d: a dictionary
[ "Works", "like", "regular", "update", "but", "only", "actually", "updates", "when", "the", "new", "value", "and", "the", "old", "value", "differ", ".", "This", "is", "necessary", "to", "prevent", "certain", "infinite", "loops", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/portal.py#L221-L231
train
LogicalDash/LiSE
ELiDE/ELiDE/charmenu.py
CharMenu.toggle_rules
def toggle_rules(self, *args): """Display or hide the view for constructing rules out of cards.""" if self.app.manager.current != 'rules' and not isinstance(self.app.selected_proxy, CharStatProxy): self.app.rules.entity = self.app.selected_proxy self.app.rules.rulebook = self.app...
python
def toggle_rules(self, *args): """Display or hide the view for constructing rules out of cards.""" if self.app.manager.current != 'rules' and not isinstance(self.app.selected_proxy, CharStatProxy): self.app.rules.entity = self.app.selected_proxy self.app.rules.rulebook = self.app...
[ "def", "toggle_rules", "(", "self", ",", "*", "args", ")", ":", "if", "self", ".", "app", ".", "manager", ".", "current", "!=", "'rules'", "and", "not", "isinstance", "(", "self", ".", "app", ".", "selected_proxy", ",", "CharStatProxy", ")", ":", "self...
Display or hide the view for constructing rules out of cards.
[ "Display", "or", "hide", "the", "view", "for", "constructing", "rules", "out", "of", "cards", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/charmenu.py#L82-L91
train
LogicalDash/LiSE
ELiDE/ELiDE/charmenu.py
CharMenu.toggle_spot_cfg
def toggle_spot_cfg(self): """Show the dialog where you select graphics and a name for a place, or hide it if already showing. """ if self.app.manager.current == 'spotcfg': dummyplace = self.screendummyplace self.ids.placetab.remove_widget(dummyplace) ...
python
def toggle_spot_cfg(self): """Show the dialog where you select graphics and a name for a place, or hide it if already showing. """ if self.app.manager.current == 'spotcfg': dummyplace = self.screendummyplace self.ids.placetab.remove_widget(dummyplace) ...
[ "def", "toggle_spot_cfg", "(", "self", ")", ":", "if", "self", ".", "app", ".", "manager", ".", "current", "==", "'spotcfg'", ":", "dummyplace", "=", "self", ".", "screendummyplace", "self", ".", "ids", ".", "placetab", ".", "remove_widget", "(", "dummypla...
Show the dialog where you select graphics and a name for a place, or hide it if already showing.
[ "Show", "the", "dialog", "where", "you", "select", "graphics", "and", "a", "name", "for", "a", "place", "or", "hide", "it", "if", "already", "showing", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/charmenu.py#L100-L118
train
LogicalDash/LiSE
ELiDE/ELiDE/charmenu.py
CharMenu.toggle_pawn_cfg
def toggle_pawn_cfg(self): """Show or hide the pop-over where you can configure the dummy pawn""" if self.app.manager.current == 'pawncfg': dummything = self.app.dummything self.ids.thingtab.remove_widget(dummything) dummything.clear() if self.app.pawncfg....
python
def toggle_pawn_cfg(self): """Show or hide the pop-over where you can configure the dummy pawn""" if self.app.manager.current == 'pawncfg': dummything = self.app.dummything self.ids.thingtab.remove_widget(dummything) dummything.clear() if self.app.pawncfg....
[ "def", "toggle_pawn_cfg", "(", "self", ")", ":", "if", "self", ".", "app", ".", "manager", ".", "current", "==", "'pawncfg'", ":", "dummything", "=", "self", ".", "app", ".", "dummything", "self", ".", "ids", ".", "thingtab", ".", "remove_widget", "(", ...
Show or hide the pop-over where you can configure the dummy pawn
[ "Show", "or", "hide", "the", "pop", "-", "over", "where", "you", "can", "configure", "the", "dummy", "pawn" ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/ELiDE/ELiDE/charmenu.py#L120-L138
train
LogicalDash/LiSE
LiSE/LiSE/handle.py
dict_delta
def dict_delta(old, new): """Return a dictionary containing the items of ``new`` that are either absent from ``old`` or whose values are different; as well as the value ``None`` for those keys that are present in ``old``, but absent from ``new``. Useful for describing changes between two versions o...
python
def dict_delta(old, new): """Return a dictionary containing the items of ``new`` that are either absent from ``old`` or whose values are different; as well as the value ``None`` for those keys that are present in ``old``, but absent from ``new``. Useful for describing changes between two versions o...
[ "def", "dict_delta", "(", "old", ",", "new", ")", ":", "r", "=", "{", "}", "oldkeys", "=", "set", "(", "old", ".", "keys", "(", ")", ")", "newkeys", "=", "set", "(", "new", ".", "keys", "(", ")", ")", "r", ".", "update", "(", "(", "k", ",",...
Return a dictionary containing the items of ``new`` that are either absent from ``old`` or whose values are different; as well as the value ``None`` for those keys that are present in ``old``, but absent from ``new``. Useful for describing changes between two versions of a dict.
[ "Return", "a", "dictionary", "containing", "the", "items", "of", "new", "that", "are", "either", "absent", "from", "old", "or", "whose", "values", "are", "different", ";", "as", "well", "as", "the", "value", "None", "for", "those", "keys", "that", "are", ...
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/handle.py#L28-L45
train
LogicalDash/LiSE
LiSE/LiSE/handle.py
EngineHandle.character_copy
def character_copy(self, char): """Return a dictionary describing character ``char``.""" ret = self.character_stat_copy(char) chara = self._real.character[char] nv = self.character_nodes_stat_copy(char) if nv: ret['node_val'] = nv ev = self.character_portals_s...
python
def character_copy(self, char): """Return a dictionary describing character ``char``.""" ret = self.character_stat_copy(char) chara = self._real.character[char] nv = self.character_nodes_stat_copy(char) if nv: ret['node_val'] = nv ev = self.character_portals_s...
[ "def", "character_copy", "(", "self", ",", "char", ")", ":", "ret", "=", "self", ".", "character_stat_copy", "(", "char", ")", "chara", "=", "self", ".", "_real", ".", "character", "[", "char", "]", "nv", "=", "self", ".", "character_nodes_stat_copy", "(...
Return a dictionary describing character ``char``.
[ "Return", "a", "dictionary", "describing", "character", "char", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/handle.py#L570-L611
train
LogicalDash/LiSE
LiSE/LiSE/handle.py
EngineHandle.character_delta
def character_delta(self, char, *, store=True): """Return a dictionary of changes to ``char`` since previous call.""" ret = self.character_stat_delta(char, store=store) nodes = self.character_nodes_delta(char, store=store) chara = self._real.character[char] if nodes: ...
python
def character_delta(self, char, *, store=True): """Return a dictionary of changes to ``char`` since previous call.""" ret = self.character_stat_delta(char, store=store) nodes = self.character_nodes_delta(char, store=store) chara = self._real.character[char] if nodes: ...
[ "def", "character_delta", "(", "self", ",", "char", ",", "*", ",", "store", "=", "True", ")", ":", "ret", "=", "self", ".", "character_stat_delta", "(", "char", ",", "store", "=", "store", ")", "nodes", "=", "self", ".", "character_nodes_delta", "(", "...
Return a dictionary of changes to ``char`` since previous call.
[ "Return", "a", "dictionary", "of", "changes", "to", "char", "since", "previous", "call", "." ]
fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84
https://github.com/LogicalDash/LiSE/blob/fe6fd4f0a7c1780e065f4c9babb9bc443af6bb84/LiSE/LiSE/handle.py#L613-L651
train