[Numpy-discussion] Problem with Numeric?
Sue Giller
sag at hydrosphere.com
Thu Oct 25 09:35:09 EDT 2001
I am using Numeric 20.2.0. I have found the following
inconsistency. I am not a python guru and have no idea how I
would fix it myself.
The following code creates a series of arrays of data, and then
applies maximum.reduce to the array to get the largest value. It then
prints the type of returned max value.
Most of the returns are typed as an array with a shape of (). If the
array is created as a type of 'l' (long) or 'd' (double), the return type
is not array. This seems wrong. Can someone tell me if this is
expected, and if not, where would I look to change/fix it.
--- CODE ---
from Numeric import *
print "++++"
for tc in ('b', 'i', 'l', 's', 'f', 'd'):
smallArray = array([1,2,3,4], tc)
amax = maximum.reduce(smallArray)
print smallArray.typecode(), smallArray, "Max:", amax,
type(amax)
if type(amax) == type(smallArray):
print amax.shape
--- OUTPUT ---
>>>> ++++
b [1 2 3 4] Max: 4 <type 'array'>
()
i [1 2 3 4] Max: 4 <type 'array'>
()
l [1 2 3 4] Max: 4 <type 'int'>
s [1 2 3 4] Max: 4 <type 'array'>
()
f [ 1. 2. 3. 4.] Max: 4.0 <type 'array'>
()
d [ 1. 2. 3. 4.] Max: 4.0 <type 'float'>
More information about the NumPy-Discussion
mailing list