From b12983622b1638d61a305286b977a64a795fc787 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Mon, 4 Dec 2023 13:49:30 +0100 Subject: [PATCH] Docs: added sorting order for autogenerated toc --- docs/.gitignore | 2 +- docs/{tutorials => 01_tutorials}/00_dqn.rst | 2 +- docs/{tutorials => 01_tutorials}/01_concepts.rst | 4 ++-- docs/{tutorials => 01_tutorials}/03_batch.rst | 0 docs/{tutorials => 01_tutorials}/04_tictactoe.rst | 0 docs/{tutorials => 01_tutorials}/05_logger.rst | 0 docs/{tutorials => 01_tutorials}/06_benchmark.rst | 0 docs/{tutorials => 01_tutorials}/07_cheatsheet.rst | 4 ++-- docs/{tutorials => 01_tutorials}/index.rst | 0 docs/{notebooks => 02_notebooks}/0_intro.md | 0 docs/{notebooks => 02_notebooks}/L0_overview.ipynb | 0 docs/{notebooks => 02_notebooks}/L1_Batch.ipynb | 2 +- docs/{notebooks => 02_notebooks}/L2_Buffer.ipynb | 0 .../L3_Vectorized__Environment.ipynb | 0 docs/{notebooks => 02_notebooks}/L4_Policy.ipynb | 0 docs/{notebooks => 02_notebooks}/L5_Collector.ipynb | 0 docs/{notebooks => 02_notebooks}/L6_Trainer.ipynb | 0 docs/{notebooks => 02_notebooks}/L7_Experiment.ipynb | 0 .../04_contributing.rst} | 6 +++--- .../{contributor.rst => 04_contributing/05_contributor.rst} | 0 docs/index.rst | 2 +- 21 files changed, 11 insertions(+), 11 deletions(-) rename docs/{tutorials => 01_tutorials}/00_dqn.rst (99%) rename docs/{tutorials => 01_tutorials}/01_concepts.rst (98%) rename docs/{tutorials => 01_tutorials}/03_batch.rst (100%) rename docs/{tutorials => 01_tutorials}/04_tictactoe.rst (100%) rename docs/{tutorials => 01_tutorials}/05_logger.rst (100%) rename docs/{tutorials => 01_tutorials}/06_benchmark.rst (100%) rename docs/{tutorials => 01_tutorials}/07_cheatsheet.rst (99%) rename docs/{tutorials => 01_tutorials}/index.rst (100%) rename docs/{notebooks => 02_notebooks}/0_intro.md (100%) rename docs/{notebooks => 02_notebooks}/L0_overview.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L1_Batch.ipynb (98%) rename docs/{notebooks => 02_notebooks}/L2_Buffer.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L3_Vectorized__Environment.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L4_Policy.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L5_Collector.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L6_Trainer.ipynb (100%) rename docs/{notebooks => 02_notebooks}/L7_Experiment.ipynb (100%) rename docs/{contributing.rst => 04_contributing/04_contributing.rst} (95%) rename docs/{contributor.rst => 04_contributing/05_contributor.rst} (100%) diff --git a/docs/.gitignore b/docs/.gitignore index 3f06ced..7151388 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,3 +1,3 @@ -/api/* +/03_api/* jupyter_execute _toc.yml \ No newline at end of file diff --git a/docs/tutorials/00_dqn.rst b/docs/01_tutorials/00_dqn.rst similarity index 99% rename from docs/tutorials/00_dqn.rst rename to docs/01_tutorials/00_dqn.rst index 1c4ec57..79d0985 100644 --- a/docs/tutorials/00_dqn.rst +++ b/docs/01_tutorials/00_dqn.rst @@ -308,7 +308,7 @@ Tianshou supports user-defined training code. Here is the code snippet: # train policy with a sampled batch data from buffer losses = policy.update(64, train_collector.buffer) -For further usage, you can refer to the :doc:`/tutorials/07_cheatsheet`. +For further usage, you can refer to the :doc:`/01_tutorials/07_cheatsheet`. .. rubric:: References diff --git a/docs/tutorials/01_concepts.rst b/docs/01_tutorials/01_concepts.rst similarity index 98% rename from docs/tutorials/01_concepts.rst rename to docs/01_tutorials/01_concepts.rst index 2589a55..5486098 100644 --- a/docs/tutorials/01_concepts.rst +++ b/docs/01_tutorials/01_concepts.rst @@ -339,7 +339,7 @@ Thus, we need a time-related interface for calculating the 2-step return. :meth: This code does not consider the done flag, so it may not work very well. It shows two ways to get :math:`s_{t + 2}` from the replay buffer easily in :meth:`~tianshou.policy.BasePolicy.process_fn`. -For other method, you can check out :doc:`/api/policy/index`. We give the usage of policy class a high-level explanation in :ref:`pseudocode`. +For other method, you can check out :doc:`/03_api/policy/index`. We give the usage of policy class a high-level explanation in :ref:`pseudocode`. Collector @@ -382,7 +382,7 @@ Trainer Once you have a collector and a policy, you can start writing the training method for your RL agent. Trainer, to be honest, is a simple wrapper. It helps you save energy for writing the training loop. You can also construct your own trainer: :ref:`customized_trainer`. -Tianshou has three types of trainer: :func:`~tianshou.trainer.onpolicy_trainer` for on-policy algorithms such as Policy Gradient, :func:`~tianshou.trainer.offpolicy_trainer` for off-policy algorithms such as DQN, and :func:`~tianshou.trainer.offline_trainer` for offline algorithms such as BCQ. Please check out :doc:`/api/trainer/index` for the usage. +Tianshou has three types of trainer: :func:`~tianshou.trainer.onpolicy_trainer` for on-policy algorithms such as Policy Gradient, :func:`~tianshou.trainer.offpolicy_trainer` for off-policy algorithms such as DQN, and :func:`~tianshou.trainer.offline_trainer` for offline algorithms such as BCQ. Please check out :doc:`/03_api/trainer/index` for the usage. We also provide the corresponding iterator-based trainer classes :class:`~tianshou.trainer.OnpolicyTrainer`, :class:`~tianshou.trainer.OffpolicyTrainer`, :class:`~tianshou.trainer.OfflineTrainer` to facilitate users writing more flexible training logic: :: diff --git a/docs/tutorials/03_batch.rst b/docs/01_tutorials/03_batch.rst similarity index 100% rename from docs/tutorials/03_batch.rst rename to docs/01_tutorials/03_batch.rst diff --git a/docs/tutorials/04_tictactoe.rst b/docs/01_tutorials/04_tictactoe.rst similarity index 100% rename from docs/tutorials/04_tictactoe.rst rename to docs/01_tutorials/04_tictactoe.rst diff --git a/docs/tutorials/05_logger.rst b/docs/01_tutorials/05_logger.rst similarity index 100% rename from docs/tutorials/05_logger.rst rename to docs/01_tutorials/05_logger.rst diff --git a/docs/tutorials/06_benchmark.rst b/docs/01_tutorials/06_benchmark.rst similarity index 100% rename from docs/tutorials/06_benchmark.rst rename to docs/01_tutorials/06_benchmark.rst diff --git a/docs/tutorials/07_cheatsheet.rst b/docs/01_tutorials/07_cheatsheet.rst similarity index 99% rename from docs/tutorials/07_cheatsheet.rst rename to docs/01_tutorials/07_cheatsheet.rst index 8a05b60..1d2c69a 100644 --- a/docs/tutorials/07_cheatsheet.rst +++ b/docs/01_tutorials/07_cheatsheet.rst @@ -126,7 +126,7 @@ The figure in the right gives an intuitive comparison among synchronous/asynchro .. note:: The async simulation collector would cause some exceptions when used as - ``test_collector`` in :doc:`/api/trainer/index` (related to + ``test_collector`` in :doc:`/03_api/trainer/index` (related to `Issue 700 `_). Please use sync version for ``test_collector`` instead. @@ -478,4 +478,4 @@ By constructing a new state ``state_ = (state, agent_id, mask)``, essentially we act = policy(state_) next_state_, reward = env.step(act) -Following this idea, we write a tiny example of playing `Tic Tac Toe `_ against a random player by using a Q-learning algorithm. The tutorial is at :doc:`/tutorials/04_tictactoe`. +Following this idea, we write a tiny example of playing `Tic Tac Toe `_ against a random player by using a Q-learning algorithm. The tutorial is at :doc:`/01_tutorials/04_tictactoe`. diff --git a/docs/tutorials/index.rst b/docs/01_tutorials/index.rst similarity index 100% rename from docs/tutorials/index.rst rename to docs/01_tutorials/index.rst diff --git a/docs/notebooks/0_intro.md b/docs/02_notebooks/0_intro.md similarity index 100% rename from docs/notebooks/0_intro.md rename to docs/02_notebooks/0_intro.md diff --git a/docs/notebooks/L0_overview.ipynb b/docs/02_notebooks/L0_overview.ipynb similarity index 100% rename from docs/notebooks/L0_overview.ipynb rename to docs/02_notebooks/L0_overview.ipynb diff --git a/docs/notebooks/L1_Batch.ipynb b/docs/02_notebooks/L1_Batch.ipynb similarity index 98% rename from docs/notebooks/L1_Batch.ipynb rename to docs/02_notebooks/L1_Batch.ipynb index 0b4aacb..eb4aa0e 100644 --- a/docs/notebooks/L1_Batch.ipynb +++ b/docs/02_notebooks/L1_Batch.ipynb @@ -368,7 +368,7 @@ "id": "8Oc1p8ud9kcu" }, "source": [ - "Would like to learn more advanced usages of Batch? Feel curious about how data is organized inside the Batch? Check the [documentation](https://tianshou.readthedocs.io/en/master/api/tianshou.data.html) and other [tutorials](https://tianshou.readthedocs.io/en/master/tutorials/batch.html#) for more details." + "Would like to learn more advanced usages of Batch? Feel curious about how data is organized inside the Batch? Check the [documentation](https://tianshou.readthedocs.io/en/master/03_api/tianshou.data.html) and other [tutorials](https://tianshou.readthedocs.io/en/master/tutorials/batch.html#) for more details." ] } ], diff --git a/docs/notebooks/L2_Buffer.ipynb b/docs/02_notebooks/L2_Buffer.ipynb similarity index 100% rename from docs/notebooks/L2_Buffer.ipynb rename to docs/02_notebooks/L2_Buffer.ipynb diff --git a/docs/notebooks/L3_Vectorized__Environment.ipynb b/docs/02_notebooks/L3_Vectorized__Environment.ipynb similarity index 100% rename from docs/notebooks/L3_Vectorized__Environment.ipynb rename to docs/02_notebooks/L3_Vectorized__Environment.ipynb diff --git a/docs/notebooks/L4_Policy.ipynb b/docs/02_notebooks/L4_Policy.ipynb similarity index 100% rename from docs/notebooks/L4_Policy.ipynb rename to docs/02_notebooks/L4_Policy.ipynb diff --git a/docs/notebooks/L5_Collector.ipynb b/docs/02_notebooks/L5_Collector.ipynb similarity index 100% rename from docs/notebooks/L5_Collector.ipynb rename to docs/02_notebooks/L5_Collector.ipynb diff --git a/docs/notebooks/L6_Trainer.ipynb b/docs/02_notebooks/L6_Trainer.ipynb similarity index 100% rename from docs/notebooks/L6_Trainer.ipynb rename to docs/02_notebooks/L6_Trainer.ipynb diff --git a/docs/notebooks/L7_Experiment.ipynb b/docs/02_notebooks/L7_Experiment.ipynb similarity index 100% rename from docs/notebooks/L7_Experiment.ipynb rename to docs/02_notebooks/L7_Experiment.ipynb diff --git a/docs/contributing.rst b/docs/04_contributing/04_contributing.rst similarity index 95% rename from docs/contributing.rst rename to docs/04_contributing/04_contributing.rst index 75cb97c..b24acbf 100644 --- a/docs/contributing.rst +++ b/docs/04_contributing/04_contributing.rst @@ -61,19 +61,19 @@ Test by GitHub Actions 1. Click the ``Actions`` button in your own repo: -.. image:: _static/images/action1.jpg +.. image:: ../_static/images/action1.jpg :align: center 2. Click the green button: -.. image:: _static/images/action2.jpg +.. image:: ../_static/images/action2.jpg :align: center 3. You will see ``Actions Enabled.`` on the top of html page. 4. When you push a new commit to your own repo (e.g. ``git push``), it will automatically run the test in this page: -.. image:: _static/images/action3.png +.. image:: ../_static/images/action3.png :align: center diff --git a/docs/contributor.rst b/docs/04_contributing/05_contributor.rst similarity index 100% rename from docs/contributor.rst rename to docs/04_contributing/05_contributor.rst diff --git a/docs/index.rst b/docs/index.rst index e111b2e..c41c7e6 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -52,7 +52,7 @@ Here is Tianshou's other features: * Support any type of environment state/action (e.g. a dict, a self-defined class, ...): :ref:`self_defined_env` * Support :ref:`customize_training` * Support n-step returns estimation :meth:`~tianshou.policy.BasePolicy.compute_nstep_return` and prioritized experience replay :class:`~tianshou.data.PrioritizedReplayBuffer` for all Q-learning based algorithms; GAE, nstep and PER are very fast thanks to numba jit function and vectorized numpy operation -* Support :doc:`/tutorials/04_tictactoe` +* Support :doc:`/01_tutorials/04_tictactoe` * Support both `TensorBoard `_ and `W&B `_ log tools * Support multi-GPU training :ref:`multi_gpu` * Comprehensive `unit tests `_, including functional checking, RL pipeline checking, documentation checking, PEP8 code-style checking, and type checking