# Path: sksurv/preprocessing.py
# class OneHotEncoder(BaseEstimator, TransformerMixin):
#     """Encode categorical columns with `M` categories into `M-1` columns according
#     to the one-hot scheme.
# 
#     The order of non-categorical columns is preserved, encoded columns are inserted
#     inplace of the original column.
# 
#     Parameters
#     ----------
#     allow_drop : boolean, optional, default: True
#         Whether to allow dropping categorical columns that only consist
#         of a single category.
# 
#     Attributes
#     ----------
#     feature_names_ : pandas.Index
#         List of encoded columns.
# 
#     categories_ : dict
#         Categories of encoded columns.
# 
#     encoded_columns_ : list
#         Name of columns after encoding.
#         Includes names of non-categorical columns.
# 
#     n_features_in_ : int
#         Number of features seen during ``fit``.
# 
#     feature_names_in_ : ndarray of shape (`n_features_in_`,)
#         Names of features seen during ``fit``. Defined only when `X`
#         has feature names that are all strings.
#     """
#     def __init__(self, allow_drop=True):
#         self.allow_drop = allow_drop
# 
#     def fit(self, X, y=None):  # pylint: disable=unused-argument
#         """Retrieve categorical columns.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
#         y :
#             Ignored. For compatibility with Pipeline.
#         Returns
#         -------
#         self : object
#             Returns self
#         """
#         self.fit_transform(X)
#         return self
# 
#     def _encode(self, X, columns_to_encode):
#         return encode_categorical(X, columns=columns_to_encode, allow_drop=self.allow_drop)
# 
#     def fit_transform(self, X, y=None, **fit_params):  # pylint: disable=unused-argument
#         """Convert categorical columns to numeric values.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
#         y :
#             Ignored. For compatibility with TransformerMixin.
#         fit_params :
#             Ignored. For compatibility with TransformerMixin.
# 
#         Returns
#         -------
#         Xt : pandas.DataFrame
#             Encoded data.
#         """
#         self._check_feature_names(X, reset=True)
#         self._check_n_features(X, reset=True)
#         columns_to_encode = X.select_dtypes(include=["object", "category"]).columns
#         x_dummy = self._encode(X, columns_to_encode)
# 
#         self.feature_names_ = columns_to_encode
#         self.categories_ = {k: X[k].cat.categories for k in columns_to_encode}
#         self.encoded_columns_ = x_dummy.columns
#         return x_dummy
# 
#     def transform(self, X):
#         """Convert categorical columns to numeric values.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
# 
#         Returns
#         -------
#         Xt : pandas.DataFrame
#             Encoded data.
#         """
#         check_is_fitted(self, "encoded_columns_")
#         self._check_n_features(X, reset=False)
#         check_columns_exist(X.columns, self.feature_names_)
# 
#         Xt = X.copy()
#         for col, cat in self.categories_.items():
#             Xt[col] = Xt[col].cat.set_categories(cat)
# 
#         new_data = self._encode(Xt, self.feature_names_)
#         return new_data.loc[:, self.encoded_columns_]
# 
#     def get_feature_names_out(self, input_features=None):
#         """Get output feature names for transformation.
# 
#         Parameters
#         ----------
#         input_features : array-like of str or None, default=None
#             Input features.
# 
#             - If `input_features` is `None`, then `feature_names_in_` is
#               used as feature names in.
#             - If `input_features` is an array-like, then `input_features` must
#               match `feature_names_in_` if `feature_names_in_` is defined.
# 
#         Returns
#         -------
#         feature_names_out : ndarray of str objects
#             Transformed feature names.
#         """
#         check_is_fitted(self, "encoded_columns_")
#         input_features = _check_feature_names_in(self, input_features)
# 
#         return self.encoded_columns_.values.copy()


from collections import OrderedDict
from numpy.testing import assert_array_equal
from sksurv.preprocessing import OneHotEncoder
import numpy as np
import pandas as pd
import pandas.testing as tm
import pytest
    def _create_data(n_samples=117):
        rnd = np.random.RandomState(51365192)
        data_num = pd.DataFrame(rnd.rand(n_samples, 5),
                                columns=["N%d" % i for i in range(5)])

        dat_cat = pd.DataFrame(OrderedDict([
            ("binary_1", pd.Categorical.from_codes(
                rnd.binomial(1, 0.6, n_samples),
                ["Yes", "No"])),
            ("binary_2", pd.Categorical.from_codes(
                rnd.binomial(1, 0.376, n_samples),
                ["East", "West"])),
            ("trinary", pd.Categorical.from_codes(
                rnd.binomial(2, 0.76, n_samples),
                ["Green", "Blue", "Red"])),
            ("many", pd.Categorical.from_codes(
                rnd.binomial(5, 0.47, n_samples),
                ["One", "Two", "Three", "Four", "Five", "Six"]))
        ]))
        data = pd.concat((data_num, dat_cat), axis=1)
        return data, _encoded_data(data)

    return _create_data


class TestOneHotEncoder:
    @staticmethod
    def test_fit(create_data):
        data, expected_data = create_data()


# Path: sksurv/preprocessing.py
# class OneHotEncoder(BaseEstimator, TransformerMixin):
#     """Encode categorical columns with `M` categories into `M-1` columns according
#     to the one-hot scheme.
# 
#     The order of non-categorical columns is preserved, encoded columns are inserted
#     inplace of the original column.
# 
#     Parameters
#     ----------
#     allow_drop : boolean, optional, default: True
#         Whether to allow dropping categorical columns that only consist
#         of a single category.
# 
#     Attributes
#     ----------
#     feature_names_ : pandas.Index
#         List of encoded columns.
# 
#     categories_ : dict
#         Categories of encoded columns.
# 
#     encoded_columns_ : list
#         Name of columns after encoding.
#         Includes names of non-categorical columns.
# 
#     n_features_in_ : int
#         Number of features seen during ``fit``.
# 
#     feature_names_in_ : ndarray of shape (`n_features_in_`,)
#         Names of features seen during ``fit``. Defined only when `X`
#         has feature names that are all strings.
#     """
#     def __init__(self, allow_drop=True):
#         self.allow_drop = allow_drop
# 
#     def fit(self, X, y=None):  # pylint: disable=unused-argument
#         """Retrieve categorical columns.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
#         y :
#             Ignored. For compatibility with Pipeline.
#         Returns
#         -------
#         self : object
#             Returns self
#         """
#         self.fit_transform(X)
#         return self
# 
#     def _encode(self, X, columns_to_encode):
#         return encode_categorical(X, columns=columns_to_encode, allow_drop=self.allow_drop)
# 
#     def fit_transform(self, X, y=None, **fit_params):  # pylint: disable=unused-argument
#         """Convert categorical columns to numeric values.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
#         y :
#             Ignored. For compatibility with TransformerMixin.
#         fit_params :
#             Ignored. For compatibility with TransformerMixin.
# 
#         Returns
#         -------
#         Xt : pandas.DataFrame
#             Encoded data.
#         """
#         self._check_feature_names(X, reset=True)
#         self._check_n_features(X, reset=True)
#         columns_to_encode = X.select_dtypes(include=["object", "category"]).columns
#         x_dummy = self._encode(X, columns_to_encode)
# 
#         self.feature_names_ = columns_to_encode
#         self.categories_ = {k: X[k].cat.categories for k in columns_to_encode}
#         self.encoded_columns_ = x_dummy.columns
#         return x_dummy
# 
#     def transform(self, X):
#         """Convert categorical columns to numeric values.
# 
#         Parameters
#         ----------
#         X : pandas.DataFrame
#             Data to encode.
# 
#         Returns
#         -------
#         Xt : pandas.DataFrame
#             Encoded data.
#         """
#         check_is_fitted(self, "encoded_columns_")
#         self._check_n_features(X, reset=False)
#         check_columns_exist(X.columns, self.feature_names_)
# 
#         Xt = X.copy()
#         for col, cat in self.categories_.items():
#             Xt[col] = Xt[col].cat.set_categories(cat)
# 
#         new_data = self._encode(Xt, self.feature_names_)
#         return new_data.loc[:, self.encoded_columns_]
# 
#     def get_feature_names_out(self, input_features=None):
#         """Get output feature names for transformation.
# 
#         Parameters
#         ----------
#         input_features : array-like of str or None, default=None
#             Input features.
# 
#             - If `input_features` is `None`, then `feature_names_in_` is
#               used as feature names in.
#             - If `input_features` is an array-like, then `input_features` must
#               match `feature_names_in_` if `feature_names_in_` is defined.
# 
#         Returns
#         -------
#         feature_names_out : ndarray of str objects
#             Transformed feature names.
#         """
#         check_is_fitted(self, "encoded_columns_")
#         input_features = _check_feature_names_in(self, input_features)
# 
#         return self.encoded_columns_.values.copy()


# Path: tests/test_preprocessing.py
from collections import OrderedDict
from numpy.testing import assert_array_equal
from sksurv.preprocessing import OneHotEncoder
import numpy as np
import pandas as pd
import pandas.testing as tm
import pytest

    def _create_data(n_samples=117):
        rnd = np.random.RandomState(51365192)
        data_num = pd.DataFrame(rnd.rand(n_samples, 5),
                                columns=["N%d" % i for i in range(5)])

        dat_cat = pd.DataFrame(OrderedDict([
            ("binary_1", pd.Categorical.from_codes(
                rnd.binomial(1, 0.6, n_samples),
                ["Yes", "No"])),
            ("binary_2", pd.Categorical.from_codes(
                rnd.binomial(1, 0.376, n_samples),
                ["East", "West"])),
            ("trinary", pd.Categorical.from_codes(
                rnd.binomial(2, 0.76, n_samples),
                ["Green", "Blue", "Red"])),
            ("many", pd.Categorical.from_codes(
                rnd.binomial(5, 0.47, n_samples),
                ["One", "Two", "Three", "Four", "Five", "Six"]))
        ]))
        data = pd.concat((data_num, dat_cat), axis=1)
        return data, _encoded_data(data)

    return _create_data


class TestOneHotEncoder:
    @staticmethod
    def test_fit(create_data):
        data, expected_data = create_data()


        t = OneHotEncoder().fit(data)