def handle_observations( cls, env: magent.GridWorld, handle ) -> List[Tuple[np.ndarray, np.ndarray]]: view_obs, feats_obs = env.get_observation(handle) entries = view_obs.shape[0] if entries == 0: return [] # copy data view_obs = np.array(view_obs) feats_obs = np.array(feats_obs) view_obs = np.moveaxis(view_obs, 3, 1) res = [] for o_view, o_feats in zip(np.vsplit(view_obs, entries), np.vsplit(feats_obs, entries)): res.append((o_view[0], o_feats[0])) return res
def handle_observations(cls, environment: GridWorld, handle: int) -> List[Tuple[ndarray, ndarray]]: view_observation, feature_observation = environment.get_observation( handle) entries: int = view_observation.shape[0] if entries == 0: return [] view_observation_array: ndarray = np.array(view_observation) feature_observation_array: ndarray = np.array(feature_observation) view_observation_array = np.moveaxis(view_observation_array, 3, 1) result: List[Tuple[ndarray, ndarray]] = [] for observation, features in zip( np.vsplit(view_observation_array, entries), np.vsplit(feature_observation_array, entries)): result.append((observation[0], features[0])) return result