Пример #1
0
    def test_design_all_component_names_id(self):
        """Test all_component_names_id functionality in design_base.py."""
        design = DesignPlanar()
        design.overwrite_enabled = True

        TransmonPocket(design, 'Q1')
        TransmonPocket(design, 'Q2')

        expected = [('Q1', 1), ('Q2', 2)]
        actual = design.all_component_names_id()

        for i in range(2):
            self.assertEqual(expected[i], actual[i])
Пример #2
0
    def test_design_delete_all_pins(self):
        """Test delete_all_pins functionality in design_base.py."""
        design = DesignPlanar()
        design.overwrite_enabled = True

        TransmonPocket(design, 'Q1')
        TransmonPocket(design, 'Q2')

        design.connect_pins(1, 'p1', 2, 'p2')
        pf = design._qnet._net_info
        self.assertFalse(pf.empty)

        design.delete_all_pins()
        pf = design._qnet._net_info
        self.assertTrue(pf.empty)
Пример #3
0
    def test_qgeometry_q_element_get_component(self):
        """Test get_component in QGeometryTables class in
        element_handler.py."""
        design = designs.DesignPlanar()
        qgt = QGeometryTables(design)
        qgt.clear_all_tables()
        TransmonPocket(design, 'Q1')

        rect = draw.rectangle(500, 300, 0, 0)
        geom = {'my_polygon': rect}
        qgt.add_qgeometry('poly', 'Q1', geom)

        # success results
        actual = qgt.get_component('Q1')
        self.assertEqual(len(actual), 3)
        self.assertTrue(isinstance(actual['path'], GeoDataFrame))
        self.assertTrue(isinstance(actual['poly'], GeoDataFrame))
        self.assertTrue(isinstance(actual['junction'], GeoDataFrame))

        # failure results
        actual = qgt.get_component('not-real')
        self.assertEqual(len(actual), 3)
        self.assertEqual(actual['path'], None)
        self.assertEqual(actual['poly'], None)
        self.assertEqual(actual['junction'], None)
Пример #4
0
    def test_design_connect_pins(self):
        """Test connect_pins functionality in design_base.py."""
        design = DesignPlanar()
        design.overwrite_enabled = True

        TransmonPocket(design, 'Q1')
        TransmonPocket(design, 'Q2')

        design.connect_pins(1, 'p1', 2, 'p2')
        pf = design._qnet._net_info

        self.assertFalse(pf.empty)
        self.assertEqual(pf['net_id'][0], 1)
        self.assertEqual(pf['net_id'][1], 1)
        self.assertEqual(pf['component_id'][0], 1)
        self.assertEqual(pf['component_id'][1], 2)
        self.assertEqual(pf['pin_name'][0], 'p1')
        self.assertEqual(pf['pin_name'][1], 'p2')
Пример #5
0
    def test_qgeometry_q_element_check_element_type(self):
        """Test check_element_type in QGeometryTables class in
        element_handler.py."""
        design = designs.DesignPlanar()
        qgt = QGeometryTables(design)
        TransmonPocket(design, 'my_id')

        self.assertTrue(qgt.check_element_type('path', log_issue=False))
        self.assertFalse(qgt.check_element_type('not-there', log_issue=False))
