[Numpy-discussion] Changes in PyArray_FromAny between 1.5.x and 1.6.x

2012-05-28 Thread Mike Hansen
Hello, In trying to upgrade NumPy within Sage, we notices some differences in behavior between 1.5 and 1.6. In particular, in 1.5, we have sage: f = 0.5 sage: f.__array_interface__ {'typestr': '=f8'} sage: numpy.array(f) array(0.5) sage: numpy.array(float(f)) array(0.5) In 1.6, we get the

Re: [Numpy-discussion] [enhancement] sum_angle() and sum_polar()

2012-05-28 Thread Ralf Gommers
On Mon, May 28, 2012 at 7:58 PM, Travis Oliphant tra...@continuum.iowrote: I didn't see anyone respond to this, but looking over his simple and elegant solution it seems like a useful addition to the 2-d functions available in NumPy as it works with any 2-d array (image or matrix) and does a

Re: [Numpy-discussion] [enhancement] sum_angle() and sum_polar()

2012-05-28 Thread Travis Oliphant
On May 28, 2012, at 1:02 PM, Ralf Gommers wrote: On Mon, May 28, 2012 at 7:58 PM, Travis Oliphant tra...@continuum.io wrote: I didn't see anyone respond to this, but looking over his simple and elegant solution it seems like a useful addition to the 2-d functions available in NumPy as

[Numpy-discussion] 1.6.2 no more unique for rows

2012-05-28 Thread josef . pktd
https://github.com/numpy/numpy/commit/74b9f5eef8fac643bf9012dbb2ac6b4b19f46892 broke return_inverse for structured arrays, because of the use of mergesort I'm using structured dtypes to get uniques and return_inverse by rows groups = np.random.randint(0,4,size=(10,2)) groups_ =

[Numpy-discussion] numpy.random.gamma returns 0 for small shape parameters

2012-05-28 Thread Uri Laserson
I am trying to sample from a Dirichlet distribution, where some of the shape parameters are very small. To do so, the algorithm samples each component individually from a Gamma(k,1) distribution where k is the shape parameter for that component of the Dirichlet. In principle, this should always

Re: [Numpy-discussion] numpy.random.gamma returns 0 for small shape parameters

2012-05-28 Thread Val Kalatsky
You'll need some patience to get non-zeros, especially for k=1e-5 In [84]: np.sum(np.random.gamma(1e-5,size=100)!=0.0) Out[84]: 7259 that's less than 1%. For k=1e-4 it's ~7% Val On Mon, May 28, 2012 at 10:33 PM, Uri Laserson uri.laser...@gmail.comwrote: I am trying to sample from a