Example #1
0
    def test_component_qcomponent_get_pin_names(self):
        """Test getting all the pin names."""
        design = designs.DesignPlanar()
        my_q_component = QComponent(design,
                                    "my_name-get-pin-names",
                                    make=False)

        spiral_list_0 = self.generate_spiral_list(0, 0)
        spiral_list_1 = self.generate_spiral_list(1, 2)

        my_q_component.add_pin('pin1-name',
                               np.array(spiral_list_0.coords)[-2:], 0.1)
        my_q_component.add_pin('pin2-name',
                               np.array(spiral_list_1.coords)[-2:], 0.1)

        my_pin_names = list(my_q_component.pin_names)
        my_pin_names.sort()
        self.assertEqual(len(my_pin_names), 2)
        self.assertEqual(my_pin_names[0], 'pin1-name')
        self.assertEqual(my_pin_names[1], 'pin2-name')
        my_q_component.delete()
    def test_component_qcomponent_add_and_get_pin(self):
        """
        Test getting a pin by name.
        """
        design = designs.DesignPlanar()
        my_q_component = QComponent(design, "my_name-get-pin", make=False)

        spiral_list_0 = self.generate_spiral_list(0, 0)
        spiral_list_1 = self.generate_spiral_list(1, 2)

        my_q_component.add_pin('pin1-name',
                               np.array(spiral_list_0.coords)[-2:], 0.1)
        my_q_component.add_pin('pin2-name',
                               np.array(spiral_list_1.coords)[-2:], 0.1)

        my_pin = my_q_component.get_pin('pin2-name')
        self.assertEqual(len(my_pin), 10)
        self.assertEqual(len(my_pin['points']), 2)
        self.assertEqual(len(my_pin['points'][0]), 2)
        self.assertEqual(len(my_pin['points'][1]), 2)
        self.assertEqual(my_pin['points'][0][0], -34.)
        self.assertEqual(my_pin['points'][0][1], 32.)
        self.assertEqual(my_pin['points'][1][0], -34.)
        self.assertEqual(my_pin['points'][1][1], -33.)
        self.assertEqual(len(my_pin['middle']), 2)
        self.assertEqual(my_pin['middle'][0], -34.)
        self.assertEqual(my_pin['middle'][1], -0.5)
        self.assertEqual(len(my_pin['normal']), 2)
        self.assertEqual(my_pin['normal'][0], 1.)
        self.assertEqual(my_pin['normal'][1], -0.)
        self.assertEqual(len(my_pin['tangent']), 2)
        self.assertEqual(my_pin['tangent'][0], 0.)
        self.assertEqual(my_pin['tangent'][1], -1.)
        self.assertEqual(my_pin['width'], 65.0)
        self.assertEqual(my_pin['gap'], 0.06)
        self.assertEqual(my_pin['chip'], 'main')
        self.assertEqual(my_pin['parent_name'], 1)
        self.assertEqual(my_pin['net_id'], 0)
        self.assertEqual(my_pin['length'], 0)
        my_q_component.delete()