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

Return type annotations for vedo functions #1089

Open
jo-mueller opened this issue Apr 8, 2024 · 4 comments
Open

Return type annotations for vedo functions #1089

jo-mueller opened this issue Apr 8, 2024 · 4 comments

Comments

@jo-mueller
Copy link
Collaborator

Hi @marcomusy ,

long time no hear :) I'm still low-key working on the idea I pitched to you last year August at the NEUBIAS conference in Dresden, which basically revolves around harvesting all vedo functions to be automatically wrapped for usage in Napari. This would be awesome because

  • no wrapper functions would be needed to maintained
  • all GUIs automatically created from function definitions alone

I have some sort of a working version, but what's making my life a bit hard is the lack of type annotations in vedo, specifically return type annotations. For starters, I wanted to limit myself to harvesting functions that take a mesh as input and return another mesh (as opposed to functions that color a mesh, or measure something on the vertices, etc).

What would make my life much easier, would be, instrad of vedo mesh functions being defined like this

def decimate(self, parameters):
  ...
  return mesh

but rather like this:

from typing import Self
def decimate(self, parameters) -> Self:
  ...
  return mesh

The return type annotation in the latter case could be used to mark functions that do return meshes and nothing else. Similarly, functions consuming a mesh and returning a pointcloud could be annotated like this:

def points_from_mesh(mesh, parameters) -> vedo.Points:
  ....
  return points

Would you be (in principle) be open to such changes? I would take the PR writing to myself, of course :)

@marcomusy
Copy link
Owner

Hi Johannes! sure i'm completely open to the idea.
Note that in the master version I had already added annotations but I didn't of from typing import Selfso feel free to make the changes you think are appropriate!

@jo-mueller
Copy link
Collaborator Author

jo-mueller commented Apr 9, 2024

HI @marcomusy, thanks for the hint, I totally hadn't seen it, cool work! I think the current return type annotations ("Mesh", "Points", etc) are totally sufficient for what I am trying to do :) I'll close this issue then :)

Also, did you just give me some sort of semi-maintainer status? 😲 (I cannot see my level of permissions)

@marcomusy
Copy link
Owner

Fantastic. I will probably update what I did with the Self thing you mentioned which seems the right thing to do..

Yes I added you to Collaborators so you can push directly any changes (i think you are a vedo expert by now!)

@jo-mueller
Copy link
Collaborator Author

@marcomusy thanks! Will proceed with a few type annotations next then. Napari has a few issues deciphering whether some inputs are supposed to be floats, integers, etc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants