code: def test_multiple_connected_components_metric_precomputed(
      global_dtype,
  ):
      # Test that an error is raised when the graph has multiple components
      # and when X is a precomputed neighbors graph.
      X = np.array([0, 1, 2, 5, 6, 7])[:, None].astype(
          global_dtype, copy=False
      )
  
      # works with a precomputed distance matrix (dense)
      X_distances = pairwise_distances(X)
      with pytest.warns(
          UserWarning, match="number of connected components"
      ):
          manifold.Isomap(n_neighbors=1, metric="precomputed").fit(
              X_distances
          )
  
      # does not work with a precomputed neighbors graph (sparse)
      X_graph = neighbors.kneighbors_graph(
          X, n_neighbors=2, mode="distance"
      )
      with pytest.raises(
          RuntimeError, match="number of connected components"
      ):
          manifold.Isomap(n_neighbors=1, metric="precomputed").fit(
              X_graph
          )
  
imports: import math
  from itertools import product
  import numpy
  import pytest
  from scipy.sparse import rand
  from sklearn import clone, datasets, manifold, neighbors, pipeline, preprocessing
  from sklearn.datasets import make_blobs
  from sklearn.metrics.pairwise import pairwise_distances
  from sklearn.utils._testing import assert_allclose, assert_allclose_dense_sparse, assert_array_equal
  from sklearn.utils.fixes import CSR_CONTAINERS
label_desc: Use image node_id 15 for calling a global function with example usage: test_multiple_connected_components_metric_precomputed(global_dtype) without return types