Compare commits
7 Commits
572c32ad1b
...
7b9f9f4012
Author | SHA1 | Date | |
---|---|---|---|
7b9f9f4012 | |||
04f5eb23cc | |||
f587fe5341 | |||
8d4a6a8867 | |||
bbdf6b877d | |||
ed649dbd1a | |||
33a1e2eb85 |
@ -1068,22 +1068,20 @@ class ILibrary(ILibraryView, MutableMapping[str, 'Pattern'], metaclass=ABCMeta):
|
|||||||
Returns:
|
Returns:
|
||||||
A set containing the names of all deleted patterns
|
A set containing the names of all deleted patterns
|
||||||
"""
|
"""
|
||||||
parent_graph = self.parent_graph()
|
|
||||||
empty = {name for name, pat in self.items() if pat.is_empty()}
|
|
||||||
trimmed = set()
|
trimmed = set()
|
||||||
while empty:
|
while empty := {name for name, pat in self.items() if pat.is_empty()}:
|
||||||
parents = set()
|
|
||||||
for name in empty:
|
for name in empty:
|
||||||
del self[name]
|
del self[name]
|
||||||
for parent in parent_graph[name]:
|
|
||||||
del self[parent].refs[name]
|
for pat in self.values():
|
||||||
parents |= parent_graph[name]
|
for name in empty:
|
||||||
|
# Second pass to skip looking at refs in empty patterns
|
||||||
|
if name in pat.refs:
|
||||||
|
del pat.refs[name]
|
||||||
|
|
||||||
trimmed |= empty
|
trimmed |= empty
|
||||||
if not repeat:
|
if not repeat:
|
||||||
break
|
break
|
||||||
|
|
||||||
empty = {parent for parent in parents if self[parent].is_empty()}
|
|
||||||
return trimmed
|
return trimmed
|
||||||
|
|
||||||
def delete(
|
def delete(
|
||||||
|
@ -20,7 +20,7 @@ class Polygon(Shape):
|
|||||||
A polygon, consisting of a bunch of vertices (Nx2 ndarray) which specify an
|
A polygon, consisting of a bunch of vertices (Nx2 ndarray) which specify an
|
||||||
implicitly-closed boundary, and an offset.
|
implicitly-closed boundary, and an offset.
|
||||||
|
|
||||||
Note that the setter for `Polygon.vertices` creates a copy of the
|
Note that the setter for `Polygon.vertices` may creates a copy of the
|
||||||
passed vertex coordinates.
|
passed vertex coordinates.
|
||||||
|
|
||||||
A `normalized_form(...)` is available, but can be quite slow with lots of vertices.
|
A `normalized_form(...)` is available, but can be quite slow with lots of vertices.
|
||||||
@ -379,9 +379,8 @@ class Polygon(Shape):
|
|||||||
def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
|
def normalized_form(self, norm_value: float) -> normalized_shape_tuple:
|
||||||
# Note: this function is going to be pretty slow for many-vertexed polygons, relative to
|
# Note: this function is going to be pretty slow for many-vertexed polygons, relative to
|
||||||
# other shapes
|
# other shapes
|
||||||
meanv = self.vertices.mean(axis=0)
|
offset = self.vertices.mean(axis=0) + self.offset
|
||||||
zeroed_vertices = self.vertices - meanv
|
zeroed_vertices = self.vertices - offset
|
||||||
offset = meanv + self.offset
|
|
||||||
|
|
||||||
scale = zeroed_vertices.std()
|
scale = zeroed_vertices.std()
|
||||||
normed_vertices = zeroed_vertices / scale
|
normed_vertices = zeroed_vertices / scale
|
||||||
|
Loading…
Reference in New Issue
Block a user