Пример #6
0
    def test_design_copy_multiple_qcomponents(self):
        """
        Test the functionality of copy_multiple_qcomponents in design_base.py.
        """
        design = DesignPlanar()
        design.overwrite_enabled = True
        q_1 = TransmonPocket(design, 'Q1')
        q_2 = TransmonPocket(design, 'Q2')
        q_3 = TransmonPocket(design, 'Q3')

        design.copy_multiple_qcomponents(
            [q_1, q_2, q_3], ['q1_copy', 'q2_copy', 'q3_copy'],
            [dict(pos_y='-1.0mm'),
             dict(pos_y='-2.0mm'),
             dict(pos_y='-3.0mm')])

        q1_copy = design._components[4]
        q2_copy = design._components[5]
        q3_copy = design._components[6]

        self.assertEqual(q_1.name, 'Q1')
        self.assertEqual(q_2.name, 'Q2')
        self.assertEqual(q_3.name, 'Q3')
        self.assertEqual(q1_copy.name, 'q1_copy')
        self.assertEqual(q2_copy.name, 'q2_copy')
        self.assertEqual(q3_copy.name, 'q3_copy')
        self.assertEqual(q_1.id, 1)
        self.assertEqual(q_2.id, 2)
        self.assertEqual(q_3.id, 3)
        self.assertEqual(q1_copy.id, 4)
        self.assertEqual(q2_copy.id, 5)
        self.assertEqual(q3_copy.id, 6)

        self.assertEqual(q_1.class_name, q1_copy.class_name)
        self.assertEqual(q_2.class_name, q2_copy.class_name)
        self.assertEqual(q_3.class_name, q3_copy.class_name)
        self.assertEqual(q_1.options['pos_x'], q1_copy.options['pos_x'])
        self.assertEqual(q_2.options['pos_x'], q2_copy.options['pos_x'])
        self.assertEqual(q_3.options['pos_x'], q3_copy.options['pos_x'])

        self.assertEqual(q1_copy.options['pos_y'], '-1.0mm')
        self.assertEqual(q2_copy.options['pos_y'], '-2.0mm')
        self.assertEqual(q3_copy.options['pos_y'], '-3.0mm')
Пример #7
0
    def test_design_get_list_of_tables_in_metadata(self):
        """Tests the get_list_of_tables_in_metadata function in design_base.py
        by exeucting get_table_values_form_renderers in a component."""
        design = DesignPlanar()
        q1 = TransmonPocket(design, 'Q1')

        result = q1._get_table_values_from_renderers(design)

        self.assertEqual(len(result), 11)
        self.assertEqual(result['hfss_inductance'], '10nH')
        self.assertEqual(result['hfss_capacitance'], 0)
        self.assertEqual(result['hfss_resistance'], 0)
        self.assertAlmostEqual(result['hfss_mesh_kw_jj'], 7e-06, places=6)
        self.assertEqual(result['q3d_inductance'], '10nH')
        self.assertEqual(result['q3d_capacitance'], 0)
        self.assertEqual(result['q3d_resistance'], 0)
        self.assertAlmostEqual(result['q3d_mesh_kw_jj'], 7e-06, places=6)
        self.assertEqual(result['gds_cell_name'], 'my_other_junction')
        self.assertEqual(result['hfss_wire_bonds'], False)
        self.assertEqual(result['q3d_wire_bonds'], False)
Пример #8
0
    def test_qgeometry_q_element_get_component_bounds(self):
        """Test get_component_bounds in QGeometryTables class in
        element_handler.py."""
        design = designs.DesignPlanar()
        qgt = QGeometryTables(design)
        qgt.clear_all_tables()
        TransmonPocket(design, 'my_id')

        four_zeros = qgt.get_component_bounds('my_id')
        self.assertEqual(len(four_zeros), 4)
        for i in range(4):
            self.assertEqual(four_zeros[i], 0)
Пример #9
0
    def test_qgeometry_q_element_delete_component_id(self):
        """Test delete_component_id in QGeometryTables class in
        element_handler.py."""
        design = designs.DesignPlanar()
        qgt = QGeometryTables(design)
        qgt.clear_all_tables()

        transmon_pocket = TransmonPocket(design, 'my_id')
        transmon_pocket.make()
        transmon_pocket.get_template_options(design)
        a_linestring = draw.LineString([[0, 0], [0, 1]])
        a_poly = draw.rectangle(2, 2, 0, 0)
        qgt.add_qgeometry('path',
                          'my_id', {'n_sprial': a_linestring},
                          width=4000)
        qgt.add_qgeometry('poly',
                          'my_id', {'n_spira_etch': a_poly},
                          subtract=True)

        self.assertEqual(len(qgt.tables['path']), 1)
        self.assertEqual(len(qgt.tables['poly']), 1)

        qgt.delete_component_id('my_id')

        self.assertEqual(len(qgt.tables['path']), 0)
        self.assertEqual(len(qgt.tables['poly']), 0)
    def test_qlibrary_qubits_transmon_pocket(self):
        """Test the instantiation of TransmonPocket."""
        design = designs.DesignPlanar()
        try:
            TransmonPocket
        except Exception:
            self.fail("TransmonPocket failed")

        try:
            TransmonPocket(design, "my_name")
        except Exception:
            self.fail("TransmonPocket(design, \"my_name\") failed")

        try:
            TransmonPocket(design, "my_name2", options={})
        except Exception:
            self.fail("TransmonPocket(design, \"my_name2\", options={}) failed")

        try:
            TransmonPocket(design, "my_name3", options={}, make=False)
        except Exception:
            self.fail(
                "TransmonPocket(design, \"my_name3\", options={}, make=False)")
