[Pattern] improve error handling in place()
This commit is contained in:
parent
20bd0640e1
commit
b44c962e07
2 changed files with 11 additions and 1 deletions
|
|
@ -1411,7 +1411,9 @@ class Pattern(PortList, AnnotatableImpl, Mirrorable):
|
||||||
other_copy.translate_elements(offset)
|
other_copy.translate_elements(offset)
|
||||||
self.append(other_copy)
|
self.append(other_copy)
|
||||||
else:
|
else:
|
||||||
assert not isinstance(other, Pattern)
|
if isinstance(other, Pattern):
|
||||||
|
raise PatternError('Must provide an `Abstract` (not a `Pattern`) when creating a reference. '
|
||||||
|
'Use `append=True` if you intended to append the full geometry.')
|
||||||
ref = Ref(mirrored=mirrored)
|
ref = Ref(mirrored=mirrored)
|
||||||
ref.rotate_around(pivot, rotation)
|
ref.rotate_around(pivot, rotation)
|
||||||
ref.translate(offset)
|
ref.translate(offset)
|
||||||
|
|
|
||||||
|
|
@ -126,6 +126,14 @@ def test_pattern_flatten_repeated_ref_with_ports_raises() -> None:
|
||||||
parent.flatten({"child": child}, flatten_ports=True)
|
parent.flatten({"child": child}, flatten_ports=True)
|
||||||
|
|
||||||
|
|
||||||
|
def test_pattern_place_requires_abstract_for_reference() -> None:
|
||||||
|
parent = Pattern()
|
||||||
|
child = Pattern()
|
||||||
|
|
||||||
|
with pytest.raises(PatternError, match='Must provide an `Abstract`'):
|
||||||
|
parent.place(child)
|
||||||
|
|
||||||
|
|
||||||
def test_pattern_interface() -> None:
|
def test_pattern_interface() -> None:
|
||||||
source = Pattern()
|
source = Pattern()
|
||||||
source.ports["A"] = Port((10, 20), 0, ptype="test")
|
source.ports["A"] = Port((10, 20), 0, ptype="test")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue