CsatiZoltan / GrainSegmentation

Identification of individual grains in microscopic images
GNU General Public License v3.0
6 stars 3 forks source link

Are empty __init__.py files needed? #5

Closed CsatiZoltan closed 4 years ago

yxdragon commented 4 years ago

init.py means it is a python package. In python2, you can not import successfully if there is no init. In python3, it seems ok, but almost any repo also has one.

and the init file has some other suage, such as all, we use np.xxxx, but np is not a model, it is a package, and how can we use a package name to access the method below?

in imagepy, the init file has a specific usage, if there are many plugins in this package, we define a field: catlog = [xxx, xxx, xxx] to determin the order to show in the ui.

yxdragon commented 4 years ago

the find_boundaries is in imagepy. here

CsatiZoltan commented 4 years ago

Understood, then I keep the __init__.py files. I know that find_boundaries is in ImagePy. However, I want other users to be able to use as many functionalities as possible without needing ImagePy. That is why I keep the _find_grainboundaries function in the GrainSegmentation class. https://github.com/CsatiZoltan/GrainSegmentation/blob/2f26456e839fb12ef3ccbecb5584a0fd805284fa/src/grain_segmentation.py#L159

yxdragon commented 4 years ago

“I want other users to be able to use as many functionalities as possible without needing ImagePy” Yes, I agree it, many imagej's plugin can only be used in ij, so they build a powerful macros. But I do not think macros and headerless is a good way. We should based a general structure such as numpy, pandas, or shapely to write the algorithms.

And I find ImagePy is a little heavy for some usage. So I try to split the ui widgets from imagepy to a new repo. sciwx. As a pure and blank framework, which can load and add tools more flexiable. (a little like matplotlib or napari)

we can use it like this:

class MyTool(Tool):
    def __init__: ...
      ...
canvas = Canvas()
canvas.add_tool(MyTool())
canvas.add_tool(MyTool2())
canvas.add_filter(xxx)
...
canvas.set_image(ndarray)
canvas.show()
CsatiZoltan commented 4 years ago

@yxdragon Let's move the general topics to the Gitter room.