[Numpy-discussion] Object array from list in 1.6.0 (vs. 1.5.1)
Mon Jun 20 18:01:40 CDT 2011
This pull request which needs some testing should fix the issue:
On Fri, Jun 10, 2011 at 11:40 AM, Ken Basye <email@example.com> wrote:
> 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
> 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.
> NumPy-Discussion mailing list
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion