[Numpy-discussion] fix random.choice for 1.7?
Sebastian Berg
sebastian@sipsolutions....
Mon Nov 12 11:16:11 CST 2012
On Mon, 2012-11-12 at 17:52 +0100, Nathaniel Smith wrote:
> On Mon, Nov 12, 2012 at 5:31 PM, Alan G Isaac <alan.isaac@gmail.com> wrote:
> > In a comment on the issue https://github.com/numpy/numpy/issues/2724 Sebastian notes:
> > "it could also be reasonable to have size=None as default and have it return a scalar/the given axes removed in that case. That would be a real change
> > in functionality unfortunately, but it would make sense for similarity to import random; random.choice mostly."
> >
> > If this is under serious consider, then perhaps
> > random.choice should not be in 1.7 unless a decision can
> > be quickly made about the default for `size`.
> > (Allowing an axis argument can however be postponed.)
> >
> > I am inclined to think that Sebastian's suggestion
> > is correct.
>
> For anyone else trying to follow, here's the current function:
> http://docs.scipy.org/doc/numpy-dev/reference/generated/numpy.random.choice.html
>
> I'm afraid I don't understand what Sebastian is suggesting should
> happen by default. size=None doesn't have any intuitive meaning to me,
> and I don't know what "a scalar/the given axes removed" means.
>
None is a little awkward I agree (but I don't think there is something
better), but basically what I meant is this:
>>> random.choice([1, 1])
1
>>> np.random.choice([1, 2])
array([1]) # its 1-D not 0-D.
So instead of taking a sequence of length 1, take an element as default.
> -n
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
More information about the NumPy-Discussion
mailing list