Add support of holes to contours generation#335
Add support of holes to contours generation#335sovrasov merged 20 commits intoopen-edge-platform:masterfrom
Conversation
ea673c9 to
8094ff5
Compare
| self.shape = shape | ||
| self.label = label | ||
| self.probability = probability | ||
| self.excluded_shapes = excluded_shapes |
There was a problem hiding this comment.
For self.shape and self.excluded_shapes, I would suggest to force the type to be np.ndarray or list[tuple[int, int]], but not both. Otherwise clients who consume contour.shape have to support both types, which isn't great.
Note: this is different from the class constructor parameter, which is instead an input interface. There, supporting more types is helpful for the clients. This principle is somehow formulated in the Postel law.
There was a problem hiding this comment.
I personally prefer garbage in garbage out principle: the system should not help clients if they don't understand that they're doing. Looks like to much hustle for a wrong type annotation, which we can not just drop. Added dummy conversion to numpy.
There was a problem hiding this comment.
Thanks for fixing it!
the system should not help clients if they don't understand that they're doing
I don't fully understand this part; the type hints come from the library and help the client build robust code through static type checking (eg mypy). If the types are imprecise or loose, the client is forced to implement extra logic or suppress the warnings.
What does this PR do?
Adds support of representing non simply connected sets with contours: main contour describes the outer border of the set and "holes" are represented as child contours lying inside the space bounded by the outer one.
Before submitting