-
Notifications
You must be signed in to change notification settings - Fork 6
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
Error in lines 970-971 #2
Comments
Thanks for the report! Can you make a PR to fix this error? |
The issue appears to be a line 961:
``` py
B = np.reshape(B, (n, int(len(B)/n)), order='F')
```
I created a Watts-Strogatz graph as follows:
```
import networkx as nx
n = 10
k = 4
p = .01
G = nx.watts_strogatz_graph(n,k,p)
A = nx.to_numpy_matrix(G)
```
The function call
``` py
SWP, delta_C, delta_L=small_world_propensity(A, method='O')
```
produced the error message
"ValueError: cannot reshape array of size 119 into shape (10,11)"
In this case, n=10, B has length 119, and int(len(B)/n)=11 so
```
B = np.reshape(B, (n, int(len(B)/n)), order='F')
```
throws the error.
…On Mon, Dec 30, 2019 at 5:27 PM Titipat Achakulvisut < ***@***.***> wrote:
Thanks for the report! Can you make a PR to fix this error?
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#2?email_source=notifications&email_token=AJWRNJMRDHY7VBJ5FMQWCRDQ3JYTNA5CNFSM4KBQTR32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH3K5RQ#issuecomment-569814726>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJWRNJJ3TXHHWLLJWUDKJATQ3JYTNANCNFSM4KBQTR3Q>
.
--
Professor of Mathematics, Grand Valley State University
President, Pi Mu Epsilon National Honorary Mathematics Society, Inc.
Department of Mathematics (MAK C-2-408)
Grand Valley State University
1 Campus Dr.
Allendale, MI 49401
[email protected]
616.331.2443
616.331.3120 (fax)
|
@fishbacp Thanks a ton! I did a quick fix to the code and it should work now. I'm not sure if the math is completely right tho. Feel free to take a look! import networkx as nx
import numpy as np
from nct import small_world_propensity, regular_matrix_generator
n = 10
k = 4
p = .01
G = nx.watts_strogatz_graph(n,k,p)
G = np.array(nx.to_numpy_matrix(G)) # has to be array input instead of matrix
SWP, delta_C, delta_L = small_world_propensity(G, method='O')
print(SWP, delta_C, delta_L)
>> (0.29237040411638093, 1.0, 0.03846153846153852) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I was not able to get this file to work unless I changed lines 970-971 from
to
The text was updated successfully, but these errors were encountered: