Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

WebAgg backend: Fix unbound variable error in get_diff_image #8656

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 2 commits into from
May 23, 2017
Merged
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
keep the old buffer so we can return something when get_diff_image is…
… called while self._png_is_old
  • Loading branch information
cknd committed May 23, 2017
commit edb58683d1caeb9aa01dac40a720472b7b24ccff
4 changes: 2 additions & 2 deletions 4 lib/matplotlib/backends/backend_webagg_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,8 @@ def get_diff_image(self):
self._last_renderer, renderer)
self._force_full = False
self._png_is_old = False

return buff
self.buff = buff
return self.buff
Copy link
Member

Choose a reason for hiding this comment

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

Would it be better to return buff inside the if block and return None if there is no changes?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

semantically yes, but the consumer of that return value in refresh_all then complains that None is not a buffer. (send_binary, that is)

    def refresh_all(self):
        if self.web_sockets:
            diff = self.canvas.get_diff_image()
            for s in self.web_sockets:
                s.send_binary(diff)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess refresh_all could inspect self.canvas._png_is_old to see whether there is a need to refresh, and otherwise just do nothing (no sending of binaries). but that's not entirely clean in terms of attribute access

Copy link
Member

Choose a reason for hiding this comment

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

Maybe in refresh_all it should only send the diff if it is non None? What does the consumer side do if it receives the same diff multiple times?

👎 on looking at private attributes.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That sounds like the sanest way to do it. I've updated the PR


def get_renderer(self, cleared=None):
# Mirrors super.get_renderer, but caches the old one
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.