commonpower.control.parsing.ArrayParser

class ArrayParser(env: Wrapper | ControlEnv, unwrapped_env: ControlEnv)[source]

Bases: BaseParser

Base class for parsers. :param env: environment (potentially wrapped) :type env: Union[gym.Wrapper, ControlEnv] :param unwrapped_env: unwrapped environment :type unwrapped_env: ControlEnv

Methods

parse_action

Transforms the action provided by the DeploymentRunner _run() function to the format required by the underlying environment :param original_action: action provided by DeploymentRunner :type original_action: OrderedDict

parse_obs

Transforms the observation returned by the environment to the form {ctrl_id: np.ndarray} used in the DeploymentRunner _run() function.

parse_action(original_action: OrderedDict) ndarray | list | dict | OrderedDict[source]

Transforms the action provided by the DeploymentRunner _run() function to the format required by the underlying environment :param original_action: action provided by DeploymentRunner :type original_action: OrderedDict

Returns:

(np.ndarray) – transformed action

parse_obs(original_obs: ndarray | list | dict | OrderedDict) OrderedDict[source]

Transforms the observation returned by the environment to the form {ctrl_id: np.ndarray} used in the DeploymentRunner _run() function. :param original_obs: observation from environment :type original_obs: np.ndarray

Returns:

(OrderedDict) – transformed observation as {ctrl_id: np.ndarray}