CIL icon indicating copy to clipboard operation
CIL copied to clipboard

Sphinx autodocumentation does not show KullbackLeibler

Open paskino opened this issue 2 years ago • 4 comments

Because the KullbackLeibler class uses the factory method __new__, upon instantiation it returns an instance of another class. Then sphinx will not show the appropriate documentation.

https://github.com/TomographicImaging/CIL/blob/d198bef918a44f88870899dcb90bfd1c0c235040/Wrappers/Python/cil/optimisation/functions/KullbackLeibler.py#L91-L105

In GradientOperator we do a similar thing, but we store an instance of the operator we use (either from the C CIL library or from numpy) and then we use that for all the calls, for instance direct

https://github.com/TomographicImaging/CIL/blob/d198bef918a44f88870899dcb90bfd1c0c235040/Wrappers/Python/cil/optimisation/operators/GradientOperator.py#L111-L114

https://github.com/TomographicImaging/CIL/blob/d198bef918a44f88870899dcb90bfd1c0c235040/Wrappers/Python/cil/optimisation/operators/GradientOperator.py#L135

In the case of the GradientOperator the documentation looks good.

In #1618 I am facing the same issue with the WeightedL1Norm.

Can sphinx add the documentation of the right class? If not, how do we get the documentation to appear correctly?

Currently #1613 is also due to this issue.

paskino avatar Dec 11 '23 16:12 paskino

Please can you explain what is wrong with the current rendered documentation for KullbackLeiber?

lauramurgatroyd avatar Dec 11 '23 17:12 lauramurgatroyd

It's missing documentation on the methods gradient, __call__, proximal, proximal_conjugate, convex_conjugate and proximal.

paskino avatar Dec 11 '23 18:12 paskino

I had a bit of a play and got it to show: image image image Not a fix to doing the factory methods automatically but one way of explaining it in the documentation

MargaretDuff avatar Dec 12 '23 10:12 MargaretDuff

Currently the documentation shows the docstrings from the parent class Function.

The solution is to use the same approach used with the GradientOperator.

paskino avatar Dec 13 '23 15:12 paskino