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
signature.asc
Description: This is a digitally signed message part
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@python.org https://mail.python.org/mailman/listinfo/numpy-discussion