James Battat wrote: > Hi, > > numpy.where() returns different things on my windowsXP machine than on my > collaborator's mac osx machine. > > For example, consider: > >>> import numpy > >>> a = numpy.array([1,2,3,4]) > >>> b = numpy.where( a > 2 ) > > On WindowsXP (python 2.4.2, numpy 1.0.1), I get: > >>> print b > (array([2, 3]), ) > >>> print b[0] > [2 3] > > While in OSX (python 2.4.3, numpy 0.9.6), he gets: > >>> print b > [2, 3] > >>> print b[0] > 2 > > This matters because we use where() to get indices to loop over. On the > mac you can then loop through the b array: > > for item in b: > if b > 5: > print 'hi' > > But this approach fails on a pc because: > if b > 5: > >>> ValueError: The truth value of an array with more than one element > >>> is ambiguous. Use a.any() or a.all() > > > I'd like to avoid having to do: > if mac: > b = numpy.where( a > 5) > if pc: > b = numpy.where( a > 5)[0] > > Has anybody else notice dealt with this? Is this a mac/pc difference or a > numpy 1.01 vs. numpy 0.9.6 difference?
The latter. Before the 1.0 release, we tried to make it clear that we were still experimenting with the APIs and that they might change up until 1.0 got released. -- Robert Kern "I have come to believe that the whole world is an enigma, a harmless enigma that is made terrible by our own mad attempt to interpret it as though it had an underlying truth." -- Umberto Eco _______________________________________________ Numpy-discussion mailing list [email protected] http://projects.scipy.org/mailman/listinfo/numpy-discussion
