stable-baselines3 icon indicating copy to clipboard operation
stable-baselines3 copied to clipboard

Wrong types for policy parameters in Documentation

Open mspils opened this issue 1 year ago • 2 comments

📚 Documentation

The documentation for all RL algorithms claims that the parameter policy has the type SACPolicy or ActorCriticPolicy or TD3Policy and so on: https://stable-baselines3.readthedocs.io/en/master/modules/td3.html#parameters Example: policy (TD3Policy) – The policy model to use (MlpPolicy, CnnPolicy, …)

This is not true, it expects either a string from the policy_aliases dict or a policy class. This is rather confusing and I just spend quite a bit figuring out why I could not pass a policy object. In the docstrings and source code the type is correct.

I think the problem may be, that the type hints for the class variables overwrite the type hints for the parameters when the documentation is generated.

Should i just make a pull request with where I change the type hints for class variables?

Checklist

  • [X] I have checked that there is no similar issue in the repo
  • [X] I have read the documentation

mspils avatar Jan 25 '24 16:01 mspils

Hello,

thanks for reporting the issue.

I think the problem may be, that the type hints for the class variables overwrite the type hints for the parameters when the documentation is generated.

sounds like a sphinx issue.

Should i just make a pull request with where I change the type hints for class variables?

I'm afraid this will generate new issue with type checking. I would rather investigate and ask sphinx devs if it's a bug on their side (might be related to https://github.com/sphinx-doc/sphinx/issues/10934).

In the meantime, we should try different options to maybe mask those attributes (from https://www.sphinx-doc.org/en/master/usage/extensions/autodoc.html).

araffin avatar Jan 26 '24 09:01 araffin

I've found a partial fix following https://stackoverflow.com/questions/46569163/sphinx-document-an-attribute-that-is-same-as-a-parameter by specifying :special-members: __init__

And this is a sphinx issue: https://github.com/sphinx-doc/sphinx/issues/11207

araffin avatar Jan 26 '24 09:01 araffin