def warp()

in bayesmark/space.py [0:0]


    def warp(self, X):
        """Warp inputs to a continuous space.

        Parameters
        ----------
        X : list(dict(str, object)) of shape (n,)
            List of `n` points in the joint space to warp. Each list element is a dictionary where each key corresponds
            to a variable in the joint space. Keys can be be missing in the records and the according warped variables
            will be ``nan``.

        Returns
        -------
        X_w : :class:`numpy:numpy.ndarray` of shape (n, m)
            Warped version of input space. Result is 2D `float` np array. `n` is the number of input points, length
            of `X`. `m` is the size of the joint warped space, which can be inferred by calling :func:`.get_bounds`.
        """
        # It would be nice to have cleaner way to deal with this corner case
        if len(X) == 0:
            return np.zeros((0, self.blocks[-1]), dtype=WARPED_DTYPE)

        X_w = [
            np.concatenate(
                [
                    self.spaces[param].warp(record[param])
                    if param in record
                    else np.full(len(self.spaces[param].get_bounds()), np.nan)
                    for param in self.param_list
                ]
            )
            for record in X
        ]
        X_w = np.stack(X_w, axis=0)
        check_array(X_w, "X", shape=(len(X), self.blocks[-1]), dtype=WARPED_DTYPE)
        return X_w