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

Add type hints for clarity #15

Open
flrs opened this issue Jul 14, 2019 · 2 comments
Open

Add type hints for clarity #15

flrs opened this issue Jul 14, 2019 · 2 comments

Comments

@flrs
Copy link
Owner

flrs commented Jul 14, 2019

We should add type hints to improve clarity regarding inputs and outputs.

@amirothman
Copy link

do you have any suggestions for which portion of the code would be most helpful if we were to add type hinting?

@flrs
Copy link
Owner Author

flrs commented Sep 12, 2020

Hi @amirothman,

I think type hinting could be useful for all blending functions. For example:

def normal(img_in, img_layer, opacity, disable_type_checks: bool = False):

Could be transformed to something like

def normal(
   img_in: np.ndarray,
   img_layer: np.ndarray,
   opacity: float,
   disable_type_checks: bool = False): 

It may be beneficial to be clearer about what kind of numpy arrays we expect, since there are some restrictions:

img_in(3-dimensional numpy array of floats (r/g/b/a) in range 0.0-255.0): Layer to be blended with image

It could be worth exploring solutions like https://github.com/ramonhagenaars/nptyping, since I don't think numpy type hints are supported by Python natively at this point.

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

No branches or pull requests

2 participants