I agree with the idea of setting apart the parameter from python , "by" sounds like a good alternative
Rakesh On Wed, Jul 1, 2020, 18:45 Sebastian Berg <sebast...@sipsolutions.net> wrote: > On Wed, 2020-07-01 at 12:48 -0700, Stephan Hoyer wrote: > > On Wed, Jul 1, 2020 at 12:23 PM Sebastian Berg < > > sebast...@sipsolutions.net> > > wrote: > > > > > This is a WIP, but allows nicely to try out how the new API > > > could/should look like, and see the potential impact to code. The > > > current choice is for: > > > > > > np.sort(arr, keys=(arr.real, arr.image)) > > > > > > for example. `keys` is like the `key` argument to pythons sorts, > > > but > > > unlike python sorts is not passed a function but rather a sequence > > > of > > > arrays. > > > > > > Alternative spellings could be `by=...`? Or maybe someone has a > > > different API idea. > > > > > > > I really like the look of np.sort(arr, by=(arr.real, arr.image)). > > - This avoids adding an extra function sortby into NumPy's API. The > > default > > behavior (by=None) would of course be to sort by the arrays being > > sorted, > > so it's backwards compatible. > > - Calling the new argument "by" instead of "key" avoids confusion > > with the > > behavior of Python's sort/sorted (which take functions instead of > > sequences). > > > I just noticed that `DataFrame.sort_values()` uses `by=...` with a list > of column names. However, I guess that is fairly compatible with this > usage. > > - Sebastan > > > > The combination of lexsort() and take_along_axis() makes it possible > > to > > achieve this behavior currently, but it is definitely less clear than > > a > > single function call. > > _______________________________________________ > > 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