bounded_space.py 文件源码

python
阅读 23 收藏 0 点赞 0 评论 0

项目:Safe-RL-Benchmark 作者: befelix 项目源码 文件源码
def __init__(self, lower, upper, shape=None):
        """Initialize BoundedSpace.

        Parameters
        ----------
        lower : array-like
            Lower bound of the space. Either an array or an integer.
            Must agree with the input of the upper bound.
        upper : array-like
            Upper bound of the space. Either an array or an integer. Must
            agree with the input of the lower bound.
        shape : integer
            Shape of the bounds. Input will be ignored, if the bounds are non
            scalar, if they are scalar, it must be set.
        """
        if (np.isscalar(lower) and np.isscalar(upper)):
            assert shape is not None, "Shape must be set, if bounds are scalar"
            self.lower = np.zeros(shape) + lower
            self.upper = np.zeros(shape) + upper
        else:
            self.lower = np.array(lower)
            self.upper = np.array(upper)
            assert self.lower.shape == self.upper.shape, "Shapes do not agree."

        self._dim = None
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号