<commit_before>import numpy as np
import itertools
from panda3d.core import Point3, BoundingBox
from citysim3d.envs import SimpleQuadPanda3dEnv
from citysim3d.spaces import BoxSpace, TupleSpace


class Bbox3dSimpleQuadPanda3dEnv(SimpleQuadPanda3dEnv):
    def __init__(self, *args, **kwargs):
        super(Bbox3dSimpleQuadPanda3dEnv, self).__init__(*args, **kwargs)

        if len(self.sensor_names) == 0:
            observation_spaces = []
        elif len(self.sensor_names) == 1:
            observation_spaces = [self._observation_space]
        else:
            assert isinstance(self._observation_space, TupleSpace)
            observation_spaces = list(self._observation_space.spaces)
        bbox_space = BoxSpace(-np.inf, np.inf, shape=(3,))
        self._observation_space = TupleSpace([bbox_space] + observation_spaces)

        self.car_env._car_local_node.showTightBounds()

    def observe(self):
        obj_node = self.car_env._car_local_node
        cam_node = self.camera_node
        bounds = BoundingBox(*obj_node.getTightBounds())
        corners_XYZ = np.array(list(itertools.product(*zip(bounds.getMin(), bounds.getMax()))))
        obj_to_cam_T = obj_node.getParent().getMat(cam_node)
        corners_XYZ = np.array([obj_to_cam_T.xform(Point3(*corner_XYZ)) for corner_XYZ in corners_XYZ])[:, :3]

        if self.sensor_names:<commit_msg>Comment out rendering of bbox3d.<commit_after>import numpy as np
import itertools
from panda3d.core import Point3, BoundingBox
from citysim3d.envs import SimpleQuadPanda3dEnv
from citysim3d.spaces import BoxSpace, TupleSpace


class Bbox3dSimpleQuadPanda3dEnv(SimpleQuadPanda3dEnv):
    def __init__(self, *args, **kwargs):
        super(Bbox3dSimpleQuadPanda3dEnv, self).__init__(*args, **kwargs)

        if len(self.sensor_names) == 0:
            observation_spaces = []
        elif len(self.sensor_names) == 1:
            observation_spaces = [self._observation_space]
        else:
            assert isinstance(self._observation_space, TupleSpace)
            observation_spaces = list(self._observation_space.spaces)
        bbox_space = BoxSpace(-np.inf, np.inf, shape=(3,))
        self._observation_space = TupleSpace([bbox_space] + observation_spaces)

        # uncomment to visualize bounding box (makes rendering slow)
        # self.car_env._car_local_node.showTightBounds()

    def observe(self):
        obj_node = self.car_env._car_local_node
        cam_node = self.camera_node
        bounds = BoundingBox(*obj_node.getTightBounds())
        corners_XYZ = np.array(list(itertools.product(*zip(bounds.getMin(), bounds.getMax()))))
        obj_to_cam_T = obj_node.getParent().getMat(cam_node)
        corners_XYZ = np.array([obj_to_cam_T.xform(Point3(*corner_XYZ)) for corner_XYZ in corners_XYZ])[:, :3]

        if self.sensor_names:
{'fraction_non_alphanumeric': 0.10240963855421686, 'fraction_numerical': 0.010985116938341602, 'mean_word_length': 3.643092105263158, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6803098', 'n_tokens_mistral': 944, 'n_tokens_neox': 924, 'n_words': 159}