def sample(
            self, 
            n: Optional[int] = None,
        ) -> Union[object,np.ndarray]:
        """
        Randomly sample ``n`` instances of a decision variable.

        Parameters
        ----------
        n : int, None
            Number of decision variable samples which to draw.
            If ``int``, sample ``n`` decision variables.
            If ``None``, sample a single decision variables.
        
        Returns
        -------
        out : object, np.ndarray
            If ``n`` is ``int``, return a ``np.ndarray`` of shape ``(n,)`` 
            containing sampled decision variables.
            If ``n`` is ``None``, return an ``object`` of a sampled decision 
            variable.
        """
        if n is None:
            return self._sample(1)[0]
        else:
            return self._sample(n)

        Randomly sample ``n`` instances of a decision variable.

        Parameters
        ----------
        n : int, None
            Number of decision variable samples which to draw.
            If ``int``, sample ``n`` decision variables.
            If ``None``, sample a single decision variables.
        
        Returns
        -------
        out : object, np.ndarray
            If ``n`` is ``int``, return a ``np.ndarray`` of shape ``(n,)`` 
            containing sampled decision variables.
            If ``n`` is ``None``, return an ``object`` of a sampled decision 
            variable.
        
pymoo/core/variable.py