asmatrix and asarray exception

Travis Oliphant oliphant at ee.byu.edu
Wed Oct 11 11:46:16 CDT 2006


Keith Goodman wrote:

>On 10/11/06, Keith Goodman <kwgoodman at gmail.com> wrote:
>  
>
>>This works:
>>
>>    
>>
>>>>M.asmatrix(['a', 'b', None])
>>>>        
>>>>
>>matrix([[a, b, None]], dtype=object)
>>
>>But this doesn't:
>>
>>    
>>
>>>>M.asmatrix(['a', 'b', None, 'c'])
>>>>        
>>>>
>>TypeError: expected a readable buffer object
>>
>>    
>>
>>>>M.__version__
>>>>        
>>>>
>>'1.0rc1'
>>
>>It also doesn't work for asarray and for tuples.
>>
>>    
>>
>
>  
>
It is pretty fragile to rely on NumPy's "detection" of object arrays.  
The problem is that with the introduction of string, unicode, and record 
array styles, what is supposed to be an object array is harder to detect. 

The type-error propagates up from trying to create a record-array 
(apparently that's what was detected).  You can only create record-array 
items from tuples or objects exposing the buffer interface. 

It's interesting that the detection algorithm gets thrown off by the 
addition of an other element.  There may be an easy fix there.

-Travis


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642




More information about the Numpy-discussion mailing list