Question: FutureWarning is not issued for deprecated class FutureWarning is not issued when using as a baseclass but its is not called in the subclass, here: As the comment suggest in your decorator, overriding ` in the class decorator indeed solves this issue. I'm happy to open a PR with the fix. Also, relatedly, I wonder whether you would be interested in using a generic deprecation package instead. Basically we have the same functionality in astropy (I feel it's actually has more features e.g. this works there out of the box, it helps with arg renames/removals, etc.), there is also a deprecated decorator in matplotlib, and also a very basic one in numpy. I feel that having one for the wider ecosystem would be beneficial instead of the current system where we all roll our own. At the numfocus summit I recall some interest from the mpl side, so I'm happy to get the ball rolling in this quoter if it's a thumb up from multiple projects. Darwin-17.7.0-x8664-i386-64bit Python 3.7.5 (default, Nov 1 2019, 02:16:38) [Clang 10.0.0 (clang-1000.11.45.5)] NumPy 1.19.0.dev0+ SciPy 1.4.1 Scikit-Learn 0.23.dev0 Quick fix for class deprecation decorator This is a quick and dirty fix for my use case, but looking at the astropy decorator I suspect there may be some corner cases that still doesn't work.

if self.extra:             msg += "; %s" % self.extra         # FIXME: we should probably reset __new__ for full generality        init = cls.__init__        new = cls.__new__         def wrapped(*args, **kwargs):        def wrapped(cls, *args, **kwargs):             warnings.warn(msg, category=FutureWarning)            return init(*args, **kwargs)            if new is object.__new__:                return object.__new__(cls)            return new(cls, *args, **kwargs)         cls.__init__ = wrapped        cls.__new__ = wrapped         wrapped.__name__ = "__init__"        wrapped.deprecated_original = init        wrapped.__name__ = "__new__"        wrapped.deprecated_original = new          return cls


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

"max_depth": [Interval(Integral, 1, None, closed="left"), None],         "min_samples_split": [             Interval(Integral, 2, None, closed="left"),            Interval(Real, 0.0, 1.0, closed="right"),            Interval("real_not_int", 0.0, 1.0, closed="right"),         ],         "min_samples_leaf": [             Interval(Integral, 1, None, closed="left"),            Interval(Real, 0.0, 1.0, closed="neither"),            Interval("real_not_int", 0.0, 1.0, closed="neither"),         ],         "min_weight_fraction_leaf": [Interval(Real, 0.0, 0.5, closed="both")],         "max_features": [             Interval(Integral, 1, None, closed="left"),            Interval(Real, 0.0, 1.0, closed="right"),            Interval("real_not_int", 0.0, 1.0, closed="right"),             StrOptions({"auto", "sqrt", "log2"}, deprecated={"auto"}),             None,         ],diff --git a/sklearn/utils/_param_validation.py b/sklearn/utils/_param_validation.py-- a/sklearn/utils/_param_validation.py++ b/sklearn/utils/_param_validation.py


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

Parameters     ----------    type : {numbers.Integral, numbers.Real}    type : {numbers.Integral, numbers.Real, "real_not_int"}         The set of numbers in which to set the interval.         If "real_not_int", only reals that don't have the integer type        are allowed. For example 1.0 is allowed but 1 is not.     left : float or int or None         The left bound of the interval. None means left bound is -∞.


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

`[0, +∞) U {+∞}`.     """ <del>    @validate_params(        {            "type": [type],            "left": [Integral, Real, None],            "right": [Integral, Real, None],            "closed": [StrOptions({"left", "right", "both", "neither"})],        }    )</del>     def __init__(self, type, left, right, *, closed):         super().__init__()         self.type = type


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

self._check_params()      def _check_params(self):<ins>        if self.type not in (Integral, Real, "real_not_int"):            raise ValueError(                "type must be either numbers.Integral, numbers.Real or 'real_not_int'."                f" Got {self.type} instead."            )        if self.closed not in ("left", "right", "both", "neither"):            raise ValueError(                "closed must be either 'left', 'right', 'both' or 'neither'. "                f"Got {self.closed} instead."            )</ins>         if self.type is Integral:             suffix = "for an interval over the integers."             if self.left is not None and not isinstance(self.left, Integral):


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

raise ValueError(                     f"right can't be None when closed == {self.closed} {suffix}"                 )<ins>        else:            if self.left is not None and not isinstance(self.left, Real):                raise TypeError("Expecting left to be a real number.")            if self.right is not None and not isinstance(self.right, Real):                raise TypeError("Expecting right to be a real number.")</ins>          if self.right is not None and self.left is not None and self.right <= self.left:             raise ValueError(


Question: Setting minsamplessplit=1 in DecisionTreeClassifier does not raise exception If is set to 1, an exception should be raised according to the paramter's constraints: However, accepts without complaining. With scikit-survival 1.0, this raises an exception as expected: I suspect that this has to do with the Intervals of the constraints overlapping. satisfies the constraint, whereas the constraint should have precedence. No exception is raised.

return False         return True     def _has_valid_type(self, val):        if self.type == "real_not_int":            return isinstance(val, Real) and not isinstance(val, Integral)        return isinstance(val, self.type)     def is_satisfied_by(self, val):        if not isinstance(val, self.type):        if not self._has_valid_type(val):             return False          return val in self


Question: FeatureUnion not working when aggregating data and pandas transform output selected I would like to use transform output and use a custom transformer in a feature union which aggregates data. When I'm using this combination I got an error. When I use default output it works fine. No error is thrown when using transform output.

`range(n_features)`.      index : array-like, default=None        Index for data.        Index for data. `index` is ignored if `data_to_wrap` is already a DataFrame.      Returns     -------


Question: FeatureUnion not working when aggregating data and pandas transform output selected I would like to use transform output and use a custom transformer in a feature union which aggregates data. When I'm using this combination I got an error. When I use default output it works fine. No error is thrown when using transform output.

if isinstance(data_to_wrap, pd.DataFrame):         if columns is not None:             data_to_wrap.columns = columns<del>        if index is not None:            data_to_wrap.index = index</del>         return data_to_wrap      return pd.DataFrame(data_to_wrap, index=index, columns=columns)


Question: FIX ignore nan values in partial dependence computation This PR implements the default behaviour suggested in that is ignoring values in both numerical and categorical features. Up to now, there is a bug since the computation of the percentile is impacted by the values for numerical features. In addition, introducing in the grid will potentially introduce a bias in the partial dependence computation depending on how missing values are handled in the model. Therefore, it is safe to remove them. To be consistent, then it is also safe to not include it as a category in the categorical features. In the future, we can think of adding an option to define the expected behaviour. I expect this PR to fail because we use instead of that does not use the same interpolation to compute the quantiles.

raise ValueError("'grid_resolution' must be strictly greater than 1.")      values = []    # TODO: we should handle missing values (i.e. `np.nan`) specifically and store them    # in a different Bunch attribute.     for feature, is_cat in enumerate(is_categorical):        uniques = np.unique(_safe_indexing(X, feature, axis=1))        try:            uniques = np.unique(_safe_indexing(X, feature, axis=1))        except TypeError as exc:            # `np.unique` will fail in the presence of `np.nan` and `str` categories            # due to sorting. Temporary, we reraise an error explaining the problem.            raise ValueError(                f"The column #{feature} contains mixed data types. Finding unique "                "categories fail due to sorting. It usually means that the column "                "contains `np.nan` values together with `str` categories. Such use "                "case is not yet supported in scikit-learn."            ) from exc         if is_cat or uniques.shape[0] < grid_resolution:             # Use the unique values either because:             # - feature has low resolution use unique values


Question: CalibratedClassifierCV fails on lgbm fitparams Hi, I'm trying to use CalibratedClassifierCV to calibrate the probabilities from a LGBM model. The issue is that when I try CalibratedClassifierCV with evalset, I get an error ValueError: Found input variables with inconsistent numbers of samples: [, 1] which is caused by checkconsistentlength function in The input to eval set is [Xvalid,Yvalid] where both Xvalid,Yvalid are arrays with different shape. Since this format is a requirement for LGBM eval set , I am not sure how will I make the checkconsistentlength pass in my scenario. Full code is given below: = (, 152) = (,) = (, 152) = (,)

if sample_weight is not None:             sample_weight = _check_sample_weight(sample_weight, X) <del>        for sample_aligned_params in fit_params.values():            check_consistent_length(y, sample_aligned_params)</del>         # TODO(1.4): Remove when base_estimator is removed         if self.base_estimator != "deprecated":             if self.estimator is not None:


Question: X does not have valid feature names, but IsolationForest was fitted with feature names If you fit an using a it generates a warning This only seems to occur if you supply a non-default value (i.e. not "auto") for the parameter. This warning is unexpected as a) X does have valid feature names and b) it is being raised by the method but in general is supposed to indicate that predict has been called with ie. an ndarray but the model was fitted using a dataframe. The reason is most likely when you pass contamination != "auto" the estimator essentially calls predict on the training data in order to determine the parameters: Does not raise "X does not have valid feature names, but IsolationForest was fitted with feature names" raises "X does not have valid feature names, but IsolationForest was fitted with feature names"

self.offset_ = -0.5             return self         # else, define offset_ wrt contamination parameter        self.offset_ = np.percentile(self.score_samples(X), 100.0 * self.contamination)        # Else, define offset_ wrt contamination parameter        # To avoid performing input validation a second time we call        # _score_samples rather than score_samples        self.offset_ = np.percentile(self._score_samples(X), 100.0 * self.contamination)          return self


Question: X does not have valid feature names, but IsolationForest was fitted with feature names If you fit an using a it generates a warning This only seems to occur if you supply a non-default value (i.e. not "auto") for the parameter. This warning is unexpected as a) X does have valid feature names and b) it is being raised by the method but in general is supposed to indicate that predict has been called with ie. an ndarray but the model was fitted using a dataframe. The reason is most likely when you pass contamination != "auto" the estimator essentially calls predict on the training data in order to determine the parameters: Does not raise "X does not have valid feature names, but IsolationForest was fitted with feature names" raises "X does not have valid feature names, but IsolationForest was fitted with feature names"

The anomaly score of the input samples.             The lower, the more abnormal.         """        # code structure from ForestClassifier/predict_proba        check_is_fitted(self)         # Check data         X = self._validate_data(X, accept_sparse="csr", dtype=np.float32, reset=False)         # Take the opposite of the scores as bigger is better (here less        # abnormal)        return self._score_samples(X)    def _score_samples(self, X):        """Private version of score_samples without input validation.        Input validation would remove feature names, so we disable it.        """        # Code structure from ForestClassifier/predict_proba        check_is_fitted(self)        # Take the opposite of the scores as bigger is better (here less abnormal)         return -self._compute_chunked_score_samples(X)      def _compute_chunked_score_samples(self, X):


Question: Unable to pass splits to SequentialFeatureSelector This runs fine with e.g. , but according to the documentation, it should also be able to take an iterable of splits. However, passing splits from the cross validator fails Im fairly certain I have done similar things in the past to other classes in scikit-learn requiring a parameter. If somebody could confirm wether this is a bug, or I'm doing something wrong, that would great. Sorry if this is unneeded noise in the feed. Expected to run without errors

import warnings  from ._base import SelectorMixinfrom ..base import BaseEstimator, MetaEstimatorMixin, clonefrom ..base import BaseEstimator, MetaEstimatorMixin, clone, is_classifier from ..utils._param_validation import HasMethods, Hidden, Interval, StrOptions from ..utils._param_validation import RealNotInt from ..utils._tags import _safe_tags from ..utils.validation import check_is_fittedfrom ..model_selection import cross_val_scorefrom ..model_selection import cross_val_score, check_cv from ..metrics import get_scorer_names


Question: Unable to pass splits to SequentialFeatureSelector This runs fine with e.g. , but according to the documentation, it should also be able to take an iterable of splits. However, passing splits from the cross validator fails Im fairly certain I have done similar things in the past to other classes in scikit-learn requiring a parameter. If somebody could confirm wether this is a bug, or I'm doing something wrong, that would great. Sorry if this is unneeded noise in the feed. Expected to run without errors

if self.tol is not None and self.tol < 0 and self.direction == "forward":             raise ValueError("tol must be positive when doing forward selection") <ins>        cv = check_cv(self.cv, y, classifier=is_classifier(self.estimator))</ins>         cloned_estimator = clone(self.estimator)          # the current mask corresponds to the set of features:


Question: Unable to pass splits to SequentialFeatureSelector This runs fine with e.g. , but according to the documentation, it should also be able to take an iterable of splits. However, passing splits from the cross validator fails Im fairly certain I have done similar things in the past to other classes in scikit-learn requiring a parameter. If somebody could confirm wether this is a bug, or I'm doing something wrong, that would great. Sorry if this is unneeded noise in the feed. Expected to run without errors

is_auto_select = self.tol is not None and self.n_features_to_select == "auto"         for _ in range(n_iterations):             new_feature_idx, new_score = self._get_best_new_feature_score(                cloned_estimator, X, y, current_mask                cloned_estimator, X, y, cv, current_mask             )             if is_auto_select and ((new_score - old_score) < self.tol):                 break


Question: Unable to pass splits to SequentialFeatureSelector This runs fine with e.g. , but according to the documentation, it should also be able to take an iterable of splits. However, passing splits from the cross validator fails Im fairly certain I have done similar things in the past to other classes in scikit-learn requiring a parameter. If somebody could confirm wether this is a bug, or I'm doing something wrong, that would great. Sorry if this is unneeded noise in the feed. Expected to run without errors

return self     def _get_best_new_feature_score(self, estimator, X, y, current_mask):    def _get_best_new_feature_score(self, estimator, X, y, cv, current_mask):         # Return the best new feature and its score to add to the current_mask,         # i.e. return the best new feature and its score to add (resp. remove)         # when doing forward selection (resp. backward selection).


Question: Unable to pass splits to SequentialFeatureSelector This runs fine with e.g. , but according to the documentation, it should also be able to take an iterable of splits. However, passing splits from the cross validator fails Im fairly certain I have done similar things in the past to other classes in scikit-learn requiring a parameter. If somebody could confirm wether this is a bug, or I'm doing something wrong, that would great. Sorry if this is unneeded noise in the feed. Expected to run without errors

estimator,                 X_new,                 y,                cv=self.cv,                cv=cv,                 scoring=self.scoring,                 n_jobs=self.n_jobs,             ).mean()


Question: Thresholds can exceed 1 in while providing probability estimate While working on , I found out that something was odd with that returns a threshold greater than 1. A non-regression test (that could be part of ) could be as follow: The reason is due to the following: Basically, this is to add a point for and . However, the rule does not make sense in the case is a probability estimate. I am not sure what would be the best fix here. A potential workaround would be to check in which case we should clip to not be above 1.

Increasing true positive rates such that element `i` is the true         positive rate of predictions with score >= `thresholds[i]`.     thresholds : ndarray of shape = (n_thresholds,)    thresholds : ndarray of shape (n_thresholds,)         Decreasing thresholds on the decision function used to compute         fpr and tpr. `thresholds[0]` represents no instances being predicted        and is arbitrarily set to `max(y_score) + 1`.        and is arbitrarily set to `np.inf`.      See Also     --------


Question: Thresholds can exceed 1 in while providing probability estimate While working on , I found out that something was odd with that returns a threshold greater than 1. A non-regression test (that could be part of ) could be as follow: The reason is due to the following: Basically, this is to add a point for and . However, the rule does not make sense in the case is a probability estimate. I am not sure what would be the best fix here. A potential workaround would be to check in which case we should clip to not be above 1.

are reversed upon returning them to ensure they correspond to both ``fpr``     and ``tpr``, which are sorted in reversed order during their calculation. <ins>    An arbritrary threshold is added for the case `tpr=0` and `fpr=0` to    ensure that the curve starts at `(0, 0)`. This threshold corresponds to the    `np.inf`.</ins>     References     ----------     .. [1] `Wikipedia entry for the Receiver operating characteristic


