You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "mtrand.pyx", line 1397, in mtrand.RandomState.choice (numpy/random/mtrand/mtrand.c:15499)
ValueError: a must be non-empty
This error makes sense when size>0, but when size=0, random.choice could simply return []. This would be useful when the a and size parameters are variable. Right now this situation requires an additional check:
Would it be a good idea to simply return an empty array when size=0? This is my first issue so I hope this is the right way to address this.
I created a simple patch that implements this: 57ab0728d4cf73c1f4b3af2450fe603bf8670b75
I'm using Python 3.5.2 with numpy 1.11.2.
Edit: My implementation returns an empty slice from the original array. My thinking was that this would assign the correct base to the resulting array, but on second thought this is not what happens with random.choice normally, so I think returning np.array([]) would be better.
The text was updated successfully, but these errors were encountered:
Uh oh!
There was an error while loading. Please reload this page.
This piece of code:
Generates this error:
This error makes sense when
size>0
, but whensize=0
,random.choice
could simply return[]
. This would be useful when thea
andsize
parameters are variable. Right now this situation requires an additional check:Would it be a good idea to simply return an empty array when
size=0
? This is my first issue so I hope this is the right way to address this.I created a simple patch that implements this: 57ab0728d4cf73c1f4b3af2450fe603bf8670b75
I'm using Python 3.5.2 with numpy 1.11.2.
Edit: My implementation returns an empty slice from the original array. My thinking was that this would assign the correct
base
to the resulting array, but on second thought this is not what happens withrandom.choice
normally, so I think returningnp.array([])
would be better.The text was updated successfully, but these errors were encountered: