You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, when I use the generative_model() function, the following error occured. I have uploaded my test file and my running environment is python 3.8.12, numpy 1.20.3, scipy 1.6.2, bctpy 0.5.2. Please help me why this happened.
/mnt/d/software_for_wsl2/miniconda3/lib/python3.8/site-packages/bct/algorithms/generative.py:444: RuntimeWarning: divide by zero encountered in power
Fd = D ** eta
/mnt/d/software_for_wsl2/miniconda3/lib/python3.8/site-packages/bct/algorithms/generative.py:444: RuntimeWarning: divide by zero encountered in reciprocal
Fd = D ** eta
Traceback (most recent call last):
File "test.py", line 20, in <module>
test_B = bct.generative_model(A_test, D, 321, eta=[eta], gamma=[gam], model_type='euclidean', model_var='powerlaw')
File "/mnt/d/software_for_wsl2/miniconda3/lib/python3.8/site-packages/bct/algorithms/generative.py", line 528, in generative_model
B[:,:,j] = euclidean_gen(A, D, m, ep, model_var)
File "/mnt/d/software_for_wsl2/miniconda3/lib/python3.8/site-packages/bct/algorithms/generative.py", line 460, in euclidean_gen
A[u[r], v[r]] = A[v[r], u[r]] = 1
IndexError: index 2278 is out of bounds for axis 0 with size 2278
···
PS: I also read the source code of `euclidean_gen()` function in `generative_model()` function. It seems that this function would modify the value of __seed network__ `A` out of this function. but my error still occured when I add `B=A.copy()` and modify the value on B for each loop.
[test.zip](https://github.com/aestrivex/bctpy/files/7648017/test.zip)
The text was updated successfully, but these errors were encountered:
Thank you, it seems fine after I fixed it.
Generally, I find two problems:
the input seed network A would be modified *_gen, e.g. euclidean_gen(), so I add A = A.copy() at the beginning for every *_gen() function.
index error, the following is an example:
# example in "euclidean_gen"
for i in range(mseed, m):
C = np.append(0, np.cumsum(P[u, v]))
#r = np.sum(rng.random_sample()*C[-1] >= C)
r = np.sum(rng.random_sample()*C[-1] >= C) - 1 # modified by duzc
b[i] = r
P = Fd
#P[u[b[:i]], v[b[:i]]] = P[v[b[:i]], u[b[:i]]] = 0
P[u[b[:i+1]], v[b[:i+1]]] = P[v[b[:i+1]], u[b[:i+1]]] = 0 # modified by duzc
A[u[r], v[r]] = A[v[r], u[r]] = 1
Hi, when I use the
generative_model()
function, the following error occured. I have uploaded my test file and my running environment ispython 3.8.12
,numpy 1.20.3
,scipy 1.6.2
,bctpy 0.5.2
. Please help me why this happened.The text was updated successfully, but these errors were encountered: