-
-
Notifications
You must be signed in to change notification settings - Fork 18.2k
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
CLN: replace lambdas with named functions so they are labeled in asv #24629
Merged
Merged
Changes from all commits
Commits
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,17 +3,55 @@ | |
from pandas import Series, Index, DatetimeIndex, Timestamp, MultiIndex | ||
|
||
|
||
def no_change(arr): | ||
return arr | ||
|
||
|
||
def list_of_str(arr): | ||
return list(arr.astype(str)) | ||
|
||
|
||
def gen_of_str(arr): | ||
return (x for x in arr.astype(str)) | ||
|
||
|
||
def arr_dict(arr): | ||
return dict(zip(range(len(arr)), arr)) | ||
|
||
|
||
def list_of_tuples(arr): | ||
return [(i, -i) for i in arr] | ||
|
||
|
||
def gen_of_tuples(arr): | ||
return ((i, -i) for i in arr) | ||
|
||
|
||
def list_of_lists(arr): | ||
return [[i, -i] for i in arr] | ||
|
||
|
||
def list_of_tuples_with_none(arr): | ||
return [(i, -i) for i in arr][:-1] + [None] | ||
|
||
|
||
def list_of_lists_with_none(arr): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above |
||
return [[i, -i] for i in arr][:-1] + [None] | ||
|
||
|
||
class SeriesConstructors(object): | ||
|
||
param_names = ["data_fmt", "with_index"] | ||
params = [[lambda x: x, | ||
params = [[no_change, | ||
list, | ||
lambda arr: list(arr.astype(str)), | ||
lambda arr: dict(zip(range(len(arr)), arr)), | ||
lambda arr: [(i, -i) for i in arr], | ||
lambda arr: [[i, -i] for i in arr], | ||
lambda arr: ([(i, -i) for i in arr][:-1] + [None]), | ||
lambda arr: ([[i, -i] for i in arr][:-1] + [None])], | ||
list_of_str, | ||
gen_of_str, | ||
arr_dict, | ||
list_of_tuples, | ||
gen_of_tuples, | ||
list_of_lists, | ||
list_of_tuples_with_none, | ||
list_of_lists_with_none], | ||
[False, True]] | ||
|
||
def setup(self, data_fmt, with_index): | ||
|
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.
Naming nit but this is a generator expression not a list, no?
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.
Seems the
[]
forces it into a list, making the outer parens a simple grouping. I'll remove the parens and add generator versions for clarity.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.
Done - generators don't support
+
, so didn't add them for this particular case