[Numpy-discussion] Object array from list in 1.6.0 (vs. 1.5.1)
Ken Basye
kbasye1@jhu....
Fri Jun 10 11:40:55 CDT 2011
Dear folks,
I have some code that stopped working with 1.6.0 and I'm wondering if
there's a better way to replace it than what I came up with. Here's a
condensed version:
x = [()] # list containing an empty tuple; this isn't the only case,
but it's one that must be handled correctly
y = np.empty(len(x), dtype=object)
y[:] = x[:]
In 1.5.1 this works, giving y as "array([()], dtype=object)"
In 1.6.0, it raises a ValueError:
ValueError: output operand requires a reduction, but reduction is not
enabled
I didn't see anything in the release notes about this; admittedly it's a
very small corner case. I also don't understand what the error message
is trying to tell me here.
Most of the more straightforward ways to construct the desired array
don't work because the interpretation of a nested structure is as a
multi-dimensional array, which is reasonable.
At this point my workaround is to replace the assignment with a loop:
for i, v in enumerate(x):
y[i] = v
but this seems non-Numpyish. Any light on what the error means or a
better way to do this would be most welcome.
Thanks,
Ken
More information about the NumPy-Discussion
mailing list