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

running anm_demo.py gives module 'networkx' has no attribute 'to_numpy_matrix' #160

Open
emoen opened this issue Oct 14, 2024 · 2 comments

Comments

@emoen
Copy link

emoen commented Oct 14, 2024

Running the anm_demo.py crashes. It looks like to_numpy_matrix is deprecated for to_numpy_array in networkx but the requirement.txt isnt pinning down the version - with: networkx>=2.5

The error

simulator.py", line 168, in erdos_renyi
    B_und = DAG._graph_to_adjmat(G_und)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\...\local-packages\Python312\site-packages\castle\datasets\simulator.py", line 64, in _graph_to_adjmat
    return nx.to_numpy_matrix(G)
           ^^^^^^^^^^^^^^^^^^
AttributeError: module 'networkx' has no attribute 'to_numpy_matrix'

@shaido987
Copy link
Collaborator

Hi @emoen, if you install the latest version 1.0.4rc1 of gCastle this problem should be solved. This version is still a pre-release so it seems you need to set the version explicitly if you install with pip.

pip install gcastle==1.0.4rc1

@emoen
Copy link
Author

emoen commented Oct 17, 2024

After installing:

print(castle.__version__)
>>> 1.0.4rc1
AttributeError                            Traceback (most recent call last)
Cell In[53], [line 6](vscode-notebook-cell:?execution_count=53&line=6)
      [4](vscode-notebook-cell:?execution_count=53&line=4) from castle.metrics import MetricsDAG
      [5](vscode-notebook-cell:?execution_count=53&line=5) print(castle.__version__)
----> [6](vscode-notebook-cell:?execution_count=53&line=6) X, true_dag, _ = load_dataset('IID_Test')
      [7](vscode-notebook-cell:?execution_count=53&line=7) n = CORL()
      [8](vscode-notebook-cell:?execution_count=53&line=8) n.learn(X)

...

[62](https://file+.vscode-resource.vscode-cdn.net/home/endrem/PycharmProjects/CausalityDiscoveryCrunchDAO/~/PycharmProjects/lama31/myenv/lib/python3.11/site-packages/castle/datasets/simulator.py:62) @staticmethod
     [63](https://file+.vscode-resource.vscode-cdn.net/home/endrem/PycharmProjects/CausalityDiscoveryCrunchDAO/~/PycharmProjects/lama31/myenv/lib/python3.11/site-packages/castle/datasets/simulator.py:63) def _graph_to_adjmat(G):
---> [64](https://file+.vscode-resource.vscode-cdn.net/home/endrem/PycharmProjects/CausalityDiscoveryCrunchDAO/~/PycharmProjects/lama31/myenv/lib/python3.11/site-packages/castle/datasets/simulator.py:64)     return nx.to_numpy_matrix(G)

AttributeError: module 'networkx' has no attribute 'to_numpy_matrix'

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

2 participants