On Tue, Feb 23, 2016 at 12:23 PM, Benjamin Root <ben.v.r...@gmail.com> wrote: > > On Tue, Feb 23, 2016 at 3:14 PM, Nathaniel Smith <n...@pobox.com> wrote: >> >> Sure, it's totally ambiguous. These are all legal: > > > > I would argue that except for the first reshape, all of those should be an > error, and that the current algorithm is buggy.
Reshape doesn't care about axes at all; all it cares about is that the number of elements stay the same. E.g. this is also totally legal: np.zeros((12, 5)).reshape((10, 3, 2)) And so are the equivalents np.zeros((12, 5)).reshape((-1, 3, 2)) np.zeros((12, 5)).reshape((10, -1, 2)) np.zeros((12, 5)).reshape((10, 3, -1)) > This isn't a heuristic. It isn't guessing. It is making the semantics > consistent. The fact that I can do: > a.shape = (-1, 5, 64) > or > a.shape = (0, 5, 64) > > but not > a.shape = (0, 5, -1) > > is totally inconsistent. It's certainly annoying and unpleasant, but it follows inevitably from the most natural way of defining the -1 semantics, so I'm not sure I'd say "inconsistent" :-) What should this do? np.zeros((12, 0)).reshape((10, -1, 2)) -n -- Nathaniel J. Smith -- https://vorpus.org _______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org https://mail.scipy.org/mailman/listinfo/numpy-discussion