Question: Thresholds can exceed 1 in while providing probability estimate While working on , I found out that something was odd with that returns a threshold greater than 1. A non-regression test (that could be part of ) could be as follow: The reason is due to the following: Basically, this is to add a point for and . However, the rule does not make sense in the case is a probability estimate. I am not sure what would be the best fix here. A potential workaround would be to check in which case we should clip to not be above 1.

>>> tpr     array([0. , 0.5, 0.5, 1. , 1. ])     >>> thresholds    array([1.8 , 0.8 , 0.4 , 0.35, 0.1 ])    array([ inf, 0.8 , 0.4 , 0.35, 0.1 ])     """     fps, tps, thresholds = _binary_clf_curve(         y_true, y_score, pos_label=pos_label, sample_weight=sample_weight


Question: Thresholds can exceed 1 in while providing probability estimate While working on , I found out that something was odd with that returns a threshold greater than 1. A non-regression test (that could be part of ) could be as follow: The reason is due to the following: Basically, this is to add a point for and . However, the rule does not make sense in the case is a probability estimate. I am not sure what would be the best fix here. A potential workaround would be to check in which case we should clip to not be above 1.

# to make sure that the curve starts at (0, 0)     tps = np.r_[0, tps]     fps = np.r_[0, fps]    thresholds = np.r_[thresholds[0] + 1, thresholds]    # get dtype of `y_score` even if it is an array-like    thresholds = np.r_[np.inf, thresholds]      if fps[-1] <= 0:         warnings.warn(


Question: AdaBoost: deprecation of "baseestimator" does not handle "baseestimator=None" setting properly Scikit-learn 1.2 deprecated 's in favour of (see ). Because there are also validators in place, old code that explicitly defined stopped working. A solution that fixes the deprecation is to add a possible to a list allowed values in ; I will do that in a PR. No error is thrown.

if self.estimator is not None:             self.estimator_ = self.estimator        elif self.base_estimator not in [None, "deprecated"]:        elif self.base_estimator != "deprecated":             warnings.warn(                 (                     "`base_estimator` was renamed to `estimator` in version 1.2 and "


Question: AdaBoost: deprecation of "baseestimator" does not handle "baseestimator=None" setting properly Scikit-learn 1.2 deprecated 's in favour of (see ). Because there are also validators in place, old code that explicitly defined stopped working. A solution that fixes the deprecation is to add a possible to a list allowed values in ; I will do that in a PR. No error is thrown.

),                 FutureWarning,             )            self.estimator_ = self.base_estimator            if self.base_estimator is not None:                self.estimator_ = self.base_estimator            else:                self.estimator_ = default         else:             self.estimator_ = default diff --git a/sklearn/ensemble/_weight_boosting.py b/sklearn/ensemble/_weight_boosting.py-- a/sklearn/ensemble/_weight_boosting.py++ b/sklearn/ensemble/_weight_boosting.py


Question: AdaBoost: deprecation of "baseestimator" does not handle "baseestimator=None" setting properly Scikit-learn 1.2 deprecated 's in favour of (see ). Because there are also validators in place, old code that explicitly defined stopped working. A solution that fixes the deprecation is to add a possible to a list allowed values in ; I will do that in a PR. No error is thrown.

"n_estimators": [Interval(Integral, 1, None, closed="left")],         "learning_rate": [Interval(Real, 0, None, closed="neither")],         "random_state": ["random_state"],        "base_estimator": [HasMethods(["fit", "predict"]), StrOptions({"deprecated"})],        "base_estimator": [            HasMethods(["fit", "predict"]),            StrOptions({"deprecated"}),            None,        ],     }      @abstractmethod


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

import numpy as np from ..utils.validation import check_is_fittedfrom ..utils.validation import check_is_fitted, check_array from ..utils._param_validation import Interval, validate_params, StrOptions  from ..base import is_classifier


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

The maximum depth of the representation. If None, the tree is fully         generated.     feature_names : list of str, default=None        Names of each of the features.    feature_names : array-like of shape (n_features,), default=None        An array containing the feature names.         If None, generic names will be used ("x[0]", "x[1]", ...).     class_names : list of str or bool, default=None    class_names : array-like of shape (n_classes,) or bool, default=None         Names of each of the target classes in ascending numerical order.         Only relevant for classification and not supported for multi-output.         If ``True``, shows a symbolic representation of the class name.


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

>>> tree.export_graphviz(clf)     'digraph Tree {...     """<ins>    if feature_names is not None:        feature_names = check_array(            feature_names, ensure_2d=False, dtype=None, ensure_min_samples=0        )    if class_names is not None and not isinstance(class_names, bool):        class_names = check_array(            class_names, ensure_2d=False, dtype=None, ensure_min_samples=0        )</ins>      check_is_fitted(decision_tree)     own_file = False


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

