pik-copan / pyunicorn

Unified Complex Network and Recurrence Analysis Toolbox
http://pik-potsdam.de/~donges/pyunicorn/
Other
195 stars 86 forks source link

Repeatedly calling core.network.Network.interregional_betweenness gives wrong results #124

Closed jkroenke closed 4 years ago

jkroenke commented 5 years ago

When a network is initialized and interregional_betweenness is called

net = Network.SmallTestNetwork()
net.interregional_betweenness(sources=[2], targets=[3, 5])

the result

array([1., 1., 0., 0., 1., 0.])

is correct for the first calculation. However, if interregional_betweenness is called a second time with different source and/or target nodes

net.interregional_betweenness(sources=range(0, 6), targets=range(0, 6))

the result is still the same. For a newly initialized network it is different:

array([9., 3., 0., 2., 6., 0.])
jkroenke commented 5 years ago

The problem occurs in core.network.Network.nsi_interregional_betweenness, too. As both call nsi_betweenness, I suspect the problem comes from there.

ntfrgl commented 5 years ago

@cached_const is wrong here. It should be either deleted or replaced with @cached_var. In the latter case, the decorator would need to be patched to handle sources=..., targets=... instead of key=....

Or, probably rather use: https://joblib.readthedocs.io/en/latest/generated/joblib.Memory.html