11# -*- coding: utf-8 -*-
22
3- """This module provides a generalized function as an interface to interact with the different diffusion methods offered
4- in this diffuPy package.
5- """
3+ """This module provides a generalized function as an interface to interact with the different diffusion methods."""
64
75import copy
86import logging
@@ -28,8 +26,7 @@ def diffuse(
2826 graph : nx .Graph = None ,
2927 ** kwargs
3028) -> Matrix :
31- """Manage the treatment of the different score diffusion methods applied of/from an path set of labels/scores
32- of/on a certain network (as a graph format or a graph kernel matrix stemming from a graph).
29+ """Run diffusion on a network given an input and a diffusion method.
3330
3431 Diffusion methods procedures provided in this package differ on:
3532 (a) How to distinguish positives, negatives and unlabelled examples.
@@ -54,9 +51,9 @@ def diffuse(
5451 nodes introduce null diffusion {y_raw[j] = 0}.
5552 [Vandin, 2011]. They are computed as:
5653
57- f_{raw} = K · y_{raw}
54+ f_{raw} = k · y_{raw}
5855
59- where K is a graph kernel, see kernels.py.
56+ where k is a graph kernel, see kernels.py.
6057 These scores treat negative and unlabelled nodes equivalently.
6158
6259 {ml}: same as raw, but negative nodes introduce a negative unit of flow.
@@ -119,10 +116,10 @@ def diffuse(
119116 Possible values ["raw", "ml", "gm", "ber_s", "ber_p", "mc", "z"]
120117 :param graph: A network as a graph. It could be optional if a Kernel is provided
121118 :param kwargs: Optional arguments:
122- - K : a kernel [matrix] steaming from a graph, thus sparing the graph transformation process
119+ - k : a kernel [matrix] steaming from a graph, thus sparing the graph transformation process
123120 - Other arguments which would differ depending on the chosen method
124121 :return: The diffused scores within the matrix transformation of the network, with the diffusion operation
125- [K x input_vector] performed
122+ [k x input_vector] performed
126123
127124 """
128125
@@ -135,8 +132,8 @@ def diffuse(
135132 if graph :
136133 format_network = "graph"
137134 else :
138- if "K " not in kwargs :
139- raise ValueError ("Neither a graph 'graph' or a kernel 'K ' has been provided." )
135+ if "k " not in kwargs :
136+ raise ValueError ("Neither a graph 'graph' or a kernel 'k ' has been provided." )
140137 format_network = "kernel"
141138
142139 if method == "raw" :
@@ -164,7 +161,7 @@ def diffuse(
164161 if format_network == "graph" :
165162 names_ordered = get_label_list_graph (graph , 'name' )
166163 elif format_network == "kernel" :
167- names_ordered = kwargs ['K ' ].rows_labels
164+ names_ordered = kwargs ['k ' ].rows_labels
168165
169166 # If the graph is defined
170167 ids_nobkgd = set (names_ordered ) - set (scores .rows_labels )
0 commit comments