Skip to content

Commit

Permalink
npe2 migration
Browse files Browse the repository at this point in the history
  • Loading branch information
Jonas Windhager committed Jun 1, 2022
1 parent e7b1c38 commit 4ca63df
Show file tree
Hide file tree
Showing 26 changed files with 99 additions and 133 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,12 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -U setuptools setuptools_scm wheel twine
pip install -U setuptools setuptools_scm wheel twine build
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.TWINE_API_KEY }}
run: |
git tag
python setup.py sdist bdist_wheel
python -m build .
twine upload dist/*
2 changes: 1 addition & 1 deletion LICENSE.md → LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2021 Jonas Windhager
Copyright (c) 2021 University of Zurich

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
2 changes: 1 addition & 1 deletion MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
include CHANGELOG.md
include CONTRIBUTING.md
include LICENSE.md
include LICENSE
include README.md
include requirements.txt

Expand Down
21 changes: 6 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
# napari-imc

<a href="https://pypi.org/project/napari-imc/">
<img src="https://img.shields.io/pypi/v/napari-imc" alt="PyPI" />
</a>
<a href="https://github.com/BodenmillerGroup/napari-imc/blob/main/LICENSE.md">
<img src="https://img.shields.io/pypi/l/napari-imc" alt="License" />
</a>
<a href="https://www.python.org/">
<img src="https://img.shields.io/pypi/pyversions/napari-imc" alt="Python" />
</a>
<a href="https://github.com/BodenmillerGroup/napari-imc/issues">
<img src="https://img.shields.io/github/issues/BodenmillerGroup/napari-imc" alt="Issues" />
</a>
<a href="https://github.com/BodenmillerGroup/napari-imc/pulls">
<img src="https://img.shields.io/github/issues-pr/BodenmillerGroup/napari-imc" alt="Pull requests" />
</a>
[![napari hub](https://img.shields.io/endpoint?url=https://api.napari-hub.org/shields/napari-imc)](https://napari-hub.org/plugins/napari-imc)
[![PyPI](https://img.shields.io/pypi/v/napari-imc.svg?color=green)](https://pypi.org/project/napari-imc)
[![License](https://img.shields.io/pypi/l/napari-imc.svg?color=green)](https://github.com/BodenmillerGroup/napari-imc/raw/main/LICENSE)
[![Python Version](https://img.shields.io/pypi/pyversions/napari-imc.svg?color=green)](https://python.org)
[![Issues](https://img.shields.io/github/issues/BodenmillerGroup/napari-imc)](https://github.com/BodenmillerGroup/napari-imc/issues)
[![Pull requests](https://img.shields.io/github/issues-pr/BodenmillerGroup/napari-imc)](https://github.com/BodenmillerGroup/napari-imc/pulls)

Imaging Mass Cytometry (IMC) file type support for napari

Expand Down
13 changes: 4 additions & 9 deletions napari_imc/__init__.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
from ._reader import napari_get_reader
from .imc_widget import IMCWidget

try:
from ._version import version as __version__
except ImportError:
__version__ = "unknown"

from .imc_widget import IMCWidget
from ._reader import napari_get_reader
from ._dock_widget import napari_experimental_provide_dock_widget

__all__ = [
"IMCWidget",
"napari_get_reader",
"napari_experimental_provide_dock_widget",
]
__all__ = ["IMCWidget", "napari_get_reader"]
12 changes: 0 additions & 12 deletions napari_imc/_dock_widget.py

This file was deleted.

16 changes: 5 additions & 11 deletions napari_imc/_reader.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
from napari import Viewer
from napari_plugin_engine import napari_hook_implementation
from typing import Optional

from .imc_widget import IMCWidget
from napari.viewer import Viewer

from .imc_controller import IMCController
from .imc_widget import IMCWidget


@napari_hook_implementation
def napari_get_reader(path):
if isinstance(path, list):
if any(not IMCController.is_imc_file(p) for p in path):
Expand Down Expand Up @@ -46,15 +45,10 @@ def _get_viewer() -> Optional[Viewer]:

def _get_imc_widget(viewer: Viewer) -> IMCWidget:
# TODO https://github.com/napari/napari/issues/2203
dock_widget = viewer.window._dock_widgets.get(IMCWidget.FULL_NAME)
dock_widget = viewer.window._dock_widgets.get("Imaging Mass Cytometry")
if dock_widget is not None:
imc_widget = dock_widget.widget()
else:
imc_widget = IMCWidget(napari_viewer=viewer)
viewer.window.add_dock_widget(
imc_widget,
name=IMCWidget.FULL_NAME,
area=IMCWidget.AREA,
allowed_areas=IMCWidget.ALLOWED_AREAS,
)
viewer.window.add_dock_widget(imc_widget, name="Imaging Mass Cytometry")
return imc_widget
8 changes: 4 additions & 4 deletions napari_imc/imc_controller.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import numpy as np
from pathlib import Path
from typing import TYPE_CHECKING, Any, List, Optional, Sequence, Tuple, Type, Union

import numpy as np
from napari import Viewer
from napari.layers import Image
from pathlib import Path
from typing import Any, List, Optional, Sequence, Tuple, Type, TYPE_CHECKING, Union

from .io import McdFileReader, TxtFileReader
from .io.base import FileReaderBase
from .models import (
ChannelModel,
IMCFileModel,
IMCFileAcquisitionModel,
IMCFileModel,
IMCFilePanoramaModel,
)
from .models.base import IMCFileTreeItem
Expand Down
16 changes: 4 additions & 12 deletions napari_imc/imc_widget.py
Original file line number Diff line number Diff line change
@@ -1,20 +1,17 @@
from typing import Optional

from napari import Viewer
from qtpy.QtCore import (
Qt,
QItemSelection,
QItemSelectionModel,
QModelIndex,
QSortFilterProxyModel,
Qt,
)
from qtpy.QtWidgets import QSizePolicy, QSplitter, QStackedWidget, QVBoxLayout, QWidget
from typing import Optional

from .imc_controller import IMCController
from .models import (
IMCFileModel,
IMCFileAcquisitionModel,
IMCFilePanoramaModel,
)
from .models import IMCFileAcquisitionModel, IMCFileModel, IMCFilePanoramaModel
from .widgets import (
ChannelControlsWidget,
ChannelTableModel,
Expand All @@ -25,11 +22,6 @@


class IMCWidget(QWidget):
NAME = "Imaging Mass Cytometry"
FULL_NAME = "Imaging Mass Cytometry"
AREA = "right"
ALLOWED_AREAS = ["left", "right"]

def __init__(self, napari_viewer: Viewer, parent: Optional[QWidget] = None) -> None:
super(IMCWidget, self).__init__(parent)
self._controller = IMCController(napari_viewer, self)
Expand Down
6 changes: 1 addition & 5 deletions napari_imc/io/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,4 @@
from .mcd import McdFileReader
from .txt import TxtFileReader

__all__ = [
"ImaxtFileReader",
"McdFileReader",
"TxtFileReader",
]
__all__ = ["ImaxtFileReader", "McdFileReader", "TxtFileReader"]
10 changes: 3 additions & 7 deletions napari_imc/io/base.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import numpy as np

from abc import abstractmethod
from pathlib import Path
from typing import List, NamedTuple, Tuple, Union

from ..models import (
IMCFileModel,
IMCFileAcquisitionModel,
IMCFilePanoramaModel,
)
import numpy as np

from ..models import IMCFileAcquisitionModel, IMCFileModel, IMCFilePanoramaModel
from ..models.base import IMCFileTreeItem


Expand Down
14 changes: 5 additions & 9 deletions napari_imc/io/imaxt.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,14 @@
import numpy as np

from imageio import imread
from pathlib import Path
from typing import List, Optional, Tuple, Union

import numpy as np
from imageio import imread

from ..io.base import FileReaderBase, ImageDimensions
from ..models import (
IMCFileModel,
IMCFileAcquisitionModel,
IMCFilePanoramaModel,
)
from ..models import IMCFileAcquisitionModel, IMCFileModel, IMCFilePanoramaModel

try:
import zarr
import zarr # type: ignore
except Exception:
zarr = None

Expand Down
12 changes: 4 additions & 8 deletions napari_imc/io/mcd.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import numpy as np

from pathlib import Path
from readimc import MCDFile
from typing import List, Optional, Tuple, Union

import numpy as np
from readimc import MCDFile

from ..io.base import FileReaderBase, ImageDimensions
from ..models import (
IMCFileModel,
IMCFileAcquisitionModel,
IMCFilePanoramaModel,
)
from ..models import IMCFileAcquisitionModel, IMCFileModel, IMCFilePanoramaModel


class McdFileReader(FileReaderBase):
Expand Down
12 changes: 4 additions & 8 deletions napari_imc/io/txt.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import numpy as np
import re

from pathlib import Path
from readimc import TXTFile
from typing import List, Optional, Tuple, Union

import numpy as np
from readimc import TXTFile

from ..io.base import FileReaderBase, ImageDimensions
from ..models import (
IMCFileModel,
IMCFileAcquisitionModel,
IMCFilePanoramaModel,
)
from ..models import IMCFileAcquisitionModel, IMCFileModel, IMCFilePanoramaModel


class TxtFileReader(FileReaderBase):
Expand Down
2 changes: 1 addition & 1 deletion napari_imc/models/channel.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Dict, List, Optional, Tuple, TYPE_CHECKING
from typing import TYPE_CHECKING, Dict, List, Optional, Tuple

from napari.layers import Image
from napari.utils import Colormap
Expand Down
2 changes: 1 addition & 1 deletion napari_imc/models/imc_file_acquisition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Any, List, Optional, Sequence, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, List, Optional, Sequence

from .base import IMCFileTreeItem, ModelBase

Expand Down
3 changes: 2 additions & 1 deletion napari_imc/models/imc_file_panorama.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import TYPE_CHECKING, Any, List, Optional

from napari.layers import Image
from typing import Any, List, Optional, TYPE_CHECKING

from .base import IMCFileTreeItem, ModelBase

Expand Down
17 changes: 17 additions & 0 deletions napari_imc/napari.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: napari-imc
schema_version: 0.1.0
contributions:
commands:
- id: napari-imc.IMCWidget
title: Create Imaging Mass Cytometry
python_name: napari_imc:IMCWidget
- id: napari-imc.get_reader
title: Read Imaging Mass Cytometry (IMC) files using readimc
python_name: napari_imc:napari_get_reader
readers:
- command: napari-imc.get_reader
filename_patterns: ["*.mcd", "*.txt"]
accepts_directories: false
widgets:
- command: napari-imc.IMCWidget
display_name: Imaging Mass Cytometry
5 changes: 3 additions & 2 deletions napari_imc/widgets/_color_picker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from qtpy.QtCore import Qt, QObject, Signal
from typing import Optional

from qtpy.QtCore import QObject, Qt, Signal
from qtpy.QtGui import QColor, qGray
from qtpy.QtWidgets import QColorDialog, QMenu, QPushButton, QWidget, QWidgetAction
from typing import Optional


class ColorPicker(QPushButton):
Expand Down
3 changes: 2 additions & 1 deletion napari_imc/widgets/channel_controls_widget.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
from typing import TYPE_CHECKING, Optional, Tuple

from napari.layers.base.base import Blending
from napari.layers.image.image import Interpolation
from qtpy.QtCore import Qt
from qtpy.QtGui import QColor
from qtpy.QtWidgets import QComboBox, QFormLayout, QSlider, QWidget
from superqt import QDoubleRangeSlider
from typing import Optional, Tuple, TYPE_CHECKING

from ._color_picker import ColorPicker

Expand Down
5 changes: 3 additions & 2 deletions napari_imc/widgets/channel_table_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from contextlib import contextmanager
from qtpy.QtCore import Qt, QAbstractTableModel, QModelIndex, QObject
from typing import Any, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Optional

from qtpy.QtCore import QAbstractTableModel, QModelIndex, QObject, Qt

if TYPE_CHECKING:
from ..imc_controller import IMCController
Expand Down
3 changes: 2 additions & 1 deletion napari_imc/widgets/channel_table_view.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Optional

from qtpy.QtCore import QModelIndex
from qtpy.QtWidgets import QTableView, QWidget
from typing import Optional


class ChannelTableView(QTableView):
Expand Down
5 changes: 3 additions & 2 deletions napari_imc/widgets/imc_file_tree_model.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from contextlib import contextmanager
from qtpy.QtCore import Qt, QAbstractItemModel, QModelIndex, QObject
from typing import Any, Optional, TYPE_CHECKING
from typing import TYPE_CHECKING, Any, Optional

from qtpy.QtCore import QAbstractItemModel, QModelIndex, QObject, Qt

from ..models.base import IMCFileTreeItem

Expand Down
5 changes: 3 additions & 2 deletions napari_imc/widgets/imc_file_tree_view.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from qtpy.QtCore import Qt, QModelIndex, QObject, QPoint, Signal
from qtpy.QtWidgets import QMenu, QStyle, QTreeView, QWidget
from typing import Optional

from qtpy.QtCore import QModelIndex, QObject, QPoint, Qt, Signal
from qtpy.QtWidgets import QMenu, QStyle, QTreeView, QWidget

from ..models import IMCFileModel


Expand Down
7 changes: 4 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
# Requirements of your napari plugin should be listed in setup.cfg
# See also: https://caremad.io/posts/2013/07/setup-vs-requirement/

napari[all]
flake8
black
-e .
black
flake8
isort
napari[all]
Loading

0 comments on commit 4ca63df

Please sign in to comment.