Esempio n. 1
0
 def test_translating_point_from_simple_to_simple_hypergrid(self):
     adapter = HierarchicalToFlatHypergridAdapter(adaptee=self.simple_hypergrid)
     self.assertTrue(isinstance(adapter.target, SimpleHypergrid))
     for _ in range(1000):
         original_point = self.simple_hypergrid.random()
         translated_point = adapter.translate_point(original_point)
         for dim_name, value in translated_point:
             self.assertFalse("." in dim_name)
         self.assertTrue(original_point == translated_point) # No translation for SimpleHypergrid-to-SimpleHypergrid adapters.
         untranslated_point = adapter.untranslate_point(translated_point)
         self.assertTrue(untranslated_point in self.simple_hypergrid)
         self.assertTrue(original_point == untranslated_point)
Esempio n. 2
0
    def test_translating_point_from_composite_to_simple_hypergrid(self):
        adapter = HierarchicalToFlatHypergridAdapter(adaptee=self.hierarchical_hypergrid)
        self.assertTrue(isinstance(adapter.target, SimpleHypergrid))
        for _ in range(1000):
            original_point = self.hierarchical_hypergrid.random()
            translated_point = adapter.translate_point(original_point)

            if original_point.categorical_mixed_types is True:
                self.assertFalse(translated_point == original_point)
            else:
                self.assertTrue(translated_point == original_point)

            for dim_name, value in translated_point:
                self.assertFalse("." in dim_name)
            untranslated_point = adapter.untranslate_point(translated_point)
            self.assertTrue(untranslated_point in self.hierarchical_hypergrid)
            self.assertTrue(untranslated_point == original_point)