-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Sniper task: Keeping 'missing' Pokemon + sorting order correction #5613
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6833f63
Snipe task: Keeping 'missing' Pokemon + sorting order correction
GhosterBot edfbbea
Merge pull request #1 from GhosterBot/SniperCorrection
GhosterBot 4cf52d6
Adding import
GhosterBot 0f5dcef
Merge pull request #2 from GhosterBot/SniperCorrection
GhosterBot 038b8c2
ortho
GhosterBot 9e3bba8
Merge pull request #3 from GhosterBot/SniperCorrection
GhosterBot f9f62e0
Changing attribut call
GhosterBot 6996ebd
Merge pull request #4 from GhosterBot/SniperCorrection
GhosterBot File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
This is and
targets.sort(key=lambda pokemon: pokemon[attr], reverse=True)
are the same thing (and requires less imports).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.
@YvesHenri
Not exactly, because this method is called as many times as there is attr in self.order: , and that's the problem.
So, at every call on the loop, the targets list will be sorted by loop's current pokemon[attr] only.
So if there is 4 orders specified (missing, priority, iv, vip), the targets.sort will be called 4 times, and everytimes the sorting will be on one attribute only. First missing only, then priority only, then iv only, and finally ordering by vip only. So finally the list will only be sorted by vip (in this example), regardless the others options.
I see it with my detailed logs .
So calling
targets = sorted(targets, key=itemgetter(*self.order), reverse=True
will do in one pass a cumulative ordering, thanks to the *self.order parameter where all the desired order will be handle at once (look at my screenshot for another example)
Please look at https://docs.python.org/2/library/operator.html :
-> Changed in version 2.5: Added support for multiple item extraction.
That's exactly what we are looking for
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 know. Thats what I meant. Although, the final/merged list will have around 30
50 items, and if you have a max of 5 ordering types, that should be an iteration of 150250 times, which is worthless. I'll accept it anyways.