@validate_params(     {         "decision_tree": [DecisionTreeClassifier, DecisionTreeRegressor],        "feature_names": [list, None],        "class_names": [list, None],        "feature_names": ["array-like", None],        "class_names": ["array-like", None],         "max_depth": [Interval(Integral, 0, None, closed="left"), None],         "spacing": [Interval(Integral, 1, None, closed="left"), None],         "decimals": [Interval(Integral, 0, None, closed="left"), None],


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

It can be an instance of         DecisionTreeClassifier or DecisionTreeRegressor.     feature_names : list of str, default=None        A list of length n_features containing the feature names.    feature_names : array-like of shape (n_features,), default=None        An array containing the feature names.         If None generic names will be used ("feature_0", "feature_1", ...).     class_names : list or None, default=None    class_names : array-like of shape (n_classes,), default=None         Names of each of the target classes in ascending numerical order.         Only relevant for classification and not supported for multi-output.          - if `None`, the class names are delegated to `decision_tree.classes_`;        - if a list, then `class_names` will be used as class names instead          of `decision_tree.classes_`. The length of `class_names` must match        - otherwise, `class_names` will be used as class names instead of          `decision_tree.classes_`. The length of `class_names` must match           the length of `decision_tree.classes_`.          .. versionadded:: 1.3


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

|   |--- petal width (cm) >  1.75     |   |   |--- class: 2     """<ins>    if feature_names is not None:        feature_names = check_array(            feature_names, ensure_2d=False, dtype=None, ensure_min_samples=0        )    if class_names is not None:        class_names = check_array(            class_names, ensure_2d=False, dtype=None, ensure_min_samples=0        )</ins>     check_is_fitted(decision_tree)     tree_ = decision_tree.tree_     if is_classifier(decision_tree):


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

class_names = decision_tree.classes_         elif len(class_names) != len(decision_tree.classes_):             raise ValueError(                "When `class_names` is a list, it should contain as"                "When `class_names` is an array, it should contain as"                 " many items as `decision_tree.classes_`. Got"                 f" {len(class_names)} while the tree was fitted with"                 f" {len(decision_tree.classes_)} classes."


Question: failing when featurenames supplied folks, I'm not sure why this works for but not for Can anyone help?

else:         value_fmt = "{}{} value: {}\n"     if feature_names:    if feature_names is not None:         feature_names_ = [             feature_names[i] if i != _tree.TREE_UNDEFINED else None             for i in tree_.feature


Question: Incorrect documentation for behavior on BaseForest-derived classes The documentation states: This is also true for all classes that derive from , such as and . However, the does not reflect this behavior. When , it does not fit a new forest and instead just recomputes the OOB score if applicable. There are two potential fixes: the documentation to state: the actual behavior of this method to fit a new forest in the case where to reflect the existing documentation.

# Collect newly grown trees             self.estimators_.extend(trees)         if self.oob_score:        if self.oob_score and (            n_more_estimators > 0 or not hasattr(self, "oob_score_")        ):             y_type = type_of_target(y)             if y_type in ("multiclass-multioutput", "unknown"):                 # FIXME: we could consider to support multiclass-multioutput if


Question: ignores the if it's an estimator When using on a , it sets the output to its sub-transformers but it ignores the transformer defined in . This issue causes the following to fail when gathering the results: Thus not gathering the final result correctly.

Estimator instance.         """         super().set_output(transform=transform)<ins></ins>         transformers = (             trans             for _, trans, _ in chain(


Question: ignores the if it's an estimator When using on a , it sets the output to its sub-transformers but it ignores the transformer defined in . This issue causes the following to fail when gathering the results: Thus not gathering the final result correctly.

for trans in transformers:             _safe_set_output(trans, transform=transform) <ins>        if self.remainder not in {"passthrough", "drop"}:            _safe_set_output(self.remainder, transform=transform)</ins>         return self      def get_params(self, deep=True):


Question: PowerTransformer fails with unhelpful stack trace with all-nan feature and method='box-cox' throws a difficult-to-debug error if x contains an all-nan column. Either no error is thrown and the all-nan column is preserved, or a descriptive error is thrown indicating that there is an unfittable column

We here use scipy builtins which uses the brent optimizer.         """        mask = np.isnan(x)        if np.all(mask):            raise ValueError("Column must not be all nan.")         # the computation of lambda is influenced by NaNs so we need to         # get rid of them        _, lmbda = stats.boxcox(x[~np.isnan(x)], lmbda=None)        _, lmbda = stats.boxcox(x[~mask], lmbda=None)          return lmbda


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

.. note::            The fast ``method='recursion'`` option is only available for           ``kind='average'``. Plotting individual dependencies requires using           the slower ``method='brute'`` option.           `kind='average'` and `sample_weights=None`. Computing individual           dependencies and doing weighted averages requires using the slower           `method='brute'`.          .. versionadded:: 0.24            Add `kind` parameter with `'average'`, `'individual'`, and `'both'`


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

X,         features,         *,<ins>        sample_weight=None,</ins>         categorical_features=None,         feature_names=None,         target=None,


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

with `kind='average'`). Each tuple must be of size 2.             If any entry is a string, then it must be in ``feature_names``. <ins>        sample_weight : array-like of shape (n_samples,), default=None            Sample weights are used to calculate weighted means when averaging the            model output. If `None`, then samples are equally weighted. If            `sample_weight` is not `None`, then `method` will be set to `'brute'`.            Note that `sample_weight` is ignored for `kind='individual'`.            .. versionadded:: 1.3</ins>         categorical_features : array-like of shape (n_features,) or shape \                 (n_categorical_features,), dtype={bool, int, str}, default=None             Indicates the categorical features.


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

computationally intensive.              - `'auto'`: the `'recursion'` is used for estimators that support it,              and `'brute'` is used otherwise.              and `'brute'` is used otherwise. If `sample_weight` is not `None`,              then `'brute'` is used regardless of the estimator.              Please see :ref:`this note <pdp_method_differences>` for             differences between the `'brute'` and `'recursion'` method.


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

- ``kind='average'`` results in the traditional PD plot;             - ``kind='individual'`` results in the ICE plot.            Note that the fast ``method='recursion'`` option is only available for           ``kind='average'``. Plotting individual dependencies requires using the           slower ``method='brute'`` option.           Note that the fast `method='recursion'` option is only available for           `kind='average'` and `sample_weights=None`. Computing individual           dependencies and doing weighted averages requires using the slower           `method='brute'`.          centered : bool, default=False             If `True`, the ICE and PD lines will start at the origin of the


Question: partialdependence should respect sample weights Currently, the inspect.partialdependence funtions calculate arithmetic averages over predictions. For models fitted with sample weights, this is between suboptimal and wrong. Add new argument "sampleweight = None". If vector of right length, replace arithmetic average of predictions by weighted averages. Note that this does not affect the calculation of ICE curves, just the aggregate. No response No response_

estimator,                 X,                 fxs,<ins>                sample_weight=sample_weight,</ins>                 feature_names=feature_names,                 categorical_features=categorical_features,                 response_method=response_method,


Question: partial AUC I suggest adding partial AUC to the metrics. this would compute the area under the curve up to a specified FPR (in the case of the ROC curve). this measure is important for comparing classifiers in cases where FPR is much more important than TPR. The partial AUC should also allow applying the McClish correction. see here: http://cran.r-

sample_weight=sample_weight)  def roc_auc_score(y_true, y_score, average="macro", sample_weight=None):def roc_auc_score(y_true, y_score, average="macro", sample_weight=None,                  max_fpr=None):     """Compute Area Under the Receiver Operating Characteristic Curve (ROC AUC)     from prediction scores.


Question: partial AUC I suggest adding partial AUC to the metrics. this would compute the area under the curve up to a specified FPR (in the case of the ROC curve). this measure is important for comparing classifiers in cases where FPR is much more important than TPR. The partial AUC should also allow applying the McClish correction. see here: http://cran.r-

sample_weight : array-like of shape = [n_samples], optional         Sample weights. <ins>    max_fpr : float > 0 and <= 1, optional        If not ``None``, the standardized partial AUC [3]_ over the range        [0, max_fpr] is returned.</ins>     Returns     -------     auc : float


Question: partial AUC I suggest adding partial AUC to the metrics. this would compute the area under the curve up to a specified FPR (in the case of the ROC curve). this measure is important for comparing classifiers in cases where FPR is much more important than TPR. The partial AUC should also allow applying the McClish correction. see here: http://cran.r-

.. [2] Fawcett T. An introduction to ROC analysis[J]. Pattern Recognition            Letters, 2006, 27(8):861-874. <ins>    .. [3] `Analyzing a portion of the ROC curve. McClish, 1989            <http://www.ncbi.nlm.nih.gov/pubmed/2668680>`_</ins>     See also     --------     average_precision_score : Area under the precision-recall curve


Question: partial AUC I suggest adding partial AUC to the metrics. this would compute the area under the curve up to a specified FPR (in the case of the ROC curve). this measure is important for comparing classifiers in cases where FPR is much more important than TPR. The partial AUC should also allow applying the McClish correction. see here: http://cran.r-

fpr, tpr, tresholds = roc_curve(y_true, y_score,                                         sample_weight=sample_weight)        return auc(fpr, tpr)        if max_fpr is None or max_fpr == 1:            return auc(fpr, tpr)        if max_fpr <= 0 or max_fpr > 1:            raise ValueError("Expected max_frp in range ]0, 1], got: %r"                             % max_fpr)        # Add a single point at max_fpr by linear interpolation        stop = np.searchsorted(fpr, max_fpr, 'right')        x_interp = [fpr[stop - 1], fpr[stop]]        y_interp = [tpr[stop - 1], tpr[stop]]        tpr = np.append(tpr[:stop], np.interp(max_fpr, x_interp, y_interp))        fpr = np.append(fpr[:stop], max_fpr)        partial_auc = auc(fpr, tpr)        # McClish correction: standardize result to be 0.5 if non-discriminant        # and 1 if maximal        min_area = 0.5 * max_fpr**2        max_area = max_fpr        return 0.5 * (1 + (partial_auc - min_area) / (max_area - min_area))      y_type = type_of_target(y_true)     if y_type == "binary":


Question: Stronger common tests for setting init params? / checkestimator In a solution was proposed that did something like The common tests let this pass, though that should wreck havoc on and . I haven't looked into it but I think the tests should fail on this.

class TestCase(unittest.TestCase):    longMessage = False    longMessage = True     failureException = AssertionError      def _formatMessage(self, msg, standardMsg):diff --git a/sklearn/utils/estimator_checks.py b/sklearn/utils/estimator_checks.py-- a/sklearn/utils/estimator_checks.py++ b/sklearn/utils/estimator_checks.py


Question: Stronger common tests for setting init params? / checkestimator In a solution was proposed that did something like The common tests let this pass, though that should wreck havoc on and . I haven't looked into it but I think the tests should fail on this.

yield check_fit2d_1feature     yield check_fit1d     yield check_get_params_invariance<ins>    yield check_set_params</ins>     yield check_dict_unchanged     yield check_dont_overwrite_parameters


Question: Stronger common tests for setting init params? / checkestimator In a solution was proposed that did something like The common tests let this pass, though that should wreck havoc on and . I haven't looked into it but I think the tests should fail on this.

shallow_params.items()))  <ins>@ignore_warnings(category=(DeprecationWarning, FutureWarning))def check_set_params(name, estimator_orig):    # Check that get_params() returns the same thing    # before and after set_params() with some fuzz    estimator = clone(estimator_orig)    orig_params = estimator.get_params(deep=False)    msg = ("get_params result does not match what was passed to set_params")    estimator.set_params(**orig_params)    curr_params = estimator.get_params(deep=False)    assert_equal(set(orig_params.keys()), set(curr_params.keys()), msg)    for k, v in curr_params.items():        assert orig_params[k] is v, msg    # some fuzz values    test_values = [-np.inf, np.inf, None]    test_params = deepcopy(orig_params)    for param_name in orig_params.keys():        default_value = orig_params[param_name]        for value in test_values:            test_params[param_name] = value            try:                estimator.set_params(**test_params)            except (TypeError, ValueError) as e:                e_type = e.__class__.__name__                # Exception occurred, possibly parameter validation                warnings.warn("{} occurred during set_params. "                              "It is recommended to delay parameter "                              "validation until fit.".format(e_type))                change_warning_msg = "Estimator's parameters changed after " \                                     "set_params raised {}".format(e_type)                params_before_exception = curr_params                curr_params = estimator.get_params(deep=False)                try:                    assert_equal(set(params_before_exception.keys()),                                 set(curr_params.keys()))                    for k, v in curr_params.items():                        assert params_before_exception[k] is v                except AssertionError:                    warnings.warn(change_warning_msg)            else:                curr_params = estimator.get_params(deep=False)                assert_equal(set(test_params.keys()),                             set(curr_params.keys()),                             msg)                for k, v in curr_params.items():                    assert test_params[k] is v, msg        test_params[param_name] = default_value</ins> @ignore_warnings(category=(DeprecationWarning, FutureWarning)) def check_classifiers_regression_target(name, estimator_orig):     # Check if classifier throws an exception when fed regression targets


Question: Isomap and LocallyLinearEmbedding do not accept sparse matrix input (contrary to documentation) The mentions that should support sparse matrix. The error comes from the 5 of from . If documentation is correct should be called with  I can submit a PR. also accepts sparse matrix according to documentation on and methods. Given that also uses the arpack solver, I guess that it also should accept sparse matrices. Check of checkarray calls in the manifold subfolder For reference, my backtrace

self.n_jobs = n_jobs      def _fit_transform(self, X):        X = check_array(X)        X = check_array(X, accept_sparse='csr')         self.nbrs_ = NearestNeighbors(n_neighbors=self.n_neighbors,                                       algorithm=self.neighbors_algorithm,                                       n_jobs=self.n_jobs)diff --git a/sklearn/manifold/locally_linear.py b/sklearn/manifold/locally_linear.py-- a/sklearn/manifold/locally_linear.py++ b/sklearn/manifold/locally_linear.py


Question: Isomap and LocallyLinearEmbedding do not accept sparse matrix input (contrary to documentation) The mentions that should support sparse matrix. The error comes from the 5 of from . If documentation is correct should be called with  I can submit a PR. also accepts sparse matrix according to documentation on and methods. Given that also uses the arpack solver, I guess that it also should accept sparse matrices. Check of checkarray calls in the manifold subfolder For reference, my backtrace

Parameters     ----------    X : {array-like, sparse matrix, BallTree, KDTree, NearestNeighbors}    X : {array-like, NearestNeighbors}         Sample data, shape = (n_samples, n_features), in the form of a        numpy array, sparse array, precomputed tree, or NearestNeighbors        object.        numpy array or a NearestNeighbors object.      n_neighbors : int         Number of neighbors for each sample.


Question: Isomap and LocallyLinearEmbedding do not accept sparse matrix input (contrary to documentation) The mentions that should support sparse matrix. The error comes from the 5 of from . If documentation is correct should be called with  I can submit a PR. also accepts sparse matrix according to documentation on and methods. Given that also uses the arpack solver, I guess that it also should accept sparse matrices. Check of checkarray calls in the manifold subfolder For reference, my backtrace

Parameters     ----------    X : {array-like, sparse matrix, BallTree, KDTree, NearestNeighbors}    X : {array-like, NearestNeighbors}         Sample data, shape = (n_samples, n_features), in the form of a        numpy array, sparse array, precomputed tree, or NearestNeighbors        object.        numpy array or a NearestNeighbors object.      n_neighbors : integer         number of neighbors to consider for each point.


Question: KMeans gives slightly different result for njobs=1 vs. njobs 1 <!-- If your issue is a usage question, submit it here instead: StackOverflow with the scikit-learn tag: Mailing List: For more information, see User Questions: http://scikit- --<!-- Instructions For Filing a Bug: --<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluateevery 0--I noticed that gives a slightly different result depending on if or . <!-- Example: If the code is too long, feel free to put it in a public gist and link it in the issue: --Below is the code I used to run the same clustering on a varying number of jobs. <!-- Example: No error is thrown. Please paste or describe the expected results.--Should expect the the clustering result (e.g. the inertia) to be the same regardless of how many jobs are run in parallel. <!-- Please paste or specifically describe the actual output or traceback. --The case has a (slightly) different inertia than the parallel cases. <!-- Please run the following snippet and paste the output below. import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("NumPy", numpy.version) import scipy; print("SciPy", scipy.version) import sklearn; print("Scikit-Learn", sklearn.version) --Darwin-16.7.0-x86_64-i386-64bit Python 3.6.1 (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] NumPy 1.13.1 SciPy 0.19.1 Scikit-Learn 0.20.dev0 <!-- Thanks for contributing! --

else:         raise ValueError("Algorithm must be 'auto', 'full' or 'elkan', got"                          " %s" % str(algorithm))    seeds = random_state.randint(np.iinfo(np.int32).max, size=n_init)     if effective_n_jobs(n_jobs) == 1:         # For a single thread, less memory is needed if we just store one set         # of the best results (as opposed to one set per run per thread).        for it in range(n_init):        for seed in seeds:             # run a k-means once             labels, inertia, centers, n_iter_ = kmeans_single(                 X, sample_weight, n_clusters, max_iter=max_iter, init=init,                 verbose=verbose, precompute_distances=precompute_distances,                 tol=tol, x_squared_norms=x_squared_norms,                random_state=random_state)                random_state=seed)             # determine if these results are the best so far             if best_inertia is None or inertia < best_inertia:                 best_labels = labels.copy()


Question: KMeans gives slightly different result for njobs=1 vs. njobs 1 <!-- If your issue is a usage question, submit it here instead: StackOverflow with the scikit-learn tag: Mailing List: For more information, see User Questions: http://scikit- --<!-- Instructions For Filing a Bug: --<!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluateevery 0--I noticed that gives a slightly different result depending on if or . <!-- Example: If the code is too long, feel free to put it in a public gist and link it in the issue: --Below is the code I used to run the same clustering on a varying number of jobs. <!-- Example: No error is thrown. Please paste or describe the expected results.--Should expect the the clustering result (e.g. the inertia) to be the same regardless of how many jobs are run in parallel. <!-- Please paste or specifically describe the actual output or traceback. --The case has a (slightly) different inertia than the parallel cases. <!-- Please run the following snippet and paste the output below. import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("NumPy", numpy.version) import scipy; print("SciPy", scipy.version) import sklearn; print("Scikit-Learn", sklearn.version) --Darwin-16.7.0-x86_64-i386-64bit Python 3.6.1 (default, May 11 2017, 13:04:09) [GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)] NumPy 1.13.1 SciPy 0.19.1 Scikit-Learn 0.20.dev0 <!-- Thanks for contributing! --

best_n_iter = n_iter_     else:         # parallelisation of k-means runs<del>        seeds = random_state.randint(np.iinfo(np.int32).max, size=n_init)</del>         results = Parallel(n_jobs=n_jobs, verbose=0)(             delayed(kmeans_single)(X, sample_weight, n_clusters,                                    max_iter=max_iter, init=init,


Question: Bug: the predict method of Pipeline object does not use the exact predict method of final step estimator I am trying to use Pipeline with a customized final step estimator. This final estimator predict method can output std when using returnstd=True. But the predict method of Pipeline does not allow returnstd option, gives error on scikit- Line 54. In the user guide:user guide http://scikit- says the following, but the predict method in Pipeline is not the same as that in final estimator """ Calling fit on the pipeline is the same as calling fit on each estimator in turn, transform the input and pass it on to the next step. The pipeline has all the methods that the last estimator in the pipeline has, i.e. if the last estimator is a classifier, the Pipeline can be used as a classifier. If the last estimator is a transformer, again, so is the pipeline. """

return last_step.fit(Xt, y, **fit_params).transform(Xt)      @if_delegate_has_method(delegate='_final_estimator')    def predict(self, X):    def predict(self, X, **predict_params):         """Apply transforms to the data, and predict with the final estimator          Parameters


Question: Bug: the predict method of Pipeline object does not use the exact predict method of final step estimator I am trying to use Pipeline with a customized final step estimator. This final estimator predict method can output std when using returnstd=True. But the predict method of Pipeline does not allow returnstd option, gives error on scikit- Line 54. In the user guide:user guide http://scikit- says the following, but the predict method in Pipeline is not the same as that in final estimator """ Calling fit on the pipeline is the same as calling fit on each estimator in turn, transform the input and pass it on to the next step. The pipeline has all the methods that the last estimator in the pipeline has, i.e. if the last estimator is a classifier, the Pipeline can be used as a classifier. If the last estimator is a transformer, again, so is the pipeline. """

Data to predict on. Must fulfill input requirements of first step             of the pipeline. <ins>        **predict_params : dict of string -> object            Parameters to the ``predict`` called at the end of all            transformations in the pipeline. Note that while this may be            used to return uncertainties from some models with return_std            or return_cov, uncertainties that are generated by the            transformations in the pipeline are not propagated to the            final estimator.</ins>         Returns         -------         y_pred : array-like


Question: Bug: the predict method of Pipeline object does not use the exact predict method of final step estimator I am trying to use Pipeline with a customized final step estimator. This final estimator predict method can output std when using returnstd=True. But the predict method of Pipeline does not allow returnstd option, gives error on scikit- Line 54. In the user guide:user guide http://scikit- says the following, but the predict method in Pipeline is not the same as that in final estimator """ Calling fit on the pipeline is the same as calling fit on each estimator in turn, transform the input and pass it on to the next step. The pipeline has all the methods that the last estimator in the pipeline has, i.e. if the last estimator is a classifier, the Pipeline can be used as a classifier. If the last estimator is a transformer, again, so is the pipeline. """

for name, transform in self.steps[:-1]:             if transform is not None:                 Xt = transform.transform(Xt)        return self.steps[-1][-1].predict(Xt)        return self.steps[-1][-1].predict(Xt, **predict_params)      @if_delegate_has_method(delegate='_final_estimator')     def fit_predict(self, X, y=None, **fit_params):


Question: sklearn.manifold.t_sne.trustworthiness should allow custom metric boolean parameter should be replaced by more standard .

#   http://cseweb.ucsd.edu/~lvdmaaten/workshops/nips2010/papers/vandermaaten.pdf from __future__ import division <ins>import warnings</ins> from time import time import numpy as np from scipy import linalg


Question: sklearn.manifold.t_sne.trustworthiness should allow custom metric boolean parameter should be replaced by more standard .

return p, error, i  def trustworthiness(X, X_embedded, n_neighbors=5, precomputed=False):def trustworthiness(X, X_embedded, n_neighbors=5,                    precomputed=False, metric='euclidean'):     r"""Expresses to what extent the local structure is retained.      The trustworthiness is within [0, 1]. It is defined as


Question: sklearn.manifold.t_sne.trustworthiness should allow custom metric boolean parameter should be replaced by more standard .

precomputed : bool, optional (default: False)         Set this flag if X is a precomputed square distance matrix.         ..deprecated:: 0.20            ``precomputed`` has been deprecated in version 0.20 and will be            removed in version 0.22. Use ``metric`` instead.    metric : string, or callable, optional, default 'euclidean'        Which metric to use for computing pairwise distances between samples        from the original input space. If metric is 'precomputed', X must be a        matrix of pairwise distances or squared distances. Otherwise, see the        documentation of argument metric in sklearn.pairwise.pairwise_distances        for a list of available metrics.     Returns     -------     trustworthiness : float         Trustworthiness of the low-dimensional embedding.     """     if precomputed:        dist_X = X    else:        dist_X = pairwise_distances(X, squared=True)        warnings.warn("The flag 'precomputed' has been deprecated in version "                      "0.20 and will be removed in 0.22. See 'metric' "                      "parameter instead.", DeprecationWarning)        metric = 'precomputed'    dist_X = pairwise_distances(X, metric=metric)     ind_X = np.argsort(dist_X, axis=1)     ind_X_embedded = NearestNeighbors(n_neighbors).fit(X_embedded).kneighbors(         return_distance=False)


Question: Incorrect predictions when fitting a LogisticRegression model on binary outcomes with . Incorrect predictions when fitting a LogisticRegression model on binary outcomes with . <!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluateevery 0--<!-- Example: If the code is too long, feel free to put it in a public gist and link it in the issue: --If we compare against R or using , the log loss (which is approximately proportional to the objective function as the regularisation is set to be negligible through the choice of ) is incorrect. We expect the log loss to be roughly The actual log loss when using is . See the stack exchange question for more information. The issue it seems is caused in In the case even if we cannot reduce to a 1D case by throwing away one of the vectors of coefficients (as we can in normal binary logistic regression). This is essentially a difference between softmax (redundancy allowed) and logistic regression. This can be fixed by commenting out the lines 762 and 763. I am apprehensive however that this may cause some other unknown issues which is why I am positing as a bug. <!-- Please run the following snippet and paste the output below. import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("NumPy", numpy.version) import scipy; print("SciPy", scipy.version) import sklearn; print("Scikit-Learn", sklearn.version) --Linux-4.10.0-33-generic-x8664-with-Ubuntu-16.04-xenial Python 3.5.2 (default, Nov 17 2016, 17:05:23) NumPy 1.13.1 SciPy 0.19.1 Scikit-Learn 0.19.0 <!-- Thanks for contributing! --

coef_ : array, shape (1, n_features) or (n_classes, n_features)         Coefficient of the features in the decision function.         `coef_` is of shape (1, n_features) when the given problem        is binary.        `coef_` is of shape (1, n_features) when the given problem is binary.        In particular, when `multi_class='multinomial'`, `coef_` corresponds        to outcome 1 (True) and `-coef_` corresponds to outcome 0 (False).      intercept_ : array, shape (1,) or (n_classes,)         Intercept (a.k.a. bias) added to the decision function.          If `fit_intercept` is set to False, the intercept is set to zero.        `intercept_` is of shape(1,) when the problem is binary.        `intercept_` is of shape (1,) when the given problem is binary.        In particular, when `multi_class='multinomial'`, `intercept_`        corresponds to outcome 1 (True) and `-intercept_` corresponds to        outcome 0 (False).      n_iter_ : array, shape (n_classes,) or (1, )         Actual number of iterations for all classes. If binary or multinomial,


Question: Incorrect predictions when fitting a LogisticRegression model on binary outcomes with . Incorrect predictions when fitting a LogisticRegression model on binary outcomes with . <!-- Example: Joblib Error thrown when calling fit on LatentDirichletAllocation with evaluateevery 0--<!-- Example: If the code is too long, feel free to put it in a public gist and link it in the issue: --If we compare against R or using , the log loss (which is approximately proportional to the objective function as the regularisation is set to be negligible through the choice of ) is incorrect. We expect the log loss to be roughly The actual log loss when using is . See the stack exchange question for more information. The issue it seems is caused in In the case even if we cannot reduce to a 1D case by throwing away one of the vectors of coefficients (as we can in normal binary logistic regression). This is essentially a difference between softmax (redundancy allowed) and logistic regression. This can be fixed by commenting out the lines 762 and 763. I am apprehensive however that this may cause some other unknown issues which is why I am positing as a bug. <!-- Please run the following snippet and paste the output below. import platform; print(platform.platform()) import sys; print("Python", sys.version) import numpy; print("NumPy", numpy.version) import scipy; print("SciPy", scipy.version) import sklearn; print("Scikit-Learn", sklearn.version) --Linux-4.10.0-33-generic-x8664-with-Ubuntu-16.04-xenial Python 3.5.2 (default, Nov 17 2016, 17:05:23) NumPy 1.13.1 SciPy 0.19.1 Scikit-Learn 0.19.0 <!-- Thanks for contributing! --

"""         if not hasattr(self, "coef_"):             raise NotFittedError("Call fit before prediction")        calculate_ovr = self.coef_.shape[0] == 1 or self.multi_class == "ovr"        if calculate_ovr:        if self.multi_class == "ovr":             return super(LogisticRegression, self)._predict_proba_lr(X)         else:            return softmax(self.decision_function(X), copy=False)            decision = self.decision_function(X)            if decision.ndim == 1:                # Workaround for multi_class="multinomial" and binary outcomes                # which requires softmax prediction with only a 1D decision.                decision_2d = np.c_[-decision, decision]            else:                decision_2d = decision            return softmax(decision_2d, copy=False)      def predict_log_proba(self, X):         """Log of probability estimates.


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

deprecated: bool  def type_to_xref(target: str, env: BuildEnvironment = None, suppress_prefix: bool = False                 ) -> addnodes.pending_xref:    """Convert a type string to a cross reference node."""    if target == 'None' or target.startswith('typing.'):def parse_reftarget(reftarget: str, suppress_prefix: bool = False                    ) -> Tuple[str, str, str, bool]:    """Parse a type string and return (reftype, reftarget, title, refspecific flag)"""    refspecific = False    if reftarget.startswith('.'):        reftarget = reftarget[1:]        title = reftarget        refspecific = True    elif reftarget.startswith('~'):        reftarget = reftarget[1:]        title = reftarget.split('.')[-1]    elif suppress_prefix:        title = reftarget.split('.')[-1]    elif reftarget.startswith('typing.'):        title = reftarget[7:]    else:        title = reftarget    if reftarget == 'None' or reftarget.startswith('typing.'):         # typing module provides non-class types.  Obj reference is good to refer them.         reftype = 'obj'     else:         reftype = 'class'     return reftype, reftarget, title, refspecificdef type_to_xref(target: str, env: BuildEnvironment = None, suppress_prefix: bool = False                 ) -> addnodes.pending_xref:    """Convert a type string to a cross reference node."""     if env:         kwargs = {'py:module': env.ref_context.get('py:module'),                   'py:class': env.ref_context.get('py:class')}     else:         kwargs = {}     refspecific = False    if target.startswith('.'):        target = target[1:]        text = target        refspecific = True    elif target.startswith('~'):        target = target[1:]        text = target.split('.')[-1]    elif suppress_prefix:        text = target.split('.')[-1]    elif target.startswith('typing.'):        text = target[7:]    else:        text = target    reftype, target, title, refspecific = parse_reftarget(target, suppress_prefix)      if env.config.python_use_unqualified_type_names:         # Note: It would be better to use qualname to describe the object to support support         # nested classes.  But python domain can't access the real python object because this         # module should work not-dynamically.        shortname = text.split('.')[-1]        shortname = title.split('.')[-1]         contnodes: List[Node] = [pending_xref_condition('', shortname, condition='resolved'),                                 pending_xref_condition('', text, condition='*')]                                 pending_xref_condition('', title, condition='*')]     else:        contnodes = [nodes.Text(text)]        contnodes = [nodes.Text(title)]      return pending_xref('', *contnodes,                         refdomain='py', reftype=reftype, reftarget=target,


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

result = super().make_xref(rolename, domain, target,  # type: ignore                                    innernode, contnode,                                    env, inliner=None, location=None)        result['refspecific'] = True        result['py:module'] = env.ref_context.get('py:module')        result['py:class'] = env.ref_context.get('py:class')        if target.startswith(('.', '~')):            prefix, result['reftarget'] = target[0], target[1:]            if prefix == '.':                text = target[1:]            elif prefix == '~':                text = target.split('.')[-1]            for node in list(result.traverse(nodes.Text)):                node.parent[node.parent.index(node)] = nodes.Text(text)                break        elif isinstance(result, pending_xref) and env.config.python_use_unqualified_type_names:            children = result.children            result.clear()            shortname = target.split('.')[-1]            textnode = innernode('', shortname)            contnodes = [pending_xref_condition('', '', textnode, condition='resolved'),                         pending_xref_condition('', '', *children, condition='*')]            result.extend(contnodes)        if isinstance(result, pending_xref):            result['refspecific'] = True            result['py:module'] = env.ref_context.get('py:module')            result['py:class'] = env.ref_context.get('py:class')            reftype, reftarget, reftitle, _ = parse_reftarget(target)            if reftarget != reftitle:                result['reftype'] = reftype                result['reftarget'] = reftarget                result.clear()                result += innernode(reftitle, reftitle)            elif env.config.python_use_unqualified_type_names:                children = result.children                result.clear()                shortname = target.split('.')[-1]                textnode = innernode('', shortname)                contnodes = [pending_xref_condition('', '', textnode, condition='resolved'),                             pending_xref_condition('', '', *children, condition='*')]                result.extend(contnodes)          return result


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

class PyField(PyXrefMixin, Field):    def make_xref(self, rolename: str, domain: str, target: str,                  innernode: Type[TextlikeNode] = nodes.emphasis,                  contnode: Node = None, env: BuildEnvironment = None,                  inliner: Inliner = None, location: Node = None) -> Node:        if rolename == 'class' and target == 'None':            # None is not a type, so use obj role instead.            rolename = 'obj'        return super().make_xref(rolename, domain, target, innernode, contnode,                                 env, inliner, location)    pass   class PyGroupedField(PyXrefMixin, GroupedField):


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

class PyTypedField(PyXrefMixin, TypedField):    def make_xref(self, rolename: str, domain: str, target: str,                  innernode: Type[TextlikeNode] = nodes.emphasis,                  contnode: Node = None, env: BuildEnvironment = None,                  inliner: Inliner = None, location: Node = None) -> Node:        if rolename == 'class' and target == 'None':            # None is not a type, so use obj role instead.            rolename = 'obj'        return super().make_xref(rolename, domain, target, innernode, contnode,                                 env, inliner, location)    pass   class PyObject(ObjectDescription[Tuple[str, str]]):diff --git a/sphinx/ext/autodoc/typehints.py b/sphinx/ext/autodoc/typehints.py-- a/sphinx/ext/autodoc/typehints.py++ b/sphinx/ext/autodoc/typehints.py


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

def record_typehints(app: Sphinx, objtype: str, name: str, obj: Any,                      options: Dict, args: str, retann: str) -> None:     """Record type hints to env object."""<ins>    if app.config.autodoc_typehints_format == 'short':        mode = 'smart'    else:        mode = 'fully-qualified'</ins>     try:         if callable(obj):             annotations = app.env.temp_data.setdefault('annotations', {})


Question: autodocunqualifiedtypehints does not work well with autodoctypehints="description" autodocunqualifiedtypehints does not work well with autodoctypehints="description". Typehints in info-field-list are also changed to the short style when autodocunqualifedtypehints enabled. N/A No response Mac 10.1 HEAD of 4.x autodoc No response No response

sig = inspect.signature(obj, type_aliases=app.config.autodoc_type_aliases)             for param in sig.parameters.values():                 if param.annotation is not param.empty:                    annotation[param.name] = typing.stringify(param.annotation)                    annotation[param.name] = typing.stringify(param.annotation, mode)             if sig.return_annotation is not sig.empty:                annotation['return'] = typing.stringify(sig.return_annotation)                annotation['return'] = typing.stringify(sig.return_annotation, mode)     except (TypeError, ValueError):         pass


Question: Change "Permalink to this headline" to use "heading" instead Sphinx-generated tooltips for headings use "Headline" instead of "Heading". Picking out of Build any Sphinx documentation, containing one or more headings (eg: ). When hovering over the Sphinx-injected "headerlink", notice that it says "Headline" instead of "Heading". Instead of: Permalink to this headline The tooltip should be: Permalink to this heading <img width="235" alt="Screenshot 2022-01-01 at 17 20 09" src="https://user-"N/A N/A No response No response The relevant chunk of code: This will also need some update to the translated strings, which means that this will likely need to be a Sphinx 5.0+ change?

node.parent.hasattr('ids') and node.parent['ids']):             # add permalink anchor             if close_tag.startswith('</h'):                self.add_permalink_ref(node.parent, _('Permalink to this headline'))                self.add_permalink_ref(node.parent, _('Permalink to this heading'))             elif close_tag.startswith('</h'):                 self.body.append('%s' % (                                     _('Permalink to this headline'),                                     _('Permalink to this heading'),                                      self.config.html_permalinks_icon))             elif isinstance(node.parent, nodes.table):                 self.body.append('')diff --git a/sphinx/writers/html5.py b/sphinx/writers/html5.py-- a/sphinx/writers/html5.py++ b/sphinx/writers/html5.py


Question: Change "Permalink to this headline" to use "heading" instead Sphinx-generated tooltips for headings use "Headline" instead of "Heading". Picking out of Build any Sphinx documentation, containing one or more headings (eg: ). When hovering over the Sphinx-injected "headerlink", notice that it says "Headline" instead of "Heading". Instead of: Permalink to this headline The tooltip should be: Permalink to this heading <img width="235" alt="Screenshot 2022-01-01 at 17 20 09" src="https://user-"N/A N/A No response No response The relevant chunk of code: This will also need some update to the translated strings, which means that this will likely need to be a Sphinx 5.0+ change?

node.parent.hasattr('ids') and node.parent['ids']):             # add permalink anchor             if close_tag.startswith('</h'):                self.add_permalink_ref(node.parent, _('Permalink to this headline'))                self.add_permalink_ref(node.parent, _('Permalink to this heading'))             elif close_tag.startswith('</h'):                 self.body.append('%s' % (                                     _('Permalink to this headline'),                                     _('Permalink to this heading'),                                      self.config.html_permalinks_icon))             elif isinstance(node.parent, nodes.table):                 self.body.append('')


Question: Latex: long option name overflows in Index Let's consider something like: Leads to the following with . ! Build snippet. No response Build the snippet No response Linux 8 0 No response No response No response

descr = _('%s command line option') % currprogram         else:             descr = _('command line option')        for option in sig.split(', '):        for option in signode.get('allnames', []):             entry = '; '.join([descr, option])             self.indexnode['entries'].append(('pair', entry, signode['ids'][0], '', None))


Question: Allow to bail out extlink replacement suggestion Feature via Consider the following ext link: and the following text: ` Can we somehow bailout out the check here, or perhaps the suggestion should only apply if there's no in the extlink, what do you think? cc

uri_pattern = re.compile(re.escape(base_uri).replace('%s', '(?P<value>.+)'))              match = uri_pattern.match(uri)            if match and match.groupdict().get('value'):            if (                match and                match.groupdict().get('value') and                '/' not in match.groupdict()['value']            ):                 # build a replacement suggestion                 msg = __('hardcoded link %r could be replaced by an extlink '                          '(try using %r instead)')


Question: Alternating multiply referred footnotes produce a ? in pdf output In some circumstances footnote mark is rendered as and there is no hyperlink file : then . Footnotes are rendered correctly See above code ! Mac 7 (CPython) 0 and current 4.x (v4.5.0+/) No response No response No response

def visit_footnote(self, node: Element) -> None:         self.in_footnote += 1         label = cast(nodes.label, node[0])        if 'referred' in node:            self.body.append(r'\sphinxstepexplicit ')         if self.in_parsed_literal:             self.body.append(r'\begin{footnote}[%s]' % label.astext())         else:             self.body.append('%' + CR)             self.body.append(r'\begin{footnote}[%s]' % label.astext())         if 'referred' in node:            self.body.append(r'\phantomsection'                             r'\label{\thesphinxscope.%s}%%' % label.astext() + CR)            # TODO: in future maybe output a latex macro with backrefs here            pass         self.body.append(r'\sphinxAtStartFootnote' + CR)      def depart_footnote(self, node: Element) -> None:


Question: Alternating multiply referred footnotes produce a ? in pdf output In some circumstances footnote mark is rendered as and there is no hyperlink file : then . Footnotes are rendered correctly See above code ! Mac 7 (CPython) 0 and current 4.x (v4.5.0+/) No response No response No response

def visit_footnotetext(self, node: Element) -> None:         label = cast(nodes.label, node[0])         self.body.append('%' + CR)        self.body.append(r'\begin{footnotetext}[%s]'                         r'\phantomsection\label{\thesphinxscope.%s}%%'                         % (label.astext(), label.astext()) + CR)        self.body.append(r'\begin{footnotetext}[%s]' % label.astext())         self.body.append(r'\sphinxAtStartFootnote' + CR)      def depart_footnotetext(self, node: Element) -> None:


Question: Overridden, overloaded class docstring return type rendered as None Some overloaded class definitions show ` as a return type, when there shouldn't be any return type. This seems to happen when the overloaded functions are overridden in the final docstring. A class without this problem is also provided for comparison. Exactly the same as ! ! Ubuntu 3 0 '', '', 'sphinxrtdtheme' No response Related Sphinx issue: This was originally reported in

return stringify_signature(sig, show_return_annotation=False, **kwargs) <ins>    def _find_signature(self) -> Tuple[str, str]:        result = super()._find_signature()        if result is not None:            # Strip a return value from signature of constructor in docstring (first entry)            result = (result[0], None)        for i, sig in enumerate(self._signatures):            if sig.endswith(' -> None'):                # Strip a return value from signatures of constructor in docstring (subsequent                # entries)                self._signatures[i] = sig[:-8]        return result</ins>     def format_signature(self, **kwargs: Any) -> str:         if self.doc_as_attr:             return ''


Question: autodocpreservedefaults=True does not work for mixture of keyword only arguments with/without defaults If I understand correctly, the following is a valid signature of a class method: When documenting this with autodoc and , generates a with for the arguments. This later raises an exception in since the dunder method now returns instead of a string. Basically what happens is that ast generates a value in the of the since the first keyword argument is required, but simply ignores that argument because the is empty. This leaves the in the to be picked up when the keyword argument with default value is processed -- instead of the actual default. This can't be resolved by the call which therefore simply returns , which ends up as the of the . Imo this could simply be resolved by ing the corresponding from the if a parameter with empty is encountered. Create a module with contents and auto-document while setting in your Make sure sphinx tries to document all parameters, (since it's a method, they will be documented when the autodoc directive has , if you try the same with a module level method you need to document the parameters) The correct default value should be documented. The Warning Message also is pretty worthless (probably the value should not be formatted with a simple but instead with a ?) Any Tested with versions 3.8 0

