def with_values(self, values: np.ndarray) -> Self:
        """
        Return a new ``TimeSeries`` similar to this one but with new specified values.

        Parameters
        ----------
        values
            A Numpy array with new values. It must have the dimensions for time
            and componentns, but may contain a different number of samples.

        Returns
        -------
        TimeSeries
            A new TimeSeries with the new values and same index, static covariates and hierarchy
        """
        values = np.array(values) if not isinstance(values, np.ndarray) else values
        values = expand_arr(values, ndim=len(DIMS))
        raise_if_not(
            values.shape[:2] == self._xa.values.shape[:2],
            "The new values must have the same shape (time, components) as the present series. "
            f"Received: {values.shape[:2]}, expected: {self._xa.values.shape[:2]}",
        )

        new_xa = xr.DataArray(
            values,
            dims=self._xa.dims,
            coords=self._xa.coords,
            attrs=self._xa.attrs,
        )

        return self.__class__(new_xa)

        Return a new ``TimeSeries`` similar to this one but with new specified values.

        Parameters
        ----------
        values
            A Numpy array with new values. It must have the dimensions for time
            and componentns, but may contain a different number of samples.

        Returns
        -------
        TimeSeries
            A new TimeSeries with the new values and same index, static covariates and hierarchy
        
darts/timeseries.py