Re: [Numpy-discussion] C-API change for 1.2

2008-08-09 Thread Jarrod Millman
On Fri, Aug 8, 2008 at 7:22 PM, Travis E. Oliphant
[EMAIL PROTECTED] wrote:
 The 1.2 version of NumPy is going to be tagged.  There is at least one
 change I'd like to add:   The hasobject member of the PyArray_Descr
 structure should be renamed to flags and converted to a 32-bit
 integer.

 What does everybody think about this change?  It should have minimal
 affect except to require a re-compile of extension modules using NumPy.
 The only people requiring code changes would be those making intimate
 use of the PyArray_Descr structure instead of using the macros.

+1
I am going to hold off on tagging 1.2.0b1 until Monday.  This way if
anyone has any objections to this change, they will have a few days to
discuss this.  If there are  no major objections by Monday, go ahead
and make the change and I will tag the beta release.

-- 
Jarrod Millman
Computational Infrastructure for Research Labs
10 Giannini Hall, UC Berkeley
phone: 510.643.4014
http://cirl.berkeley.edu/
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion


[Numpy-discussion] np.bincount() won't accept list or array from np.random.beta and acts like len

2008-08-09 Thread Michael
Hi list,

I have found np.bincount() not to behave as expected when provided with
data from np.random.beta.

It works fine with lists, but not the type returned by np.random.beta...
there seems to be a block on casting too. When it does give output on
np.array it just reports the number of items, like len()

??  

x = np.array([1,1,1,1,2,2,4,4,5,6,6,6])
print np.bincount(x)

prior = np.random.beta(2,7,1000)
a = prior.tolist()

print type(a)
print np.bincount(a)

b = [ round(i,2) for i in a ] 
print b; print type(b)
print np.bincount(b) 

#c = np.array(a)
#print np.bincount(c); print type(c)

i know its easily solved but bincount is probably faster than making a
pass over the probabilities and hashing them as strings etc

have got a class that subclasses dict and accepts np.random.beta as
'seq':
... 
for prob in seq: 
self.bincount( prob )

def bincount( self, pr, increment=1 ):
strPr = str(round(pr,self.dp))  
self[strPr] = increment + self.get( strPr, 0 )

would prefer the one-liner:

self.bincount = np.bincount(seq)

any ideas? 

thanks.

Michael Nandris

(btw apologies for the cross posting)


signature.asc
Description: This is a digitally signed message part
___
Numpy-discussion mailing list
Numpy-discussion@scipy.org
http://projects.scipy.org/mailman/listinfo/numpy-discussion