mrkwjc / ffnet

Feed-forward neural network for python
GNU Lesser General Public License v3.0
12 stars 7 forks source link

random is no longer part of scipy #9

Closed mathomp4 closed 1 year ago

mathomp4 commented 1 year ago

scipy no longer has a random import. You need to use numpy.

Note that despite what this says in the scipy code:

 _msg = ('scipy.{0} is deprecated and will be removed in SciPy 2.0.0, '
     |   'use numpy.random.{0} instead')

it looks like even scipy 1.11.1 doesn't have it:

$ ipython3
Python 3.10.12 | packaged by conda-forge | (main, Jun 23 2023, 22:40:32) [GCC 12.3.0]
Type 'copyright', 'credits' or 'license' for more information
IPython 8.14.0 -- An enhanced Interactive Python. Type '?' for help.

In [1]: import scipy

In [2]: scipy.__version__
Out[2]: '1.11.1'

In [3]: from scipy import random
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
Cell In[3], line 1
----> 1 from scipy import random

ImportError: cannot import name 'random' from 'scipy' (/discover/nobackup/mathomp4/Miniconda-Test/python3/23.3.1-0_py3.10/2023-07-11/lib/python3.10/site-packages/scipy/__init__.py)
mrkwjc commented 1 year ago

Thanks for reporting! Merged.

mathomp4 commented 1 year ago

@mrkwjc Thanks. Query: Are you planning a new tag soon? I'm currently doing:

pip install git+https://github.com/GMAO-SI-Team/ffnet

in my setup and I suppose I can now move to this repo instead, but it would be nice to get a new tag of what's in master (now) as that seems to be the only thing that works for me in Python3 and with new scipy.

And I guess PyPI goes off of tags since the latest one there is 0.8.4 as it is here?

mathomp4 commented 1 year ago

Oh nuts. I now just realized I might have broken Python 2 compatibility. @mrkwjc Can you test that (I no longer use Python 2)?

If so, perhaps what needs to be done is:

from scipy import zeros, ones, optimize, sqrt, ndarray, array
try:
   from scipy import random
except ImportError:
   from numpy import random
mrkwjc commented 1 year ago

I'll do 0.8.5 tag for you on github. But ffnet needs a bit maintance now. For example setup.py became depreciated... Unfortutnately Travis CI stppped working for me and i'm going to move to Github Workflows for testing (also Python 2) and deploying.

I think numpy.random was always on place and ffnet should always import from there, so this change should not break things.

mathomp4 commented 1 year ago

Thanks, @mrkwjc

Though I have no idea how PyPI stuff works. Does this mean a GitHub Workflow deploys it there? If so...cool. I'm learning! 😄

mrkwjc commented 1 year ago

It can deploy, see for example: https://github.com/mrkwjc/einsumt/blob/master/.github/workflows/publish.yml

mathomp4 commented 1 year ago

Very cool! Thanks for pointing it out to me. I might be doing PyPI stuff soon so I'm glad to learn