python/ray/tune/tests/test_ray_trial_executor.py
def testPlacementGroupFactoryEquality(self):
        """
        Test that two different placement group factory objects are considered
        equal and evaluate to the same hash.
        """
        from collections import Counter

        pgf_1 = PlacementGroupFactory(
            [{"CPU": 2, "GPU": 4, "custom": 7}, {"GPU": 2, "custom": 1, "CPU": 3}],
            "PACK",
            "no_name",
            None,
        )

        pgf_2 = PlacementGroupFactory(
            [
                {
                    "custom": 7,
                    "GPU": 4,
                    "CPU": 2,
                },
                {"custom": 1, "GPU": 2, "CPU": 3},
            ],
            strategy="PACK",
            name="no_name",
            lifetime=None,
        )

        pgf_3 = PlacementGroupFactory(
            [
                {"custom": 7, "GPU": 4, "CPU": 2.0, "custom2": 0},
                {"custom": 1.0, "GPU": 2, "CPU": 3, "custom2": 0},
            ],
            strategy="PACK",
            name="no_name",
            lifetime=None,
        )

        self.assertEqual(pgf_1, pgf_2)
        self.assertEqual(pgf_2, pgf_3)

        # Hash testing
        counter = Counter()
        counter[pgf_1] += 1
        counter[pgf_2] += 1
        counter[pgf_3] += 1

        self.assertEqual(counter[pgf_1], 3)
        self.assertEqual(counter[pgf_2], 3)
        self.assertEqual(counter[pgf_3], 3)

        Test that two different placement group factory objects are considered
        equal and evaluate to the same hash.
        
Test that two different placement group factory objects are considered
equal and evaluate to the same hash.
Test that two different placement group factory objects are considered equal and evaluate to the same hash .
def testPlacementGroupFactoryEquality(self):
        from collections import Counter
        pgf_1 = PlacementGroupFactory(
            [{"CPU": 2, "GPU": 4, "custom": 7}, {"GPU": 2, "custom": 1, "CPU": 3}],
            "PACK",
            "no_name",
            None,
        )
        pgf_2 = PlacementGroupFactory(
            [
                {
                    "custom": 7,
                    "GPU": 4,
                    "CPU": 2,
                },
                {"custom": 1, "GPU": 2, "CPU": 3},
            ],
            strategy="PACK",
            name="no_name",
            lifetime=None,
        )
        pgf_3 = PlacementGroupFactory(
            [
                {"custom": 7, "GPU": 4, "CPU": 2.0, "custom2": 0},
                {"custom": 1.0, "GPU": 2, "CPU": 3, "custom2": 0},
            ],
            strategy="PACK",
            name="no_name",
            lifetime=None,
        )
        self.assertEqual(pgf_1, pgf_2)
        self.assertEqual(pgf_2, pgf_3)
        counter = Counter()
        counter[pgf_1] += 1
        counter[pgf_2] += 1
        counter[pgf_3] += 1
        self.assertEqual(counter[pgf_1], 3)
        self.assertEqual(counter[pgf_2], 3)
        self.assertEqual(counter[pgf_3], 3)
def testPlacementGroupFactoryEquality ( self ) : from collections import Counter pgf_1 = PlacementGroupFactory ( [ { "CPU" : 2 , "GPU" : 4 , "custom" : 7 } , { "GPU" : 2 , "custom" : 1 , "CPU" : 3 } ] , "PACK" , "no_name" , None , ) pgf_2 = PlacementGroupFactory ( [ { "custom" : 7 , "GPU" : 4 , "CPU" : 2 , } , { "custom" : 1 , "GPU" : 2 , "CPU" : 3 } , ] , strategy = "PACK" , name = "no_name" , lifetime = None , ) pgf_3 = PlacementGroupFactory ( [ { "custom" : 7 , "GPU" : 4 , "CPU" : 2.0 , "custom2" : 0 } , { "custom" : 1.0 , "GPU" : 2 , "CPU" : 3 , "custom2" : 0 } , ] , strategy = "PACK" , name = "no_name" , lifetime = None , ) self . assertEqual ( pgf_1 , pgf_2 ) self . assertEqual ( pgf_2 , pgf_3 ) counter = Counter ( ) counter [ pgf_1 ] += 1 counter [ pgf_2 ] += 1 counter [ pgf_3 ] += 1 self . assertEqual ( counter [ pgf_1 ] , 3 ) self . assertEqual ( counter [ pgf_2 ] , 3 ) self . assertEqual ( counter [ pgf_3 ] , 3 )
Test that two different placement group factory objects are considered
equal and evaluate to the same hash.
Test that two different placement group factory objects are considered equal and evaluate to the same hash .
"""
        Test that two different placement group factory objects are considered
        equal and evaluate to the same hash.
        """ # Hash testing
self