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

Nathaniel Smith njs@pobox....
Mon Nov 12 08:03:56 CST 2012


On Mon, Nov 12, 2012 at 2:48 PM, Alan G Isaac <alan.isaac@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 browsed github after failing to find
> a productive search string, but failed
> to find it.

Looks like it's in numpy/random/mtrand/mtrand.pyx (cython code)

I was actually thinking you would check by just trying it, since
that's an easier and more reliable way to determine what code actually
does than reading it :-). (Or even better, writing a test?)

> Which remind me: it would be nice if the
> docs linked to the source.

True, though it's a difficult problem for code like this that goes
Cython file -> C -> .so file -> Python. I'm not sure Cython actually
preserves any metadata that would let us look at the np.random.choice
object in the interpreter and map that back to a line of a source
file.

-n


More information about the NumPy-Discussion mailing list