Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List<Shape> Module parameter interpreted as napari layer #210

Open
gselzer opened this issue May 4, 2023 · 3 comments
Open

List<Shape> Module parameter interpreted as napari layer #210

gselzer opened this issue May 4, 2023 · 3 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@gselzer
Copy link
Collaborator

gselzer commented May 4, 2023

Trying to run the op morphology.dilate(img "out"?, img "in1", list "in2", boolean "isFull"?) -> (img "out"?) yields a widget that provides a layer selector for in2.

image

Unfortunately, this will probably be a tricky issue to fix, because we are dealing with java generics, and we already have a complicated widget for dealing with Shapes.

@gselzer gselzer added the bug Something isn't working label May 4, 2023
@gselzer gselzer added this to the 0.2.0 milestone May 4, 2023
@gselzer gselzer self-assigned this May 4, 2023
@ctrueden
Copy link
Member

ctrueden commented May 4, 2023

I suggest to encapsulate all the various places you call ModuleItem.getType() throughout the codebase into a single utility function that computes the Pythonic type hint from the ModuleItem. Then, you can refactor to call getGenericType() instead of (or in addition to) getType(), and have some case logic around "easy" cases like ParameterizedType of collections. And later we could even push such logic up into scyjava.

@gselzer
Copy link
Collaborator Author

gselzer commented May 5, 2023

I suggest to encapsulate all the various places you call ModuleItem.getType() throughout the codebase into a single utility function that computes the Pythonic type hint from the ModuleItem.

Yup, the function is type_hint_for

@gselzer
Copy link
Collaborator Author

gselzer commented Jun 1, 2023

I looked a little more into why this is failing. Here's what's happening:

  1. The OpListing reduces ListDilate's parameters down to their raw types, via the default type reducer. Therefore, the List<Shape> parameter becomes a List parameter
  2. napari-imagej, in the attempt to find a suitable type hint, finds that ImageDisplays can be converted to a List, and recommends the corresponding python type, a napari Image layer, as the input type.

As a result, I think that the OpSearcher needs to have a bit more intelligence in creating the OpListings, especially w.r.t. type parameters. Iirc this change was made to avoid the distinction between, for example, Img<IntegerType> and Img<RealType> showing up as two separate signatures, and I still think that's nice.

We could also make some changes in napari-imagej to solve this, but I'm guessing Fiji will see similar issues, so maybe we should just fix it in Ops?

@gselzer gselzer modified the milestones: 0.2.0, 0.3.0 Jun 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants