Repository: scikit-learn/scikit-learn
File: sklearn/base.py (Python)

Code before:

        init_func = getattr(self.__init__, "deprecated_original", self.__init__)
        init_default_params = inspect.signature(init_func).parameters
        init_default_params = {
            name: param.default for name, param in init_default_params.items()
        }

        def is_non_default(param_name, param_value):
            """Finds the parameters that have been set by the user."""
            if param_name not in init_default_params:
                # happens if k is part of a **kwargs
                return True
            if init_default_params[param_name] == inspect._empty:
                # k has no default value
                return True
            # avoid calling repr on nested estimators
            if isinstance(param_value, BaseEstimator) and type(param_value) is not type(
                init_default_params[param_name]
            ):
                return True

            if is_pandas_na(param_value) and not is_pandas_na(
                init_default_params[param_name]
            ):
                return True

            if not np.array_equal(
                param_value, init_default_params[param_name]
            ) and not (
                is_scalar_nan(init_default_params[param_name])
                and is_scalar_nan(param_value)
            ):
                return True

            return False

        # reorder the parameters from `self.get_params` using the `__init__`
        # signature
        remaining_params = [name for name in out if name not in init_default_params]
        ordered_out = {name: out[name] for name in init_default_params if name in out}
        ordered_out.update({name: out[name] for name in remaining_params})

        non_default_ls = tuple(
            [name for name, value in ordered_out.items() if is_non_default(name, value)]
        )

        return ParamsDict(
            params=ordered_out,
            non_default=non_default_ls,
            estimator_class=self.__class__,
            doc_link=doc_link,

Review comment (suggestion):
nitpick for consistency with the rest of this function
```suggestion
            if is_pandas_na(param_value) and not is_pandas_na(
                init_default_params[param_name]
            ):
                return True
```

Code after:

        init_func = getattr(self.__init__, "deprecated_original", self.__init__)
        init_default_params = inspect.signature(init_func).parameters
        init_default_params = {
            name: param.default for name, param in init_default_params.items()
        }

        def is_non_default(param_name, param_value):
            """Finds the parameters that have been set by the user."""
            if param_name not in init_default_params:
                # happens if k is part of a **kwargs
                return True
            if init_default_params[param_name] == inspect._empty:
                # k has no default value
                return True
            # avoid calling repr on nested estimators
            if isinstance(param_value, BaseEstimator) and type(param_value) is not type(
                init_default_params[param_name]
            ):
                return True
            if is_pandas_na(param_value) and not is_pandas_na(
                init_default_params[param_name]
            ):
                return True
            if not np.array_equal(
                param_value, init_default_params[param_name]
            ) and not (
                is_scalar_nan(init_default_params[param_name])
                and is_scalar_nan(param_value)
            ):
                return True

            return False

        # reorder the parameters from `self.get_params` using the `__init__`
        # signature
        remaining_params = [name for name in out if name not in init_default_params]
        ordered_out = {name: out[name] for name in init_default_params if name in out}
        ordered_out.update({name: out[name] for name in remaining_params})

        non_default_ls = tuple(
            [name for name, value in ordered_out.items() if is_non_default(name, value)]
        )

        return ParamsDict(
            params=ordered_out,
            non_default=non_default_ls,
            estimator_class=self.__class__,
            doc_link=doc_link,
        )