Пример #1
0
    def test_scale_ratio(self):
        """
        Make sure filling works correctly.
        """
        # Make C_layout bigger than S_layout
        S_layout = mml.Layout(self.S, scale=1)
        C_layout = mml.Layout(self.C, scale=10)

        # Have S_layout scale to various ratios
        placement = mml.Placement(S_layout, C_layout, scale_ratio=1)
        self.assertAlmostEqual(placement.S_layout.scale, 10)

        placement = mml.Placement(S_layout, C_layout, scale_ratio=.5)
        self.assertAlmostEqual(placement.S_layout.scale, 5)
Пример #2
0
 def test_precomputed_placement(self):
     """
     Tests passing in a placement as a dictionary
     """
     rando = rando_placer(self.S_layout, self.C_layout)
     placement = mml.Placement(self.S_layout, self.C_layout, rando)
     self.assertIsPlacement(self.S, self.C, placement)
Пример #3
0
    def test_placement_class(self):
        """
        Test the placement mutable mapping behavior.
        """
        P = mml.Placement(self.G_layout, self.G_layout)

        # Test __setitem__
        P['a'] = 1

        # Test __iter__ and __getitem__
        for k, v in P.items():
            self.assertEqual(k, 'a')
            self.assertEqual(v, 1)

        # Test __len__
        self.assertEqual(len(P), 1)

        # Test __del__
        del P['a']

        # Test __repr__
        self.assertEqual(repr(P), "{}")
Пример #4
0
 def test_placement_functions(self):
     """
     Functions can be passed in to Placement objects.
     """
     placement = mml.Placement(self.S_layout, self.C_layout, rando_placer)
     self.assertIsPlacement(self.S, self.C, placement)