Skip to content

Commit

Permalink
Merge pull request #8 from ch-n/npe2_migration
Browse files Browse the repository at this point in the history
Migrated to napari plugin engine version 0.2.0
  • Loading branch information
Chris-N-K authored Mar 9, 2022
2 parents 21da60d + bde31d0 commit e70e5cf
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 39 deletions.
10 changes: 5 additions & 5 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
-e .

# development requirements
matplotlib==3.4.3
napari==0.4.12
matplotlib>=3.4.3
napari>=0.4.12
napari_plugin_engine==0.2.0
numpy==1.21.4
pytest==6.2.5
qtpy==1.11.2
numpy>=1.21.4
pytest>=6.2.5
qtpy>=1.11.2
23 changes: 14 additions & 9 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -31,18 +31,23 @@ packages = find:
python_requires = >=3.7
package_dir =
=src

# add your package requirements here
install_requires =
matplotlib
napari
napari-plugin-engine>=0.1.4
numpy
qtpy
matplotlib>=3.4.3
napari>=0.4.12
napari-plugin-engine==0.2.0
numpy>=1.21.4
pytest>=6.2.5
qtpy>=1.11.2
include_package_data = True

[options.packages.find]
where = src

[options.entry_points]
napari.plugin =
napari-time_series_plotter = napari_time_series_plotter
[options.entry_points]
napari.manifest =
napari-time_series_plotter = napari_time_series_plotter:napari.yaml

[options.package_data]
napari_time_series_plotter = napari.yaml

4 changes: 0 additions & 4 deletions src/napari_time_series_plotter/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +0,0 @@

__version__ = "0.0.2"

from ._dock_widget import napari_experimental_provide_dock_widget
21 changes: 6 additions & 15 deletions src/napari_time_series_plotter/_dock_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,20 @@
The widgets are send to the viewer through the ``napari_experimental_provide_dock_widget`` hook specification.
see: https://napari.org/docs/dev/plugins/hook_specifications.html
"""

import matplotlib
import napari.layers
from matplotlib.figure import Figure
import numpy as np
from matplotlib.backends.backend_qt5agg import FigureCanvas
# from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar

from matplotlib.figure import Figure
from napari.layers.image import Image
from napari_plugin_engine import napari_hook_implementation

import numpy as np

from qtpy.QtCore import Signal, Slot, QObject
from qtpy.QtWidgets import QDialog, QWidget, QVBoxLayout

from ._widgets import TSPCheckBox

# from matplotlib.backends.backend_qt5agg import NavigationToolbar2QT as NavigationToolbar

matplotlib.use('QT5Agg')

# Thanks a lot to Grzegorz Bokota for pointing out this solution for connecting the widgets!
Expand Down Expand Up @@ -202,8 +200,7 @@ def _update_layer_selection(self, selected_layers):
"""
self.selected_layers = selected_layers

@staticmethod
def _extract_voxel_time_series(cpos, nlayer):
def _extract_voxel_time_series(self, cpos, nlayer):
"""Method to extract the array element values along the first axis of a napari viewer layer.
First the data array is extracted from a napari image layer and the cursor position is
Expand Down Expand Up @@ -257,9 +254,3 @@ def _plot_voxel_callback(self, viewer, event):
# redraw figure
self.ax.legend(loc=1)
self.fig.canvas.draw()


@napari_hook_implementation
def napari_experimental_provide_dock_widget():
# you can return either a single widget, or a sequence of widgets
return [LayerSelector, VoxelPlotter]
8 changes: 2 additions & 6 deletions src/napari_time_series_plotter/_tests/test_dock_widget.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"""
Napari-time_series_plotter test module.
"""
from napari_time_series_plotter._dock_widget import *
import pytest
import numpy as np

from napari_time_series_plotter._dock_widget import *


# fixture for LayerSelector class tests
Expand Down Expand Up @@ -172,10 +172,6 @@ def test_extract_voxel_time_series(plotter: VoxelPlotter, monkeypatch):


# test functions
def test_napari_experimental_provide_dock_widget():
assert all([a == b for a, b in zip([LayerSelector, VoxelPlotter], napari_experimental_provide_dock_widget())])


def test_tspcheckbox():
class MockLayer:
name = 'test'
Expand Down
15 changes: 15 additions & 0 deletions src/napari_time_series_plotter/napari.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: napari-time-series-plotter
schema_version: 0.1.0
contributions:
commands:
- id: napari-time-series-plotter.LayerSelector
title: Create Layer Selector
python_name: napari_time_series_plotter._dock_widget:LayerSelector
- id: napari-time-series-plotter.VoxelPlotter
title: Create Voxel Plotter
python_name: napari_time_series_plotter._dock_widget:VoxelPlotter
widgets:
- command: napari-time-series-plotter.LayerSelector
display_name: Layer Selector
- command: napari-time-series-plotter.VoxelPlotter
display_name: Voxel Plotter

0 comments on commit e70e5cf

Please sign in to comment.