kw_defaults = list(function.args.kw_defaults)             parameters = list(sig.parameters.values())             for i, param in enumerate(parameters):                if param.default is not param.empty:                if param.default is param.empty:                    if param.kind == param.KEYWORD_ONLY:                        # Consume kw_defaults for kwonly args                        kw_defaults.pop(0)                else:                     if param.kind in (param.POSITIONAL_ONLY, param.POSITIONAL_OR_KEYWORD):                         default = defaults.pop(0)                         value = get_default_value(lines, default)


Question: Use of literalinclude prepend results in incorrect indent formatting for code eamples Cannot determine a mechanism to use literalinclude directive with or to match code example indentation, as leading whitespace is removed. Example of including xml snippet, that should be prefixed with . File: File : Produces the following valid xml, which is indented poorly: I cannot think of good warning free way to indent to match the included code example. Expect leading white space to be preserved in output: No response Mac 10 0 ['', ''] No response Using creatively almost provides a workaround: Produces a warning, which fails the build with build policy. Use of could be a good solution, if was applied only to the literalinclude and not to the and content.

self.start_filter,                        self.end_filter,                        self.lines_filter,                       self.dedent_filter,                        self.prepend_filter,                       self.append_filter,                       self.dedent_filter]                       self.append_filter]             lines = self.read_file(self.filename, location=location)             for func in filters:                 lines = func(lines, location=location)


Question: inherited-members should support more than one class Is your feature request related to a problem? Please describe. I have two situations: A class inherits from multiple other classes. I want to document members from some of the base classes but ignore some of the base classes A module contains several class definitions that inherit from different classes that should all be ignored (e.g., classes that inherit from list or set or tuple). I want to ignore members from list, set, and tuple while documenting all other inherited members in classes in the module. Describe the solution you'd like The :inherited-members: option to automodule should accept a list of classes. If any of these classes are encountered as base classes when instantiating autoclass documentation, they should be ignored. Describe alternatives you've considered The alternative is to not use automodule, but instead manually enumerate several autoclass blocks for a module. This only addresses the second bullet in the problem description and not the first. It is also tedious for modules containing many class definitions.

return {x.strip() for x in arg.split(',') if x.strip()}  def inherited_members_option(arg: Any) -> Union[object, Set[str]]:def inherited_members_option(arg: Any) -> Set[str]:     """Used to convert the :members: option to auto directives."""     if arg in (None, True):        return 'object'        return {'object'}    elif arg:        return set(x.strip() for x in arg.split(','))     else:        return arg        return set()   def member_order_option(arg: Any) -> Optional[str]:


Question: inherited-members should support more than one class Is your feature request related to a problem? Please describe. I have two situations: A class inherits from multiple other classes. I want to document members from some of the base classes but ignore some of the base classes A module contains several class definitions that inherit from different classes that should all be ignored (e.g., classes that inherit from list or set or tuple). I want to ignore members from list, set, and tuple while documenting all other inherited members in classes in the module. Describe the solution you'd like The :inherited-members: option to automodule should accept a list of classes. If any of these classes are encountered as base classes when instantiating autoclass documentation, they should be ignored. Describe alternatives you've considered The alternative is to not use automodule, but instead manually enumerate several autoclass blocks for a module. This only addresses the second bullet in the problem description and not the first. It is also tedious for modules containing many class definitions.

