code: def test_spline_transformer_extrapolation(bias, intercept, degree):
      """Test that B-spline extrapolation works correctly."""
      # we use a straight line for that
      X = np.linspace(-1, 1, 100)[:, None]
      y = X.squeeze()
  
      # 'constant'
      pipe = Pipeline(
          [
              [
                  "spline",
                  SplineTransformer(
                      n_knots=4,
                      degree=degree,
                      include_bias=bias,
                      extrapolation="constant",
                  ),
              ],
              ["ols", LinearRegression(fit_intercept=intercept)],
          ]
      )
      pipe.fit(X, y)
      assert_allclose(pipe.predict([[-10], [5]]), [-1, 1])
  
      # 'linear'
      pipe = Pipeline(
          [
              [
                  "spline",
                  SplineTransformer(
                      n_knots=4,
                      degree=degree,
                      include_bias=bias,
                      extrapolation="linear",
                  ),
              ],
              ["ols", LinearRegression(fit_intercept=intercept)],
          ]
      )
      pipe.fit(X, y)
      assert_allclose(pipe.predict([[-10], [5]]), [-10, 5])
  
      # 'error'
      splt = SplineTransformer(
          n_knots=4,
          degree=degree,
          include_bias=bias,
          extrapolation="error",
      )
      splt.fit(X)
      msg = "X contains values beyond the limits of the knots"
      with pytest.raises(ValueError, match=msg):
          splt.transform([[-10]])
      with pytest.raises(ValueError, match=msg):
          splt.transform([[5]])
  
imports: import sys
  import numpy
  import pytest
  from numpy.testing import assert_allclose, assert_array_equal
  from scipy import sparse
  from scipy.interpolate import BSpline
  from scipy.sparse import random
  from sklearn.linear_model import LinearRegression
  from sklearn.pipeline import Pipeline
  from sklearn.preprocessing import KBinsDiscretizer, PolynomialFeatures, SplineTransformer
  from sklearn.preprocessing._csr_polynomial_expansion import _calc_expanded_nnz, _calc_total_nnz, _get_sizeof_LARGEST_INT_t
  from sklearn.utils._testing import assert_array_almost_equal
  from sklearn.utils.fixes import CSC_CONTAINERS, CSR_CONTAINERS, parse_version, sp_version
label_desc: Use image node_id 13 for calling a global function with example usage: test_spline_transformer_extrapolation(bias, intercept, degree) without return types