[PortList] find_transform requires a non-empty connection map
This commit is contained in:
parent
b3a1489258
commit
f0a4b08a31
2 changed files with 15 additions and 0 deletions
|
|
@ -581,6 +581,8 @@ class PortList(metaclass=ABCMeta):
|
||||||
|
|
||||||
The rotation should be performed before the translation.
|
The rotation should be performed before the translation.
|
||||||
"""
|
"""
|
||||||
|
if not map_in:
|
||||||
|
raise PortError('Must provide at least one port connection')
|
||||||
s_ports = self[map_in.keys()]
|
s_ports = self[map_in.keys()]
|
||||||
o_ports = other[map_in.values()]
|
o_ports = other[map_in.values()]
|
||||||
return self.find_port_transform(
|
return self.find_port_transform(
|
||||||
|
|
@ -632,6 +634,8 @@ class PortList(metaclass=ABCMeta):
|
||||||
|
|
||||||
The rotation should be performed before the translation.
|
The rotation should be performed before the translation.
|
||||||
"""
|
"""
|
||||||
|
if not map_in:
|
||||||
|
raise PortError('Must provide at least one port connection')
|
||||||
s_offsets = numpy.array([p.offset for p in s_ports.values()])
|
s_offsets = numpy.array([p.offset for p in s_ports.values()])
|
||||||
o_offsets = numpy.array([p.offset for p in o_ports.values()])
|
o_offsets = numpy.array([p.offset for p in o_ports.values()])
|
||||||
s_types = [p.ptype for p in s_ports.values()]
|
s_types = [p.ptype for p in s_ports.values()]
|
||||||
|
|
|
||||||
|
|
@ -257,3 +257,14 @@ def test_pattern_plug_rejects_map_out_on_connected_ports_atomically() -> None:
|
||||||
host.plug(other, {"A": "X"}, map_out={"X": "renamed", "Y": "out"}, append=True)
|
host.plug(other, {"A": "X"}, map_out={"X": "renamed", "Y": "out"}, append=True)
|
||||||
|
|
||||||
assert set(host.ports) == {"A"}
|
assert set(host.ports) == {"A"}
|
||||||
|
|
||||||
|
|
||||||
|
def test_find_transform_requires_connection_map() -> None:
|
||||||
|
host = Pattern(ports={"A": Port((0, 0), 0)})
|
||||||
|
other = Pattern(ports={"X": Port((0, 0), pi)})
|
||||||
|
|
||||||
|
with pytest.raises(PortError, match="at least one port connection"):
|
||||||
|
host.find_transform(other, {})
|
||||||
|
|
||||||
|
with pytest.raises(PortError, match="at least one port connection"):
|
||||||
|
Pattern.find_port_transform({}, {}, {})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue