numpydoc
numpydoc copied to clipboard
List a property as a class method
In scikit-learn, we have the following use-case.
We want a class method (e.g. predict_proba
) to only be defined under some condition meaning that hasattr(instance, "class_method")
should return False
or True
depending of some internal class attributes. The trick used to get this behaviour is to implement this class method as a property
where we can implement a checking mechanism which can raise an AttributeError
allowing to use hasattr
.
With this hack, the property is not listed in the summary of the methods: https://scikit-learn.org/dev/modules/generated/sklearn.linear_model.SGDClassifier.html#sklearn.linear_model.SGDClassifier We still get the property documented with the other methods thought.
I was wondering if there is any mechanism such that we could get this property shown in the methods toc?