[SciPy-dev] Object array comparisons, Monte Carlo package

Travis Oliphant oliphant.travis at ieee.org
Mon Jan 16 16:06:49 CST 2006


Ed Schofield wrote:

>Hi Travis,
>
>I'm finding object arrays useful with the new syntax.  +1 from me :)
>
>I have a feature request.  Object arrays currently don't support rich
>(elementwise) comparisons:
>  
>
Well, they actually do.  But, there is some code left-over from Numeric 
that is not working the same way now that there are string arrays 
available.

>  
>
>>>>d = {'a':10,'b':20,'c':30}
>>>>s = montecarlo.dictsampler(d)
>>>>s.sample(10000)
>>>>        
>>>>
>array([c, c, b, ..., c, c, b], dtype=object)
>  
>
>>>>s == 'b'
>>>>        
>>>>
>False
>
>Could we enable this again?  
>
I never disabled it.   Consider s == array('b', object)

The problem is that 'b' is being interpreted as a string array and that 
is returning False (probably due to special code in the rich_compare 
function.

I need to re-look at the code in the Py_EQ section of array_richcompare 
to make sure it is not special-casing inappropriately...

-Travis






More information about the Scipy-dev mailing list