Skip to content

Commit 94edf4b

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 2e74d1f commit 94edf4b

File tree

5 files changed

+39
-41
lines changed

5 files changed

+39
-41
lines changed

ipympl/backend_nbagg.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
from collections.abc import Iterable
2525
except ImportError:
2626
# Python 2.7
27-
from collections import Iterable
27+
from collections.abc import Iterable
2828

2929
import matplotlib
3030
import numpy as np
@@ -91,7 +91,6 @@ def connection_info():
9191

9292

9393
class Toolbar(DOMWidget, NavigationToolbar2WebAgg):
94-
9594
_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
9695
_model_module_version = Unicode(js_semver).tag(sync=True)
9796
_model_name = Unicode('ToolbarModel').tag(sync=True)
@@ -178,7 +177,6 @@ def _on_orientation_collapsed_changed(self, change):
178177

179178

180179
class Canvas(DOMWidget, FigureCanvasWebAggCore):
181-
182180
_model_module = Unicode('jupyter-matplotlib').tag(sync=True)
183181
_model_module_version = Unicode(js_semver).tag(sync=True)
184182
_model_name = Unicode('MPLCanvasModel').tag(sync=True)

src/mpl_widget.ts

+28-28
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
238238
const url_creator = window.URL || window.webkitURL;
239239

240240
const buffer = new Uint8Array(
241-
ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0]
241+
ArrayBuffer.isView(buffers[0]) ? buffers[0].buffer : buffers[0],
242242
);
243243
const blob = new Blob([buffer], { type: 'image/png' });
244244
const image_url = url_creator.createObjectURL(blob);
@@ -277,7 +277,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
277277
} catch (e) {
278278
console.log(
279279
"No handler for the '" + msg_type + "' message type: ",
280-
msg
280+
msg,
281281
);
282282
return;
283283
}
@@ -330,7 +330,7 @@ export class MPLCanvasModel extends DOMWidgetModel {
330330
0,
331331
0,
332332
this.offscreen_canvas.width,
333-
this.offscreen_canvas.height
333+
this.offscreen_canvas.height,
334334
);
335335
}
336336

