Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Empty adjacency matrix induces various errors #45

Closed
ntfrgl opened this issue Apr 10, 2015 · 4 comments
Closed

Empty adjacency matrix induces various errors #45

ntfrgl opened this issue Apr 10, 2015 · 4 comments

Comments

@ntfrgl
Copy link
Member

ntfrgl commented Apr 10, 2015

Empty adjacency matrix induces various errors, e.g., in computing network measures.


Originally reported by: Jonathan Donges
Originally created on: 2014-09-24

@ntfrgl ntfrgl closed this as completed Apr 10, 2015
@ntfrgl
Copy link
Member Author

ntfrgl commented Apr 10, 2015

Bug report by Marlene Kretschmer (I experienced simmilar problems several time before):

*... konstruieren ich gerade probeweise mid-latitude networks (1872 Knoten) mit der "normalen" cross correlation und verschiedenen time-lags (0, 1, 7, 14 Tage). Also in etwa so:
*

#!python

# lag 1: 

# initialize matrix
A_1 = numpy.zeros((1872, 1872))

for i in range(1872):
    for j in range(1872):
            CC = core.Data.calculate_cross_correlation(summer_anomaly[:, i], summer_anomaly[:, j], max_delay=15, gamma=0, normed=False)

            # 0.5 ist der threshold
            if numpy.fabs(CC[15]) >= 0.5: 
                A_1[i, j] = 1
            else:
                A_1[i, j] = 0

net_lag1 = core.Network(A_1)
degree_lag1 = net_lag1.get_degree()

*Für größere lags kriege ich allerdings die Fehlermeldung bei Aufruf von get_degree():

File "/iplex/01/sys/applications/pik-python/lib/python2.7/site-packages/pyunicorn/core/network.py", line 1738, in get_degree
k = self.get_outdegree()
File "/iplex/01/sys/applications/pik-python/lib/python2.7/site-packages/pyunicorn/core/network.py", line 1778, in get_outdegree
spmatrix.matrixmultiply(self.sparse_A, self._sp_ones)).
File "/iplex/01/sys/applications/pik-python/lib/python2.7/site-packages/pyunicorn/core/network.py", line 1796, in _sparse_to_column
v.put(np.array(self._get_sparse_keys(matrix))[:, 0], matrix.values())
IndexError: too many indices

Ich vermute, dass es daran liegt, dass die Adjacency Matrix dann keine Einträge ungleich Null hat? Zumindest klappt es wenn ich den threshold auf 0.1 runter setze.*


Original comment by: Jonathan Donges
Original comment on: 2014-09-24

@ntfrgl
Copy link
Member Author

ntfrgl commented Apr 10, 2015

Should be resolved by the still experimental code ported to scipy.sparse. @jdonges: minimal reproducible case for testing?


Original comment by: ntfrgl
Original comment on: 2014-09-24

@ntfrgl
Copy link
Member Author

ntfrgl commented Apr 10, 2015

Here is a minimal example:

#!python

from pyunicorn import Network

g = Network(np.zeros((2,2)))
g.get_degree()


Original comment by: Jonathan Donges
Original comment on: 2014-09-25

@ntfrgl
Copy link
Member Author

ntfrgl commented Apr 10, 2015

Commit 5a6b858 seems to do the job.


Original comment by: ntfrgl
Original comment on: 2014-10-01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant