def setUp(self): # Build tasks for test scene -> featurized objects -> scene [self._task_object_test] = build_task_for_objects('test_objects') [self._task_complicated_object_test ] = build_complicated_task_for_objects('test_objects_complicated') self._ball_user_input_small = simulator.build_user_input( balls=[100, 100, 5]) self._ball_user_input_big = simulator.build_user_input( balls=[200, 200, 10]) # Build vectorized objects for unit tests self.x_s = np.array([[0.1, 0.3, 0.2, 0.4]]) self.y_s = np.array([[0.05, 0.15, 0.25, 0.65]]) self.thetas = np.array([[0.0, 0.1, 0.2, 0.3]]) self.diameters = np.array([[0.15, 0.1, 0.25, 0.23]]) self.colors_str = np.array(['black', 'blue', 'red', 'purple']) colors_one_hot = np.array([[0, 0, 0, 0, 0, 1], [0, 0, 1, 0, 0, 0], [1, 0, 0, 0, 0, 0], [0, 0, 0, 1, 0, 0]]).astype(float) self.dynamic = np.array([False, True, False, False]) self.user_input = np.array([False, False, True, False]) self.shapes_str = np.array(['jar', 'standingsticks', 'ball', 'bar']) shapes_one_hot = np.array([[0, 0, 1, 0], [0, 0, 0, 1], [1, 0, 0, 0], [0, 1, 0, 0]]).astype(float) self.features = np.concatenate( (self.x_s.T, self.y_s.T, self.thetas.T, self.diameters.T, shapes_one_hot, colors_one_hot), axis=1) phyre.simulation.DIAMETER_CENTERS = {}
def setUp(self): [self._task] = build_task('test') [self._task_object_test] = build_task_for_objects('test_objects') [self._task_jar_test] = build_task_for_jars('test_jars') # Build a box at position 100, 100. points = [] for dx in range(10): for dy in range(10): points.append((100 + dx, 100 + dy)) self._box_compressed_user_input = (points, None, None) self._box_user_input = simulator.build_user_input(points=points) self._ball_user_input = simulator.build_user_input(balls=[100, 100, 5])
def setUp(self): [self._task] = build_task('test') # Build a box at position 100, 100. points = [] for dx in range(10): for dy in range(10): points.append((100 + dx, 100 + dy)) self._box_compressed_user_input = (points, None, None) self._box_user_input = simulator.build_user_input(points=points)
def save_user_input(user_input, fpath): if not isinstance(user_input, scene_if.UserInput): user_input = simulator.build_user_input(*user_input) with open(fpath, 'wb') as stream: stream.write(simulator.serialize(user_input))
def test_add_empy_user_input_to_scene(self): points = [] scene = simulator.add_user_input_to_scene( self._task.scene, simulator.build_user_input(points)) self.assertEqual(len(scene.bodies), 6) self.assertEqual(len(scene.user_input_bodies), 0)