Repository: gdsfactory/gdsfactory
Issue: ring_double netlist breaks when length_y is zero

The `ring_double` component causes errors if `length_y` is set to zero (or a small delta) if asked to extract the netlist

Changed files:
gdsfactory/components/ring_single.py, gdsfactory/components/coupler_ring.py, gdsfactory/components/ring_double.py

diff --git a/gdsfactory/components/coupler_ring.py b/gdsfactory/components/coupler_ring.py
index 226484ccc..692e2b20e 100644
--- a/gdsfactory/components/coupler_ring.py
+++ b/gdsfactory/components/coupler_ring.py
@@ -78,7 +78,11 @@ def coupler_ring(
     # add references to subcells
     cbl = c << coupler90_component
     cbr = c << coupler90_component
-    cs = c << coupler_straight_component
+
+    cs = coupler_straight_component.ref()
+
+    if length_x > 0:
+        c.add(cs)
 
     # connect references
     y = coupler90_component.y
@@ -150,10 +154,8 @@ def coupler_ring_point(
         c << gf.geometry.boolean(subcomponent, rectangle, "A-B", layer=layer)
 
     coupler_ref = c << coupler_ring_component.extract(layers=untouched_layers)
-
     c.add_ports(coupler_ring_component.get_ports_list())
     c.absorb(coupler_ref)
-
     return c
 
 
@@ -175,7 +177,9 @@ if __name__ == "__main__":
     # )
     # c = coupler_ring_point(c, open_layers=("HEATER",), open_sizes=((5, 7),))
 
-    c = coupler_ring_point()
+    # c = coupler_ring_point()
+    # c = coupler_ring(length_x=0)
+    c = coupler_ring()
 
     # c = gf.Component()
     # c1 = coupler_ring(cladding_layers=[(111, 0)], cladding_offsets=[0.5])
diff --git a/gdsfactory/components/ring_double.py b/gdsfactory/components/ring_double.py
index 591c76faf..68d1d98e5 100644
--- a/gdsfactory/components/ring_double.py
+++ b/gdsfactory/components/ring_double.py
@@ -62,8 +62,13 @@ def ring_double(
     c = Component()
     cb = c.add_ref(coupler_component)
     ct = c.add_ref(coupler_component)
-    sl = c.add_ref(straight_component)
-    sr = c.add_ref(straight_component)
+
+    sl = straight_component.ref()
+    sr = straight_component.ref()
+
+    if length_y > 0:
+        c.add(sl)
+        c.add(sr)
 
     sl.connect(port="o1", destination=cb.ports["o2"])
     ct.connect(port="o3", destination=sl.ports["o2"])
@@ -76,5 +81,6 @@ def ring_double(
 
 
 if __name__ == "__main__":
-    c = ring_double(width=1, layer=(2, 0), length_y=3)
+    c = ring_double(width=1, layer=(2, 0), length_y=0, length_x=0)
+    c.get_netlist()
     c.show(show_subports=False)
diff --git a/gdsfactory/components/ring_single.py b/gdsfactory/components/ring_single.py
index 8a9dc1593..6ea14106b 100644
--- a/gdsfactory/components/ring_single.py
+++ b/gdsfactory/components/ring_single.py
@@ -58,11 +58,20 @@ def ring_single(
     sy = straight(length=length_y, cross_section=cross_section, **kwargs)
     b = gf.get_component(bend, cross_section=cross_section, radius=radius, **kwargs)
     sx = straight(length=length_x, cross_section=cross_section, **kwargs)
-    sl = c << sy
-    sr = c << sy
+
+    sl = sy.ref()
+    sr = sy.ref()
+    st = sx.ref()
+
+    if length_y > 0:
+        c.add(sl)
+        c.add(sr)
+
+    if length_x > 0:
+        c.add(st)
+
     bl = c << b
     br = c << b
-    st = c << sx
 
     sl.connect(port="o1", destination=cb.ports["o2"])
     bl.connect(port="o2", destination=sl.ports["o2"])
@@ -83,7 +92,9 @@ if __name__ == "__main__":
     # print(c.ports)
 
     # c = gf.routing.add_fiber_array(ring_single)
-    c = ring_single(cross_section="rib", width=2)
+    # c = ring_single(cross_section="rib", width=2)
+    c = ring_single(length_y=0, length_x=0)
+    c.get_netlist()
     c.show(show_ports=True)
 
     # cc = gf.add_pins(c)