[Numpy-discussion] making "low" optional in numpy.randint

josef.pktd at gmail.com josef.pktd at gmail.com
Wed Feb 17 21:24:41 EST 2016


On Wed, Feb 17, 2016 at 7:17 PM, Juan Nunez-Iglesias <jni.soma at gmail.com>
wrote:

> Ah! Touché! =) My last and admittedly weak defense is that I've been
> writing numpy since before 1.7. =)
>
> On Thu, Feb 18, 2016 at 11:08 AM, Alan Isaac <alan.isaac at gmail.com> wrote:
>
>> On 2/17/2016 7:01 PM, Juan Nunez-Iglesias wrote:
>>
>>> Notice the limitation "1D array-like".
>>>
>>
>>
>>
>> http://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.random.choice.html
>> "If an int, the random sample is generated as if a was np.arange(n)"
>>
>
(un)related aside:
my R doc quote about "may lead to undesired behavior" refers to this,
IIRC, R's `sample` was the inspiration for this function

but numpy distinguishes scalar from one element (1D) arrays

>>> for i in range(3, 10): np.random.choice(np.arange(10)[i:])

Josef



>
>> hth,
>>
>> Alan Isaac
>>
>> _______________________________________________
>> NumPy-Discussion mailing list
>> NumPy-Discussion at scipy.org
>> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>>
>
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> https://mail.scipy.org/mailman/listinfo/numpy-discussion
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20160217/6cb17251/attachment.html>


More information about the NumPy-Discussion mailing list