Source code for grid2op.Exceptions.observationExceptions

# Copyright (c) 2019-2020, RTE (https://www.rte-france.com)
# See AUTHORS.txt
# This Source Code Form is subject to the terms of the Mozilla Public License, version 2.0.
# If a copy of the Mozilla Public License, version 2.0 was not distributed with this file,
# you can obtain one at http://mozilla.org/MPL/2.0/.
# SPDX-License-Identifier: MPL-2.0
# This file is part of Grid2Op, Grid2Op a testbed platform to model sequential decision making in power systems.

from grid2op.Exceptions.grid2OpException import Grid2OpException


[docs]class BaseObservationError(Grid2OpException): """ Generic type of exceptions raised by the observation """ pass
# BaseObservation # Functionality not implemented by the observation
[docs]class NoForecastAvailable(Grid2OpException): """ This exception is mainly raised by the :class:`grid2op.Observation.BaseObservation`. It specifies the :class:`grid2op.Agent.BaseAgent` that the :class:`grid2op.Chronics.GridValue` doesn't produce any forecasts. In that case it is not possible to use the :func:`grid2op.Observation.BaseObservation.forecasts` method. """ pass
[docs]class SimulateError(BaseObservationError): """ This is the generic exception related to :func:`grid2op.Observation.BaseObservation.simulate` function """ pass
class SimulateUsedTooMuch(SimulateError): pass
[docs]class SimulateUsedTooMuchThisStep(SimulateUsedTooMuch): """ This exception is raised by the :class:`grid2op.Observation.BaseObservation` when using "obs.simulate(...)". It is raised when the total number of calls to `obs.simulate(...)` exceeds the maximum number of allowed calls to it, for a given step. You can do more "obs.simulate" if you call "env.step". """ pass
[docs]class SimulateUsedTooMuchThisEpisode(SimulateUsedTooMuch): """ This exception is raised by the :class:`grid2op.Observation.BaseObservation` when using "obs.simulate(...)". It is raised when the total number of calls to `obs.simulate(...)` exceeds the maximum number of allowed calls to it for this episode. The only way to use "obs.simulate(...)" again is to call "env.reset(...)" """ pass
[docs]class EnvDependantAttributeCalledTooLate(BaseObservationError): """This error tells you that you called a observation attribute that depends on the env state (*eg* gen_uptime) but that the env state has moved between (env.reset or env.step has been called) the time the observation has been created and the time this attribute has been called. This can happen in this case: .. code-block:: python import grid2op env_name = "l2rpn_case14_sandbox" env = grid2op.make(env_name) init_obs = env.reset() next_obs, *_ = env.step(env.action_space()) next_obs.gen_uptime # perfectly fine init_obs.gen_uptime """ pass