Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

fix doc for the op sort() and argsort() #15317

Merged
merged 1 commit into from
Jul 8, 2019
Merged

Conversation

suyz526
Copy link
Contributor

@suyz526 suyz526 commented Jun 21, 2019

Description

Errors in the example of sort() and argsort(). Those op flatten and sort the array only when axis=None is given explicitly.

Checklist

@suyz526 suyz526 closed this Jun 21, 2019
@suyz526 suyz526 reopened this Jun 21, 2019
@suyz526
Copy link
Contributor Author

suyz526 commented Jun 22, 2019

@mxnet-label-bot add [Doc, pr-awaiting-review]

@marcoabreu marcoabreu added Doc pr-awaiting-review PR is waiting for code review labels Jun 22, 2019
@suyz526 suyz526 closed this Jun 23, 2019
@suyz526 suyz526 reopened this Jun 23, 2019
@suyz526 suyz526 closed this Jun 23, 2019
@suyz526 suyz526 reopened this Jun 23, 2019
@suyz526
Copy link
Contributor Author

suyz526 commented Jun 24, 2019

@aaronmarkham

Copy link
Contributor

@aaronmarkham aaronmarkham left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the last axis example might need to be updated for clarity...please verify.

@@ -114,7 +114,7 @@ Examples::
[ 1., 3.]]

// flattens and then sorts
sort(x) = [ 1., 1., 3., 4.]
sort(x, axis=None) = [ 1., 1., 3., 4.]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This sort makes sense.
But I'm thrown off by the other example. Sorting along the last axis would be 3 then 4 unless it is descending rather than ascending. Does this need to be specified for clarity?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi,
Thanks for your reply!

Do you mean this example?
// sorts along the last axis
sort(x) = [[ 1., 4.], [ 1., 3.]]

Since x = [[ 1, 4],[ 3, 1]], the pairs in the last axis are [1,4] and [3,1]. Sorting only along the last axis in a descend way would be [1,4] and [1,3]. So, in my opinion, it is correct? or maybe I'm wrong?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested it in numpy and it matches fine.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry that I didn't get your point. What I did wrong in this PR?

If the argument axis=None is not given, this function will sort the array alone the last axis. However, in the second example, we want the array to be flattened and then sorted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything is fine. I might have needed more examples to see the patterns, but I understand that if you're conversant with NumPy then this all works as expected.

@roywei
Copy link
Member

roywei commented Jul 8, 2019

@mxnet-label-bot add [pr-awaiting-merge]

is this good to go?

@marcoabreu marcoabreu added the pr-awaiting-merge Review and CI is complete. Ready to Merge label Jul 8, 2019
@aaronmarkham aaronmarkham merged commit 1ae73de into apache:master Jul 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Doc pr-awaiting-merge Review and CI is complete. Ready to Merge pr-awaiting-review PR is waiting for code review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants