hetio / xswap

Python library (C++ backend) for degree-preserving network randomization
https://hetio.github.io/xswap/
BSD 2-Clause "Simplified" License
12 stars 3 forks source link

`import xswap` requires numpy but setup.py does not include this dependency #23

Open dhimmel opened 5 years ago

dhimmel commented 5 years ago
>>> import xswap
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/dhimmel/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/__init__.py", line 1, in <module>
    from xswap import network_formats
  File "/home/dhimmel/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/network_formats.py", line 3, in <module>
    import numpy
ModuleNotFoundError: No module named 'numpy'

I think we wanted users without numpy to be able to use the package, right? So we should probably just make the numpy import lazy.

Also you may want to specify extras_require in setup.py for users who want to install the extra dependencies.

dhimmel commented 5 years ago

Similar issue with scipy:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-2-a8f39505b870> in <module>
----> 1 import xswap

~/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/__init__.py in <module>
----> 1 from xswap import network_formats
      2 from xswap import preprocessing
      3 from xswap import prior
      4 from xswap.permute import permute_edge_list
      5 

~/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/network_formats.py in <module>
      2 
      3 import numpy
----> 4 import scipy.sparse
      5 
      6 

ModuleNotFoundError: No module named 'scipy'
dhimmel commented 5 years ago

And pandas:

ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-1-a8f39505b870> in <module>
----> 1 import xswap

~/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/__init__.py in <module>
      1 from xswap import network_formats
      2 from xswap import preprocessing
----> 3 from xswap import prior
      4 from xswap.permute import permute_edge_list
      5 

~/anaconda3/envs/xswap/lib/python3.7/site-packages/xswap/prior.py in <module>
      2 
      3 import numpy
----> 4 import pandas
      5 import scipy.sparse
      6 

ModuleNotFoundError: No module named 'pandas'
dhimmel commented 5 years ago

BTW these errors are using https://github.com/hetio/xswap/releases/tag/v0.0.2 which is 6 commits behind master currently.