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 7, 2024
1 parent d630f36 commit 0173212
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 39 deletions.
2 changes: 1 addition & 1 deletion ipympl/backend_nbagg.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
from collections.abc import Iterable
except ImportError:
# Python 2.7
from collections import Iterable
from collections.abc import Iterable

import matplotlib
import numpy as np
Expand Down
56 changes: 28 additions & 28 deletions src/mpl_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
const url_creator = window.URL || window.webkitURL;

const buffer = new Uint8Array(
ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0]
ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0],
);
const blob = new Blob([buffer], { type: 'image/png' });
const image_url = url_creator.createObjectURL(blob);
Expand Down Expand Up @@ -277,7 +277,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
} catch (e) {
console.log(
"No handler for the '" + msg_type + "' message type: ",
msg
msg,
);
return;
}
Expand Down Expand Up @@ -330,7 +330,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
0,
0,
this.offscreen_canvas.width,
this.offscreen_canvas.height
this.offscreen_canvas.height,
);
}

Expand Down Expand Up @@ -412,23 +412,23 @@ export class MPLCanvasView extends DOMWidgetView {
model_events() {
this.model.on(
'change:header_visible',
this._update_header_visible.bind(this)
this._update_header_visible.bind(this),
);
this.model.on(
'change:footer_visible',
this._update_footer_visible.bind(this)
this._update_footer_visible.bind(this),
);
this.model.on(
'change:toolbar_visible',
this._update_toolbar_visible.bind(this)
this._update_toolbar_visible.bind(this),
);
this.model.on(
'change:toolbar_position',
this._update_toolbar_position.bind(this)
this._update_toolbar_position.bind(this),
);
this.model.on(
'change:_figure_label',
this._update_figure_label.bind(this)
this._update_figure_label.bind(this),
);
this.model.on('change:_message', this._update_message.bind(this));
this.model.on('change:_cursor', this._update_cursor.bind(this));
Expand Down Expand Up @@ -461,7 +461,7 @@ export class MPLCanvasView extends DOMWidgetView {
this.header.classList.add(
'jupyter-widgets',
'widget-label',
'jupyter-matplotlib-header'
'jupyter-matplotlib-header',
);
this._update_header_visible();
this._update_figure_label();
Expand All @@ -476,7 +476,7 @@ export class MPLCanvasView extends DOMWidgetView {
const canvas_container = document.createElement('div');
canvas_container.classList.add(
'jupyter-widgets',
'jupyter-matplotlib-canvas-container'
'jupyter-matplotlib-canvas-container',
);
this.figure.appendChild(canvas_container);

Expand All @@ -485,7 +485,7 @@ export class MPLCanvasView extends DOMWidgetView {
canvas_div.style.clear = 'both';
canvas_div.classList.add(
'jupyter-widgets',
'jupyter-matplotlib-canvas-div'
'jupyter-matplotlib-canvas-div',
);

canvas_div.addEventListener('keydown', this.key_event('key_press'));
Expand Down Expand Up @@ -514,35 +514,35 @@ export class MPLCanvasView extends DOMWidgetView {
top_canvas.addEventListener('dblclick', this.mouse_event('dblclick'));
top_canvas.addEventListener(
'mousedown',
this.mouse_event('button_press')
this.mouse_event('button_press'),
);
top_canvas.addEventListener(
'mouseup',
this.mouse_event('button_release')
this.mouse_event('button_release'),
);
top_canvas.addEventListener(
'mousemove',
throttle(
this.mouse_event('motion_notify'),
this.model.get('pan_zoom_throttle')
)
this.model.get('pan_zoom_throttle'),
),
);

top_canvas.addEventListener(
'mouseenter',
this.mouse_event('figure_enter')
this.mouse_event('figure_enter'),
);
top_canvas.addEventListener(
'mouseleave',
this.mouse_event('figure_leave')
this.mouse_event('figure_leave'),
);

top_canvas.addEventListener(
'wheel',
throttle(
this.mouse_event('scroll'),
this.model.get('pan_zoom_throttle')
)
this.model.get('pan_zoom_throttle'),
),
);
top_canvas.addEventListener('wheel', (event: any) => {
if (this.model.get('capture_scroll')) {
Expand All @@ -568,7 +568,7 @@ export class MPLCanvasView extends DOMWidgetView {

async _init_toolbar() {
this.toolbar_view = (await this.create_child_view(
this.model.get('toolbar')
this.model.get('toolbar'),
)) as ToolbarView;

this.figure.appendChild(this.toolbar_view.el);
Expand All @@ -595,7 +595,7 @@ export class MPLCanvasView extends DOMWidgetView {
0,
0,
this.canvas.width,
this.canvas.height
this.canvas.height,
);
} else {
this.context.drawImage(this.model.offscreen_canvas, 0, 0);
Expand All @@ -605,7 +605,7 @@ export class MPLCanvasView extends DOMWidgetView {
0,
0,
this.top_canvas.width,
this.top_canvas.height
this.top_canvas.height,
);

// Draw rubberband
Expand All @@ -624,7 +624,7 @@ export class MPLCanvasView extends DOMWidgetView {
this.model.get('_rubberband_x'),
this.model.get('_rubberband_y'),
this.model.get('_rubberband_width'),
this.model.get('_rubberband_height')
this.model.get('_rubberband_height'),
);
}

Expand All @@ -636,7 +636,7 @@ export class MPLCanvasView extends DOMWidgetView {
this.top_canvas.height - this.resize_handle_size,
// Stop
this.top_canvas.width,
this.top_canvas.height
this.top_canvas.height,
);
gradient.addColorStop(0, 'white');
gradient.addColorStop(1, 'black');
Expand All @@ -648,15 +648,15 @@ export class MPLCanvasView extends DOMWidgetView {
this.top_context.beginPath();
this.top_context.moveTo(
this.top_canvas.width,
this.top_canvas.height
this.top_canvas.height,
);
this.top_context.lineTo(
this.top_canvas.width,
this.top_canvas.height - this.resize_handle_size
this.top_canvas.height - this.resize_handle_size,
);
this.top_context.lineTo(
this.top_canvas.width - this.resize_handle_size,
this.top_canvas.height
this.top_canvas.height,
);
this.top_context.closePath();
this.top_context.fill();
Expand All @@ -675,7 +675,7 @@ export class MPLCanvasView extends DOMWidgetView {
this.footer.classList.add(
'jupyter-widgets',
'widget-label',
'jupyter-matplotlib-footer'
'jupyter-matplotlib-footer',
);
this._update_footer_visible();
this._update_message();
Expand Down
2 changes: 1 addition & 1 deletion src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default jupyterMatplotlibPlugin;
*/
function activateWidgetExtension(
app: Application<Widget>,
registry: IJupyterWidgetRegistry
registry: IJupyterWidgetRegistry,
): void {
registry.registerWidget({
name: MODULE_NAME,
Expand Down
10 changes: 5 additions & 5 deletions src/toolbar_widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export class ToolbarView extends DOMWidgetView {
'jupyter-widgets',
'jupyter-matplotlib-toolbar',
'widget-container',
'widget-box'
'widget-box',
);

// Fade-in/fade-out mode by default, the figure will decide
Expand Down Expand Up @@ -69,14 +69,14 @@ export class ToolbarView extends DOMWidgetView {
button.classList.add(
'jupyter-matplotlib-button',
'jupyter-widgets',
'jupyter-button'
'jupyter-button',
);
button.setAttribute('href', '#');
button.setAttribute('title', tooltip);
button.style.outline = 'none';
button.addEventListener(
'click',
this.toolbar_button_onclick(method_name)
this.toolbar_button_onclick(method_name),
);

const icon = document.createElement('i');
Expand Down Expand Up @@ -162,7 +162,7 @@ export class ToolbarView extends DOMWidgetView {
}

set_visibility(
value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean
value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean,
): void {
// For backward compatibility with the old API
if (typeof value === 'boolean') {
Expand Down Expand Up @@ -247,7 +247,7 @@ export class ToolbarView extends DOMWidgetView {
this.model.on_some_change(
['button_style', '_current_action'],
this.set_buttons_style,
this
this,
);
}
}
1 change: 1 addition & 0 deletions ui-tests/jupyter_server_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
opens the server to the world and provide access to JupyterLab
JavaScript objects through the global window variable.
"""

from jupyterlab.galata import configure_jupyter_server

configure_jupyter_server(c) # noqa F821
Expand Down
8 changes: 4 additions & 4 deletions ui-tests/tests/ipympl.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const filterUpdateNotebooks = (item) => {

const testCellOutputs = async (
page: IJupyterLabPageFixture,
tmpPath: string
tmpPath: string,
) => {
const paths = klaw(path.resolve(__dirname, './notebooks'), {
filter: (item) => !filterUpdateNotebooks(item),
Expand Down Expand Up @@ -53,7 +53,7 @@ const testCellOutputs = async (
for (let c = 0; c < numCellImages; ++c) {
expect(results[c]).toMatchSnapshot(
getCaptureImageName(notebook, c),
{ threshold: 0.4 }
{ threshold: 0.4 },
);
}

Expand Down Expand Up @@ -96,7 +96,7 @@ const testUpdates = async (page: IJupyterLabPageFixture, tmpPath: string) => {
for (let i = 0; i < cellCount; i++) {
expect(results[i]).toMatchSnapshot(
getCaptureImageName(notebook, i),
{ threshold: 0.4 }
{ threshold: 0.4 },
);
}

Expand All @@ -108,7 +108,7 @@ test.describe('ipympl Visual Regression', () => {
test.beforeEach(async ({ page, tmpPath }) => {
await page.contents.uploadDirectory(
path.resolve(__dirname, './notebooks'),
tmpPath
tmpPath,
);
await page.filebrowser.openDirectory(tmpPath);
});
Expand Down

0 comments on commit 0173212

Please sign in to comment.