Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-13 Thread Sebastian Berg
On Mon, 2012-11-12 at 22:44 -0500, Alan G Isaac wrote: On 11/12/2012 8:18 PM, Sebastian Berg wrote: I have created a pull request This is still a bit different than I thought you intended. With `size=None` we don't get an element, but rather a 0d array. You are right, it should not be

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/9/2012 12:21 PM, Nathaniel Smith wrote: you might want to double-check that the np.random.choice in 1.7 actually*does* give an error if the input array is not 1-d Any idea where I can look at the code? I browsed github after failing to find a productive search string, but failed to

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Sebastian Berg
Hey, On Mon, 2012-11-12 at 08:48 -0500, Alan G Isaac wrote: On 11/9/2012 12:21 PM, Nathaniel Smith wrote: you might want to double-check that the np.random.choice in 1.7 actually*does* give an error if the input array is not 1-d Any idea where I can look at the code? I browsed

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Nathaniel Smith
On Mon, Nov 12, 2012 at 2:48 PM, Alan G Isaac alan.is...@gmail.com wrote: On 11/9/2012 12:21 PM, Nathaniel Smith wrote: you might want to double-check that the np.random.choice in 1.7 actually*does* give an error if the input array is not 1-d Any idea where I can look at the code? I

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/12/2012 8:59 AM, Sebastian Berg wrote: https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/mtrand.pyx#L919 Sounds like it should be pretty simple to add axis=None which would change the current behavior very little, it would stop give an error anymore for none 1-d arrays

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Nathaniel Smith
On Mon, Nov 12, 2012 at 3:50 PM, Alan G Isaac alan.is...@gmail.com wrote: On 11/12/2012 8:59 AM, Sebastian Berg wrote: https://github.com/numpy/numpy/blob/master/numpy/random/mtrand/mtrand.pyx#L919 Sounds like it should be pretty simple to add axis=None which would change the current behavior

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/12/2012 10:00 AM, Nathaniel Smith wrote: I don't really have an opinion on whether those things should be supported, or what the right API should be; I haven't really thought about it. Maybe others on the list have opinions. I was just saying that we have plenty of time to decide about

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
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

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Nathaniel Smith
On Mon, Nov 12, 2012 at 5:31 PM, Alan G Isaac alan.is...@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

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Sebastian Berg
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.is...@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

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/12/2012 12:16 PM, Sebastian Berg wrote: So instead of taking a sequence of length 1, take an element as default. Sebastien has proposed that np.random.choice return a single *element* by default, not a 1d array of length 1. He proposes to associate this with a default value of

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Nathaniel Smith
On Mon, Nov 12, 2012 at 11:34 PM, Alan G Isaac alan.is...@gmail.com wrote: On 11/12/2012 12:16 PM, Sebastian Berg wrote: So instead of taking a sequence of length 1, take an element as default. Sebastien has proposed that np.random.choice return a single *element* by default, not a 1d array

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/12/2012 5:46 PM, Nathaniel Smith wrote: Want to make a pull request? Well, I'd be happy to help Sebastien to change the code, but I'm not a git user. And I'd have some questions. E.g., with `size=None`, couldn't we just call Python's random.choice? And for sampling without replacement,

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Sebastian Berg
On Mon, 2012-11-12 at 18:36 -0500, Alan G Isaac wrote: On 11/12/2012 5:46 PM, Nathaniel Smith wrote: Want to make a pull request? Well, I'd be happy to help Sebastien to change the code, but I'm not a git user. I have created a pull request, but tests are still needed... If you like it

Re: [Numpy-discussion] fix random.choice for 1.7?

2012-11-12 Thread Alan G Isaac
On 11/12/2012 8:18 PM, Sebastian Berg wrote: I have created a pull request This is still a bit different than I thought you intended. With `size=None` we don't get an element, but rather a 0d array. I thought the idea was to return an element in this case? Alan