repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6
values | func_code_string stringlengths 52 3.87M | func_documentation_string stringlengths 1 47.2k | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|
coin-or/GiMPy | src/gimpy/graph.py | Graph.process_edge_search | def process_edge_search(self, current, neighbor, pred, q, component, algo,
**kargs):
'''
API: process_edge_search(self, current, neighbor, pred, q, component,
algo, **kargs)
Description:
Used by search() method. Processes edges... | python | def process_edge_search(self, current, neighbor, pred, q, component, algo,
**kargs):
'''
API: process_edge_search(self, current, neighbor, pred, q, component,
algo, **kargs)
Description:
Used by search() method. Processes edges... | API: process_edge_search(self, current, neighbor, pred, q, component,
algo, **kargs)
Description:
Used by search() method. Processes edges according to the underlying
algortihm. User does not need to call this method directly.
Input:
current: ... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1096-L1161 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.minimum_spanning_tree_prim | def minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue()):
'''
API: minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue())
Description:
Determines a minimum spanning ... | python | def minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue()):
'''
API: minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue())
Description:
Determines a minimum spanning ... | API: minimum_spanning_tree_prim(self, source, display = None,
q = PriorityQueue())
Description:
Determines a minimum spanning tree of all nodes reachable
from source using Prim's Algorithm.
Input:
source: Name of source node.
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1163-L1215 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.minimum_spanning_tree_kruskal | def minimum_spanning_tree_kruskal(self, display = None, components = None):
'''
API: minimum_spanning_tree_kruskal(self, display = None,
components = None)
Description:
Determines a minimum spanning tree using Kruskal's Algorithm.
Input:... | python | def minimum_spanning_tree_kruskal(self, display = None, components = None):
'''
API: minimum_spanning_tree_kruskal(self, display = None,
components = None)
Description:
Determines a minimum spanning tree using Kruskal's Algorithm.
Input:... | API: minimum_spanning_tree_kruskal(self, display = None,
components = None)
Description:
Determines a minimum spanning tree using Kruskal's Algorithm.
Input:
display: Display method.
component: component number.
Post:
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1217-L1257 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.max_flow_preflowpush | def max_flow_preflowpush(self, source, sink, algo = 'FIFO', display = None):
'''
API: max_flow_preflowpush(self, source, sink, algo = 'FIFO',
display = None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmen... | python | def max_flow_preflowpush(self, source, sink, algo = 'FIFO', display = None):
'''
API: max_flow_preflowpush(self, source, sink, algo = 'FIFO',
display = None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmen... | API: max_flow_preflowpush(self, source, sink, algo = 'FIFO',
display = None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmenting path algorithm.
Pre:
Assumes a directed graph in which each arc has a '... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1259-L1365 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.process_edge_flow | def process_edge_flow(self, source, sink, i, j, algo, q):
'''
API: process_edge_flow(self, source, sink, i, j, algo, q)
Description:
Used by by max_flow_preflowpush() method. Processes edges along
prefolow push.
Input:
source: Source node name of flow graph.
... | python | def process_edge_flow(self, source, sink, i, j, algo, q):
'''
API: process_edge_flow(self, source, sink, i, j, algo, q)
Description:
Used by by max_flow_preflowpush() method. Processes edges along
prefolow push.
Input:
source: Source node name of flow graph.
... | API: process_edge_flow(self, source, sink, i, j, algo, q)
Description:
Used by by max_flow_preflowpush() method. Processes edges along
prefolow push.
Input:
source: Source node name of flow graph.
sink: Sink node name of flow graph.
i: Source node in t... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1367-L1404 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.relabel | def relabel(self, i):
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for relabelling node i.
Input:
i: Node that is being relabelled.
Post:
'distance' attribute of node i is updated.
'''
min_distance = ... | python | def relabel(self, i):
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for relabelling node i.
Input:
i: Node that is being relabelled.
Post:
'distance' attribute of node i is updated.
'''
min_distance = ... | API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for relabelling node i.
Input:
i: Node that is being relabelled.
Post:
'distance' attribute of node i is updated. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1406-L1426 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.show_flow | def show_flow(self):
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for display purposed.
Post:
'color' and 'label' attribute of edges/nodes are updated.
'''
for n in self.get_node_list():
excess = self.get_nod... | python | def show_flow(self):
'''
API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for display purposed.
Post:
'color' and 'label' attribute of edges/nodes are updated.
'''
for n in self.get_node_list():
excess = self.get_nod... | API: relabel(self, i)
Description:
Used by max_flow_preflowpush() method for display purposed.
Post:
'color' and 'label' attribute of edges/nodes are updated. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1428-L1455 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.create_residual_graph | def create_residual_graph(self):
'''
API: create_residual_graph(self)
Description:
Creates and returns residual graph, which is a Graph instance
itself.
Pre:
(1) Arcs should have 'flow', 'capacity' and 'cost' attribute
(2) Graph should be a directe... | python | def create_residual_graph(self):
'''
API: create_residual_graph(self)
Description:
Creates and returns residual graph, which is a Graph instance
itself.
Pre:
(1) Arcs should have 'flow', 'capacity' and 'cost' attribute
(2) Graph should be a directe... | API: create_residual_graph(self)
Description:
Creates and returns residual graph, which is a Graph instance
itself.
Pre:
(1) Arcs should have 'flow', 'capacity' and 'cost' attribute
(2) Graph should be a directed graph
Return:
Returns residual ... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1457-L1482 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.cycle_canceling | def cycle_canceling(self, display):
'''
API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attr... | python | def cycle_canceling(self, display):
'''
API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attr... | API:
cycle_canceling(self, display)
Description:
Solves minimum cost feasible flow problem using cycle canceling
algorithm. Returns True when an optimal solution is found, returns
False otherwise. 'flow' attribute values of arcs should be
considered as... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1484-L1524 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.find_feasible_flow | def find_feasible_flow(self):
'''
API:
find_feasible_flow(self)
Description:
Solves feasible flow problem, stores solution in 'flow' attribute
or arcs. This method is used to get an initial feasible flow for
simplex and cycle canceling algorithms. ... | python | def find_feasible_flow(self):
'''
API:
find_feasible_flow(self)
Description:
Solves feasible flow problem, stores solution in 'flow' attribute
or arcs. This method is used to get an initial feasible flow for
simplex and cycle canceling algorithms. ... | API:
find_feasible_flow(self)
Description:
Solves feasible flow problem, stores solution in 'flow' attribute
or arcs. This method is used to get an initial feasible flow for
simplex and cycle canceling algorithms. Uses max_flow() method.
Other max flow... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1526-L1572 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.write | def write(self, basename = 'graph', layout = None, format='png'):
'''
API:
write(self, basename = 'graph', layout = None, format='png')
Description:
Writes graph to dist using layout and format.
Input:
basename: name of the file that will be written.
... | python | def write(self, basename = 'graph', layout = None, format='png'):
'''
API:
write(self, basename = 'graph', layout = None, format='png')
Description:
Writes graph to dist using layout and format.
Input:
basename: name of the file that will be written.
... | API:
write(self, basename = 'graph', layout = None, format='png')
Description:
Writes graph to dist using layout and format.
Input:
basename: name of the file that will be written.
layout: Dot layout for generating graph image.
format: Image format... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1598-L1618 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.create | def create(self, layout, format, **args):
'''
API:
create(self, layout, format, **args)
Description:
Returns postscript representation of graph.
Input:
layout: Dot layout for generating graph image.
format: Image format, all format supporte... | python | def create(self, layout, format, **args):
'''
API:
create(self, layout, format, **args)
Description:
Returns postscript representation of graph.
Input:
layout: Dot layout for generating graph image.
format: Image format, all format supporte... | API:
create(self, layout, format, **args)
Description:
Returns postscript representation of graph.
Input:
layout: Dot layout for generating graph image.
format: Image format, all format supported by Dot are wellcome.
Return:
Returns pos... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1620-L1655 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.display | def display(self, highlight = None, basename = 'graph', format = 'png',
pause = True):
'''
API:
display(self, highlight = None, basename = 'graph', format = 'png',
pause = True)
Description:
Displays graph according to the arguments provide... | python | def display(self, highlight = None, basename = 'graph', format = 'png',
pause = True):
'''
API:
display(self, highlight = None, basename = 'graph', format = 'png',
pause = True)
Description:
Displays graph according to the arguments provide... | API:
display(self, highlight = None, basename = 'graph', format = 'png',
pause = True)
Description:
Displays graph according to the arguments provided.
Current display modes: 'off', 'file', 'pygame', 'PIL', 'xdot',
'svg'
Current layout ... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1657-L1778 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.max_flow | def max_flow(self, source, sink, display = None, algo = 'DFS'):
'''
API: max_flow(self, source, sink, display=None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmenting path algorithm.
Pre:
Assumes a directed graph in wh... | python | def max_flow(self, source, sink, display = None, algo = 'DFS'):
'''
API: max_flow(self, source, sink, display=None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmenting path algorithm.
Pre:
Assumes a directed graph in wh... | API: max_flow(self, source, sink, display=None)
Description:
Finds maximum flow from source to sink by a depth-first search based
augmenting path algorithm.
Pre:
Assumes a directed graph in which each arc has a 'capacity'
attribute and for which there does does no... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1793-L1956 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_negative_cycle | def get_negative_cycle(self):
'''
API:
get_negative_cycle(self)
Description:
Finds and returns negative cost cycle using 'cost' attribute of
arcs. Return value is a list of nodes representing cycle it is in
the following form; n_1-n_2-...-n_k, when... | python | def get_negative_cycle(self):
'''
API:
get_negative_cycle(self)
Description:
Finds and returns negative cost cycle using 'cost' attribute of
arcs. Return value is a list of nodes representing cycle it is in
the following form; n_1-n_2-...-n_k, when... | API:
get_negative_cycle(self)
Description:
Finds and returns negative cost cycle using 'cost' attribute of
arcs. Return value is a list of nodes representing cycle it is in
the following form; n_1-n_2-...-n_k, when the cycle has k nodes.
Pre:
A... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1958-L1979 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.floyd_warshall | def floyd_warshall(self):
'''
API:
floyd_warshall(self)
Description:
Finds all pair shortest paths and stores it in a list of lists.
This is possible if the graph does not have negative cycles. It will
return a tuple with 3 elements. The first elem... | python | def floyd_warshall(self):
'''
API:
floyd_warshall(self)
Description:
Finds all pair shortest paths and stores it in a list of lists.
This is possible if the graph does not have negative cycles. It will
return a tuple with 3 elements. The first elem... | API:
floyd_warshall(self)
Description:
Finds all pair shortest paths and stores it in a list of lists.
This is possible if the graph does not have negative cycles. It will
return a tuple with 3 elements. The first element indicates whether
the graph ha... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L1981-L2044 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.floyd_warshall_get_path | def floyd_warshall_get_path(self, distance, nextn, i, j):
'''
API:
floyd_warshall_get_path(self, distance, nextn, i, j):
Description:
Finds shortest path between i and j using distance and nextn
dictionaries.
Pre:
(1) distance and nextn are... | python | def floyd_warshall_get_path(self, distance, nextn, i, j):
'''
API:
floyd_warshall_get_path(self, distance, nextn, i, j):
Description:
Finds shortest path between i and j using distance and nextn
dictionaries.
Pre:
(1) distance and nextn are... | API:
floyd_warshall_get_path(self, distance, nextn, i, j):
Description:
Finds shortest path between i and j using distance and nextn
dictionaries.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The graph does not have a n... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2046-L2067 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.floyd_warshall_get_cycle | def floyd_warshall_get_cycle(self, distance, nextn, element = None):
'''
API:
floyd_warshall_get_cycle(self, distance, nextn, element = None)
Description:
Finds a negative cycle in the graph.
Pre:
(1) distance and nextn are outputs of floyd_warshall me... | python | def floyd_warshall_get_cycle(self, distance, nextn, element = None):
'''
API:
floyd_warshall_get_cycle(self, distance, nextn, element = None)
Description:
Finds a negative cycle in the graph.
Pre:
(1) distance and nextn are outputs of floyd_warshall me... | API:
floyd_warshall_get_cycle(self, distance, nextn, element = None)
Description:
Finds a negative cycle in the graph.
Pre:
(1) distance and nextn are outputs of floyd_warshall method.
(2) The graph should have a negative cycle, , ie.
distance[... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2069-L2103 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.find_cycle_capacity | def find_cycle_capacity(self, cycle):
'''
API:
find_cycle_capacity(self, cycle):
Description:
Finds capacity of the cycle input.
Pre:
(1) Arcs should have 'capacity' attribute.
Input:
cycle: a list representing a cycle
Retur... | python | def find_cycle_capacity(self, cycle):
'''
API:
find_cycle_capacity(self, cycle):
Description:
Finds capacity of the cycle input.
Pre:
(1) Arcs should have 'capacity' attribute.
Input:
cycle: a list representing a cycle
Retur... | API:
find_cycle_capacity(self, cycle):
Description:
Finds capacity of the cycle input.
Pre:
(1) Arcs should have 'capacity' attribute.
Input:
cycle: a list representing a cycle
Return:
Returns an integer number representing capa... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2105-L2128 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.fifo_label_correcting | def fifo_label_correcting(self, source):
'''
API:
fifo_label_correcting(self, source)
Description:
finds shortest path from source to every other node. Returns
predecessor dictionary. If graph has a negative cycle, detects it
and returns to it.
... | python | def fifo_label_correcting(self, source):
'''
API:
fifo_label_correcting(self, source)
Description:
finds shortest path from source to every other node. Returns
predecessor dictionary. If graph has a negative cycle, detects it
and returns to it.
... | API:
fifo_label_correcting(self, source)
Description:
finds shortest path from source to every other node. Returns
predecessor dictionary. If graph has a negative cycle, detects it
and returns to it.
Pre:
(1) 'cost' attribute of arcs. It will b... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2130-L2176 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.label_correcting_check_cycle | def label_correcting_check_cycle(self, j, pred):
'''
API:
label_correcting_check_cycle(self, j, pred)
Description:
Checks if predecessor dictionary has a cycle, j represents the node
that predecessor is recently updated.
Pre:
(1) predecesso... | python | def label_correcting_check_cycle(self, j, pred):
'''
API:
label_correcting_check_cycle(self, j, pred)
Description:
Checks if predecessor dictionary has a cycle, j represents the node
that predecessor is recently updated.
Pre:
(1) predecesso... | API:
label_correcting_check_cycle(self, j, pred)
Description:
Checks if predecessor dictionary has a cycle, j represents the node
that predecessor is recently updated.
Pre:
(1) predecessor of source node should be None.
Input:
j: node t... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2178-L2204 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.label_correcting_get_cycle | def label_correcting_get_cycle(self, j, pred):
'''
API:
label_correcting_get_cycle(self, labelled, pred)
Description:
In label correcting check cycle it is decided pred has a cycle and
nodes in the cycle are labelled. We will create a list of nodes
... | python | def label_correcting_get_cycle(self, j, pred):
'''
API:
label_correcting_get_cycle(self, labelled, pred)
Description:
In label correcting check cycle it is decided pred has a cycle and
nodes in the cycle are labelled. We will create a list of nodes
... | API:
label_correcting_get_cycle(self, labelled, pred)
Description:
In label correcting check cycle it is decided pred has a cycle and
nodes in the cycle are labelled. We will create a list of nodes
in the cycle using labelled and pred inputs.
Pre:
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2206-L2232 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.augment_cycle | def augment_cycle(self, amount, cycle):
'''
API:
augment_cycle(self, amount, cycle):
Description:
Augments 'amount' unit of flow along cycle.
Pre:
Arcs should have 'flow' attribute.
Inputs:
amount: An integer representing the amount... | python | def augment_cycle(self, amount, cycle):
'''
API:
augment_cycle(self, amount, cycle):
Description:
Augments 'amount' unit of flow along cycle.
Pre:
Arcs should have 'flow' attribute.
Inputs:
amount: An integer representing the amount... | API:
augment_cycle(self, amount, cycle):
Description:
Augments 'amount' unit of flow along cycle.
Pre:
Arcs should have 'flow' attribute.
Inputs:
amount: An integer representing the amount to augment
cycle: A list representing a cycle
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2234-L2267 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.network_simplex | def network_simplex(self, display, pivot, root):
'''
API:
network_simplex(self, display, pivot, root)
Description:
Solves minimum cost feasible flow problem using network simplex
algorithm. It is recommended to use min_cost_flow(algo='simplex')
ins... | python | def network_simplex(self, display, pivot, root):
'''
API:
network_simplex(self, display, pivot, root)
Description:
Solves minimum cost feasible flow problem using network simplex
algorithm. It is recommended to use min_cost_flow(algo='simplex')
ins... | API:
network_simplex(self, display, pivot, root)
Description:
Solves minimum cost feasible flow problem using network simplex
algorithm. It is recommended to use min_cost_flow(algo='simplex')
instead of using network_simplex() directly. Returns True when an
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2269-L2333 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_determine_leaving_arc | def simplex_determine_leaving_arc(self, t, k, l):
'''
API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
... | python | def simplex_determine_leaving_arc(self, t, k, l):
'''
API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
... | API:
simplex_determine_leaving_arc(self, t, k, l)
Description:
Determines and returns the leaving arc.
Input:
t: current spanning tree solution.
k: tail of the entering arc.
l: head of the entering arc.
Return:
Returns the t... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2349-L2403 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_mark_st_arcs | def simplex_mark_st_arcs(self, t):
'''
API:
simplex_mark_st_arcs(self, t)
Description:
Marks spanning tree arcs.
Case 1, Blue: Arcs that are at lower bound and in tree.
Case 2, Red: Arcs that are at upper bound and in tree.
Case 3, Gree... | python | def simplex_mark_st_arcs(self, t):
'''
API:
simplex_mark_st_arcs(self, t)
Description:
Marks spanning tree arcs.
Case 1, Blue: Arcs that are at lower bound and in tree.
Case 2, Red: Arcs that are at upper bound and in tree.
Case 3, Gree... | API:
simplex_mark_st_arcs(self, t)
Description:
Marks spanning tree arcs.
Case 1, Blue: Arcs that are at lower bound and in tree.
Case 2, Red: Arcs that are at upper bound and in tree.
Case 3, Green: Arcs that are between bounds are green.
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2419-L2453 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.print_flow | def print_flow(self):
'''
API:
print_flow(self)
Description:
Prints all positive flows to stdout. This method can be used for
debugging purposes.
'''
print('printing current edge, flow, capacity')
for e in self.edge_attr:
if... | python | def print_flow(self):
'''
API:
print_flow(self)
Description:
Prints all positive flows to stdout. This method can be used for
debugging purposes.
'''
print('printing current edge, flow, capacity')
for e in self.edge_attr:
if... | API:
print_flow(self)
Description:
Prints all positive flows to stdout. This method can be used for
debugging purposes. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2455-L2467 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_redraw | def simplex_redraw(self, display, root):
'''
API:
simplex_redraw(self, display, root)
Description:
Returns a new graph instance that is same as self but adds nodes
and arcs in a way that the resulting tree will be displayed
properly.
Input:... | python | def simplex_redraw(self, display, root):
'''
API:
simplex_redraw(self, display, root)
Description:
Returns a new graph instance that is same as self but adds nodes
and arcs in a way that the resulting tree will be displayed
properly.
Input:... | API:
simplex_redraw(self, display, root)
Description:
Returns a new graph instance that is same as self but adds nodes
and arcs in a way that the resulting tree will be displayed
properly.
Input:
display: display mode
root: root nod... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2469-L2518 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_remove_arc | def simplex_remove_arc(self, t, p, q, min_capacity, cycle):
'''
API:
simplex_remove_arc(self, p, q, min_capacity, cycle)
Description:
Removes arc (p,q), updates t, updates flows, where (k,l) is
the entering arc.
Input:
t: tree solution to b... | python | def simplex_remove_arc(self, t, p, q, min_capacity, cycle):
'''
API:
simplex_remove_arc(self, p, q, min_capacity, cycle)
Description:
Removes arc (p,q), updates t, updates flows, where (k,l) is
the entering arc.
Input:
t: tree solution to b... | API:
simplex_remove_arc(self, p, q, min_capacity, cycle)
Description:
Removes arc (p,q), updates t, updates flows, where (k,l) is
the entering arc.
Input:
t: tree solution to be updated.
p: tail of the leaving arc.
q: head of the le... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2520-L2576 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_select_entering_arc | def simplex_select_entering_arc(self, t, pivot):
'''
API:
simplex_select_entering_arc(self, t, pivot)
Description:
Decides and returns entering arc using pivot rule.
Input:
t: current spanning tree solution
pivot: May be one of the followin... | python | def simplex_select_entering_arc(self, t, pivot):
'''
API:
simplex_select_entering_arc(self, t, pivot)
Description:
Decides and returns entering arc using pivot rule.
Input:
t: current spanning tree solution
pivot: May be one of the followin... | API:
simplex_select_entering_arc(self, t, pivot)
Description:
Decides and returns entering arc using pivot rule.
Input:
t: current spanning tree solution
pivot: May be one of the following; 'first_eligible' or 'dantzig'.
'dantzig' is the defaul... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2578-L2638 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_optimal | def simplex_optimal(self, t):
'''
API:
simplex_optimal(self, t)
Description:
Checks if the current solution is optimal, if yes returns True,
False otherwise.
Pre:
'flow' attributes represents a solution.
Input:
t: Graph ... | python | def simplex_optimal(self, t):
'''
API:
simplex_optimal(self, t)
Description:
Checks if the current solution is optimal, if yes returns True,
False otherwise.
Pre:
'flow' attributes represents a solution.
Input:
t: Graph ... | API:
simplex_optimal(self, t)
Description:
Checks if the current solution is optimal, if yes returns True,
False otherwise.
Pre:
'flow' attributes represents a solution.
Input:
t: Graph instance tat reperesents spanning tree solution.
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2640-L2670 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_find_tree | def simplex_find_tree(self):
'''
API:
simplex_find_tree(self)
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs and converts this solution to a feasible spanning tree
solution.
Pre:
(1) 'flow' at... | python | def simplex_find_tree(self):
'''
API:
simplex_find_tree(self)
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs and converts this solution to a feasible spanning tree
solution.
Pre:
(1) 'flow' at... | API:
simplex_find_tree(self)
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs and converts this solution to a feasible spanning tree
solution.
Pre:
(1) 'flow' attributes represents a feasible flow solution.
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2672-L2712 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_connect | def simplex_connect(self, solution_g):
'''
API:
simplex_connect(self, solution_g)
Description:
At this point we assume that the solution does not have a cycle.
We check if all the nodes are connected, if not we add an arc to
solution_g that does no... | python | def simplex_connect(self, solution_g):
'''
API:
simplex_connect(self, solution_g)
Description:
At this point we assume that the solution does not have a cycle.
We check if all the nodes are connected, if not we add an arc to
solution_g that does no... | API:
simplex_connect(self, solution_g)
Description:
At this point we assume that the solution does not have a cycle.
We check if all the nodes are connected, if not we add an arc to
solution_g that does not create a cycle and return True. Otherwise
we ... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2714-L2748 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_search | def simplex_search(self, source, component_nr):
'''
API:
simplex_search(self, source, component_nr)
Description:
Searches graph starting from source. Its difference from usual
search is we can also go backwards along an arc. When the graph
is a spa... | python | def simplex_search(self, source, component_nr):
'''
API:
simplex_search(self, source, component_nr)
Description:
Searches graph starting from source. Its difference from usual
search is we can also go backwards along an arc. When the graph
is a spa... | API:
simplex_search(self, source, component_nr)
Description:
Searches graph starting from source. Its difference from usual
search is we can also go backwards along an arc. When the graph
is a spanning tree it computes predecessor, thread and depth
ind... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2750-L2795 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_augment_cycle | def simplex_augment_cycle(self, cycle):
'''
API:
simplex_augment_cycle(self, cycle)
Description:
Augments along the cycle to break it.
Pre:
'flow', 'capacity' attributes on arcs.
Input:
cycle: list representing a cycle in the soluti... | python | def simplex_augment_cycle(self, cycle):
'''
API:
simplex_augment_cycle(self, cycle)
Description:
Augments along the cycle to break it.
Pre:
'flow', 'capacity' attributes on arcs.
Input:
cycle: list representing a cycle in the soluti... | API:
simplex_augment_cycle(self, cycle)
Description:
Augments along the cycle to break it.
Pre:
'flow', 'capacity' attributes on arcs.
Input:
cycle: list representing a cycle in the solution
Post:
'flow' attribute will be modifi... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2797-L2832 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_find_cycle | def simplex_find_cycle(self):
'''
API:
simplex_find_cycle(self)
Description:
Returns a cycle (list of nodes) if the graph has one, returns None
otherwise. Uses DFS. During DFS checks existence of arcs to lower
depth regions. Note that direction of ... | python | def simplex_find_cycle(self):
'''
API:
simplex_find_cycle(self)
Description:
Returns a cycle (list of nodes) if the graph has one, returns None
otherwise. Uses DFS. During DFS checks existence of arcs to lower
depth regions. Note that direction of ... | API:
simplex_find_cycle(self)
Description:
Returns a cycle (list of nodes) if the graph has one, returns None
otherwise. Uses DFS. During DFS checks existence of arcs to lower
depth regions. Note that direction of the arcs are not important.
Return:
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2834-L2901 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_simplex_solution_graph | def get_simplex_solution_graph(self):
'''
API:
get_simplex_solution_graph(self):
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs. Returns the graph with arcs that have flow between 0 and
capacity.
Pre:
... | python | def get_simplex_solution_graph(self):
'''
API:
get_simplex_solution_graph(self):
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs. Returns the graph with arcs that have flow between 0 and
capacity.
Pre:
... | API:
get_simplex_solution_graph(self):
Description:
Assumes a feasible flow solution stored in 'flow' attribute's of
arcs. Returns the graph with arcs that have flow between 0 and
capacity.
Pre:
(1) 'flow' attribute represents a feasible flow s... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2903-L2926 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_compute_potentials | def simplex_compute_potentials(self, t, root):
'''
API:
simplex_compute_potentials(self, t, root)
Description:
Computes node potentials for a minimum cost flow problem and stores
them as node attribute 'potential'. Based on pseudocode given in
Netw... | python | def simplex_compute_potentials(self, t, root):
'''
API:
simplex_compute_potentials(self, t, root)
Description:
Computes node potentials for a minimum cost flow problem and stores
them as node attribute 'potential'. Based on pseudocode given in
Netw... | API:
simplex_compute_potentials(self, t, root)
Description:
Computes node potentials for a minimum cost flow problem and stores
them as node attribute 'potential'. Based on pseudocode given in
Network Flows by Ahuja et al.
Pre:
(1) Assumes a di... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2928-L2957 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.simplex_identify_cycle | def simplex_identify_cycle(self, t, k, l):
'''
API:
identify_cycle(self, t, k, l)
Description:
Identifies and returns to the pivot cycle, which is a list of
nodes.
Pre:
(1) t is spanning tree solution, (k,l) is the entering arc.
Inp... | python | def simplex_identify_cycle(self, t, k, l):
'''
API:
identify_cycle(self, t, k, l)
Description:
Identifies and returns to the pivot cycle, which is a list of
nodes.
Pre:
(1) t is spanning tree solution, (k,l) is the entering arc.
Inp... | API:
identify_cycle(self, t, k, l)
Description:
Identifies and returns to the pivot cycle, which is a list of
nodes.
Pre:
(1) t is spanning tree solution, (k,l) is the entering arc.
Input:
t: current spanning tree solution
k... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L2959-L2999 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.min_cost_flow | def min_cost_flow(self, display = None, **args):
'''
API:
min_cost_flow(self, display='off', **args)
Description:
Solves minimum cost flow problem using node/edge attributes with
the algorithm specified.
Pre:
(1) Assumes a directed graph in... | python | def min_cost_flow(self, display = None, **args):
'''
API:
min_cost_flow(self, display='off', **args)
Description:
Solves minimum cost flow problem using node/edge attributes with
the algorithm specified.
Pre:
(1) Assumes a directed graph in... | API:
min_cost_flow(self, display='off', **args)
Description:
Solves minimum cost flow problem using node/edge attributes with
the algorithm specified.
Pre:
(1) Assumes a directed graph in which each arc has 'capacity' and
'cost' attributes.
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3001-L3076 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.random | def random(self, numnodes = 10, degree_range = (2, 4), length_range = (1, 10),
density = None, edge_format = None, node_format = None,
Euclidean = False, seedInput = 0, add_labels = True,
parallel_allowed = False, node_selection = 'closest',
scale = 10, scale_... | python | def random(self, numnodes = 10, degree_range = (2, 4), length_range = (1, 10),
density = None, edge_format = None, node_format = None,
Euclidean = False, seedInput = 0, add_labels = True,
parallel_allowed = False, node_selection = 'closest',
scale = 10, scale_... | API:
random(self, numnodes = 10, degree_range = None, length_range = None,
density = None, edge_format = None, node_format = None,
Euclidean = False, seedInput = 0)
Description:
Populates graph with random edges and nodes.
Input:
numnodes... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3078-L3229 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.page_rank | def page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001):
'''
API:
page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001)
Description:
Compute and return the page-rank of a directed graph.
... | python | def page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001):
'''
API:
page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001)
Description:
Compute and return the page-rank of a directed graph.
... | API:
page_rank(self, damping_factor=0.85, max_iterations=100,
min_delta=0.00001)
Description:
Compute and return the page-rank of a directed graph.
This function was originally taken from here and modified for this
graph class: http://code.google... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3231-L3273 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_degrees | def get_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree = {... | python | def get_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree = {... | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3275-L3293 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_in_degrees | def get_in_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree ... | python | def get_in_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree ... | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3295-L3311 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_out_degrees | def get_out_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree... | python | def get_out_degrees(self):
'''
API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees.
'''
degree... | API:
get_degree(self)
Description:
Returns degrees of nodes in dictionary format.
Return:
Returns a dictionary of node degrees. Keys are node names, values
are corresponding degrees. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3313-L3329 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.get_diameter | def get_diameter(self):
'''
API:
get_diameter(self)
Description:
Returns diameter of the graph. Diameter is defined as follows.
distance(n,m): shortest unweighted path from n to m
eccentricity(n) = $\max _m distance(n,m)$
diameter = $\m... | python | def get_diameter(self):
'''
API:
get_diameter(self)
Description:
Returns diameter of the graph. Diameter is defined as follows.
distance(n,m): shortest unweighted path from n to m
eccentricity(n) = $\max _m distance(n,m)$
diameter = $\m... | API:
get_diameter(self)
Description:
Returns diameter of the graph. Diameter is defined as follows.
distance(n,m): shortest unweighted path from n to m
eccentricity(n) = $\max _m distance(n,m)$
diameter = $\min _n eccentricity(n) = \min _n \max _m dist... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3331-L3362 |
coin-or/GiMPy | src/gimpy/graph.py | Graph.create_cluster | def create_cluster(self, node_list, cluster_attrs={}, node_attrs={}):
'''
API:
create_cluster(self, node_list, cluster_attrs, node_attrs)
Description:
Creates a cluster from the node given in the node list.
Input:
node_list: List of nodes in the cluste... | python | def create_cluster(self, node_list, cluster_attrs={}, node_attrs={}):
'''
API:
create_cluster(self, node_list, cluster_attrs, node_attrs)
Description:
Creates a cluster from the node given in the node list.
Input:
node_list: List of nodes in the cluste... | API:
create_cluster(self, node_list, cluster_attrs, node_attrs)
Description:
Creates a cluster from the node given in the node list.
Input:
node_list: List of nodes in the cluster.
cluster_attrs: Dictionary of cluster attributes, see Dot language
... | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3364-L3392 |
coin-or/GiMPy | src/gimpy/graph.py | DisjointSet.add | def add(self, aList):
'''
API:
add(self, aList)
Description:
Adds items in the list to the set.
Input:
aList: List of items.
Post:
self.sizes will be updated.
'''
self.add_node(aList[0])
for i in range(1, len... | python | def add(self, aList):
'''
API:
add(self, aList)
Description:
Adds items in the list to the set.
Input:
aList: List of items.
Post:
self.sizes will be updated.
'''
self.add_node(aList[0])
for i in range(1, len... | API:
add(self, aList)
Description:
Adds items in the list to the set.
Input:
aList: List of items.
Post:
self.sizes will be updated. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3416-L3430 |
coin-or/GiMPy | src/gimpy/graph.py | DisjointSet.union | def union(self, i, j):
'''
API:
union(self, i, j):
Description:
Finds sets of i and j and unites them.
Input:
i: Item.
j: Item.
Post:
self.sizes will be updated.
'''
roots = (self.find(i), self.find(j))
... | python | def union(self, i, j):
'''
API:
union(self, i, j):
Description:
Finds sets of i and j and unites them.
Input:
i: Item.
j: Item.
Post:
self.sizes will be updated.
'''
roots = (self.find(i), self.find(j))
... | API:
union(self, i, j):
Description:
Finds sets of i and j and unites them.
Input:
i: Item.
j: Item.
Post:
self.sizes will be updated. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3432-L3454 |
coin-or/GiMPy | src/gimpy/graph.py | DisjointSet.find | def find(self, i):
'''
API:
find(self, i)
Description:
Returns root of set that has i.
Input:
i: Item.
Return:
Returns root of set that has i.
'''
current = i
edge_list = []
while len(self.get_neighbo... | python | def find(self, i):
'''
API:
find(self, i)
Description:
Returns root of set that has i.
Input:
i: Item.
Return:
Returns root of set that has i.
'''
current = i
edge_list = []
while len(self.get_neighbo... | API:
find(self, i)
Description:
Returns root of set that has i.
Input:
i: Item.
Return:
Returns root of set that has i. | https://github.com/coin-or/GiMPy/blob/51853122a50eb6019d06bbdedbfc396a833b5a22/src/gimpy/graph.py#L3456-L3478 |
CZ-NIC/yangson | yangson/xpathast.py | Expr.evaluate | def evaluate(self, node: InstanceNode) -> XPathValue:
"""Evaluate the receiver and return the result.
Args:
node: Context node for XPath evaluation.
Raises:
XPathTypeError: If a subexpression of the receiver is of a wrong
type.
"""
return... | python | def evaluate(self, node: InstanceNode) -> XPathValue:
"""Evaluate the receiver and return the result.
Args:
node: Context node for XPath evaluation.
Raises:
XPathTypeError: If a subexpression of the receiver is of a wrong
type.
"""
return... | Evaluate the receiver and return the result.
Args:
node: Context node for XPath evaluation.
Raises:
XPathTypeError: If a subexpression of the receiver is of a wrong
type. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/xpathast.py#L62-L72 |
CZ-NIC/yangson | yangson/datatype.py | DataType.from_raw | def from_raw(self, raw: RawScalar) -> Optional[ScalarValue]:
"""Return a cooked value of the receiver type.
Args:
raw: Raw value obtained from JSON parser.
"""
if isinstance(raw, str):
return raw | python | def from_raw(self, raw: RawScalar) -> Optional[ScalarValue]:
"""Return a cooked value of the receiver type.
Args:
raw: Raw value obtained from JSON parser.
"""
if isinstance(raw, str):
return raw | Return a cooked value of the receiver type.
Args:
raw: Raw value obtained from JSON parser. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L88-L95 |
CZ-NIC/yangson | yangson/datatype.py | DataType.from_yang | def from_yang(self, text: str) -> ScalarValue:
"""Parse value specified in a YANG module.
Args:
text: String representation of the value.
Raises:
InvalidArgument: If the receiver type cannot parse the text.
"""
res = self.parse_value(text)
if res... | python | def from_yang(self, text: str) -> ScalarValue:
"""Parse value specified in a YANG module.
Args:
text: String representation of the value.
Raises:
InvalidArgument: If the receiver type cannot parse the text.
"""
res = self.parse_value(text)
if res... | Parse value specified in a YANG module.
Args:
text: String representation of the value.
Raises:
InvalidArgument: If the receiver type cannot parse the text. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L116-L128 |
CZ-NIC/yangson | yangson/datatype.py | DataType._handle_properties | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle type substatements."""
self._handle_restrictions(stmt, sctx) | python | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle type substatements."""
self._handle_restrictions(stmt, sctx) | Handle type substatements. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L182-L184 |
CZ-NIC/yangson | yangson/datatype.py | DataType._type_digest | def _type_digest(self, config: bool) -> Dict[str, Any]:
"""Return receiver's type digest.
Args:
config: Specifies whether the type is on a configuration node.
"""
res = {"base": self.yang_type()}
if self.name is not None:
res["derived"] = self.name
... | python | def _type_digest(self, config: bool) -> Dict[str, Any]:
"""Return receiver's type digest.
Args:
config: Specifies whether the type is on a configuration node.
"""
res = {"base": self.yang_type()}
if self.name is not None:
res["derived"] = self.name
... | Return receiver's type digest.
Args:
config: Specifies whether the type is on a configuration node. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L190-L199 |
CZ-NIC/yangson | yangson/datatype.py | BitsType.sorted_bits | def sorted_bits(self) -> List[Tuple[str, int]]:
"""Return list of bit items sorted by position."""
return sorted(self.bit.items(), key=lambda x: x[1]) | python | def sorted_bits(self) -> List[Tuple[str, int]]:
"""Return list of bit items sorted by position."""
return sorted(self.bit.items(), key=lambda x: x[1]) | Return list of bit items sorted by position. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L231-L233 |
CZ-NIC/yangson | yangson/datatype.py | BitsType.as_int | def as_int(self, val: Tuple[str]) -> int:
"""Transform a "bits" value to an integer."""
res = 0
try:
for b in val:
res += 1 << self.bit[b]
except KeyError:
return None
return res | python | def as_int(self, val: Tuple[str]) -> int:
"""Transform a "bits" value to an integer."""
res = 0
try:
for b in val:
res += 1 << self.bit[b]
except KeyError:
return None
return res | Transform a "bits" value to an integer. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L251-L259 |
CZ-NIC/yangson | yangson/datatype.py | BitsType._handle_properties | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **bit** statements."""
nextpos = 0
for bst in stmt.find_all("bit"):
if not sctx.schema_data.if_features(bst, sctx.text_mid):
continue
label = bst.argument
pst... | python | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **bit** statements."""
nextpos = 0
for bst in stmt.find_all("bit"):
if not sctx.schema_data.if_features(bst, sctx.text_mid):
continue
label = bst.argument
pst... | Handle **bit** statements. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L269-L284 |
CZ-NIC/yangson | yangson/datatype.py | BooleanType.from_raw | def from_raw(self, raw: RawScalar) -> Optional[bool]:
"""Override superclass method."""
if isinstance(raw, bool):
return raw | python | def from_raw(self, raw: RawScalar) -> Optional[bool]:
"""Override superclass method."""
if isinstance(raw, bool):
return raw | Override superclass method. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L317-L320 |
CZ-NIC/yangson | yangson/datatype.py | BooleanType.parse_value | def parse_value(self, text: str) -> Optional[bool]:
"""Parse boolean value.
Args:
text: String representation of the value.
"""
if text == "true":
return True
if text == "false":
return False | python | def parse_value(self, text: str) -> Optional[bool]:
"""Parse boolean value.
Args:
text: String representation of the value.
"""
if text == "true":
return True
if text == "false":
return False | Parse boolean value.
Args:
text: String representation of the value. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L322-L331 |
CZ-NIC/yangson | yangson/datatype.py | BinaryType.from_raw | def from_raw(self, raw: RawScalar) -> Optional[bytes]:
"""Override superclass method."""
try:
return base64.b64decode(raw, validate=True)
except TypeError:
return None | python | def from_raw(self, raw: RawScalar) -> Optional[bytes]:
"""Override superclass method."""
try:
return base64.b64decode(raw, validate=True)
except TypeError:
return None | Override superclass method. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L410-L415 |
CZ-NIC/yangson | yangson/datatype.py | EnumerationType.sorted_enums | def sorted_enums(self) -> List[Tuple[str, int]]:
"""Return list of enum items sorted by value."""
return sorted(self.enum.items(), key=lambda x: x[1]) | python | def sorted_enums(self) -> List[Tuple[str, int]]:
"""Return list of enum items sorted by value."""
return sorted(self.enum.items(), key=lambda x: x[1]) | Return list of enum items sorted by value. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L438-L440 |
CZ-NIC/yangson | yangson/datatype.py | EnumerationType._handle_properties | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **enum** statements."""
nextval = 0
for est in stmt.find_all("enum"):
if not sctx.schema_data.if_features(est, sctx.text_mid):
continue
label = est.argument
v... | python | def _handle_properties(self, stmt: Statement, sctx: SchemaContext) -> None:
"""Handle **enum** statements."""
nextval = 0
for est in stmt.find_all("enum"):
if not sctx.schema_data.if_features(est, sctx.text_mid):
continue
label = est.argument
v... | Handle **enum** statements. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L448-L463 |
CZ-NIC/yangson | yangson/datatype.py | IdentityrefType.from_yang | def from_yang(self, text: str) -> Optional[QualName]:
"""Override the superclass method."""
try:
return self.sctx.schema_data.translate_pname(text, self.sctx.text_mid)
except (ModuleNotRegistered, UnknownPrefix):
raise InvalidArgument(text) | python | def from_yang(self, text: str) -> Optional[QualName]:
"""Override the superclass method."""
try:
return self.sctx.schema_data.translate_pname(text, self.sctx.text_mid)
except (ModuleNotRegistered, UnknownPrefix):
raise InvalidArgument(text) | Override the superclass method. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L579-L584 |
CZ-NIC/yangson | yangson/datatype.py | IntegralType.from_yang | def from_yang(self, text: str) -> Optional[int]:
"""Override the superclass method."""
if text.startswith("0"):
base = 16 if text.startswith("0x") else 8
else:
base = 10
try:
return int(text, base)
except (ValueError, TypeError):
ra... | python | def from_yang(self, text: str) -> Optional[int]:
"""Override the superclass method."""
if text.startswith("0"):
base = 16 if text.startswith("0x") else 8
else:
base = 10
try:
return int(text, base)
except (ValueError, TypeError):
ra... | Override the superclass method. | https://github.com/CZ-NIC/yangson/blob/a4b9464041fa8b28f6020a420ababf18fddf5d4a/yangson/datatype.py#L711-L720 |
aiidateam/aiida-cp2k | aiida_cp2k/calculations/__init__.py | Cp2kCalculation.prepare_for_submission | def prepare_for_submission(self, folder):
"""Create the input files from the input nodes passed to this instance of the `CalcJob`.
:param folder: an `aiida.common.folders.Folder` to temporarily write files on disk
:return: `aiida.common.datastructures.CalcInfo` instance
"""
# cr... | python | def prepare_for_submission(self, folder):
"""Create the input files from the input nodes passed to this instance of the `CalcJob`.
:param folder: an `aiida.common.folders.Folder` to temporarily write files on disk
:return: `aiida.common.datastructures.CalcInfo` instance
"""
# cr... | Create the input files from the input nodes passed to this instance of the `CalcJob`.
:param folder: an `aiida.common.folders.Folder` to temporarily write files on disk
:return: `aiida.common.datastructures.CalcInfo` instance | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/calculations/__init__.py#L72-L141 |
aiidateam/aiida-cp2k | aiida_cp2k/calculations/__init__.py | Cp2kInput._add_keyword_low | def _add_keyword_low(self, kwpath, value, params):
"""Adds keyword"""
if len(kwpath) == 1:
params[kwpath[0]] = value
elif kwpath[0] not in params.keys():
new_subsection = {}
params[kwpath[0]] = new_subsection
self._add_keyword_low(kwpath[1:], value... | python | def _add_keyword_low(self, kwpath, value, params):
"""Adds keyword"""
if len(kwpath) == 1:
params[kwpath[0]] = value
elif kwpath[0] not in params.keys():
new_subsection = {}
params[kwpath[0]] = new_subsection
self._add_keyword_low(kwpath[1:], value... | Adds keyword | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/calculations/__init__.py#L156-L165 |
aiidateam/aiida-cp2k | aiida_cp2k/calculations/__init__.py | Cp2kInput._render_section | def _render_section(self, output, params, indent=0):
"""
It takes a dictionary and recurses through.
For key-value pair it checks whether the value is a dictionary
and prepends the key with &
It passes the valued to the same function, increasing the indentation
If the va... | python | def _render_section(self, output, params, indent=0):
"""
It takes a dictionary and recurses through.
For key-value pair it checks whether the value is a dictionary
and prepends the key with &
It passes the valued to the same function, increasing the indentation
If the va... | It takes a dictionary and recurses through.
For key-value pair it checks whether the value is a dictionary
and prepends the key with &
It passes the valued to the same function, increasing the indentation
If the value is a list, I assume that this is something the user
wants to ... | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/calculations/__init__.py#L174-L222 |
mozilla/django-tidings | tidings/models.py | multi_raw | def multi_raw(query, params, models, model_to_fields):
"""Scoop multiple model instances out of the DB at once, given a query that
returns all fields of each.
Return an iterable of sequences of model instances parallel to the
``models`` sequence of classes. For example::
[(<User such-and-such>... | python | def multi_raw(query, params, models, model_to_fields):
"""Scoop multiple model instances out of the DB at once, given a query that
returns all fields of each.
Return an iterable of sequences of model instances parallel to the
``models`` sequence of classes. For example::
[(<User such-and-such>... | Scoop multiple model instances out of the DB at once, given a query that
returns all fields of each.
Return an iterable of sequences of model instances parallel to the
``models`` sequence of classes. For example::
[(<User such-and-such>, <Watch such-and-such>), ...] | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/models.py#L16-L34 |
mozilla/django-tidings | tidings/models.py | Watch.unsubscribe_url | def unsubscribe_url(self):
"""Return the absolute URL to visit to delete me."""
server_relative = ('%s?s=%s' % (reverse('tidings.unsubscribe',
args=[self.pk]),
self.secret))
return 'https://%s%s' % (Site.obje... | python | def unsubscribe_url(self):
"""Return the absolute URL to visit to delete me."""
server_relative = ('%s?s=%s' % (reverse('tidings.unsubscribe',
args=[self.pk]),
self.secret))
return 'https://%s%s' % (Site.obje... | Return the absolute URL to visit to delete me. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/models.py#L83-L89 |
mozilla/django-tidings | tidings/tasks.py | claim_watches | def claim_watches(user):
"""Attach any anonymous watches having a user's email to that user.
Call this from your user registration process if you like.
"""
Watch.objects.filter(email=user.email).update(email=None, user=user) | python | def claim_watches(user):
"""Attach any anonymous watches having a user's email to that user.
Call this from your user registration process if you like.
"""
Watch.objects.filter(email=user.email).update(email=None, user=user) | Attach any anonymous watches having a user's email to that user.
Call this from your user registration process if you like. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/tasks.py#L7-L13 |
mozilla/django-tidings | tidings/utils.py | collate | def collate(*iterables, **kwargs):
"""Return an iterable ordered collation of the already-sorted items
from each of ``iterables``, compared by kwarg ``key``.
If ``reverse=True`` is passed, iterables must return their results in
descending order rather than ascending.
"""
key = kwargs.pop('key'... | python | def collate(*iterables, **kwargs):
"""Return an iterable ordered collation of the already-sorted items
from each of ``iterables``, compared by kwarg ``key``.
If ``reverse=True`` is passed, iterables must return their results in
descending order rather than ascending.
"""
key = kwargs.pop('key'... | Return an iterable ordered collation of the already-sorted items
from each of ``iterables``, compared by kwarg ``key``.
If ``reverse=True`` is passed, iterables must return their results in
descending order rather than ascending. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/utils.py#L13-L46 |
mozilla/django-tidings | tidings/utils.py | hash_to_unsigned | def hash_to_unsigned(data):
"""If ``data`` is a string or unicode string, return an unsigned 4-byte int
hash of it. If ``data`` is already an int that fits those parameters,
return it verbatim.
If ``data`` is an int outside that range, behavior is undefined at the
moment. We rely on the ``PositiveI... | python | def hash_to_unsigned(data):
"""If ``data`` is a string or unicode string, return an unsigned 4-byte int
hash of it. If ``data`` is already an int that fits those parameters,
return it verbatim.
If ``data`` is an int outside that range, behavior is undefined at the
moment. We rely on the ``PositiveI... | If ``data`` is a string or unicode string, return an unsigned 4-byte int
hash of it. If ``data`` is already an int that fits those parameters,
return it verbatim.
If ``data`` is an int outside that range, behavior is undefined at the
moment. We rely on the ``PositiveIntegerField`` on
:class:`~tidin... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/utils.py#L49-L76 |
mozilla/django-tidings | tidings/utils.py | emails_with_users_and_watches | def emails_with_users_and_watches(
subject, template_path, vars, users_and_watches,
from_email=settings.TIDINGS_FROM_ADDRESS, **extra_kwargs):
"""Return iterable of EmailMessages with user and watch values substituted.
A convenience function for generating emails by repeatedly rendering a
D... | python | def emails_with_users_and_watches(
subject, template_path, vars, users_and_watches,
from_email=settings.TIDINGS_FROM_ADDRESS, **extra_kwargs):
"""Return iterable of EmailMessages with user and watch values substituted.
A convenience function for generating emails by repeatedly rendering a
D... | Return iterable of EmailMessages with user and watch values substituted.
A convenience function for generating emails by repeatedly rendering a
Django template with the given ``vars`` plus a ``user`` and ``watches`` key
for each pair in ``users_and_watches``
:arg template_path: path to template file
... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/utils.py#L79-L107 |
mozilla/django-tidings | tidings/utils.py | import_from_setting | def import_from_setting(setting_name, fallback):
"""Return the resolution of an import path stored in a Django setting.
:arg setting_name: The name of the setting holding the import path
:arg fallback: An alternate object to use if the setting is empty or
doesn't exist
Raise ImproperlyConfigured... | python | def import_from_setting(setting_name, fallback):
"""Return the resolution of an import path stored in a Django setting.
:arg setting_name: The name of the setting holding the import path
:arg fallback: An alternate object to use if the setting is empty or
doesn't exist
Raise ImproperlyConfigured... | Return the resolution of an import path stored in a Django setting.
:arg setting_name: The name of the setting holding the import path
:arg fallback: An alternate object to use if the setting is empty or
doesn't exist
Raise ImproperlyConfigured if a path is given that can't be resolved. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/utils.py#L110-L127 |
aiidateam/aiida-cp2k | aiida_cp2k/parsers/__init__.py | Cp2kParser.parse | def parse(self, **kwargs):
"""
Receives in input a dictionary of retrieved nodes.
Does all the logic here.
"""
from aiida.engine import ExitCode
from aiida.common import NotExistent
try:
out_folder = self.retrieved
except NotExistent:
... | python | def parse(self, **kwargs):
"""
Receives in input a dictionary of retrieved nodes.
Does all the logic here.
"""
from aiida.engine import ExitCode
from aiida.common import NotExistent
try:
out_folder = self.retrieved
except NotExistent:
... | Receives in input a dictionary of retrieved nodes.
Does all the logic here. | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/parsers/__init__.py#L30-L51 |
aiidateam/aiida-cp2k | aiida_cp2k/parsers/__init__.py | Cp2kParser._parse_stdout | def _parse_stdout(self, out_folder):
"""CP2K output parser"""
fname = self.node.load_process_class()._DEFAULT_OUTPUT_FILE # pylint: disable=protected-access
if fname not in out_folder._repository.list_object_names(): # pylint: disable=protected-access
raise OutputParsingError("Cp2k... | python | def _parse_stdout(self, out_folder):
"""CP2K output parser"""
fname = self.node.load_process_class()._DEFAULT_OUTPUT_FILE # pylint: disable=protected-access
if fname not in out_folder._repository.list_object_names(): # pylint: disable=protected-access
raise OutputParsingError("Cp2k... | CP2K output parser | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/parsers/__init__.py#L54-L84 |
aiidateam/aiida-cp2k | aiida_cp2k/parsers/__init__.py | Cp2kParser._parse_bands | def _parse_bands(lines, n_start):
"""Parse band structure from cp2k output"""
kpoints = []
labels = []
bands_s1 = []
bands_s2 = []
known_kpoints = {}
pattern = re.compile(".*?Nr.*?Spin.*?K-Point.*?", re.DOTALL)
selected_lines = lines[n_start:]
for... | python | def _parse_bands(lines, n_start):
"""Parse band structure from cp2k output"""
kpoints = []
labels = []
bands_s1 = []
bands_s2 = []
known_kpoints = {}
pattern = re.compile(".*?Nr.*?Spin.*?K-Point.*?", re.DOTALL)
selected_lines = lines[n_start:]
for... | Parse band structure from cp2k output | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/parsers/__init__.py#L88-L122 |
aiidateam/aiida-cp2k | aiida_cp2k/parsers/__init__.py | Cp2kParser._parse_trajectory | def _parse_trajectory(self, out_folder):
"""CP2K trajectory parser"""
fname = self.node.load_process_class()._DEFAULT_RESTART_FILE_NAME # pylint: disable=protected-access
if fname not in out_folder._repository.list_object_names(): # pylint: disable=protected-access
raise Exception ... | python | def _parse_trajectory(self, out_folder):
"""CP2K trajectory parser"""
fname = self.node.load_process_class()._DEFAULT_RESTART_FILE_NAME # pylint: disable=protected-access
if fname not in out_folder._repository.list_object_names(): # pylint: disable=protected-access
raise Exception ... | CP2K trajectory parser | https://github.com/aiidateam/aiida-cp2k/blob/27f5e075ddf2f1badaa5523a487339f8ed7711b1/aiida_cp2k/parsers/__init__.py#L125-L151 |
mozilla/django-tidings | tidings/views.py | unsubscribe | def unsubscribe(request, watch_id):
"""Unsubscribe from (i.e. delete) the watch of ID ``watch_id``.
Expects an ``s`` querystring parameter matching the watch's secret.
GET will result in a confirmation page (or a failure page if the secret is
wrong). POST will actually delete the watch (again, if the ... | python | def unsubscribe(request, watch_id):
"""Unsubscribe from (i.e. delete) the watch of ID ``watch_id``.
Expects an ``s`` querystring parameter matching the watch's secret.
GET will result in a confirmation page (or a failure page if the secret is
wrong). POST will actually delete the watch (again, if the ... | Unsubscribe from (i.e. delete) the watch of ID ``watch_id``.
Expects an ``s`` querystring parameter matching the watch's secret.
GET will result in a confirmation page (or a failure page if the secret is
wrong). POST will actually delete the watch (again, if the secret is
correct).
Uses these tem... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/views.py#L7-L44 |
mozilla/django-tidings | tidings/events.py | _unique_by_email | def _unique_by_email(users_and_watches):
"""Given a sequence of (User/EmailUser, [Watch, ...]) pairs
clustered by email address (which is never ''), yield from each
cluster a single pair like this::
(User/EmailUser, [Watch, Watch, ...]).
The User/Email is that of...
(1) the first incoming pa... | python | def _unique_by_email(users_and_watches):
"""Given a sequence of (User/EmailUser, [Watch, ...]) pairs
clustered by email address (which is never ''), yield from each
cluster a single pair like this::
(User/EmailUser, [Watch, Watch, ...]).
The User/Email is that of...
(1) the first incoming pa... | Given a sequence of (User/EmailUser, [Watch, ...]) pairs
clustered by email address (which is never ''), yield from each
cluster a single pair like this::
(User/EmailUser, [Watch, Watch, ...]).
The User/Email is that of...
(1) the first incoming pair where the User has an email and is not
... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L24-L76 |
mozilla/django-tidings | tidings/events.py | Event.fire | def fire(self, exclude=None, delay=True):
"""Notify everyone watching the event.
We are explicit about sending notifications; we don't just key off
creation signals, because the receiver of a ``post_save`` signal has no
idea what just changed, so it doesn't know which notifications to s... | python | def fire(self, exclude=None, delay=True):
"""Notify everyone watching the event.
We are explicit about sending notifications; we don't just key off
creation signals, because the receiver of a ``post_save`` signal has no
idea what just changed, so it doesn't know which notifications to s... | Notify everyone watching the event.
We are explicit about sending notifications; we don't just key off
creation signals, because the receiver of a ``post_save`` signal has no
idea what just changed, so it doesn't know which notifications to send.
Also, we could easily send mail accident... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L110-L136 |
mozilla/django-tidings | tidings/events.py | Event._fire_task | def _fire_task(self, exclude=None):
"""Build and send the emails as a celery task."""
connection = mail.get_connection(fail_silently=True)
# Warning: fail_silently swallows errors thrown by the generators, too.
connection.open()
for m in self._mails(self._users_watching(exclude=e... | python | def _fire_task(self, exclude=None):
"""Build and send the emails as a celery task."""
connection = mail.get_connection(fail_silently=True)
# Warning: fail_silently swallows errors thrown by the generators, too.
connection.open()
for m in self._mails(self._users_watching(exclude=e... | Build and send the emails as a celery task. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L139-L145 |
mozilla/django-tidings | tidings/events.py | Event._validate_filters | def _validate_filters(cls, filters):
"""Raise a TypeError if ``filters`` contains any keys inappropriate to
this event class."""
for k in iterkeys(filters):
if k not in cls.filters:
# Mirror "unexpected keyword argument" message:
raise TypeError("%s go... | python | def _validate_filters(cls, filters):
"""Raise a TypeError if ``filters`` contains any keys inappropriate to
this event class."""
for k in iterkeys(filters):
if k not in cls.filters:
# Mirror "unexpected keyword argument" message:
raise TypeError("%s go... | Raise a TypeError if ``filters`` contains any keys inappropriate to
this event class. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L148-L155 |
mozilla/django-tidings | tidings/events.py | Event._users_watching_by_filter | def _users_watching_by_filter(self, object_id=None, exclude=None,
**filters):
"""Return an iterable of (``User``/:class:`~tidings.models.EmailUser`,
[:class:`~tidings.models.Watch` objects]) tuples watching the event.
Of multiple Users/EmailUsers having the sam... | python | def _users_watching_by_filter(self, object_id=None, exclude=None,
**filters):
"""Return an iterable of (``User``/:class:`~tidings.models.EmailUser`,
[:class:`~tidings.models.Watch` objects]) tuples watching the event.
Of multiple Users/EmailUsers having the sam... | Return an iterable of (``User``/:class:`~tidings.models.EmailUser`,
[:class:`~tidings.models.Watch` objects]) tuples watching the event.
Of multiple Users/EmailUsers having the same email address, only one is
returned. Users are favored over EmailUsers so we are sure to be able
to, for ... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L157-L283 |
mozilla/django-tidings | tidings/events.py | Event._watches_belonging_to_user | def _watches_belonging_to_user(cls, user_or_email, object_id=None,
**filters):
"""Return a QuerySet of watches having the given user or email, having
(only) the given filters, and having the event_type and content_type
attrs of the class.
Matched Watch... | python | def _watches_belonging_to_user(cls, user_or_email, object_id=None,
**filters):
"""Return a QuerySet of watches having the given user or email, having
(only) the given filters, and having the event_type and content_type
attrs of the class.
Matched Watch... | Return a QuerySet of watches having the given user or email, having
(only) the given filters, and having the event_type and content_type
attrs of the class.
Matched Watches may be either confirmed and unconfirmed. They may
include duplicates if the get-then-create race condition in
... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L286-L335 |
mozilla/django-tidings | tidings/events.py | Event.is_notifying | def is_notifying(cls, user_or_email_, object_id=None, **filters):
"""Return whether the user/email is watching this event (either
active or inactive watches), conditional on meeting the criteria in
``filters``.
Count only watches that match the given filters exactly--not ones which
... | python | def is_notifying(cls, user_or_email_, object_id=None, **filters):
"""Return whether the user/email is watching this event (either
active or inactive watches), conditional on meeting the criteria in
``filters``.
Count only watches that match the given filters exactly--not ones which
... | Return whether the user/email is watching this event (either
active or inactive watches), conditional on meeting the criteria in
``filters``.
Count only watches that match the given filters exactly--not ones which
match merely a superset of them. This lets callers distinguish between
... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L339-L361 |
mozilla/django-tidings | tidings/events.py | Event.notify | def notify(cls, user_or_email_, object_id=None, **filters):
"""Start notifying the given user or email address when this event
occurs and meets the criteria given in ``filters``.
Return the created (or the existing matching) Watch so you can call
:meth:`~tidings.models.Watch.activate()`... | python | def notify(cls, user_or_email_, object_id=None, **filters):
"""Start notifying the given user or email address when this event
occurs and meets the criteria given in ``filters``.
Return the created (or the existing matching) Watch so you can call
:meth:`~tidings.models.Watch.activate()`... | Start notifying the given user or email address when this event
occurs and meets the criteria given in ``filters``.
Return the created (or the existing matching) Watch so you can call
:meth:`~tidings.models.Watch.activate()` on it if you're so inclined.
Implementations in subclasses ma... | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L364-L427 |
mozilla/django-tidings | tidings/events.py | InstanceEvent.notify | def notify(cls, user_or_email, instance):
"""Create, save, and return a watch which fires when something
happens to ``instance``."""
return super(InstanceEvent, cls).notify(user_or_email,
object_id=instance.pk) | python | def notify(cls, user_or_email, instance):
"""Create, save, and return a watch which fires when something
happens to ``instance``."""
return super(InstanceEvent, cls).notify(user_or_email,
object_id=instance.pk) | Create, save, and return a watch which fires when something
happens to ``instance``. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L583-L587 |
mozilla/django-tidings | tidings/events.py | InstanceEvent.stop_notifying | def stop_notifying(cls, user_or_email, instance):
"""Delete the watch created by notify."""
super(InstanceEvent, cls).stop_notifying(user_or_email,
object_id=instance.pk) | python | def stop_notifying(cls, user_or_email, instance):
"""Delete the watch created by notify."""
super(InstanceEvent, cls).stop_notifying(user_or_email,
object_id=instance.pk) | Delete the watch created by notify. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L590-L593 |
mozilla/django-tidings | tidings/events.py | InstanceEvent.is_notifying | def is_notifying(cls, user_or_email, instance):
"""Check if the watch created by notify exists."""
return super(InstanceEvent, cls).is_notifying(user_or_email,
object_id=instance.pk) | python | def is_notifying(cls, user_or_email, instance):
"""Check if the watch created by notify exists."""
return super(InstanceEvent, cls).is_notifying(user_or_email,
object_id=instance.pk) | Check if the watch created by notify exists. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L596-L599 |
mozilla/django-tidings | tidings/events.py | InstanceEvent._users_watching | def _users_watching(self, **kwargs):
"""Return users watching this instance."""
return self._users_watching_by_filter(object_id=self.instance.pk,
**kwargs) | python | def _users_watching(self, **kwargs):
"""Return users watching this instance."""
return self._users_watching_by_filter(object_id=self.instance.pk,
**kwargs) | Return users watching this instance. | https://github.com/mozilla/django-tidings/blob/b2895b3cdec6aae18315afcceb92bb16317f0f96/tidings/events.py#L601-L604 |
Zemanta/py-secretcrypt | secretcrypt/__init__.py | StrictSecret.decrypt | def decrypt(self):
"""Decrypt decrypts the secret and returns the plaintext.
Calling decrypt() may incur side effects such as a call to a remote service for decryption.
"""
if not self._crypter:
return b''
try:
plaintext = self._crypter.decrypt(self._ciph... | python | def decrypt(self):
"""Decrypt decrypts the secret and returns the plaintext.
Calling decrypt() may incur side effects such as a call to a remote service for decryption.
"""
if not self._crypter:
return b''
try:
plaintext = self._crypter.decrypt(self._ciph... | Decrypt decrypts the secret and returns the plaintext.
Calling decrypt() may incur side effects such as a call to a remote service for decryption. | https://github.com/Zemanta/py-secretcrypt/blob/9e36efd13997248d01e17d2b10c4955e3a00a5f7/secretcrypt/__init__.py#L55-L71 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/aes.py | AES_GCMEncrypter.encrypt | def encrypt(self, msg, iv='', auth_data=None):
"""
Encrypts and authenticates the data provided as well as authenticating
the associated_data.
:param msg: The message to be encrypted
:param iv: MUST be present, at least 96-bit long
:param auth_data: Associated data
... | python | def encrypt(self, msg, iv='', auth_data=None):
"""
Encrypts and authenticates the data provided as well as authenticating
the associated_data.
:param msg: The message to be encrypted
:param iv: MUST be present, at least 96-bit long
:param auth_data: Associated data
... | Encrypts and authenticates the data provided as well as authenticating
the associated_data.
:param msg: The message to be encrypted
:param iv: MUST be present, at least 96-bit long
:param auth_data: Associated data
:return: The cipher text bytes with the 16 byte tag appended. | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/aes.py#L106-L119 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/aes.py | AES_GCMEncrypter.decrypt | def decrypt(self, cipher_text, iv='', auth_data=None, tag=b''):
"""
Decrypts the data and authenticates the associated_data (if provided).
:param cipher_text: The data to decrypt including tag
:param iv: Initialization Vector
:param auth_data: Associated data
:param tag:... | python | def decrypt(self, cipher_text, iv='', auth_data=None, tag=b''):
"""
Decrypts the data and authenticates the associated_data (if provided).
:param cipher_text: The data to decrypt including tag
:param iv: Initialization Vector
:param auth_data: Associated data
:param tag:... | Decrypts the data and authenticates the associated_data (if provided).
:param cipher_text: The data to decrypt including tag
:param iv: Initialization Vector
:param auth_data: Associated data
:param tag: Authentication tag
:return: The original plaintext | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/aes.py#L121-L134 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/jwekey.py | JWEKey.enc_setup | def enc_setup(self, enc_alg, msg, auth_data=b'', key=None, iv=""):
""" Encrypt JWE content.
:param enc_alg: The JWE "enc" value specifying the encryption algorithm
:param msg: The plain text message
:param auth_data: Additional authenticated data
:param key: Key (CEK)
:r... | python | def enc_setup(self, enc_alg, msg, auth_data=b'', key=None, iv=""):
""" Encrypt JWE content.
:param enc_alg: The JWE "enc" value specifying the encryption algorithm
:param msg: The plain text message
:param auth_data: Additional authenticated data
:param key: Key (CEK)
:r... | Encrypt JWE content.
:param enc_alg: The JWE "enc" value specifying the encryption algorithm
:param msg: The plain text message
:param auth_data: Additional authenticated data
:param key: Key (CEK)
:return: Tuple (ciphertext, tag), both as bytes | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwekey.py#L42-L63 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/jwekey.py | JWEKey._decrypt | def _decrypt(enc, key, ctxt, iv, tag, auth_data=b''):
""" Decrypt JWE content.
:param enc: The JWE "enc" value specifying the encryption algorithm
:param key: Key (CEK)
:param iv : Initialization vector
:param auth_data: Additional authenticated data (AAD)
:param ctxt : ... | python | def _decrypt(enc, key, ctxt, iv, tag, auth_data=b''):
""" Decrypt JWE content.
:param enc: The JWE "enc" value specifying the encryption algorithm
:param key: Key (CEK)
:param iv : Initialization vector
:param auth_data: Additional authenticated data (AAD)
:param ctxt : ... | Decrypt JWE content.
:param enc: The JWE "enc" value specifying the encryption algorithm
:param key: Key (CEK)
:param iv : Initialization vector
:param auth_data: Additional authenticated data (AAD)
:param ctxt : Ciphertext
:param tag: Authentication tag
:return:... | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwekey.py#L66-L87 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/pss.py | PSSSigner.sign | def sign(self, msg, key):
"""
Create a signature over a message
:param msg: The message
:param key: The key
:return: A signature
"""
hasher = hashes.Hash(self.hash_algorithm(), backend=default_backend())
hasher.update(msg)
digest = hasher.finalize... | python | def sign(self, msg, key):
"""
Create a signature over a message
:param msg: The message
:param key: The key
:return: A signature
"""
hasher = hashes.Hash(self.hash_algorithm(), backend=default_backend())
hasher.update(msg)
digest = hasher.finalize... | Create a signature over a message
:param msg: The message
:param key: The key
:return: A signature | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/pss.py#L28-L45 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jws/pss.py | PSSSigner.verify | def verify(self, msg, signature, key):
"""
Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True
... | python | def verify(self, msg, signature, key):
"""
Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True
... | Verify a message signature
:param msg: The message
:param sig: A signature
:param key: A ec.EllipticCurvePublicKey to use for the verification.
:raises: BadSignature if the signature can't be verified.
:return: True | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jws/pss.py#L47-L65 |
openid/JWTConnect-Python-CryptoJWT | src/cryptojwt/jwe/jwe_hmac.py | JWE_SYM.encrypt | def encrypt(self, key, iv="", cek="", **kwargs):
"""
Produces a JWE as defined in RFC7516 using symmetric keys
:param key: Shared symmetric key
:param iv: Initialization vector
:param cek: Content master key
:param kwargs: Extra keyword arguments, just ignore for now.
... | python | def encrypt(self, key, iv="", cek="", **kwargs):
"""
Produces a JWE as defined in RFC7516 using symmetric keys
:param key: Shared symmetric key
:param iv: Initialization vector
:param cek: Content master key
:param kwargs: Extra keyword arguments, just ignore for now.
... | Produces a JWE as defined in RFC7516 using symmetric keys
:param key: Shared symmetric key
:param iv: Initialization vector
:param cek: Content master key
:param kwargs: Extra keyword arguments, just ignore for now.
:return: | https://github.com/openid/JWTConnect-Python-CryptoJWT/blob/8863cfbfe77ca885084870b234a66b55bd52930c/src/cryptojwt/jwe/jwe_hmac.py#L25-L66 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.