[Numpy-discussion] Object array from list in 1.6.0 (vs. 1.5.1)

Mark Wiebe mwwiebe at gmail.com
Mon Jun 20 19:01:40 EDT 2011


This pull request which needs some testing should fix the issue:

https://github.com/numpy/numpy/pull/92

-Mark

On Fri, Jun 10, 2011 at 11:40 AM, Ken Basye <kbasye1 at jhu.edu> 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
> 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
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20110620/1827a55d/attachment.html>


More information about the NumPy-Discussion mailing list