def test_projecting_point_from_simple_to_simple_hypergrid(self):
     adapter = HierarchicalToFlatHypergridAdapter(
         adaptee=self.simple_hypergrid)
     assert isinstance(adapter.target, SimpleHypergrid)
     for _ in range(1000):
         original_point = self.simple_hypergrid.random()
         projected_point = adapter.project_point(original_point)
         for dim_name, value in projected_point:
             assert not "." in dim_name
         assert original_point == projected_point  # No projection for SimpleHypergrid-to-SimpleHypergrid adapters.
         unprojected_point = adapter.unproject_point(projected_point)
         assert unprojected_point in self.simple_hypergrid
         assert original_point == unprojected_point
    def test_projecting_point_from_hierarchical_to_flat_hypergrid(self):
        adapter = HierarchicalToFlatHypergridAdapter(
            adaptee=self.hierarchical_hypergrid)
        self.assertTrue(isinstance(adapter.target, SimpleHypergrid))
        for _ in range(1000):
            original_point = self.hierarchical_hypergrid.random()
            projected_point = adapter.project_point(original_point)

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

            for dim_name, value in projected_point:
                self.assertFalse("." in dim_name)
            unprojected_point = adapter.unproject_point(projected_point)
            self.assertTrue(unprojected_point in self.hierarchical_hypergrid)
            self.assertTrue(unprojected_point == original_point)