Describe the bug
The expectation, as I understand it, is that when use_mirror = True, the connect transformation should respect any previous mirror transformations applied to the instance before connecting. This does not seem to be true. Also, it seems like there is different behavior when the port is provided by name or as an actual port (I can see in the code that when it is specified by name it gets p = self.cell.ports[port] rather than p = self.ports[port]. This is a mistake, no?).
To Reproduce
Try running the script below:
import gdsfactory as gf
@gf.cell
def mirror_and_connect(from_name: bool = False, use_mirror: bool = True, apply_mirror: bool = True):
c = gf.Component()
i1 = c.add_ref(gf.c.straight(), "i1")
i2 = c.add_ref(gf.c.bend_circular(), "i2")
if apply_mirror:
i2.dmirror()
if from_name:
port = "o2"
else:
port = i2.ports["o2"]
i2.connect(port, i1.ports["o2"], use_mirror=use_mirror, mirror=False)
return c
if __name__ == "__main__":
samples = []
for from_name in True, False:
for use_mirror in True, False:
for apply_mirror in True, False:
cc = mirror_and_connect(from_name=from_name, use_mirror=use_mirror, apply_mirror=apply_mirror)
samples.append(cc)
c = gf.grid(samples)
c.show()
Expected behavior
Toggling from_name should have no effect. Results should be the same in either case.
Toggling use_mirror when apply_mirror is True should cause the bend to mirrored or not
Toggling apply_mirror when use_mirror is True should cause the bend to mirrored or not
Toggling apply_mirror when use_mirror is False should have no effect
Toggling use_mirror when apply_mirror is False should have no effect
In all cases the two components should be connected.
Describe the bug The expectation, as I understand it, is that when
use_mirror = True
, the connect transformation should respect any previous mirror transformations applied to the instance before connecting. This does not seem to be true. Also, it seems like there is different behavior when the port is provided by name or as an actual port (I can see in the code that when it is specified by name it getsp = self.cell.ports[port]
rather thanp = self.ports[port]
. This is a mistake, no?).To Reproduce Try running the script below:
Expected behavior
from_name
should have no effect. Results should be the same in either case.use_mirror
whenapply_mirror
is True should cause the bend to mirrored or notapply_mirror
whenuse_mirror
is True should cause the bend to mirrored or notapply_mirror
whenuse_mirror
is False should have no effectuse_mirror
whenapply_mirror
is False should have no effectIn all cases the two components should be connected.
Screenshots Shit's all over the place...![image](https://github.com/gdsfactory/kfactory/assets/3070522/8087e5bf-b960-4f21-a2cf-fb6fc63627be)