On So, 2014-07-06 at 16:14 -0400, Benjamin Root wrote: > re: deprecation warnings... that's what I get when I am working on my > non-dev box because I am at the conference, and have gotten too used > to the setup of my dev box... > > > 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. >
Well, from a technical point of view, it is more like changing the shape to whatever fits while setting the stride to 0. I am sure there are a few places where the doc is not clear. From a practical point of view, it makes sense if you consider this: arr[arr < 0] = 0 Where it might be that the array has no elements smaller 0. Though I admit I would write 0 here, and not [0]. - Sebastian > > Ben > > > > On Sun, Jul 6, 2014 at 3:59 PM, Charles R Harris > <charlesr.har...@gmail.com> wrote: > > > > On Sun, Jul 6, 2014 at 1:32 PM, Benjamin Root > <ben.r...@ou.edu> wrote: > While trying to wrap my head around the issues with > matplotlib's tri module and the new numpy indexing, I > have made some test cases where I wonder if warnings > should be issued. > > > import numpy as np > > a = np.ones((10,)) > > all_false = np.zeros((10,), dtype=bool) > > a[all_false] = np.array([2.0]) # the shapes don't > match here > > > > It broadcasts because the leading dimension is 1. > > > > > mask_in = np.array([False]*8 + [True, True]) > > a[mask_in] = np.array([]) # raises ValueError as > expected > > a[mask_in] = np.array([[]]) # no exception because it > is 2-D, for some reason (on master, but not > release-0.9b1) > > > Now falls back to old behavior and raises a > DeprecationWarning. You don't see that by default. > > > > > a[mask_in] = np.array([2.0]) # This works and repeats > 2.0 twice. I thought this wasn't supposed to happen > anymore? > > > > Broadcasting again. > > > > Chuck > > > _______________________________________________ > 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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion