Utilities: utils
Topo processing
mbnet.utils.topo_to_adj(topo)
Convert a topology (.topo) file to an adjacency matrix. The topo file should be tab-seperated with source target type. Type: 1 -> Activation, 2 -> Inhibition.
Parameters:
-
topo(str) –The path to the topofile.
Returns:
-
DataFrame–The adjacency matrix. Rows: Source, Columns: Target
Source code in src/mbnet/utils.py
Boolean
mbnet.utils.B(k)
Return all Boolean vectors of length k.
Parameters:
-
k(int) –Lenght of Boolean vector. Must be a positive integer.
Returns:
-
ndarray–A 2**k by k array of integers (0 or 1) containing every binary combination of length k.
Source code in src/mbnet/utils.py
mbnet.utils.T(adjmat, states, tgt)
Applies transformation based on the topology for a given state to convert for inputs for increasing MBFs, split as inputs and outputs.
Parameters:
-
adjmat–Adjacency matrix of the network topology.
-
states–State values of the network nodes, where rows are different states and columns are the nodes.
-
tgt–Target node identifier/column name in the adjacency matrix and states DataFrame.
Returns:
-
tuple of (pd.DataFrame, pd.Series)–inpt : pd.DataFrame Transformed inputs for the target node. Only nodes with incoming edges are considered for inputs. NOT operation is done for the negative edges. oupt : pd.Series Output states for the target (tgt) node.
Source code in src/mbnet/utils.py
Monotone Boolean Functions
mbnet.utils.MBF(k)
Loads the precomputed Monotone Boolean Functions (MBFs) for k inputs.
Parameters:
-
k(int) –The number of inputs for which to load MBF data.
Returns:
-
DataFrame–DataFrame containing MBF values indexed by input combinations. Column names for the functions are included if available.
Raises:
-
FileNotFoundError–If the required input files are not found.
Source code in src/mbnet/utils.py
Counts
mbnet.utils.D(k)
Return the number of monotone Boolean functions (MBFs) on k input variables. This value is equivalent to the Dedekind numbers.
Parameters:
-
k(int) –Number of input variables. Must be a positive integer.
Returns:
-
int–Number of MBFs with k inputs.
Source code in src/mbnet/utils.py
mbnet.utils.U(k, i)
Return the number of monotone Boolean functions (MBFs) on k input variables that evaluate to 1 on inputs with exactly i ones (Hamming weight i). This value is equivalent to the size of the corresponding up-sets in the lattice of MBFs.
Parameters:
-
k(int) –Number of input variables. Must be a positive integer.
-
i(int) –Number of 1s of input vectors. Must satisfy 0 <= i <= k.
Returns:
-
int–Number of MBFs that evaluate to 1 for inputs with i 1s
Source code in src/mbnet/utils.py
mbnet.utils.L(k, i)
Return the number of monotone Boolean functions (MBFs) on k input variables that evaluate to 0 on inputs with exactly i ones (Hamming weight i). This value is equivalent to the size of the corresponding up-sets in the lattice of MBFs.
Parameters:
-
k(int) –Number of input variables. Must be a positive integer.
-
i(int) –Number of 1s of input vectors. Must satisfy 0 <= i <= k.
Returns:
-
int–Number of MBFs that evaluate to 0 for inputs with i 1s