Пример #11
0
    def test_design_copy_qcomponent(self):
        """Test the functionlaity of copy_qcomponent in design_base.py."""
        design = DesignPlanar()
        design.overwrite_enabled = True
        q_1 = TransmonPocket(design, 'Q1')
        q1_copy = design.copy_qcomponent(q_1, 'Q1_copy')

        self.assertEqual(q_1.name, 'Q1')
        self.assertEqual(q1_copy.name, 'Q1_copy')
        self.assertEqual(q_1.id, 1)
        self.assertEqual(q1_copy.id, 2)
        self.assertEqual(q_1.class_name, q1_copy.class_name)
        self.assertEqual(q_1.options['pos_x'], q1_copy.options['pos_x'])

        q1_copy.options['pos_x'] = '1.0mm'
        self.assertEqual(q_1.options['pos_x'], '0.0um')
        self.assertEqual(q1_copy.options['pos_x'], '1.0mm')
Пример #12
0
    def test_design_default_component_name(self):
        """Test automatic naming of components."""
        design = DesignPlanar(metadata={})

        ResonatorCoilRect(design, make=False)
        self.assertEqual('res_1' in design.components, True)
        ResonatorCoilRect(design, make=False)
        self.assertEqual('res_2' in design.components, True)

        # Manually add the next automatic name to check it doesn't get repeated
        ResonatorCoilRect(design, 'res_3', make=False)
        ResonatorCoilRect(design, make=False)
        self.assertEqual('res_3' in design.components, True)
        self.assertEqual('res_4' in design.components, True)

        # Add a different component
        TransmonPocket(design, make=False)
        self.assertEqual('Q_1' in design.components, False)

        # Add a component with no predefined prefix
        QComponent(design, make=False)
        self.assertEqual('QComponent_1' in design.components, True)
Пример #13
0
    def test_qgeometry_get_all_unique_layers(self):
        """Test get_all_unique_layers functionality in elment_handler.py."""
        design = designs.DesignPlanar()
        qgt = QGeometryTables(design)
        qgt.clear_all_tables()

        transmon_pocket = TransmonPocket(design, 'my_id')
        transmon_pocket.make()
        transmon_pocket.get_template_options(design)
        a_linestring = draw.LineString([[0, 0], [0, 1]])
        a_poly = draw.rectangle(2, 2, 0, 0)
        qgt.add_qgeometry('path',
                          'my_id', {'n_sprial': a_linestring},
                          width=4000)
        qgt.add_qgeometry('poly',
                          'my_id', {'n_spira_etch': a_poly},
                          subtract=True)

        self.assertEqual(qgt.get_all_unique_layers('main'), [1])
        self.assertEqual(qgt.get_all_unique_layers('fake'), [])
Пример #14
0
    def test_renderer_get_chip_names(self):
        """Test functionality of get_chip_names in gds_renderer.py."""
        design = designs.DesignPlanar()
        renderer = QGDSRenderer(design)

        qgt = QGeometryTables(design)
        qgt.clear_all_tables()

        transmon_pocket_1 = TransmonPocket(design, 'my_id')
        transmon_pocket_1.make()
        transmon_pocket_1.get_template_options(design)

        a_linestring = draw.LineString([[0, 0], [0, 1]])
        a_poly = draw.rectangle(2, 2, 0, 0)
        qgt.add_qgeometry('path',
                          'my_id', {'n_sprial': a_linestring},
                          width=4000)
        qgt.add_qgeometry('poly',
                          'my_id', {'n_spira_etch': a_poly},
                          subtract=True)

        result = renderer._get_chip_names()
        self.assertEqual(result, {'main': {}})