meshed.scrap.gk_with_networkx#
seriously modified version of yahoo/graphkit
Classes
|
This wraps any data that is consumed or produced by a Operation. |
|
|
|
This is an abstract class representing a data transformation. |
Input values in |
- class meshed.scrap.gk_with_networkx.Data(**kwargs)[source]#
Bases:
objectThis 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.Operation(name='None', needs=None, provides=None, params=<factory>)[source]#
Bases:
objectThis is an abstract class representing a data transformation. To use this, please inherit from this class and customize the
.computemethod 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
.paramsattribute of your object.- NOTE:
It’s important that any values stored in this argument must be pickelable.
- class meshed.scrap.gk_with_networkx.optional[source]#
Bases:
strInput values in
needsmay be designated as optional using this modifier. If this modifier is applied to an input value, that value will be input to theoperationif it is available. The function underlying theoperationshould have a parameter with the same name as the input value inneeds, 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