Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed Oct 8, 2021
1 parent 1a83e34 commit 86ea718
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 22 deletions.
36 changes: 16 additions & 20 deletions ipympl/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,12 @@
import json
from base64 import b64encode

from PIL import Image

import matplotlib
import numpy as np

from traitlets import (
Any,
Bool,
CaselessStrEnum,
CInt,
Enum,
Instance,
List,
Unicode,
default,
)

from IPython import get_ipython
from IPython import version_info as ipython_version_info
from IPython.display import HTML, display

from ipywidgets import DOMWidget, widget_serialization

import matplotlib
from matplotlib import is_interactive, rcParams
from matplotlib._pylab_helpers import Gcf
from matplotlib.backend_bases import NavigationToolbar2, _Backend, cursors
Expand All @@ -36,6 +19,18 @@
NavigationToolbar2WebAgg,
TimerTornado,
)
from PIL import Image
from traitlets import (
Any,
Bool,
CaselessStrEnum,
CInt,
Enum,
Instance,
List,
Unicode,
default,
)

from ._version import js_semver

Expand Down Expand Up @@ -241,8 +236,9 @@ def get_image(self):
# The buffer is created as type uint32 so that entire
# pixels can be compared in one numpy call, rather than
# needing to compare each plane separately.
output = (np.frombuffer(renderer.buffer_rgba(), dtype=np.uint32)
.reshape((renderer.height, renderer.width)))
output = np.frombuffer(renderer.buffer_rgba(), dtype=np.uint32).reshape(
(renderer.height, renderer.width)
)

self._png_is_old = False

Expand Down
4 changes: 2 additions & 2 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ function deserialize_image(image: DataView | null): Uint8Array | null {
// Base64 image
if (typeof image === 'string') {
return new Uint8Array(
Array.from(atob(image)).map(c => c.charCodeAt(0))
)
Array.from(atob(image)).map((c) => c.charCodeAt(0))
);
}
// Array of pixels
return new Uint8Array(image.buffer);
Expand Down

0 comments on commit 86ea718

Please sign in to comment.