Skip to content

[BUGFIX] (Bug #2714) For _.uniq which acted incorrectly on sorted lists using a non injective iteratee #2715

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

Merged
merged 3 commits into from
Nov 27, 2017

Conversation

josephrubin
Copy link
Contributor

When using an iteratee that is not a one-to-one function, and isSorted=true, then _.uniq would attempt to use the fast algorithm which fails for non one-to-one (injective) functions, because they map to resultant values which are not sorted.

…d list with a non injective iteratee and added a test case to test this fix
@josephrubin
Copy link
Contributor Author

This is my first pull request ever, so please, kindly point out if I am doing something wrong, or if I have made any mistakes. Thank you so much.

Copy link
Owner

@jashkenas jashkenas left a comment

Choose a reason for hiding this comment

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

Congrats on the first PR! Fix these and I'll be happy to merge.

underscore.js Outdated
@@ -558,6 +558,8 @@

// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// The faster algorithm will not work with an iteratee if the iteratee is not a one-to-one function, so providing an iteratee will disable the faster algorithm
Copy link
Owner

Choose a reason for hiding this comment

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

Comments should be complete sentences, with punctuation, wrapped to an ~80 line width.

underscore.js Outdated
@@ -558,6 +558,8 @@

// Produce a duplicate-free version of the array. If the array has already
// been sorted, you have the option of using a faster algorithm.
// The faster algorithm will not work with an iteratee if the iteratee is not a one-to-one function, so providing an iteratee will disable the faster algorithm
// Perhaps a warning should be thrown if an iteratee is provided while isSorted is true, to warn that the faster algorithm will not be used
Copy link
Owner

Choose a reason for hiding this comment

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

Let's get rid of this sentence — we don't need to publish it along with the library.

@josephrubin
Copy link
Contributor Author

Thanks! I updated the lines that the bot flagged, and now I will update the code with the comments that you added. In a minute I will make another commit.

@coveralls
Copy link

coveralls commented Nov 27, 2017

Coverage Status

Coverage remained the same at 96.763% when pulling 78a507a on jojois74:master into 65e18d4 on jashkenas:master.

@josephrubin
Copy link
Contributor Author

I fixed the comments in the code as per your request. Let me know if you would like me to change anything else.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.763% when pulling 644cd3c on jojois74:master into 65e18d4 on jashkenas:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.763% when pulling 644cd3c on jojois74:master into 65e18d4 on jashkenas:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.763% when pulling 644cd3c on jojois74:master into 65e18d4 on jashkenas:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 96.763% when pulling 644cd3c on jojois74:master into 65e18d4 on jashkenas:master.

@jashkenas jashkenas merged commit 5c237a7 into jashkenas:master Nov 27, 2017
@jashkenas
Copy link
Owner

Nice work!

@josephrubin
Copy link
Contributor Author

Thank you, I really appreciate it!

mAiNiNfEcTiOn pushed a commit to mAiNiNfEcTiOn/interview-process that referenced this pull request Mar 2, 2018
[BUGFIX] (Bug jashkenas#2714) For _.uniq which acted incorrectly on sorted lists using a non injective iteratee
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants