class_docstr: An environment wrapper for normalization.
  
  This wrapper normalizes action, and optionally observation and reward.
  
  Args:
      env (Environment): An environment instance.
      scale_reward (float): Scale of environment reward.
      normalize_obs (bool): If True, normalize observation.
      normalize_reward (bool): If True, normalize reward. scale_reward is
          applied after normalization.
      expected_action_scale (float): Assuming action falls in the range of
          [-expected_action_scale, expected_action_scale] when normalize it.
      flatten_obs (bool): Flatten observation if True.
      obs_alpha (float): Update rate of moving average when estimating the
          mean and variance of observations.
      reward_alpha (float): Update rate of moving average when estimating the
          mean and variance of rewards.
class_docstr_tok: ["An","environment","wrapper","for","normalization",".","This","wrapper","normalizes","action",",","and","optionally","observation","and","reward",".","Args",":","env","(","Environment",")",":","An","environment","instance",".","scale_reward","(","float",")",":","Scale","of","environment","reward",".","normalize_obs","(","bool",")",":","If","True",",","normalize","observation",".","normalize_reward","(","bool",")",":","If","True",",","normalize","reward",".","scale_reward","is","applied","after","normalization",".","expected_action_scale","(","float",")",":","Assuming","action","falls","in","the","range","of","[","-expected_action_scale",",","expected_action_scale","]","when","normalize","it",".","flatten_obs","(","bool",")",":","Flatten","observation","if","True",".","obs_alpha","(","float",")",":","Update","rate","of","moving","average","when","estimating","the","mean","and","variance","of","observations",".","reward_alpha","(","float",")",":","Update","rate","of","moving","average","when","estimating","the","mean","and","variance","of","rewards","."]
docstr: Call step on wrapped env.
  
  Args:
      action (np.ndarray): An action provided by the agent.
  
  Returns:
      EnvStep: The environment step resulting from the action.
  
  Raises:
      RuntimeError: if `step()` is called after the environment has been
          constructed and `reset()` has not been called.
docstr_tok: ["Call","step","on","wrapped","env",".","Args",":","action","(","np.ndarray",")",":","An","action","provided","by","the","agent",".","Returns",":","EnvStep",":","The","environment","step","resulting","from","the","action",".","Raises",":","RuntimeError",":","if","`","step","(",")","`","is","called","after","the","environment","has","been","constructed","and","`","reset","(",")","`","has","not","been","called","."]
code: def step(self, action):
      """Call step on wrapped env.
  
      Args:
          action (np.ndarray): An action provided by the agent.
  
      Returns:
          EnvStep: The environment step resulting from the action.
  
      Raises:
          RuntimeError: if `step()` is called after the environment has been
              constructed and `reset()` has not been called.
  
      """
      if isinstance(self.action_space, akro.Box):
          # rescale the action when the bounds are not inf
          lb, ub = self.action_space.low, self.action_space.high
          if np.all(lb != -np.inf) and np.all(ub != -np.inf):
              scaled_action = lb + (
                  action + self._expected_action_scale
              ) * (0.5 * (ub - lb) / self._expected_action_scale)
              scaled_action = np.clip(scaled_action, lb, ub)
          else:
              scaled_action = action
      else:
          scaled_action = action
  
      es = self._env.step(scaled_action)
      next_obs = es.observation
      reward = es.reward
  
      if self._normalize_obs:
          next_obs = self._apply_normalize_obs(next_obs)
      if self._normalize_reward:
          reward = self._apply_normalize_reward(reward)
  
      return EnvStep(
          env_spec=es.env_spec,
          action=action,
          reward=reward * self._scale_reward,
          observation=next_obs,
          env_info=es.env_info,
          step_type=es.step_type,
      )
  
file_path: garage/src/garage/envs/normalized_env.py
imports: import akro
  import numpy
  from garage import EnvStep, Wrapper
label_desc: Use image node_id 3 for calling the NormalizedEnv obj's underlying member method code with example usage: obj.step(action) and returns: EnvStep