code: def test_one_hot(self):
      X = th.create_dataset(n_rows=100)
      X_t = th.create_dataset(n_rows=50, extras=True)
      enc = encoders.OneHotEncoder(verbose=1, return_df=False)
      enc.fit(X)
      self.assertEqual(
          enc.transform(X_t).shape[1],
          enc.transform(X).shape[1],
          "We have to get the same count of columns despite the presence of a new value",
      )
  
      enc = encoders.OneHotEncoder(
          verbose=1, return_df=True, handle_unknown="indicator"
      )
      enc.fit(X)
      out = enc.transform(X_t)
      self.assertIn("extra_-1", out.columns)
  
      enc = encoders.OneHotEncoder(
          verbose=1, return_df=True, handle_unknown="return_nan"
      )
      enc.fit(X)
      out = enc.transform(X_t)
      self.assertEqual(
          len([x for x in out.columns if str(x).startswith("extra_")]),
          3,
      )
  
      enc = encoders.OneHotEncoder(
          verbose=1, return_df=True, handle_unknown="error"
      )
      # The exception is already raised in fit() because transform() is called there to get
      # feature_names right.
      enc.fit(X)
      with self.assertRaises(ValueError):
          enc.transform(X_t)
  
      enc = encoders.OneHotEncoder(
          verbose=1,
          return_df=True,
          handle_unknown="return_nan",
          use_cat_names=True,
      )
      enc.fit(X)
      out = enc.transform(X_t)
      self.assertIn("extra_A", out.columns)
  
      enc = encoders.OneHotEncoder(
          verbose=1,
          return_df=True,
          use_cat_names=True,
          handle_unknown="indicator",
      )
      enc.fit(X)
      out = enc.transform(X_t)
      self.assertIn("extra_-1", out.columns)
  
      # test inverse_transform
      X_i = th.create_dataset(n_rows=100, has_missing=False)
      X_i_t = th.create_dataset(n_rows=50, has_missing=False)
      cols = ["underscore", "none", "extra", "categorical"]
  
      enc = encoders.OneHotEncoder(
          verbose=1, use_cat_names=True, cols=cols
      )
      enc.fit(X_i)
      obtained = enc.inverse_transform(enc.transform(X_i_t))
      th.verify_inverse_transform(X_i_t, obtained)
  
imports: import pandas
  from unittest import TestCase
  import numpy
  import tests.helpers
  import category_encoders
label_desc: Use image node_id 1 for calling the TestOneHotEncoderTestCase obj's underlying member method code with example usage: obj.test_one_hot() without return types