Skip to content

Commit

Permalink
Work around jpype convert limitation
Browse files Browse the repository at this point in the history
Without this change, the ConvertService doesn't know what to do when
it's given a python type

Thanks @gselzer
  • Loading branch information
hinerm authored and ctrueden committed May 19, 2023
1 parent 5cbc170 commit 85f0d5c
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/napari_imagej/types/converters/images.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@
from napari.layers import Image
from napari.utils.colormaps import Colormap
from numpy import ones
from scyjava import Priority
from scyjava import isjava, Priority

from napari_imagej.java import ij, jc
from napari_imagej.types.converters import java_to_py_converter, py_to_java_converter


@java_to_py_converter(
predicate=lambda obj: ij().convert().supports(obj, jc.DatasetView),
predicate=lambda obj: isjava(obj) and ij().convert().supports(obj, jc.DatasetView),
priority=Priority.VERY_HIGH + 1,
)
def _dataset_view_to_image(image: Any) -> Image:
Expand All @@ -37,7 +37,7 @@ def _dataset_view_to_image(image: Any) -> Image:


def _can_convert_img_plus(obj: Any):
can_convert = ij().convert().supports(obj, jc.ImgPlus)
can_convert = isjava(obj) and ij().convert().supports(obj, jc.ImgPlus)
has_axis = _has_axis(obj)
return can_convert and has_axis

Expand Down

0 comments on commit 85f0d5c

Please sign in to comment.