def test_connections_different_factory(): c = component_from_yaml(sample_different_factory) # print(c.routes["bl,S:br,E"].parent.length) assert np.isclose(c.routes["tl,E:tr,W"]["length"], 700.0) assert np.isclose(c.routes["bl,E:br,W"]["length"], 850.0) assert np.isclose(c.routes["bl,S:br,E"]["length"], 1171.259) return c
def needs_fixing(): """FIXME: there is a zero length path on the route""" import pp # c = component_from_yaml(sample_2x2_connections) # c = component_from_yaml(sample_waypoints) c = component_from_yaml(sample_different_factory) pp.show(c) full_settings = True n = c.get_netlist(full_settings=full_settings) yaml_str = OmegaConf.to_yaml(n, sort_keys=True) c2 = component_from_yaml(yaml_str) n2 = c2.get_netlist(full_settings=full_settings) d = jsondiff.diff(n, n2) assert len(d) == 0 pp.show(c2)
def test_docstring_sample(): c = component_from_yaml(sample_docstring) route_name = "mmi_top,E0:mmi_bot,W0" length = 50.16592653589793 print(c.routes[route_name]["length"]) assert np.isclose(c.routes[route_name]["length"], length) return c
def test_mirror(): c = component_from_yaml(sample_mirror) # print(len(c.get_dependencies())) # print(len(c.ports)) assert len(c.get_dependencies()) == 4 assert len(c.ports) == 2 return c
def test_connections(): c = component_from_yaml(sample_connections) # print(len(c.get_dependencies())) # print(len(c.ports)) assert len(c.get_dependencies()) == 2 assert len(c.ports) == 0 return c
def test_sample(): c = component_from_yaml(sample_mmis) # print(len(c.get_dependencies())) # print(len(c.ports)) assert len(c.get_dependencies()) == 7 assert len(c.ports) == 2 return c
def test_netlists(yaml_key, full_settings, data_regression): """Write netlists for hierarchical circuits. Checks that both netlists are the same jsondiff does a hierarchical diff Component -> netlist -> Component -> netlist """ yaml_string = yaml_strings[yaml_key] c = component_from_yaml(yaml_string) n = c.get_netlist(full_settings=full_settings) data_regression.check(n) yaml_str = OmegaConf.to_yaml(n, sort_keys=True) c2 = component_from_yaml(yaml_str) n2 = c2.get_netlist(full_settings=full_settings) d = jsondiff.diff(n, n2) assert len(d) == 0
def test_connections_waypoints(): c = component_from_yaml(sample_waypoints) # print(c.routes['t,S5:b,N4'].parent.length) length = 1241.415926535898 route_name = "t,S5:b,N4" assert np.isclose(c.routes[route_name]["length"], length) return c
def test_connections_regex(): c = component_from_yaml(sample_regex_connections) route_names = ["left,E0:right,W0", "left,E1:right,W1", "left,E2:right,W2"] length = 12.0 for route_name in route_names: assert np.isclose(c.routes[route_name]["length"], length) return c
def test_connections_different_link_factory(): c = component_from_yaml(sample_different_link_factory) # print(c.routes['tl,E:tr,W'].parent.length) # print(c.routes['bl,E:br,W'].parent.length) length = 1716.248 assert np.isclose(c.routes["tl,E:tr,W"]["length"], length) assert np.isclose(c.routes["bl,E:br,W"]["length"], length) return c
def test_connections_2x2(): c = component_from_yaml(sample_2x2_connections) # print(len(c.get_dependencies())) # print(len(c.ports)) assert len(c.get_dependencies()) == 9 assert len(c.ports) == 0 print(c.routes) length = c.routes["mmi_bottom,E1:mmi_top,W1"]["length"] print(length) assert length == 163.916 return c
def coupler(wg_width: float = 0.5, gap: float = 0.236, length: float = 10.007) -> Component: pp.drc.assert_on_1nm_grid(length) pp.drc.assert_on_2nm_grid(gap) netlist = f""" instances: sl: component: coupler_symmetric settings: gap: {gap} wg_width: {wg_width} sr: component: coupler_symmetric settings: gap: {gap} wg_width: {wg_width} cs: component: coupler_straight settings: gap: {gap} width: {wg_width} length: {length} placements: cs: x: 0 y: {gap/2} connections: sl,W0: cs,W0 sr,W0: cs,E0 ports: w1: sl,E0 w0: sl,E1 e0: sr,E0 e1: sr,E1 """ return component_from_yaml(netlist)
def test_ports(yaml_key, num_regression): """Avoid regressions in port names and locations.""" yaml_string = yaml_strings[yaml_key] c = component_from_yaml(yaml_string) if c.ports: num_regression.check(c.get_ports_array())
def test_gds(yaml_key, data_regression): """Avoid regressions in GDS geometry shapes and layers.""" yaml_string = yaml_strings[yaml_key] c = component_from_yaml(yaml_string) difftest(c)