code: def test_error_when_nan_introduced_during_transform():
      # test error when NA are introduced during the discretisation.
      rng = default_rng()
  
      # create dataframe with 2 variables, 1 normal and 1 skewed
      random = skewnorm.rvs(a=-50, loc=4, size=100)
      random = random - min(
          random
      )  # Shift so the minimum value is equal to zero.
  
      train = pd.concat(
          [
              pd.Series(rng.standard_normal(100)),
              pd.Series(random),
          ],
          axis=1,
      )
  
      train.columns = ["var_a", "var_b"]
  
      # create a dataframe with 2 variables normally distributed
      test = pd.concat(
          [
              pd.Series(rng.standard_normal(100)),
              pd.Series(rng.standard_normal(100)),
          ],
          axis=1,
      )
  
      test.columns = ["var_a", "var_b"]
  
      msg = (
          "During the discretisation, NaN values were introduced "
          "in the feature(s) var_b."
      )
  
      limits_dict = {"var_a": [-5, -2, 0, 2, 5], "var_b": [0, 2, 5]}
  
      # check for warning when errors equals 'ignore'
      with pytest.warns(UserWarning) as record:
          transformer = ArbitraryDiscretiser(
              binning_dict=limits_dict, errors="ignore"
          )
          transformer.fit(train)
          transformer.transform(test)
  
      # check that only one warning was returned
      assert len(record) == 1
      # check that message matches
      assert record[0].message.args[0] == msg
  
      # check for error when errors equals 'raise'
      with pytest.raises(ValueError) as record:
          transformer = ArbitraryDiscretiser(
              binning_dict=limits_dict, errors="raise"
          )
          transformer.fit(train)
          transformer.transform(test)
  
      # check that error message matches
      assert str(record.value) == msg
  
file_path: feature_engine/tests/test_discretisation/test_arbitrary_discretiser.py
imports: import numpy
  import pandas
  import pytest
  from numpy.random import default_rng
  from scipy.stats import skewnorm
  from sklearn.datasets import fetch_california_housing
  from feature_engine.discretisation import ArbitraryDiscretiser
label_desc: Use image node_id 3 for calling a global function with example usage: test_error_when_nan_introduced_during_transform() without return types