Skip to content

Commit

Permalink
Linting—for real this time?
Browse files Browse the repository at this point in the history
  • Loading branch information
psobolewskiPhD committed Sep 16, 2021
1 parent 63f564d commit ff81a0c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 31 deletions.
19 changes: 6 additions & 13 deletions napari_aicsimageio/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,14 @@
# -*- coding: utf-8 -*-

from functools import partial
from typing import Any, Callable, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Optional

import napari
from napari.types import LayerData, ReaderFunction, PathLike
import xarray as xr
from aicsimageio import AICSImage, exceptions, types
from aicsimageio import AICSImage, exceptions
from aicsimageio.dimensions import DimensionNames
from qtpy.QtWidgets import QListWidget

###############################################################################

LayerData = Union[Tuple[types.ArrayLike, Dict[str, Any], str]]
PathLike = Union[str, List[str]]
ReaderFunction = Callable[[PathLike], List[LayerData]]

###############################################################################
from qtpy.QtWidgets import QListWidget, QListWidgetItem


def _get_full_image_data(img: AICSImage, in_memory: bool) -> Optional[xr.DataArray]:
Expand Down Expand Up @@ -54,7 +47,7 @@ def _get_scenes(img: AICSImage, in_memory: bool) -> None:
viewer.window.add_dock_widget(list_widget, area="right", name="Scene Selector")

# Function to create image layer from a scene selected in the list widget
def open_scene(item) -> None:
def open_scene(item: QListWidgetItem) -> None:
scene_text = item.text()

# Use scene indexes to cover for duplicate names
Expand Down Expand Up @@ -85,7 +78,7 @@ def open_scene(item) -> None:


# Function to get Metadata to provide with data
def _get_meta(data, img) -> Dict[str, Any]:
def _get_meta(data: xr.DataArray, img: AICSImage) -> Dict[str, Any]:
meta = {}
if DimensionNames.Channel in data.dims:

Expand Down
38 changes: 20 additions & 18 deletions napari_aicsimageio/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@
# -*- coding: utf-8 -*-

from pathlib import Path
from typing import Any, Dict, Tuple
from typing import Any, Callable, Dict, Tuple

import dask.array as da
import napari
import numpy as np
import pytest

Expand Down Expand Up @@ -115,7 +116,7 @@ def test_reader(
],
)
def test_for_multiscene_widget(
make_napari_viewer,
make_napari_viewer: Callable[..., napari.Viewer],
resources_dir: Path,
filename: str,
in_memory: bool,
Expand All @@ -135,19 +136,20 @@ def test_for_multiscene_widget(
# Get reader
reader = core.get_reader(path, in_memory)

# Call reader on path
reader(path)

# Check for list widget
assert len(viewer.window._dock_widgets) == nr_widgets

if len(viewer.window._dock_widgets) != 0:
assert list(viewer.window._dock_widgets.keys())[0] == "Scene Selector"
viewer.window._dock_widgets["Scene Selector"].widget().setCurrentRow(1)
data = viewer.layers[0].data
assert isinstance(data.data, expected_dtype) # type: ignore
assert data.shape == expected_shape # type: ignore
else:
data, meta, _ = reader(path)[0]
assert isinstance(data, expected_dtype) # type: ignore
assert data.shape == expected_shape # type: ignore
if reader is not None:
# Call reader on path
reader(path)

# Check for list widget
assert len(viewer.window._dock_widgets) == nr_widgets

if len(viewer.window._dock_widgets) != 0:
assert list(viewer.window._dock_widgets.keys())[0] == "Scene Selector"
viewer.window._dock_widgets["Scene Selector"].widget().setCurrentRow(1)
data = viewer.layers[0].data
assert isinstance(data.data, expected_dtype) # type: ignore
assert data.shape == expected_shape # type: ignore
else:
data, meta, _ = reader(path)[0]
assert isinstance(data, expected_dtype) # type: ignore
assert data.shape == expected_shape # type: ignore

0 comments on commit ff81a0c

Please sign in to comment.