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
评论列表
文章目录