I'm not sure I understand the motivation here. Is the idea that you want to reuse min/max values computed with keepdims that you also want to use for other purposes?
If so, this could be achieved with squeeze(), e.g., np.linspace( arr.min(axis=ax, keepdims=True).squeeze(ax), arr.max(axis=ax, keepdims=True).squeeze(ax), axis=ax, ) This is not the most elegant code, but it seems better than adding a new keyword argument, and the resulting code is likely about as efficient. On Tue, Dec 10, 2019 at 11:54 AM Sebastian Berg <sebast...@sipsolutions.net> wrote: > On Tue, 2019-12-10 at 10:43 -0800, Zijie Poh wrote: > > Hi all, > > > > We've created a PR (#14922) on > > adding keepdims to linspace / logspace / geomspace, which > > enables linspace to directly take the output > > of min and max with keepdims = True as the start and stop arguments. > > That is, the following two linspace calls return the same result. > > > > np.linspace( > > arr.min(axis=ax), > > arr.max(axis=ax), > > axis=ax > > ) > > > > np.linspace( > > arr.min(axis=ax, keepdims=True), > > arr.max(axis=ax, keepdims=True), > > axis=ax, keepdims=True > > ) > > > > I am a bit hesitant about the name `keepdims` being the best one. I > realize it is nice to have the pattern to use the same name for > symmetry. But on the other hand, there is no axes being "kept" here. In > fact, `keepdims=True` returns fewer dims than `keepdims=False` :). > > Not sure I have a better idea though, `expand_axis` (or axis) might be > closer to what happens? > > `keepdims` is currently used entirely for reduction-like operations > (including complex reduce-like behaviour in `percentile`). However, the > closest to an opposite of reduce-like operations are maybe broadcasts > (they expand axis), but I cannot think of a way to use that for a > parameter name ;). > > The change itself is small enough and I am good with adding it, I have > some doubts it will be used much. But it is like a very natural thing > to give input with the same number of dimensions/axis as the output > will have. > > Maybe we should have had `new_axis=` and `expand_axis=` and you can > only use one ;). > > - Sebastian > > > > Please let me know if you have any questions / suggestions. > > > > Regards, > > ZJ > > _______________________________________________ > > NumPy-Discussion mailing list > > NumPy-Discussion@python.org > > https://mail.python.org/mailman/listinfo/numpy-discussion > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@python.org > https://mail.python.org/mailman/listinfo/numpy-discussion >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion