meshed.scrap.gk_with_networkx#

seriously modified version of yahoo/graphkit

Classes

Data(**kwargs)

This wraps any data that is consumed or produced by a Operation.

NetworkOperation(**kwargs)

Operation([name, needs, provides, params])

This is an abstract class representing a data transformation.

optional

Input values in needs may be designated as optional using this modifier.

class meshed.scrap.gk_with_networkx.Data(**kwargs)[source]#

Bases: object

This wraps any data that is consumed or produced by a Operation. This data should also know how to serialize itself appropriately. This class an “abstract” class that should be extended by any class working with data in the HiC framework.

class meshed.scrap.gk_with_networkx.NetworkOperation(**kwargs)[source]#

Bases: Operation

set_execution_method(method)[source]#

Determine how the network will be executed.

Parameters:

method – If “parallel”, execute graph operations concurrently using a threadpool.

class meshed.scrap.gk_with_networkx.Operation(name='None', needs=None, provides=None, params=<factory>)[source]#

Bases: object

This is an abstract class representing a data transformation. To use this, please inherit from this class and customize the .compute method to your specific application.

Names may be given to this layer and its inputs and outputs. This is important when connecting layers and data in a Network object, as the names are used to construct the graph.

Parameters:
  • name (str) – The name the operation (e.g. conv1, conv2, etc..)

  • needs (list) – Names of input data objects this layer requires.

  • provides (list) – Names of output data objects this provides.

  • params (dict) –

    A dict of key/value pairs representing parameters associated with your operation. These values will be accessible using the .params attribute of your object.

    NOTE:

    It’s important that any values stored in this argument must be pickelable.

compute(inputs)[source]#

This method must be implemented to perform this layer’s feed-forward computation on a given set of inputs.

Parameters:

inputs (list) – A list of Data objects on which to run the layer’s feed-forward computation.

Returns list:

Should return a list of Data objects representing the results of running the feed-forward computation on inputs.

class meshed.scrap.gk_with_networkx.optional[source]#

Bases: str

Input values in needs may be designated as optional using this modifier. If this modifier is applied to an input value, that value will be input to the operation if it is available. The function underlying the operation should have a parameter with the same name as the input value in needs, and the input value will be passed as a keyword argument if it is available.

Here is an example of an operation that uses an optional argument:

from graphkit import operation, compose
from graphkit.modifiers import optional

# Function that adds either two or three numbers.
def myadd(a, b, c=0):
    return a + b + c

# Designate c as an optional argument.
graph = compose('mygraph')(
    operator(name='myadd', needs=['a', 'b', optional('c')], provides='sum')(myadd)
)

# The graph works with and without 'c' provided as input.
assert graph({'a': 5, 'b': 2, 'c': 4})['sum'] == 11
assert graph({'a': 5, 'b': 2})['sum'] == 7