error using all()/numpy [TypeError: cannot perform reduce with flexible type]
I V
ivlenin at gmail.com
Fri May 23 04:27:27 EDT 2008
On Fri, 23 May 2008 00:12:35 -0700, Marc Oldenhof wrote:
> It seems that Python calls numpy's "all" instead of the standard one, is
> that right? If so, how can I call the standard "all" after the numpy
> import? ["import numpy" is not a desirable option, I use a lot of math
> in my progs]
I think the ideal solution is to try and persuade yourself that typing
"numpy." in front of some functions now and then is not that big a price
to pay to avoid name collisions; using an editor with code completion
would probably help in that task.
You could also try:
import numpy as n
which reduces the typing a bit and limits you to one possible name
collision, or
from numpy import array, gradient #and whatever else you need
or
import numpy
array = numpy.array
gradient = numpy.gradient # Then you can access the names you use a lot
# directly, while accessing stuff you use less
# frequently via numpy.whatever
in which case you'll know exactly which names you're overwriting. Peter's
solution, of explicitly deleting some names that you've imported, strikes
me as less good, because you might find the same problem recurs later, if
the numpy developers add new names to the module.
More information about the Python-list
mailing list