[SciPy-dev] Example of power of new data-type descriptors.
oliphant.travis at ieee.org
Sat Jan 7 21:36:04 CST 2006
Hugo Gamboa wrote:
>I was looking at these new datatype mechanisms, and was unable to make
>an array string compare.
>example: (using Travis code)
>Out: array([Bill, Fred], dtype=(string,30))
>In : a['name']=='Bill'
>In : a['name'].__eq__('Bill')
>I expected that a['name']=='Bill' would return [True, False]
Problem is nobody has implemented that yet for strings. Comparisons go
through universal functions. And there is no support for
flexible-length arrays in the universal functions (ufuncs) right now.
We could special-case the (rich) comparisons for strings and unicodes
rather easily (and I think we should), but that hasn't been done yet.
Right now, the chararray does implement equality testing (in Python so
Use a.view(numpy.chararray) to get a chararray. But, note the
chararray has not been well-tested, yet.
More information about the Scipy-dev