code: def test_spline_transformer_periodic_splines_smoothness(degree):
      """Test that spline transformation is smooth at first / last knot."""
      X = np.linspace(-2, 10, 10_000)[:, None]
  
      transformer = SplineTransformer(
          degree=degree,
          extrapolation="periodic",
          knots=[[0.0], [1.0], [3.0], [4.0], [5.0], [8.0]],
      )
      Xt = transformer.fit_transform(X)
  
      delta = (X.max() - X.min()) / len(X)
      tol = 10 * delta
  
      dXt = Xt
      # We expect splines of degree `degree` to be (`degree`-1) times
      # continuously differentiable. I.e. for d = 0, ..., `degree` - 1 the d-th
      # derivative should be continuous. This is the case if the (d+1)-th
      # numerical derivative is reasonably small (smaller than `tol` in absolute
      # value). We thus compute d-th numeric derivatives for d = 1, ..., `degree`
      # and compare them to `tol`.
      #
      # Note that the 0-th derivative is the function itself, such that we are
      # also checking its continuity.
      for d in range(1, degree + 1):
          # Check continuity of the (d-1)-th derivative
          diff = np.diff(dXt, axis=0)
          assert np.abs(diff).max() < tol
          # Compute d-th numeric derivative
          dXt = diff / delta
  
      # As degree `degree` splines are not `degree` times continuously
      # differentiable at the knots, the `degree + 1`-th numeric derivative
      # should have spikes at the knots.
      diff = np.diff(dXt, axis=0)
      assert np.abs(diff).max() > 1
  
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 12 for calling a global function with example usage: test_spline_transformer_periodic_splines_smoothness(degree) without return types