(observation_dict, observation_excluded=())
Flattens the observation dictionary to an array.

  If observation_excluded is passed in, it will still return a dictionary,
  which includes all the (key, observation_dict[key]) in observation_excluded,
  and ('other': the flattened array).

  Args:
    observation_dict: A dictionary of all the observations.
    observation_excluded: A list/tuple of all the keys of the observations to be
      ignored during flattening.

  Returns:
    An array or a dictionary of observations based on whether
      observation_excluded is empty.
Flattens the observation dictionary to an array.
Flattens the observation dictionary to an array .
def flatten_observations(observation_dict, observation_excluded=()):
  """Flattens the observation dictionary to an array.

  If observation_excluded is passed in, it will still return a dictionary,
  which includes all the (key, observation_dict[key]) in observation_excluded,
  and ('other': the flattened array).

  Args:
    observation_dict: A dictionary of all the observations.
    observation_excluded: A list/tuple of all the keys of the observations to be
      ignored during flattening.

  Returns:
    An array or a dictionary of observations based on whether
      observation_excluded is empty.
  """
  if not isinstance(observation_excluded, (list, tuple)):
    observation_excluded = [observation_excluded]
  observations = []
  for key, value in observation_dict.items():
    if key not in observation_excluded:
      observations.append(np.asarray(value).flatten())
  flat_observations = np.concatenate(observations)
  if not observation_excluded:
    return flat_observations
  else:
    observation_dict_after_flatten = {"other": flat_observations}
    for key in observation_excluded:
      observation_dict_after_flatten[key] = observation_dict[key]
    return collections.OrderedDict(
        sorted(list(observation_dict_after_flatten.items())))
def flatten_observations ( observation_dict , observation_excluded = ( ) ) : if not isinstance ( observation_excluded , ( list , tuple ) ) : observation_excluded = [ observation_excluded ] observations = [ ] for key , value in observation_dict . items ( ) : if key not in observation_excluded : observations . append ( np . asarray ( value ) . flatten ( ) ) flat_observations = np . concatenate ( observations ) if not observation_excluded : return flat_observations else : observation_dict_after_flatten = { "other" : flat_observations } for key in observation_excluded : observation_dict_after_flatten [ key ] = observation_dict [ key ] return collections . OrderedDict ( sorted ( list ( observation_dict_after_flatten . items ( ) ) ) )