(self, limits, num_points)
Initialization, see `GridWorld`.
Initialization, see `GridWorld`.
Initialization see GridWorld .
def __init__(self, limits, num_points):
        """Initialization, see `GridWorld`."""
        super(GridWorld, self).__init__()

        self.limits = np.atleast_2d(limits).astype(config.np_dtype)
        num_points = np.broadcast_to(num_points, len(self.limits))
        self.num_points = num_points.astype(np.int, copy=False)

        if np.any(self.num_points < 2):
            raise DimensionError('There must be at least 2 points in each '
                                 'dimension.')

        # Compute offset and unit hyperrectangle
        self.offset = self.limits[:, 0]
        self.unit_maxes = ((self.limits[:, 1] - self.offset)
                           / (self.num_points - 1)).astype(config.np_dtype)
        self.offset_limits = np.stack((np.zeros_like(self.limits[:, 0]),
                                       self.limits[:, 1] - self.offset),
                                      axis=1)

        # Statistics about the grid
        self.discrete_points = [np.linspace(low, up, n, dtype=config.np_dtype)
                                for (low, up), n in zip(self.limits,
                                                        self.num_points)]

        self.nrectangles = np.prod(self.num_points - 1)
        self.nindex = np.prod(self.num_points)

        self.ndim = len(self.limits)
        self._all_points = None
def __init__ ( self , limits , num_points ) : super ( GridWorld , self ) . __init__ ( ) self . limits = np . atleast_2d ( limits ) . astype ( config . np_dtype ) num_points = np . broadcast_to ( num_points , len ( self . limits ) ) self . num_points = num_points . astype ( np . int , copy = False ) if np . any ( self . num_points < 2 ) : raise DimensionError ( 'There must be at least 2 points in each ' 'dimension.' ) # Compute offset and unit hyperrectangle self . offset = self . limits [ : , 0 ] self . unit_maxes = ( ( self . limits [ : , 1 ] - self . offset ) / ( self . num_points - 1 ) ) . astype ( config . np_dtype ) self . offset_limits = np . stack ( ( np . zeros_like ( self . limits [ : , 0 ] ) , self . limits [ : , 1 ] - self . offset ) , axis = 1 ) # Statistics about the grid self . discrete_points = [ np . linspace ( low , up , n , dtype = config . np_dtype ) for ( low , up ) , n in zip ( self . limits , self . num_points ) ] self . nrectangles = np . prod ( self . num_points - 1 ) self . nindex = np . prod ( self . num_points ) self . ndim = len ( self . limits ) self . _all_points = None