A ViewData that is implemented in memory.
| 184 | |
| 185 | |
| 186 | class MemoryViewData(ViewData): |
| 187 | """ |
| 188 | A ViewData that is implemented in memory. |
| 189 | """ |
| 190 | |
| 191 | def __init__(self, channels: Dict[str, np.ndarray], cameras: List[Camera]): |
| 192 | assert all(v.shape[0] == len(cameras) for v in channels.values()) |
| 193 | self.channels = channels |
| 194 | self.cameras = cameras |
| 195 | |
| 196 | @property |
| 197 | def num_views(self) -> int: |
| 198 | return len(self.cameras) |
| 199 | |
| 200 | @property |
| 201 | def channel_names(self) -> List[str]: |
| 202 | return list(self.channels.keys()) |
| 203 | |
| 204 | def load_view(self, index: int, channels: List[str]) -> Tuple[Camera, np.ndarray]: |
| 205 | outputs = [self.channels[channel][index] for channel in channels] |
| 206 | return self.cameras[index], np.stack(outputs, axis=-1) |
nothing calls this directly
no outgoing calls
no test coverage detected