Repository: scikit-learn/scikit-learn
File: sklearn/manifold/_mds.py (Python)

Code before:
            chosen array.

        Returns
        -------
        X_new : ndarray of shape (n_samples, n_components)
            X transformed in the new space.
        """

        if self.n_init == "warn":
            warnings.warn(
                "The default value of `n_init` will change from 4 to 1 in 1.9. "
                "To suppress this warning, provide some value of `n_init`.",
                FutureWarning,
            )
            self._n_init = 4
        else:
            self._n_init = self.n_init

        if self.init == "warn":
            warnings.warn(
                "The default value of `init` will change from 'random' to "
                "'classical_mds' in 1.10. To suppress this warning, provide "
                "some value of `init`.",
                FutureWarning,
            )
            self._init = "random"
        else:
            self._init = self.init

        if self.dissimilarity != "deprecated":
            warnings.warn(
                "The `dissimilarity` parameter is deprecated and will be removed "
                "in 1.10. Use `metric` instead. Until then, `dissimilarity` value "
                "overrides `metric` value.",
                FutureWarning,
            )
            self._metric = self.dissimilarity

        if isinstance(self.metric, bool):
            warnings.warn(
                f"Use metric_mds={self.metric} instead of metric={self.metric}. The "
                "support for metric={True/False} will be dropped in 1.10.",
                FutureWarning,
            )
            if self.dissimilarity == "deprecated":
                self._metric = "euclidean"
            self._metric_mds = self.metric
        else:
            if self.dissimilarity == "deprecated":
                self._metric = self.metric
            self._metric_mds = self.metric_mds

Review comment (suggestion):
we should also raise a `ValueError` if `dissimilarity` and `metric` (non-boolean) are both provided.

Code after:
        X_new : ndarray of shape (n_samples, n_components)
            X transformed in the new space.
        """

        if self.n_init == "warn":
            warnings.warn(
                "The default value of `n_init` will change from 4 to 1 in 1.9. "
                "To suppress this warning, provide some value of `n_init`.",
                FutureWarning,
            )
            self._n_init = 4
        else:
            self._n_init = self.n_init

        if self.init == "warn":
            warnings.warn(
                "The default value of `init` will change from 'random' to "
                "'classical_mds' in 1.10. To suppress this warning, provide "
                "some value of `init`.",
                FutureWarning,
            )
            self._init = "random"
        else:
            self._init = self.init

        if self.dissimilarity != "deprecated":
            if not isinstance(self.metric, bool) and self.metric != "euclidean":
                raise ValueError(
                    "You provided both `dissimilarity` and `metric`. Please use "
                    "only `metric`."
                )
            else:
                warnings.warn(
                    "The `dissimilarity` parameter is deprecated and will be "
                    "removed in 1.10. Use `metric` instead.",
                    FutureWarning,
                )
                self._metric = self.dissimilarity

        if isinstance(self.metric, bool):
            warnings.warn(
                f"Use metric_mds={self.metric} instead of metric={self.metric}. The "
                "support for metric={True/False} will be dropped in 1.10.",
                FutureWarning,
            )
            if self.dissimilarity == "deprecated":
                self._metric = "euclidean"
            self._metric_mds = self.metric
        else:
            if self.dissimilarity == "deprecated":
                self._metric = self.metric