``autodoc-skip-member`` event.         """         def is_filtered_inherited_member(name: str, obj: Any) -> bool:            inherited_members = self.options.inherited_members or set()             if inspect.isclass(self.object):                 for cls in self.object.__mro__:                    if cls.__name__ == self.options.inherited_members and cls != self.object:                    if cls.__name__ in inherited_members and cls != self.object:                         # given member is a member of specified *super class*                         return True                     elif name in cls.__dict__:


Question: Reference targets not found when using When using the above directive in my for sphinx, I suddenly get the following output: Previously I had , but when changing this behaviour suddenly it cannot find these names/targets. NOTE: I use the following command to generate my docs, hence being able to see all warnings as errors:- I expected the docs to build correctly with the resolved types and reference links. N/A I think ! Linux - Debian 10 6 0 , , , , sphinxcontribtrio, resourcelinks No response No response

def __eq__(self, other: Any) -> bool:         return self.name == other <ins>    def __hash__(self) -> int:        return hash(self.name)    def __repr__(self) -> str:        return self.name</ins>  class TypeAliasModule:     """Pseudo module class for autodoc_type_aliases."""


Question: doesn't work on class methods Default values for class methods are rendered as their , even with in Extract the and run . Note that the default value for the argument of the regular and static methods render correctly as , but the default value for the class method renders as its repr. All three methods' argument's default values should render as Screenshot of the rendered attached example demonstrating incorrect rendering: ! Arch Linux 10.0 Tested on 4.5 and current 5.x branch (commit ) No response No response

import ast import inspect import sys<ins>from inspect import Parameter</ins> from typing import Any, Dict, List, Optional  from sphinx.application import Sphinx


Question: doesn't work on class methods Default values for class methods are rendered as their , even with in Extract the and run . Note that the default value for the argument of the regular and static methods render correctly as , but the default value for the class method renders as its repr. All three methods' argument's default values should render as Screenshot of the rendered attached example demonstrating incorrect rendering: ! Arch Linux 10.0 Tested on 4.5 and current 5.x branch (commit ) No response No response

if value is None:                             value = ast_unparse(default)  # type: ignore                         parameters[i] = param.replace(default=DefaultValue(value))            if bound_method and inspect.ismethod(obj):                # classmethods                cls = inspect.Parameter('cls', Parameter.POSITIONAL_OR_KEYWORD)                parameters.insert(0, cls)             sig = sig.replace(parameters=parameters)            obj.__signature__ = sig            if bound_method and inspect.ismethod(obj):                # classmethods can't be assigned __signature__ attribute.                obj.__dict__['__signature__'] = sig            else:                obj.__signature__ = sig     except (AttributeError, TypeError):         # failed to update signature (ex. built-in or extension types)         pass


Question: LaTeX: new Inline code highlighting from adds whitespace at start and end in pdf output The enhancement activates syntax highlighting for the Docutiles role. For LaTeX output, a space character is inserted at start and end of the inline code. Example a priori, mark-up should be: But I have no no strong opinion if good or bad. See screenshots. in and . No response extracted from with current: ! if space characters removed from file produced by LaTeX writer: ! For comparison prior to merge: ! Mac 9 No response No response Relates

# TODO: Use nowrap option once LaTeX formatter supports it         # https://github.com/pygments/pygments/pull/1343         hlcode = hlcode.replace(r'\begin{Verbatim}[commandchars=\\\{\}]',                                r'\sphinxcode{\sphinxupquote{')                                r'\sphinxcode{\sphinxupquote{%')         # get consistent trailer        hlcode = hlcode.rstrip()[:-14]  # strip \end{Verbatim}        hlcode = hlcode.rstrip()[:-15]  # strip \n\end{Verbatim}         self.body.append(hlcode)        self.body.append('}}')        self.body.append('%' + CR + '}}')         raise nodes.SkipNode      def depart_literal(self, node: Element) -> None:


Question: causes autoclass to put a return type Using the option causes Sphinx's to include the class's "return type" for code such as this: <details<summaryOld repro, the repository no longer exists</summary</detailsa folder. that folder create files: : : : a virtual environment and install Sphinx 4.4 in it. into the docs folder and build the documentation with a command (in activated virtual environment): in the browser and see the issue. I expected there to be no return type listed for the class. Here's a link to generated docs: https://sphinx-issue- Windows 10, Ubuntu 18.04 7, 3.8, 3.9 0 No response No response

for field_list in field_lists:             if app.config.autodoc_typehints_description_target == "all":                modify_field_list(field_list, annotations[fullname])                if objtype == 'class':                    modify_field_list(field_list, annotations[fullname], suppress_rtype=True)                else:                    modify_field_list(field_list, annotations[fullname])             elif app.config.autodoc_typehints_description_target == "documented_params":                 augment_descriptions_with_types(                     field_list, annotations[fullname], force_rtype=True


Question: causes autoclass to put a return type Using the option causes Sphinx's to include the class's "return type" for code such as this: <details<summaryOld repro, the repository no longer exists</summary</detailsa folder. that folder create files: : : : a virtual environment and install Sphinx 4.4 in it. into the docs folder and build the documentation with a command (in activated virtual environment): in the browser and see the issue. I expected there to be no return type listed for the class. Here's a link to generated docs: https://sphinx-issue- Windows 10, Ubuntu 18.04 7, 3.8, 3.9 0 No response No response

return field_list  def modify_field_list(node: nodes.field_list, annotations: Dict[str, str]) -> None:def modify_field_list(node: nodes.field_list, annotations: Dict[str, str],                      suppress_rtype: bool = False) -> None:     arguments: Dict[str, Dict[str, bool]] = {}     fields = cast(Iterable[nodes.field], node)     for field in fields:


Question: causes autoclass to put a return type Using the option causes Sphinx's to include the class's "return type" for code such as this: <details<summaryOld repro, the repository no longer exists</summary</detailsa folder. that folder create files: : : : a virtual environment and install Sphinx 4.4 in it. into the docs folder and build the documentation with a command (in activated virtual environment): in the browser and see the issue. I expected there to be no return type listed for the class. Here's a link to generated docs: https://sphinx-issue- Windows 10, Ubuntu 18.04 7, 3.8, 3.9 0 No response No response

node += field      if 'return' in annotations and 'return' not in arguments:<ins>        annotation = annotations['return']        if annotation == 'None' and suppress_rtype:            return</ins>         field = nodes.field()         field += nodes.field_name('', 'rtype')         field += nodes.field_body('', nodes.paragraph('', annotation))


Question: Fix duplicated args and kwargs with autodoctypehints Fix duplicated args and kwargs with autodoctypehints Bugfix Consider this when using the autodoc extension and the setting . WIth sphinx 4.2.0, the current output is where the args and *kwargs are duplicated and incomplete. The expected output is

if name == 'return':             continue         arg = arguments.get(name, {})        if '*' + name in arguments:            name = '*' + name            arguments.get(name)        elif '**' + name in arguments:            name = '**' + name            arguments.get(name)        else:            arg = arguments.get(name, {})         if not arg.get('type'):             field = nodes.field()             field += nodes.field_name('', 'type ' + name)


Question: Fix duplicated args and kwargs with autodoctypehints Fix duplicated args and kwargs with autodoctypehints Bugfix Consider this when using the autodoc extension and the setting . WIth sphinx 4.2.0, the current output is where the args and *kwargs are duplicated and incomplete. The expected output is

has_type.add('return')      # Add 'type' for parameters with a description but no declared type.    for name in annotations:    for name, annotation in annotations.items():         if name in ('return', 'returns'):             continue        if '*' + name in has_description:            name = '*' + name        elif '**' + name in has_description:            name = '**' + name         if name in has_description and name not in has_type:             field = nodes.field()             field += nodes.field_name('', 'type ' + name)            field += nodes.field_body('', nodes.paragraph('', annotations[name]))            field += nodes.field_body('', nodes.paragraph('', annotation))             node += field      # Add 'rtype' if 'return' is present and 'rtype' isn't.


Question: fails to remove more than one meta-field from a fieldlist If a field list contains more then one "meta"-field, the generated documentation shows all but the first meta-field. It is a classical coding bug: the function stops removing meta fields after the first meta-field. Generated documentation contains a box with the text . The generated documentation does not contain any traces of the meta-fields. No response Linux 6 and 4.5.x No response The function filtermetafields was introduced by commit , which I'll provide a pull request with a test and a fix. fails to remove more than one meta-field from a fieldlist If a field list contains more then one "meta"-field, the generated documentation shows all but the first meta-field. It is a classical coding bug: the function stops removing meta fields after the first meta-field. Generated documentation contains a box with the text . The generated documentation does not contain any traces of the meta-fields. No response Linux 6 and 4.5.x No response The function filtermetafields was introduced by commit , which I'll provide a pull request with a test and a fix.

for node in content:         if isinstance(node, nodes.field_list):             fields = cast(List[nodes.field], node)            for field in fields:            # removing list items while iterating the list needs reversed()            for field in reversed(fields):                 field_name = cast(nodes.field_body, field[0]).astext().strip()                 if field_name == 'meta' or field_name.startswith('meta '):                     node.remove(field)                    break   class PythonModuleIndex(Index):