Make SelectionWidget.values a dict#5012
Merged
Merged
Conversation
Member
There was a problem hiding this comment.
Should the help string here say name:value?
Member
There was a problem hiding this comment.
I think it's possible to construct an OrderedDict with 2-tuples if we want to make this a bit shorter:
OrderedDict((unicode_type(v), v) for v in values)
Member
Author
|
Various changes recommended by @takluyver should be done. |
Member
There was a problem hiding this comment.
I believe our List traitlet can validate the type of items in the list, i.e. List(Unicode, ...). Is that worth using here?
rename 'labels' and '_value' to 'value_names' and 'value_name'. To specify a mapping of value names and values, use a dict. If you specify `values=[list]`, then an OrderedDict will be used. Assignment after construction only supports a dict.
Member
Author
|
value_names is now read-only, so it is clear that there is only one place to edit this information - the values dictionary. |
raises KeyError on failed lookup (in both directions)
Member
|
Looks good, merging. |
ellisonbg
added a commit
that referenced
this pull request
Feb 4, 2014
Make `SelectionWidget.values` a dict
mattvonrocketstein
pushed a commit
to mattvonrocketstein/ipython
that referenced
this pull request
Nov 3, 2014
Make `SelectionWidget.values` a dict
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
rename
labelstovalue_namesand_valuetovalue_name.To specify a mapping of value names and values, use a dict. If you specify
values=[list], then an OrderedDict will be used, whose keys arestr(value).Assignment to
valuesafter construction only supports a dict.closes #4961