simulariumio/trajectory_converter.py
def _get_spatial_bundle_data_no_subpoints(
        agent_data: AgentData,
        type_ids: np.ndarray,
    ) -> List[Dict[str, Any]]:
        """
        Return the spatialData's bundleData for a simulation
        of agents without subpoints, using list slicing for speed
        """
        bundle_data = []
        max_n_agents = int(np.amax(agent_data.n_agents, 0))
        ix_positions = np.empty((3 * max_n_agents,), dtype=int)
        ix_rotations = np.empty((3 * max_n_agents,), dtype=int)
        buffer_struct = V1_SPATIAL_BUFFER_STRUCT
        for i in range(max_n_agents):
            ix_positions[3 * i : 3 * i + 3] = np.arange(
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.POSX_INDEX,
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.POSX_INDEX + 3,
            )
            ix_rotations[3 * i : 3 * i + 3] = np.arange(
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.ROTX_INDEX,
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.ROTX_INDEX + 3,
            )
        frame_buf = np.zeros((buffer_struct.VALUES_PER_AGENT - 1) * max_n_agents)
        total_steps = (
            agent_data.n_timesteps
            if agent_data.n_timesteps >= 0
            else len(agent_data.times)
        )
        for time_index in range(total_steps):
            frame_data = {}
            frame_data["frameNumber"] = time_index
            frame_data["time"] = float(agent_data.times[time_index])
            n_agents = int(agent_data.n_agents[time_index])
            local_buf = frame_buf[: (buffer_struct.VALUES_PER_AGENT - 1) * n_agents]
            local_buf[
                buffer_struct.VIZ_TYPE_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.viz_types[time_index, :n_agents]
            local_buf[
                buffer_struct.UID_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.unique_ids[time_index, :n_agents]
            local_buf[
                buffer_struct.TID_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = type_ids[time_index, :n_agents]
            local_buf[ix_positions[: 3 * n_agents]] = agent_data.positions[
                time_index, :n_agents
            ].flatten()
            local_buf[ix_rotations[: 3 * n_agents]] = agent_data.rotations[
                time_index, :n_agents
            ].flatten()
            local_buf[
                buffer_struct.R_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.radii[time_index, :n_agents]
            frame_data["data"] = local_buf.tolist()
            bundle_data.append(frame_data)
        return bundle_data

        Return the spatialData's bundleData for a simulation
        of agents without subpoints, using list slicing for speed
        
Return the spatialData's bundleData for a simulation
of agents without subpoints, using list slicing for speed
Return the spatialData ' s bundleData for a simulation of agents without subpoints using list slicing for speed
def _get_spatial_bundle_data_no_subpoints(
        agent_data: AgentData,
        type_ids: np.ndarray,
    ) -> List[Dict[str, Any]]:
        bundle_data = []
        max_n_agents = int(np.amax(agent_data.n_agents, 0))
        ix_positions = np.empty((3 * max_n_agents,), dtype=int)
        ix_rotations = np.empty((3 * max_n_agents,), dtype=int)
        buffer_struct = V1_SPATIAL_BUFFER_STRUCT
        for i in range(max_n_agents):
            ix_positions[3 * i : 3 * i + 3] = np.arange(
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.POSX_INDEX,
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.POSX_INDEX + 3,
            )
            ix_rotations[3 * i : 3 * i + 3] = np.arange(
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.ROTX_INDEX,
                i * (buffer_struct.VALUES_PER_AGENT - 1) + buffer_struct.ROTX_INDEX + 3,
            )
        frame_buf = np.zeros((buffer_struct.VALUES_PER_AGENT - 1) * max_n_agents)
        total_steps = (
            agent_data.n_timesteps
            if agent_data.n_timesteps >= 0
            else len(agent_data.times)
        )
        for time_index in range(total_steps):
            frame_data = {}
            frame_data["frameNumber"] = time_index
            frame_data["time"] = float(agent_data.times[time_index])
            n_agents = int(agent_data.n_agents[time_index])
            local_buf = frame_buf[: (buffer_struct.VALUES_PER_AGENT - 1) * n_agents]
            local_buf[
                buffer_struct.VIZ_TYPE_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.viz_types[time_index, :n_agents]
            local_buf[
                buffer_struct.UID_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.unique_ids[time_index, :n_agents]
            local_buf[
                buffer_struct.TID_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = type_ids[time_index, :n_agents]
            local_buf[ix_positions[: 3 * n_agents]] = agent_data.positions[
                time_index, :n_agents
            ].flatten()
            local_buf[ix_rotations[: 3 * n_agents]] = agent_data.rotations[
                time_index, :n_agents
            ].flatten()
            local_buf[
                buffer_struct.R_INDEX :: buffer_struct.VALUES_PER_AGENT - 1
            ] = agent_data.radii[time_index, :n_agents]
            frame_data["data"] = local_buf.tolist()
            bundle_data.append(frame_data)
        return bundle_data
def _get_spatial_bundle_data_no_subpoints ( agent_data : AgentData , type_ids : np . ndarray , ) -> List [ Dict [ str , Any ] ] : bundle_data = [ ] max_n_agents = int ( np . amax ( agent_data . n_agents , 0 ) ) ix_positions = np . empty ( ( 3 * max_n_agents , ) , dtype = int ) ix_rotations = np . empty ( ( 3 * max_n_agents , ) , dtype = int ) buffer_struct = V1_SPATIAL_BUFFER_STRUCT for i in range ( max_n_agents ) : ix_positions [ 3 * i : 3 * i + 3 ] = np . arange ( i * ( buffer_struct . VALUES_PER_AGENT - 1 ) + buffer_struct . POSX_INDEX , i * ( buffer_struct . VALUES_PER_AGENT - 1 ) + buffer_struct . POSX_INDEX + 3 , ) ix_rotations [ 3 * i : 3 * i + 3 ] = np . arange ( i * ( buffer_struct . VALUES_PER_AGENT - 1 ) + buffer_struct . ROTX_INDEX , i * ( buffer_struct . VALUES_PER_AGENT - 1 ) + buffer_struct . ROTX_INDEX + 3 , ) frame_buf = np . zeros ( ( buffer_struct . VALUES_PER_AGENT - 1 ) * max_n_agents ) total_steps = ( agent_data . n_timesteps if agent_data . n_timesteps >= 0 else len ( agent_data . times ) ) for time_index in range ( total_steps ) : frame_data = { } frame_data [ "frameNumber" ] = time_index frame_data [ "time" ] = float ( agent_data . times [ time_index ] ) n_agents = int ( agent_data . n_agents [ time_index ] ) local_buf = frame_buf [ : ( buffer_struct . VALUES_PER_AGENT - 1 ) * n_agents ] local_buf [ buffer_struct . VIZ_TYPE_INDEX : : buffer_struct . VALUES_PER_AGENT - 1 ] = agent_data . viz_types [ time_index , : n_agents ] local_buf [ buffer_struct . UID_INDEX : : buffer_struct . VALUES_PER_AGENT - 1 ] = agent_data . unique_ids [ time_index , : n_agents ] local_buf [ buffer_struct . TID_INDEX : : buffer_struct . VALUES_PER_AGENT - 1 ] = type_ids [ time_index , : n_agents ] local_buf [ ix_positions [ : 3 * n_agents ] ] = agent_data . positions [ time_index , : n_agents ] . flatten ( ) local_buf [ ix_rotations [ : 3 * n_agents ] ] = agent_data . rotations [ time_index , : n_agents ] . flatten ( ) local_buf [ buffer_struct . R_INDEX : : buffer_struct . VALUES_PER_AGENT - 1 ] = agent_data . radii [ time_index , : n_agents ] frame_data [ "data" ] = local_buf . tolist ( ) bundle_data . append ( frame_data ) return bundle_data
Return the spatialData's bundleData for a simulation
of agents without subpoints, using list slicing for speed
Return the spatialData ' s bundleData for a simulation of agents without subpoints using list slicing for speed
"""
        Return the spatialData's bundleData for a simulation
        of agents without subpoints, using list slicing for speed
        """
agent_data
AgentData
type_ids
np.ndarray