From 0b67447541532b6eb2e2b27f9f34ae7029ec8c89 Mon Sep 17 00:00:00 2001 From: Michael Panchenko Date: Tue, 5 Dec 2023 13:22:04 +0100 Subject: [PATCH] Docs: fixing spelling, re-adding spellcheck to pipeline --- .../L3_Vectorized__Environment.ipynb | 4 +- docs/_config.yml | 6 ++- docs/spelling_wordlist.txt | 37 +++++++++++++++++++ pyproject.toml | 7 ++-- tianshou/data/batch.py | 4 +- tianshou/utils/string.py | 6 +-- 6 files changed, 53 insertions(+), 11 deletions(-) diff --git a/docs/02_notebooks/L3_Vectorized__Environment.ipynb b/docs/02_notebooks/L3_Vectorized__Environment.ipynb index 5421248..3540474 100644 --- a/docs/02_notebooks/L3_Vectorized__Environment.ipynb +++ b/docs/02_notebooks/L3_Vectorized__Environment.ipynb @@ -101,7 +101,7 @@ "source": [ "You may notice that the speed doesn't increase linearly when we add subprocess numbers. There are multiple reasons behind this. One reason is that synchronize exception causes straggler effect. One way to solve this would be to use asynchronous mode. We leave this for further reading if you feel interested.\n", "\n", - "Note that SubprocVectorEnv should only be used when the environment exection is slow. In practice, DummyVectorEnv (or raw Gym environment) is actually more efficient for a simple environment like CartPole because now you avoid both straggler effect and the overhead of communication between subprocesses." + "Note that SubprocVectorEnv should only be used when the environment execution is slow. In practice, DummyVectorEnv (or raw Gym environment) is actually more efficient for a simple environment like CartPole because now you avoid both straggler effect and the overhead of communication between subprocesses." ] }, { @@ -154,7 +154,7 @@ "id": "kvIfqh0vqAR5" }, "source": [ - "### Environment exection and resetting\n", + "### Environment execution and resetting\n", "The only difference between Vectorized environments and standard Gym environments is that passed in actions and returned rewards/observations are also vectorized." ] }, diff --git a/docs/_config.yml b/docs/_config.yml index 62f7429..89e4734 100644 --- a/docs/_config.yml +++ b/docs/_config.yml @@ -93,7 +93,11 @@ repository: ####################################################################################### # Advanced and power-user settings sphinx: - extra_extensions : ['sphinx.ext.autodoc', 'sphinx.ext.viewcode', 'sphinx_toolbox.more_autodoc.sourcelink'] + extra_extensions : + - sphinx.ext.autodoc + - sphinx.ext.viewcode + - sphinx_toolbox.more_autodoc.sourcelink + - sphinxcontrib.spelling local_extensions : # A list of local extensions to load by sphinx specified by "name: path" items recursive_update : false # A boolean indicating whether to overwrite the Sphinx config (true) or recursively update (false) config : # key-value pairs to directly over-ride the Sphinx configuration diff --git a/docs/spelling_wordlist.txt b/docs/spelling_wordlist.txt index 4be7cd0..1645ea3 100644 --- a/docs/spelling_wordlist.txt +++ b/docs/spelling_wordlist.txt @@ -199,3 +199,40 @@ img src parallelized infty +venv +venvs +subproc +bcq +highlevel +icm +modelbased +td +psrl +ddpg +npg +tf +trpo +crr +pettingzoo +multidiscrete +vecbuf +prio +colab +segtree +multiagent +mapolicy +sensai +sensAI +docstrings +superclass +iterable +functools +str +sklearn +attr +bc +redq +modelfree +bdq +util +logp diff --git a/pyproject.toml b/pyproject.toml index f55929a..bd1df7c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -180,10 +180,11 @@ _poetry_sort = "poetry sort" _clean-nbs = "nbstripout docs/02_notebooks/*" format = ["_black_format", "_ruff_format", "_poetry_install_sort_plugin", "_poetry_sort", "_clean-nbs"] _autogen_rst = "python docs/autogen_rst.py" -_spellcheck = "sphinx-build -W -b spelling docs docs/_build" _sphinx_build = "sphinx-build -W -b html docs docs/_build" _jb_generate_toc = "bash -c \"jupyter-book toc from-project docs -e .rst -e .md -e .ipynb > docs/_toc.yml \"" -_jb_config = "jupyter-book config sphinx docs/" +_jb_generate_config = "jupyter-book config sphinx docs/" doc-clean = "rm -rf docs/_build" -doc-build = ["_autogen_rst", "_jb_generate_toc", " _jb_config", "_sphinx_build"] +doc-generate-files = ["_autogen_rst", "_jb_generate_toc", "_jb_generate_config"] +doc-spellcheck = "sphinx-build -W -b spelling docs docs/_build" +doc-build = ["doc-generate-files", "doc-spellcheck", "_sphinx_build"] type-check = "mypy tianshou" diff --git a/tianshou/data/batch.py b/tianshou/data/batch.py index 354333c..7002b55 100644 --- a/tianshou/data/batch.py +++ b/tianshou/data/batch.py @@ -95,10 +95,10 @@ def create_value( size: int, stack: bool = True, ) -> Union["Batch", np.ndarray, torch.Tensor]: - """Create empty place-holders accroding to inst's shape. + """Create empty place-holders according to inst's shape. :param stack: whether to stack or to concatenate. E.g. if inst has shape of - (3, 5), size = 10, stack=True returns an np.ndarry with shape of (10, 3, 5), + (3, 5), size = 10, stack=True returns an np.array with shape of (10, 3, 5), otherwise (10, 5) """ has_shape = isinstance(inst, np.ndarray | torch.Tensor) diff --git a/tianshou/utils/string.py b/tianshou/utils/string.py index dcc71d0..a6d4792 100644 --- a/tianshou/utils/string.py +++ b/tianshou/utils/string.py @@ -1,4 +1,5 @@ -"""Copy of sensai.util.string from sensAI commit d7b4afcc89b4d2e922a816cb07dffde27f297354.""" +"""Copy of sensai.util.string from sensAI """ +# From commit commit d7b4afcc89b4d2e922a816cb07dffde27f297354 import functools @@ -11,7 +12,6 @@ from collections.abc import Callable, Iterable, Mapping, Sequence from typing import ( Any, Self, - cast, ) reCommaWhitespacePotentiallyBreaks = re.compile(r",\s+") @@ -136,7 +136,7 @@ def object_repr(obj: Any, member_names_or_dict: list[str] | dict[str, Any]) -> s def or_regex_group(allowed_names: Sequence[str]) -> str: """:param allowed_names: strings to include as literals in the regex - :return: a regular expression string of the form (| ...|), which any of the given names + :return: a regular expression string of the form `(| ...|)`, which any of the given names """ allowed_names = [re.escape(name) for name in allowed_names] return r"(%s)" % "|".join(allowed_names)