Skip to content
Advertisement

Tag: annotations

Mark selected pixels in an image with circle

I have an image, and I have to mark pixels whose intensity value is less than threshold value with a circle. How do you do this, Scatter plot wont work as we need two input. Help in this regard is appreciated. Answer You can use the Circle patch function from matplotlib (see doc here). Here is an example inspired by

Python: use Type Hints together with Annotations

In Python, we all know Type hints, which became available from 2015: and we also know Function Annotations, in particular here I am referring to textual annotations like: But is it possible to use Type Hints together with a textual function annotation? For example: This last one throws an error. I cannot seem to find any source in PEP or

Optional[Type[Foo]] raises TypeError in Python 3.5.2

This code: will raise TypeError on 3.5.2: whereas it runs fine on 3.6. Same problem if I spell out Optional as Union[None, Type[Foo]]. Is there any workaround for 3.5.2, while still accurately annotating the return type? Answer This is a bug in Python 3.5.2. Optional[cls] is a wrapper for Union[cls, type(None)], which uses __subclasses__() to establish whether one class is

Advertisement