@@ -412,23 +412,23 @@ export class MPLCanvasView extends DOMWidgetView {
412412
model_events() {
413413
this.model.on(
414414
'change:header_visible',
415-
this._update_header_visible.bind(this)
415+
this._update_header_visible.bind(this),
416416
);
417417
this.model.on(
418418
'change:footer_visible',
419-
this._update_footer_visible.bind(this)
419+
this._update_footer_visible.bind(this),
420420
);
421421
this.model.on(
422422
'change:toolbar_visible',
423-
this._update_toolbar_visible.bind(this)
423+
this._update_toolbar_visible.bind(this),
424424
);
425425
this.model.on(
426426
'change:toolbar_position',
427-
this._update_toolbar_position.bind(this)
427+
this._update_toolbar_position.bind(this),
428428
);
429429
this.model.on(
430430
'change:_figure_label',
431-
this._update_figure_label.bind(this)
431+
this._update_figure_label.bind(this),
432432
);
433433
this.model.on('change:_message', this._update_message.bind(this));
434434
this.model.on('change:_cursor', this._update_cursor.bind(this));
@@ -461,7 +461,7 @@ export class MPLCanvasView extends DOMWidgetView {
461461
this.header.classList.add(
462462
'jupyter-widgets',
463463
'widget-label',
464-
'jupyter-matplotlib-header'
464+
'jupyter-matplotlib-header',
465465
);
466466
this._update_header_visible();
467467
this._update_figure_label();
@@ -476,7 +476,7 @@ export class MPLCanvasView extends DOMWidgetView {
476476
const canvas_container = document.createElement('div');
477477
canvas_container.classList.add(
478478
'jupyter-widgets',
479-
'jupyter-matplotlib-canvas-container'
479+
'jupyter-matplotlib-canvas-container',
480480
);
481481
this.figure.appendChild(canvas_container);
482482

@@ -485,7 +485,7 @@ export class MPLCanvasView extends DOMWidgetView {
485485
canvas_div.style.clear = 'both';
486486
canvas_div.classList.add(
487487
'jupyter-widgets',
488-
'jupyter-matplotlib-canvas-div'
488+
'jupyter-matplotlib-canvas-div',
489489
);
490490

491491
canvas_div.addEventListener('keydown', this.key_event('key_press'));
@@ -514,35 +514,35 @@ export class MPLCanvasView extends DOMWidgetView {
514514
top_canvas.addEventListener('dblclick', this.mouse_event('dblclick'));
515515
top_canvas.addEventListener(
516516
'mousedown',
517-
this.mouse_event('button_press')
517+
this.mouse_event('button_press'),
518518
);
519519
top_canvas.addEventListener(
520520
'mouseup',
521-
this.mouse_event('button_release')
521+
this.mouse_event('button_release'),
522522
);
523523
top_canvas.addEventListener(
524524
'mousemove',
525525
throttle(
526526
this.mouse_event('motion_notify'),
527-
this.model.get('pan_zoom_throttle')
528-
)
527+
this.model.get('pan_zoom_throttle'),
528+
),
529529
);
530530

531531
top_canvas.addEventListener(
532532
'mouseenter',
533-
this.mouse_event('figure_enter')
533+
this.mouse_event('figure_enter'),
534534
);
535535
top_canvas.addEventListener(
536536
'mouseleave',
537-
this.mouse_event('figure_leave')
537+
this.mouse_event('figure_leave'),
538538
);
539539

540540
top_canvas.addEventListener(
541541
'wheel',
542542
throttle(
543543
this.mouse_event('scroll'),
544-
this.model.get('pan_zoom_throttle')
545-
)
544+
this.model.get('pan_zoom_throttle'),
545+
),
546546
);
547547
top_canvas.addEventListener('wheel', (event: any) => {
548548
if (this.model.get('capture_scroll')) {
@@ -568,7 +568,7 @@ export class MPLCanvasView extends DOMWidgetView {
568568

569569
async _init_toolbar() {
570570
this.toolbar_view = (await this.create_child_view(
571-
this.model.get('toolbar')
571+
this.model.get('toolbar'),
572572
)) as ToolbarView;
573573

574574
this.figure.appendChild(this.toolbar_view.el);
@@ -595,7 +595,7 @@ export class MPLCanvasView extends DOMWidgetView {
595595
0,
596596
0,
597597
this.canvas.width,
598-
this.canvas.height
598+
this.canvas.height,
599599
);
600600
} else {
601601
this.context.drawImage(this.model.offscreen_canvas, 0, 0);
@@ -605,7 +605,7 @@ export class MPLCanvasView extends DOMWidgetView {
605605
0,
606606
0,
607607
this.top_canvas.width,
608-
this.top_canvas.height
608+
this.top_canvas.height,
609609
);
610610

611611
// Draw rubberband
@@ -624,7 +624,7 @@ export class MPLCanvasView extends DOMWidgetView {
624624
this.model.get('_rubberband_x'),
625625
this.model.get('_rubberband_y'),
626626
this.model.get('_rubberband_width'),
627-
this.model.get('_rubberband_height')
627+
this.model.get('_rubberband_height'),
628628
);
629629
}
630630

@@ -636,7 +636,7 @@ export class MPLCanvasView extends DOMWidgetView {
636636
this.top_canvas.height - this.resize_handle_size,
637637
// Stop
638638
this.top_canvas.width,
639-
this.top_canvas.height
639+
this.top_canvas.height,
640640
);
641641
gradient.addColorStop(0, 'white');
642642
gradient.addColorStop(1, 'black');
@@ -648,15 +648,15 @@ export class MPLCanvasView extends DOMWidgetView {
648648
this.top_context.beginPath();
649649
this.top_context.moveTo(
650650
this.top_canvas.width,
651-
this.top_canvas.height
651+
this.top_canvas.height,
652652
);
653653
this.top_context.lineTo(
654654
this.top_canvas.width,
655-
this.top_canvas.height - this.resize_handle_size
655+
this.top_canvas.height - this.resize_handle_size,
656656
);
657657
this.top_context.lineTo(
658658
this.top_canvas.width - this.resize_handle_size,
659-
this.top_canvas.height
659+
this.top_canvas.height,
660660
);
661661
this.top_context.closePath();
662662
this.top_context.fill();
@@ -675,7 +675,7 @@ export class MPLCanvasView extends DOMWidgetView {
675675
this.footer.classList.add(
676676
'jupyter-widgets',
677677
'widget-label',
678-
'jupyter-matplotlib-footer'
678+
'jupyter-matplotlib-footer',
679679
);
680680
this._update_footer_visible();
681681
this._update_message();

src/plugin.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export default jupyterMatplotlibPlugin;
2727
*/
2828
function activateWidgetExtension(
2929
app: Application<Widget>,
30-
registry: IJupyterWidgetRegistry
30+
registry: IJupyterWidgetRegistry,
3131
): void {
3232
registry.registerWidget({
3333
name: MODULE_NAME,

src/toolbar_widget.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ export class ToolbarView extends DOMWidgetView {
3838
'jupyter-widgets',
3939
'jupyter-matplotlib-toolbar',
4040
'widget-container',
41-
'widget-box'
41+
'widget-box',
4242
);
4343

4444
// Fade-in/fade-out mode by default, the figure will decide
@@ -69,14 +69,14 @@ export class ToolbarView extends DOMWidgetView {
6969
button.classList.add(
7070
'jupyter-matplotlib-button',
7171
'jupyter-widgets',
72-
'jupyter-button'
72+
'jupyter-button',
7373
);
7474
button.setAttribute('href', '#');
7575
button.setAttribute('title', tooltip);
7676
button.style.outline = 'none';
7777
button.addEventListener(
7878
'click',
79-
this.toolbar_button_onclick(method_name)
79+
this.toolbar_button_onclick(method_name),
8080
);
8181

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

164164
set_visibility(
165-
value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean
165+
value: 'visible' | 'hidden' | 'fade-in-fade-out' | boolean,
166166
): void {
167167
// For backward compatibility with the old API
168168
if (typeof value === 'boolean') {
@@ -247,7 +247,7 @@ export class ToolbarView extends DOMWidgetView {
247247
this.model.on_some_change(
248248
['button_style', '_current_action'],
249249
this.set_buttons_style,
250-
this
250+
this,
251251
);
252252
}
253253
}

ui-tests/tests/ipympl.test.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const filterUpdateNotebooks = (item) => {
1717

1818
const testCellOutputs = async (
1919
page: IJupyterLabPageFixture,
20-
tmpPath: string
20+
tmpPath: string,
2121
) => {
2222
const paths = klaw(path.resolve(__dirname, './notebooks'), {
2323
filter: (item) => !filterUpdateNotebooks(item),
@@ -53,7 +53,7 @@ const testCellOutputs = async (
5353
for (let c = 0; c < numCellImages; ++c) {
5454
expect(results[c]).toMatchSnapshot(
5555
getCaptureImageName(notebook, c),
56-
{ threshold: 0.4 }
56+
{ threshold: 0.4 },
5757
);
5858
}
5959

@@ -96,7 +96,7 @@ const testUpdates = async (page: IJupyterLabPageFixture, tmpPath: string) => {
9696
for (let i = 0; i < cellCount; i++) {
9797
expect(results[i]).toMatchSnapshot(
9898
getCaptureImageName(notebook, i),
99-
{ threshold: 0.4 }
99+
{ threshold: 0.4 },
100100
);
101101
}
102102

@@ -108,7 +108,7 @@ test.describe('ipympl Visual Regression', () => {
108108
test.beforeEach(async ({ page, tmpPath }) => {
109109
await page.contents.uploadDirectory(
110110
path.resolve(__dirname, './notebooks'),
111-
tmpPath
111+
tmpPath,
112112
);
113113
await page.filebrowser.openDirectory(tmpPath);
114114
});

0 commit comments

Comments
 (0)