Skip to content

improve error handling in BaseEnv

Summary

(Summarize the bug encountered concisely.)

Explain your context

(Explain what you did.)

What is the expected correct behavior? What was your goal?

def _observations(self) -> np.ndarray:
        """Determine the observations list from environment state. This uses state_config to determine all
        observations.

        :return: Observations for the agent as determined by state_config.
        """
        assert self.state_config is not None, "Set state_config before calling _observations function."
        try: 
            obs = np.array([self.state[name] for name in self.state_config.observations], dtype=np.float64)
         except ValueError as e:
            raise ValueError("Could not find all observations in state.") from e
        return obs

What is the current bug behavior?

(What actually happens.)

Was there an error message?

(Paste any relevant logs - please use

code blocks like this one

or

this one

to format console output, logs, and code, as it's very hard to read otherwise.)

Steps to reproduce

(How one can reproduce the issue - this is very important)