Thanks to visit codestin.com
Credit goes to github.com

Skip to content

BUG : nbagg py3k compatibility #3464

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
Sep 18, 2014
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
BUG : fix list comprehensions over class members
Due to scoping fixes in py3k, list comprehensions over class level
attributes during class definition does not work (see
http://stackoverflow.com/questions/13905741/accessing-class-variables-from-a-list-comprehension-in-the-class-definition).

Superficially Fixes #3436. There seem to be other issues
  • Loading branch information
tacaswell committed Sep 3, 2014
commit 126fb9c3eb820ecf08bca5efb8796eb0a55d9cd6
22 changes: 11 additions & 11 deletions lib/matplotlib/backends/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,25 +63,25 @@ def connection_info():
str(len(pylab_helpers.Gcf._activeQue)))
return '\n'.join(result)

# Note: Version 3.2 icons, not the later 4.0 ones.
# http://fontawesome.io/3.2.1/icons/
_FONT_AWESOME_CLASSES = {
'home': 'icon-home',
'back': 'icon-arrow-left',
'forward': 'icon-arrow-right',
'zoom_to_rect': 'icon-check-empty',
'move': 'icon-move',
None: None
}

class NavigationIPy(NavigationToolbar2WebAgg):
# Note: Version 3.2 icons, not the later 4.0 ones.
# http://fontawesome.io/3.2.1/icons/
_font_awesome_classes = {
'home': 'icon-home',
'back': 'icon-arrow-left',
'forward': 'icon-arrow-right',
'zoom_to_rect': 'icon-check-empty',
'move': 'icon-move',
None: None
}

# Use the standard toolbar items + download button
toolitems = [(text, tooltip_text,
_font_awesome_classes[image_file], name_of_method)
Copy link
Member

Choose a reason for hiding this comment

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

How can this work? _font_awesome_classes now appears only here in this file, so as far as I can see, it is undefined. Overall, this block of code looks like a list incomprehension, not a list comprehension.

Copy link
Member Author

Choose a reason for hiding this comment

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

indeed, fixed it earlier today, but didn't get the commit pushed up till now.

for text, tooltip_text, image_file, name_of_method
in NavigationToolbar2.toolitems
if image_file in _font_awesome_classes]
if image_file in _FONT_AWESOME_CLASSES]


class FigureManagerNbAgg(FigureManagerWebAgg):
Expand Down
20 changes: 10 additions & 10 deletions lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,25 @@ def stop_event_loop(self):
stop_event_loop.__doc__ = \
backend_bases.FigureCanvasBase.stop_event_loop_default.__doc__

_JQUERY_ICON_CLASSES = {
'home': 'ui-icon ui-icon-home',
'back': 'ui-icon ui-icon-circle-arrow-w',
'forward': 'ui-icon ui-icon-circle-arrow-e',
'zoom_to_rect': 'ui-icon ui-icon-search',
'move': 'ui-icon ui-icon-arrow-4',
'download': 'ui-icon ui-icon-disk',
None: None,
}

class NavigationToolbar2WebAgg(backend_bases.NavigationToolbar2):
_jquery_icon_classes = {
'home': 'ui-icon ui-icon-home',
'back': 'ui-icon ui-icon-circle-arrow-w',
'forward': 'ui-icon ui-icon-circle-arrow-e',
'zoom_to_rect': 'ui-icon ui-icon-search',
'move': 'ui-icon ui-icon-arrow-4',
'download': 'ui-icon ui-icon-disk',
None: None,
}

# Use the standard toolbar items + download button
toolitems = [(text, tooltip_text, _jquery_icon_classes[image_file],
name_of_method)
for text, tooltip_text, image_file, name_of_method
in (backend_bases.NavigationToolbar2.toolitems +
(('Download', 'Download plot', 'download', 'download'),))
if image_file in _jquery_icon_classes]
if image_file in _JQUERY_ICON_CLASSES]

def _init_toolbar(self):
self.message = ''
Expand Down