I guess I always treated scalars as something special when it comes to broadcasting. Seeing these examples, I can see how my grokking of broadcasting was incomplete.
I still think that the assignment of an array of values (as opposed to a scalar) to nothing could potentially mask deeper issues, but now I see that it may be impossible to distinguish from the perfectly normal case. Cheers! Ben Root On Sun, Jul 6, 2014 at 5:48 PM, Nathaniel Smith <n...@pobox.com> wrote: > On Sun, Jul 6, 2014 at 9:14 PM, Benjamin Root <ben.r...@ou.edu> wrote: > > as for the broadcasting issue, I can see it for the second case, but the > > first case still doesn't sit right with me. My understanding of > broadcasting > > is to effectively *expand* an array to match the shape of another array > (or > > some target shape). In this case, the array is being effectively > > *contracted* in shape. That makes zero sense to me. > > That's how it's always worked though, in all cases of broadcasting; > nothing special about indexing: > > In [8]: a = np.zeros((3, 0)) > > In [9]: a + 1 > Out[9]: array([], shape=(3, 0), dtype=float64) > > In [10]: a + [[1], [2], [3]] > Out[10]: array([], shape=(3, 0), dtype=float64) > > IME it's extremely useful in practice for avoiding special cases when > some axis has a vary size that can be zero. > > -- > Nathaniel J. Smith > Postdoctoral researcher - Informatics - University of Edinburgh > http://vorpus.org > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion