# Buggy code
def _initial_imputation(self, X):
    """Perform initial imputation for input X.

    Parameters
    ----------
    X : ndarray, shape (n_samples, n_features)
        Input data, where "n_samples" is the number of samples and
        "n_features" is the number of features.

    Returns
    -------
    Xt : ndarray, shape (n_samples, n_features)
        Input data, where "n_samples" is the number of samples and
        "n_features" is the number of features.

    X_filled : ndarray, shape (n_samples, n_features)
        Input data with the most recent imputations.

    mask_missing_values : ndarray, shape (n_samples, n_features)
        Input data's missing indicator matrix, where "n_samples" is the
        number of samples and "n_features" is the number of features.
    """
    if is_scalar_nan(self.missing_values):
        force_all_finite = "allow-nan"
    else:
        force_all_finite = True

    X = check_array(X, dtype=FLOAT_DTYPES, order="F", force_all_finite=force_all_finite)

    mask_missing_values = _get_mask(X, self.missing_values)
    if self.initial_imputer_ is None:
        self.initial_imputer_ = SimpleImputer(
            missing_values=self.missing_values, strategy=self.initial_strategy
        )
        X_filled = self.initial_imputer_.fit_transform(X)
    else:
        X_filled = self.initial_imputer_.transform(X)

    valid_mask = np.flatnonzero(
        np.logical_not(np.isnan(self.initial_imputer_.statistics_))
    )
    Xt = X[:, valid_mask]
    mask_missing_values = mask_missing_values[:, valid_mask]

    return Xt, X_filled, mask_missing_values


# Traceback (TypeError)
/home/lemaitre/Documents/code/toolbox/scikit-learn/sklearn/impute.py:59: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
return np.equal(X, value_to_mask)
/home/lemaitre/Documents/code/toolbox/scikit-learn/sklearn/impute.py:59: FutureWarning: elementwise comparison failed; returning scalar instead, but in the future will perform elementwise comparison
return np.equal(X, value_to_mask)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/miniconda3/envs/dev/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
51     try:
---> 52         return getattr(obj, method)(*args, **kwds)
53

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NotImplementedType'

During handling of the above exception, another exception occurred:

TypeError                                 Traceback (most recent call last)
<ipython-input-18-151141bb4b39> in <module>()
----> 1 trans.fit_transform(X)

~/Documents/code/toolbox/scikit-learn/sklearn/base.py in fit_transform(self, X, y, **fit_params)
457         if y is None:
458             # fit method of arity 1 (unsupervised transformation)
--> 459             return self.fit(X, **fit_params).transform(X)
460         else:
461             # fit method of arity 2 (supervised transformation)

~/Documents/code/toolbox/scikit-learn/sklearn/impute.py in transform(self, X)
417             mask = _get_mask(X, self.missing_values)
418             n_missing = np.sum(mask, axis=0)
--> 419             values = np.repeat(valid_statistics, n_missing)
420             coordinates = np.where(mask.transpose())[::-1]
421

~/miniconda3/envs/dev/lib/python3.6/site-packages/numpy/core/fromnumeric.py in repeat(a, repeats, axis)
421
422     """
--> 423     return _wrapfunc(a, 'repeat', repeats, axis=axis)
424
425

~/miniconda3/envs/dev/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapfunc(obj, method, *args, **kwds)
60     # a downstream library like 'pandas'.
61     except (AttributeError, TypeError):
---> 62         return _wrapit(obj, method, *args, **kwds)
63
64

~/miniconda3/envs/dev/lib/python3.6/site-packages/numpy/core/fromnumeric.py in _wrapit(obj, method, *args, **kwds)
40     except AttributeError:
41         wrap = None
---> 42     result = getattr(asarray(obj), method)(*args, **kwds)
43     if wrap:
44         if not isinstance(result, mu.ndarray):

TypeError: int() argument must be a string, a bytes-like object or a number, not 'NotImplementedType'

# Fixed code
def _initial_imputation(self, X):
    """Perform initial imputation for input X.

    Parameters
    ----------
    X : ndarray, shape (n_samples, n_features)
        Input data, where "n_samples" is the number of samples and
        "n_features" is the number of features.

    Returns
    -------
    Xt : ndarray, shape (n_samples, n_features)
        Input data, where "n_samples" is the number of samples and
        "n_features" is the number of features.

    X_filled : ndarray, shape (n_samples, n_features)
        Input data with the most recent imputations.

    mask_missing_values : ndarray, shape (n_samples, n_features)
        Input data's missing indicator matrix, where "n_samples" is the
        number of samples and "n_features" is the number of features.
    """
    if is_scalar_nan(self.missing_values):
        force_all_finite = "allow-nan"
    else:
        force_all_finite = True

    X = check_array(X, dtype=FLOAT_DTYPES, order="F", force_all_finite=force_all_finite)
    _check_inputs_dtype(X, self.missing_values)

    mask_missing_values = _get_mask(X, self.missing_values)
    if self.initial_imputer_ is None:
        self.initial_imputer_ = SimpleImputer(
            missing_values=self.missing_values, strategy=self.initial_strategy
        )
        X_filled = self.initial_imputer_.fit_transform(X)
    else:
        X_filled = self.initial_imputer_.transform(X)

    valid_mask = np.flatnonzero(
        np.logical_not(np.isnan(self.initial_imputer_.statistics_))
    )
    Xt = X[:, valid_mask]
    mask_missing_values = mask_missing_values[:, valid_mask]

    return Xt, X_filled, mask_missing_values