On Thu, 2021-07-01 at 00:39 -0700, Stefan van der Walt wrote: > Hi Sebastian, > > On Wed, Jun 30, 2021, at 18:23, Sebastian Berg wrote: > > The PR https://github.com/numpy/numpy/pull/19211 proposes to extend > > argmin and argmax with a `keepdims=False` keyword-only argument. > > This seems consistent with existing APIs, so I'm not concerned. > > For those wondering, `keepdims` preserves the number of dimensions of > the original array in a reduction operation like `sum`: > > In [1]: X = np.random.random((10, 15)) > > In [2]: np.sum(X).shape > Out[2]: () > > In [3]: np.sum(X, keepdims=True).shape > Out[3]: (1, 1) > > This is sometimes useful for broadcasting. > > > The PR also proposes to add: > > > > * `PyArray_ArgMinWithKeepdims` > > * `PyArray_ArgMaxWithKeepdims` > > I am curious whether this is our general pattern for adding keyword > argument functionality to functions in the C-API. It seems a bit > excessive!
True, I am now tending a bit towards delaying this until someone actually asks for it... In most use-cases just using the Python API is likely only a small overhead anyway if done right. I do not think we have a pattern. We do have some functions with the pattern of `With...And...` to allow signatures of different complexity. But very few of this type of python additions ever made it into the C- API. For `Reshape`, `order=` was added by introducing `NewShape`. I have some hope that very long-term, HPy might solve this for us... Cheers, Sebastian > > Stéfan > _______________________________________________ > 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