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

Can't import GraKeL due to a numpy import error #115

Open
edisnord opened this issue Oct 13, 2024 · 1 comment
Open

Can't import GraKeL due to a numpy import error #115

edisnord opened this issue Oct 13, 2024 · 1 comment

Comments

@edisnord
Copy link

edisnord commented Oct 13, 2024

Describe the bug
When trying to import GraKel, I get an error due to a numpy import which doesn't seem to be located in the same place in the package anymore. I'm using numpy version 2.1.1

To Reproduce
Write import grakel in an empty file and run as a python script.

Expected behavior
The script should run without any errors.

Stack Trace

{
	"name": "ImportError",
	"message": "cannot import name 'ComplexWarning' from 'numpy' (/home/edishasaj/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/numpy/__init__.py)",
	"stack": "---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[6], line 1
----> 1 import grakel
      3 gk_computer = grakel.GraphletSampling(k=5)

File ~/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/grakel/__init__.py:6
      2 from grakel import datasets
      4 from grakel.graph import Graph
----> 6 from grakel.graph_kernels import GraphKernel
      9 from grakel.kernels import Kernel
     11 from grakel.kernels import GraphletSampling

File ~/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/grakel/graph_kernels.py:13
     10 from sklearn.utils import check_random_state
     11 from sklearn.utils.validation import check_is_fitted
---> 13 from grakel.kernels import GraphletSampling
     14 from grakel.kernels import RandomWalk
     15 from grakel.kernels import RandomWalkLabeled

File ~/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/grakel/kernels/__init__.py:7
      4 from grakel.kernels.kernel import Kernel
      6 from grakel.kernels.graphlet_sampling import GraphletSampling
----> 7 from grakel.kernels.random_walk import RandomWalk
      8 from grakel.kernels.random_walk import RandomWalkLabeled
      9 from grakel.kernels.shortest_path import ShortestPath

File ~/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/grakel/kernels/random_walk.py:10
      6 import numpy as np
      8 from itertools import product
---> 10 from numpy import ComplexWarning
     11 from numpy.linalg import inv
     12 from numpy.linalg import eig

ImportError: cannot import name 'ComplexWarning' from 'numpy' (~/.local/share/virtualenvs/GNN/lib64/python3.12/site-packages/numpy/__init__.py)"
}
@ysig
Copy link
Owner

ysig commented Oct 24, 2024

@edisnord please suggest a fix/pull-request probably a latest version problem. I suggest doing it the following way.

if np.__version__ < 'X':
   from numpy import ComplexWarning
else:
  from ... # the updated import 

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