[Numpy-discussion] somewhat less stupid problem with 0-d arrays
Robert Kern
robert.kern at gmail.com
Sat May 11 10:00:31 EDT 2013
On Sat, May 11, 2013 at 12:57 AM, Neal Becker <ndbecker2 at gmail.com> wrote:
> It would be convenient if in arithmetic 0-d arrays were just ignored - it would
> seem to me to be convenient in generic code where a degenerate array is treated
> as "nothing"
>
> np.zeros ((0,0)) + np.ones ((2,2))
> ---------------------------------------------------------------------------
> ValueError Traceback (most recent call last)
> <ipython-input-17-27af0e0bbc6f> in <module>()
> ----> 1 np.zeros ((0,0)) + np.ones ((2,2))
>
> ValueError: operands could not be broadcast together with shapes (0,0) (2,2)
What would be the result of the following?
np.zeros((0,0)) - np.ones((2,2))
Would it have positive or negative values? I don't think we can
properly interpret that expression, so I think that the current
behavior is sound.
--
Robert Kern
More information about the NumPy-Discussion
mailing list