From c7736a18c34e36496ac2ae85d9a8bdc6befdd32b Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 27 Oct 2023 21:55:17 -0700 Subject: [PATCH 1/2] add missing arc endpoints --- masque/shapes/arc.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/masque/shapes/arc.py b/masque/shapes/arc.py index 1841aed..a2631c4 100644 --- a/masque/shapes/arc.py +++ b/masque/shapes/arc.py @@ -235,14 +235,16 @@ class Arc(Shape): n_pts = numpy.ceil(2 * pi * max(self.radii) / max_arclen).astype(int) arc_lengths, thetas = get_arclens(n_pts, *a_ranges[0 if inner else 1]) - keep = [] + keep = [0] removable = (numpy.cumsum(arc_lengths) <= max_arclen) - start = 0 + start = 1 while start < arc_lengths.size: next_to_keep = start + numpy.where(removable)[0][-1] # TODO: any chance we haven't sampled finely enough? keep.append(next_to_keep) removable = (numpy.cumsum(arc_lengths[next_to_keep + 1:]) <= max_arclen) start = next_to_keep + 1 + if keep[-1] != thetas.size - 1: + keep.append(thetas.size -1) return thetas[keep] wh = self.width / 2.0 From 55e3066485e422b704abe0b7be5ea3196f45f677 Mon Sep 17 00:00:00 2001 From: Jan Petykiewicz Date: Fri, 27 Oct 2023 21:59:48 -0700 Subject: [PATCH 2/2] Wrap Pattern functions for label, ref, polygon, etc. --- masque/builder/builder.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/masque/builder/builder.py b/masque/builder/builder.py index a401abc..1fbbe88 100644 --- a/masque/builder/builder.py +++ b/masque/builder/builder.py @@ -4,6 +4,7 @@ Simplified Pattern assembly (`Builder`) from typing import Self, Sequence, Mapping import copy import logging +from functools import wraps from numpy.typing import ArrayLike @@ -188,6 +189,26 @@ class Builder(PortList): new = Builder(library=library, pattern=pat, name=name) return new + @wraps(Pattern.label) + def label(self, *args, **kwargs) -> Self: + self.pattern.label(*args, **kwargs) + + @wraps(Pattern.ref) + def ref(self, *args, **kwargs) -> Self: + self.pattern.ref(*args, **kwargs) + + @wraps(Pattern.polygon) + def polygon(self, *args, **kwargs) -> Self: + self.pattern.polygon(*args, **kwargs) + + @wraps(Pattern.rect) + def rect(self, *args, **kwargs) -> Self: + self.pattern.rect(*args, **kwargs) + + @wraps(Pattern.path) + def path(self, *args, **kwargs) -> Self: + self.pattern.path(*args, **kwargs) + def plug( self, other: Abstract | str | Pattern | TreeView,