-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Additional cleanups #7547
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
Additional cleanups #7547
Changes from 1 commit
de302f5
46b9d47
1504540
3d00576
69622dd
f1b25e6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -658,7 +658,7 @@ def __repr__(self): | |
|
||
def unique(x): | ||
"""Return a list of unique elements of *x*""" | ||
return list(six.iterkeys(dict([(val, 1) for val in x]))) | ||
return list(set(x)) | ||
|
||
|
||
def iterable(obj): | ||
|
@@ -1407,15 +1407,15 @@ def finddir(o, match, case=False): | |
|
||
def reverse_dict(d): | ||
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. Could probably be used in a couple places you've updated... 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. I'd rather deprecate this function... I think everyone can understand what 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. No argument there. |
||
"""reverse the dictionary -- may lose data if values are not unique!""" | ||
return dict([(v, k) for k, v in six.iteritems(d)]) | ||
return {v: k for k, v in six.iteritems(d)} | ||
|
||
|
||
def restrict_dict(d, keys): | ||
""" | ||
Return a dictionary that contains those keys that appear in both | ||
d and keys, with values from d. | ||
""" | ||
return dict([(k, v) for (k, v) in six.iteritems(d) if k in keys]) | ||
return {k: v for k, v in six.iteritems(d) if k in keys} | ||
|
||
|
||
def report_memory(i=0): # argument may go away | ||
|
@@ -2077,7 +2077,7 @@ def unmasked_index_ranges(mask, compressed=True): | |
# The ls_mapper maps short codes for line style to their full name used | ||
# by backends | ||
# The reverse mapper is for mapping full names to short ones | ||
ls_mapper_r = dict([(ls[1], ls[0]) for ls in _linestyles]) | ||
ls_mapper_r = reverse_dict(ls_mapper) | ||
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. Can 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. yes |
||
|
||
|
||
def align_iterators(func, *iterables): | ||
|
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.
One more dict comprehension?
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.
yes