From 86ea718b42961222ef61a2ee3e3ff32f8025b81c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 8 Oct 2021 13:39:15 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- ipympl/backend_nbagg.py | 36 ++++++++++++++++-------------------- src/mpl_widget.ts | 4 ++-- 2 files changed, 18 insertions(+), 22 deletions(-) diff --git a/ipympl/backend_nbagg.py b/ipympl/backend_nbagg.py index 3b037d79..d07fff90 100644 --- a/ipympl/backend_nbagg.py +++ b/ipympl/backend_nbagg.py @@ -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 @@ -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 @@ -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 diff --git a/src/mpl_widget.ts b/src/mpl_widget.ts index c15b58ab..fd53dbad 100644 --- a/src/mpl_widget.ts +++ b/src/mpl_widget.ts @@ -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);