-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
DOC, TST: cover setdiff1d assume_unique #12153
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
numpy/lib/arraysetops.py
Outdated
@@ -770,6 +770,7 @@ def setdiff1d(ar1, ar2, assume_unique=False): | |||
""" | |||
if assume_unique: | |||
ar1 = np.asarray(ar1).ravel() | |||
ar1.sort() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was worried this might mutate the input array, may be safer with np.sort
. If so, should test for that too since all green already.
I think this is just a documentation bug - none of the functions taking |
5a4e362
to
0b5b458
Compare
Ok, adjusted to DOC / TST change only. |
I think there may be other functions in this file that have the same issue. An alternative would be to document assume_unique as also assuming sortedness. |
Azure missing in CI list |
Close/reopen to trigger appveyor tests |
The added test increases coverage. LGTM. |
I think I'd like to continue this by documenting the result as:
|
* add unit test for setdiff1d covering code path where assume_unique is True * remove setdiff1d docstring guarantee that returned value is sorted -- it is not
0b5b458
to
2ddba2a
Compare
Revised to reflect docstring suggestions from Eric--hopefully we can confine this PR to this specific function though. |
Thanks Tyler. |
Sorted 1D array of values in `ar1` that are not in `ar2`. | ||
1D array of values in `ar1` that are not in `ar2`. The result | ||
is sorted when `assume_unique=False`, but otherwise only sorted | ||
if the input is sorted. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice wording, thanks
setdiff1d
now tested for case whereassume_unique
isTrue
; docs had incorrect guarantee about sorting return val too.uncovered code.