1

c:\python38\lib\site-packages\numpy\core_asarray.py:136: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray return array(a, dtype, copy=False, order=order, subok=True)

I have gone through some questions in the stackoverflow so tried to upgrade scipy for this but it shows another error:

ERROR: tensorflow 2.2.0 has requirement scipy==1.4.1; python_version >= "3", but you'll have scipy 1.5.0 which is incompatible.

can someone tell why is this happening?

2
  • You have to tell us what you are trying to save. Also, you seem to be conflating two problems at once here: one seems to be NumPy complaining about what you're trying to save to an npy file. Another seems to be you wanting to upgrade SciPy, and having dependency problems doing so. The latter is not in the scope of SO, and may be more suited for a site like Superuser. For the former, you have to show some code. Commented Jul 1, 2020 at 14:27
  • That's a warning, not an error. It's produced by numpy version 1.19, which I think is still in dev. What exactly are you trying to do at this point? saving what? and how? Commented Jul 1, 2020 at 14:58

1 Answer 1

3

In numpy 1.19dev, trying to create an array from a ragged list of lists or array is starting to display this warning. Dev's are trying to fix a problem that's been around for a while. np.save saves arrays, so if given a list, it first turns it into an array:

In [227]: np.save('test.npy', [[1,2,3],[4,5]])                                          
/usr/local/lib/python3.6/dist-packages/numpy/core/_asarray.py:136: VisibleDeprecationWarning: Creating an ndarray from ragged nested sequences (which is a list-or-tuple of lists-or-tuples-or ndarrays with different lengths or shapes) is deprecated. If you meant to do this, you must specify 'dtype=object' when creating the ndarray
  return array(a, dtype, copy=False, order=order, subok=True)

Loading such an array also can produce an error:

In [228]: np.load('test.npy')                                                           
---------------------------------------------------------------------------    
ValueError: Object arrays cannot be loaded when allow_pickle=False

In [229]: np.load('test.npy', allow_pickle=True)                                        
Out[229]: array([list([1, 2, 3]), list([4, 5])], dtype=object)
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.