From dbb8e95fa020dbcd0560e8461f6a539e21d2b059 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 11 Oct 2021 19:45:57 +0530 Subject: [PATCH 01/11] Fixed typo in error message --- pydatastructs/linear_data_structures/arrays.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/pydatastructs/linear_data_structures/arrays.py b/pydatastructs/linear_data_structures/arrays.py index 58d82d809..32fa0ee42 100644 --- a/pydatastructs/linear_data_structures/arrays.py +++ b/pydatastructs/linear_data_structures/arrays.py @@ -187,8 +187,8 @@ def __new__(cls, dtype: type = NoneType, *args, **kwargs): if dtype is NoneType: raise ValueError("Data type is not defined.") elif not args: - raise ValueError("Too few arguments to create a multi dimensional array," - " pass dimensions.") + raise ValueError("Too few arguments to create a " + "multi dimensional array, pass dimensions.") if len(args) == 1: obj = Array.__new__(cls) obj._dtype = dtype @@ -199,8 +199,7 @@ def __new__(cls, dtype: type = NoneType, *args, **kwargs): dimensions = args for dimension in dimensions: if dimension < 1: - raise ValueError("Number of dimensions" - " cannot be less than 1") + raise ValueError("Size of dimension cannot be less than 1") n_dimensions = len(dimensions) d_sizes = [] index = 0 From 89c51fe4a04c51f89144dc23c95a495ce2a81481 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sun, 17 Oct 2021 21:01:11 +0530 Subject: [PATCH 02/11] Documentation framework ready --- README.md | 4 +- docs/Makefile | 20 ++++++ docs/make.bat | 35 +++++++++++ docs/source/conf.py | 62 +++++++++++++++++++ docs/source/index.rst | 33 ++++++++++ .../linear_data_structures/arrays.rst | 8 +++ .../linear_data_structures.rst | 7 +++ docs/source/pydatastructs/pydatastructs.rst | 9 +++ 8 files changed, 176 insertions(+), 2 deletions(-) create mode 100644 docs/Makefile create mode 100644 docs/make.bat create mode 100644 docs/source/conf.py create mode 100644 docs/source/index.rst create mode 100644 docs/source/pydatastructs/linear_data_structures/arrays.rst create mode 100644 docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst create mode 100644 docs/source/pydatastructs/pydatastructs.rst diff --git a/README.md b/README.md index b6a7c5731..e18ea92c7 100644 --- a/README.md +++ b/README.md @@ -6,9 +6,9 @@ PyDataStructs About ----- -This project aims to be a Python package for various data structures in computer science. We are also working on the development of various algorithms including parallel algorithms. To the best of our knowledge, a well-designed library/package which has covered most of the data structures and algorithms including their parallel implementation doesn't exist. +This project aims to be a Python package for various data structures in computer science. We are also working on the development of algorithms including their parallel implementations. To the best of our knowledge, a well-designed library/package which has covered most of the data structures and algorithms including their parallel implementation doesn't exist yet. - Once the software design becomes more stable after a few releases of this package in the near future, we also aim to provide APIs for the code in C++ and Java as well. +Once the software design becomes more stable after a few releases of this package in the near future, we also aim to provide APIs for the code in C++ and Java as well. Installation ------------ diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 000000000..d0c3cbf10 --- /dev/null +++ b/docs/Makefile @@ -0,0 +1,20 @@ +# Minimal makefile for Sphinx documentation +# + +# You can set these variables from the command line, and also +# from the environment for the first two. +SPHINXOPTS ?= +SPHINXBUILD ?= sphinx-build +SOURCEDIR = source +BUILDDIR = build + +# Put it first so that "make" without argument is like "make help". +help: + @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + +.PHONY: help Makefile + +# Catch-all target: route all unknown targets to Sphinx using the new +# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). +%: Makefile + @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 000000000..6fcf05b4b --- /dev/null +++ b/docs/make.bat @@ -0,0 +1,35 @@ +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.https://www.sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O% + +:end +popd diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 000000000..187d50089 --- /dev/null +++ b/docs/source/conf.py @@ -0,0 +1,62 @@ +# Configuration file for the Sphinx documentation builder. +# +# This file only contains a selection of the most common options. For a full +# list see the documentation: +# https://www.sphinx-doc.org/en/master/usage/configuration.html + +# -- Path setup -------------------------------------------------------------- + +# If extensions (or modules to document with autodoc) are in another directory, +# add these directories to sys.path here. If the directory is relative to the +# documentation root, use os.path.abspath to make it absolute, like shown here. +# +# import os +# import sys +# sys.path.insert(0, os.path.abspath('.')) + + +# -- Project information ----------------------------------------------------- + +project = 'PyDataStructs' +copyright = '2021, PyDataStructs Development Team' +author = 'PyDataStructs Development Team' + +# The full version, including alpha/beta/rc tags +release = '0.0.1' + + +# -- General configuration --------------------------------------------------- + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.napoleon' +] + +napoleon_numpy_docstring = True + +# Add any paths that contain templates here, relative to this directory. +templates_path = ['_templates'] + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +# This pattern also affects html_static_path and html_extra_path. +exclude_patterns = [] + + +# -- Options for HTML output ------------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +import sphinx_readable_theme + +html_theme = 'readable' +html_theme_path = [sphinx_readable_theme.get_html_theme_path()] + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +html_static_path = ['_static'] \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 000000000..71a19ccba --- /dev/null +++ b/docs/source/index.rst @@ -0,0 +1,33 @@ +.. PyDataStructs documentation master file, created by + sphinx-quickstart on Sun Oct 17 19:57:08 2021. + You can adapt this file completely to your liking, but it should at least + contain the root `toctree` directive. + +Welcome to PyDataStructs's documentation! +========================================= + +This project aims to be a Python package for various data +structures in computer science. We are also working on the +development of algorithms including their parallel implementations. +To the best of our knowledge, a well-designed library/package which +has covered most of the data structures and algorithms doesn't exist yet. + +Once the software design becomes more stable after a few releases of +this package in the near future, we also aim to provide APIs for the +code in C++ and Java as well. + +.. note:: + + This project is under active development and contributions are welcome. + +Contents +======== + +.. toctree:: + :maxdepth: 2 + + pydatastructs/pydatastructs.rst + + + + diff --git a/docs/source/pydatastructs/linear_data_structures/arrays.rst b/docs/source/pydatastructs/linear_data_structures/arrays.rst new file mode 100644 index 000000000..f44a4003c --- /dev/null +++ b/docs/source/pydatastructs/linear_data_structures/arrays.rst @@ -0,0 +1,8 @@ +Arrays +====== + +.. autoclass:: pydatastructs.OneDimensionalArray + +.. autoclass:: pydatastructs.MultiDimensionalArray + +.. autoclass:: pydatastructs.DynamicOneDimensionalArray \ No newline at end of file diff --git a/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst new file mode 100644 index 000000000..3bd0952ff --- /dev/null +++ b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst @@ -0,0 +1,7 @@ +Linear Data Structures +====================== + +.. toctree:: + :maxdepth: 2 + + arrays.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/pydatastructs.rst b/docs/source/pydatastructs/pydatastructs.rst new file mode 100644 index 000000000..a07d785f3 --- /dev/null +++ b/docs/source/pydatastructs/pydatastructs.rst @@ -0,0 +1,9 @@ +Modules +======= + +.. automodule:: pydatastructs + +.. toctree:: + :maxdepth: 2 + + linear_data_structures/linear_data_structures.rst \ No newline at end of file From 517fa67914b5ceb81f3dcd4915d4ccf407f2cde1 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sun, 17 Oct 2021 21:03:23 +0530 Subject: [PATCH 03/11] Updated CI --- .travis.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index a3f9c5f76..34ff494f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,12 +3,14 @@ sudo: false language: python python: - - "3.6" + - "3.8" install: - pip install -r requirements.txt + - pip install sphinx==4.2.0 script: - python -m pytest --doctest-modules --cov=./ --cov-report=xml -s after_success: - codecov + - sphinx-build -b html docs/source/ docs/build/html From e900c68f460599f36d4a6ea5b84d5f85726181b9 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Sun, 17 Oct 2021 21:16:03 +0530 Subject: [PATCH 04/11] Fixed CI and completed linear_data_structures --- .travis.yml | 1 + docs/source/conf.py | 6 ++-- .../linear_data_structures/algorithms.rst | 34 +++++++++++++++++++ .../linear_data_structures.rst | 4 ++- .../linear_data_structures/linked_lists.rst | 12 +++++++ 5 files changed, 54 insertions(+), 3 deletions(-) create mode 100644 docs/source/pydatastructs/linear_data_structures/algorithms.rst create mode 100644 docs/source/pydatastructs/linear_data_structures/linked_lists.rst diff --git a/.travis.yml b/.travis.yml index 34ff494f5..df32ed33f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,6 +7,7 @@ python: install: - pip install -r requirements.txt - pip install sphinx==4.2.0 + - pip install sphinx-readable-theme==1.3.0 script: - python -m pytest --doctest-modules --cov=./ --cov-report=xml -s diff --git a/docs/source/conf.py b/docs/source/conf.py index 187d50089..15c7066b4 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -14,6 +14,9 @@ # import sys # sys.path.insert(0, os.path.abspath('.')) +# -- Imports ---------------- + +import sphinx_readable_theme # -- Project information ----------------------------------------------------- @@ -51,9 +54,8 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. # -import sphinx_readable_theme - html_theme = 'readable' + html_theme_path = [sphinx_readable_theme.get_html_theme_path()] # Add any paths that contain custom static files (such as style sheets) here, diff --git a/docs/source/pydatastructs/linear_data_structures/algorithms.rst b/docs/source/pydatastructs/linear_data_structures/algorithms.rst new file mode 100644 index 000000000..994bf980a --- /dev/null +++ b/docs/source/pydatastructs/linear_data_structures/algorithms.rst @@ -0,0 +1,34 @@ +Algorithms +========== + +.. autofunction:: pydatastructs.merge_sort_parallel + +.. autofunction:: pydatastructs.brick_sort + +.. autofunction:: pydatastructs.brick_sort_parallel + +.. autofunction:: pydatastructs.heapsort + +.. autofunction:: pydatastructs.matrix_multiply_parallel + +.. autofunction:: pydatastructs.counting_sort + +.. autofunction:: pydatastructs.bucket_sort + +.. autofunction:: pydatastructs.cocktail_shaker_sort + +.. autofunction:: pydatastructs.quick_sort + +.. autofunction:: pydatastructs.longest_common_subsequence + +.. autofunction:: pydatastructs.is_ordered + +.. autofunction:: pydatastructs.upper_bound + +.. autofunction:: pydatastructs.lower_bound + +.. autofunction:: pydatastructs.longest_increasing_subsequence + +.. autofunction:: pydatastructs.next_permutation + +.. autofunction:: pydatastructs.prev_permutation \ No newline at end of file diff --git a/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst index 3bd0952ff..3353eb4ab 100644 --- a/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst +++ b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst @@ -4,4 +4,6 @@ Linear Data Structures .. toctree:: :maxdepth: 2 - arrays.rst \ No newline at end of file + arrays.rst + linked_lists.rst + algorithms.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/linear_data_structures/linked_lists.rst b/docs/source/pydatastructs/linear_data_structures/linked_lists.rst new file mode 100644 index 000000000..18fe8e6fa --- /dev/null +++ b/docs/source/pydatastructs/linear_data_structures/linked_lists.rst @@ -0,0 +1,12 @@ +Linked Lists +============ + +.. autoclass:: pydatastructs.SinglyLinkedList + +.. autoclass:: pydatastructs.DoublyLinkedList + +.. autoclass:: pydatastructs.SinglyCircularLinkedList + +.. autoclass:: pydatastructs.DoublyCircularLinkedList + +.. autoclass:: pydatastructs.SkipList \ No newline at end of file From b0a33a15f37e242089e08b2252cbf33419c9184d Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 12:33:29 +0530 Subject: [PATCH 05/11] improved docs --- docs/source/conf.py | 12 ++++++++++-- docs/source/index.rst | 2 +- .../linear_data_structures.rst | 2 +- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 15c7066b4..0ca99ed03 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -41,7 +41,7 @@ napoleon_numpy_docstring = True # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = [] # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. @@ -61,4 +61,12 @@ # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, # so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ['_static'] \ No newline at end of file +html_static_path = [] + +autodoc_default_options = { + 'member-order': 'bysource', + 'members': True, + 'undoc-members': True, + 'special-members': True, + 'exclude-members': '__new__, methods, __slots__' +} \ No newline at end of file diff --git a/docs/source/index.rst b/docs/source/index.rst index 71a19ccba..d9d319495 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -24,7 +24,7 @@ Contents ======== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 pydatastructs/pydatastructs.rst diff --git a/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst index 3353eb4ab..b173ff714 100644 --- a/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst +++ b/docs/source/pydatastructs/linear_data_structures/linear_data_structures.rst @@ -2,7 +2,7 @@ Linear Data Structures ====================== .. toctree:: - :maxdepth: 2 + :maxdepth: 1 arrays.rst linked_lists.rst From c0543883293bd44c479bd7a11cf782deaca80d31 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 12:39:41 +0530 Subject: [PATCH 06/11] ignore, __weakref__, __dict__ --- docs/source/conf.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/source/conf.py b/docs/source/conf.py index 0ca99ed03..a0349d95b 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -68,5 +68,5 @@ 'members': True, 'undoc-members': True, 'special-members': True, - 'exclude-members': '__new__, methods, __slots__' + 'exclude-members': '__new__, methods, __slots__, __dict__, __weakref__' } \ No newline at end of file From aa3ecec4b1aee29311f44049c6489c8c44061936 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 12:56:05 +0530 Subject: [PATCH 07/11] Added doc for graphs --- .../pydatastructs/graphs/algorithms.rst | 22 +++++++++++++++++++ docs/source/pydatastructs/graphs/graph.rst | 4 ++++ docs/source/pydatastructs/graphs/graphs.rst | 8 +++++++ docs/source/pydatastructs/pydatastructs.rst | 3 ++- pydatastructs/graphs/algorithms.py | 19 +++++++++++----- pydatastructs/graphs/graph.py | 8 ++++++- 6 files changed, 56 insertions(+), 8 deletions(-) create mode 100644 docs/source/pydatastructs/graphs/algorithms.rst create mode 100644 docs/source/pydatastructs/graphs/graph.rst create mode 100644 docs/source/pydatastructs/graphs/graphs.rst diff --git a/docs/source/pydatastructs/graphs/algorithms.rst b/docs/source/pydatastructs/graphs/algorithms.rst new file mode 100644 index 000000000..1749e3a4c --- /dev/null +++ b/docs/source/pydatastructs/graphs/algorithms.rst @@ -0,0 +1,22 @@ +Algorithms +========== + +.. autofunction:: pydatastructs.breadth_first_search + +.. autofunction:: pydatastructs.breadth_first_search_parallel + +.. autofunction:: pydatastructs.minimum_spanning_tree + +.. autofunction:: pydatastructs.minimum_spanning_tree_parallel + +.. autofunction:: pydatastructs.strongly_connected_components + +.. autofunction:: pydatastructs.depth_first_search + +.. autofunction:: pydatastructs.shortest_paths + +.. autofunction:: pydatastructs.all_pair_shortest_paths + +.. autofunction:: pydatastructs.topological_sort + +.. autofunction:: pydatastructs.topological_sort_parallel diff --git a/docs/source/pydatastructs/graphs/graph.rst b/docs/source/pydatastructs/graphs/graph.rst new file mode 100644 index 000000000..169ca6567 --- /dev/null +++ b/docs/source/pydatastructs/graphs/graph.rst @@ -0,0 +1,4 @@ +Graph +===== + +.. autoclass:: pydatastructs.Graph \ No newline at end of file diff --git a/docs/source/pydatastructs/graphs/graphs.rst b/docs/source/pydatastructs/graphs/graphs.rst new file mode 100644 index 000000000..b1ebd9c4a --- /dev/null +++ b/docs/source/pydatastructs/graphs/graphs.rst @@ -0,0 +1,8 @@ +Graphs +====== + +.. toctree:: + :maxdepth: 1 + + graph.rst + algorithms.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/pydatastructs.rst b/docs/source/pydatastructs/pydatastructs.rst index a07d785f3..09320793f 100644 --- a/docs/source/pydatastructs/pydatastructs.rst +++ b/docs/source/pydatastructs/pydatastructs.rst @@ -6,4 +6,5 @@ Modules .. toctree:: :maxdepth: 2 - linear_data_structures/linear_data_structures.rst \ No newline at end of file + linear_data_structures/linear_data_structures.rst + graphs/graphs.rst \ No newline at end of file diff --git a/pydatastructs/graphs/algorithms.py b/pydatastructs/graphs/algorithms.py index cfb2b3330..4997245ac 100644 --- a/pydatastructs/graphs/algorithms.py +++ b/pydatastructs/graphs/algorithms.py @@ -272,8 +272,9 @@ def minimum_spanning_tree(graph, algorithm): computing a minimum spanning tree. Currently the following algorithms are supported, - 'kruskal' -> Kruskal's algorithm as given in - [1]. + + 'kruskal' -> Kruskal's algorithm as given in [1]. + 'prim' -> Prim's algorithm as given in [2]. Returns @@ -405,8 +406,9 @@ def minimum_spanning_tree_parallel(graph, algorithm, num_threads): computing a minimum spanning tree. Currently the following algorithms are supported, - 'kruskal' -> Kruskal's algorithm as given in - [1]. + + 'kruskal' -> Kruskal's algorithm as given in [1]. + 'prim' -> Prim's algorithm as given in [2]. num_threads: int The number of threads to be used. @@ -519,8 +521,8 @@ def strongly_connected_components(graph, algorithm): computing strongly connected components. Currently the following algorithms are supported, - 'kosaraju' -> Kosaraju's algorithm as given in - [1]. + + 'kosaraju' -> Kosaraju's algorithm as given in [1]. Returns ======= @@ -656,7 +658,9 @@ def shortest_paths(graph: Graph, algorithm: str, algorithm: str The algorithm to be used. Currently, the following algorithms are implemented, + 'bellman_ford' -> Bellman-Ford algorithm as given in [1]. + 'dijkstra' -> Dijkstra algorithm as given in [2]. source: str The name of the source the node. @@ -775,6 +779,7 @@ def all_pair_shortest_paths(graph: Graph, algorithm: str) -> tuple: algorithm: str The algorithm to be used. Currently, the following algorithms are implemented, + 'floyd_warshall' -> Floyd Warshall algorithm as given in [1]. Returns @@ -856,6 +861,7 @@ def topological_sort(graph: Graph, algorithm: str) -> list: algorithm: str The algorithm to be used. Currently, following are supported, + 'kahn' -> Kahn's algorithm as given in [1]. Returns @@ -927,6 +933,7 @@ def topological_sort_parallel(graph: Graph, algorithm: str, num_threads: int) -> algorithm: str The algorithm to be used. Currently, following are supported, + 'kahn' -> Kahn's algorithm as given in [1]. num_threads: int The maximum number of threads to be used. diff --git a/pydatastructs/graphs/graph.py b/pydatastructs/graphs/graph.py index 80f884bee..f19fc8e97 100644 --- a/pydatastructs/graphs/graph.py +++ b/pydatastructs/graphs/graph.py @@ -14,8 +14,14 @@ class Graph(object): The implementation to be used for storing graph in memory. It can be figured out from type of the vertices(if passed at construction). + Currently the following implementations are supported, + + 'adjacency_list' -> Adjacency list implementation. + + 'adjacency_matrix' -> Adjacency matrix implementation. + By default, 'adjacency_list'. - vertices: AdjacencyListGraphNode(s) + vertices: GraphNode(s) For AdjacencyList implementation vertices can be passed for initializing the graph. From 072d0b79027427a0740ac70f70a8f76b9f0e87aa Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 13:06:55 +0530 Subject: [PATCH 08/11] Added doc for strings --- docs/source/index.rst | 4 ---- docs/source/pydatastructs/pydatastructs.rst | 5 +++-- docs/source/pydatastructs/strings/algorithms.rst | 4 ++++ docs/source/pydatastructs/strings/strings.rst | 8 ++++++++ docs/source/pydatastructs/strings/trie.rst | 4 ++++ pydatastructs/strings/algorithms.py | 4 +++- 6 files changed, 22 insertions(+), 7 deletions(-) create mode 100644 docs/source/pydatastructs/strings/algorithms.rst create mode 100644 docs/source/pydatastructs/strings/strings.rst create mode 100644 docs/source/pydatastructs/strings/trie.rst diff --git a/docs/source/index.rst b/docs/source/index.rst index d9d319495..b1a53eb1b 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -27,7 +27,3 @@ Contents :maxdepth: 1 pydatastructs/pydatastructs.rst - - - - diff --git a/docs/source/pydatastructs/pydatastructs.rst b/docs/source/pydatastructs/pydatastructs.rst index 09320793f..325e1be60 100644 --- a/docs/source/pydatastructs/pydatastructs.rst +++ b/docs/source/pydatastructs/pydatastructs.rst @@ -4,7 +4,8 @@ Modules .. automodule:: pydatastructs .. toctree:: - :maxdepth: 2 + :maxdepth: 1 linear_data_structures/linear_data_structures.rst - graphs/graphs.rst \ No newline at end of file + graphs/graphs.rst + strings/strings.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/strings/algorithms.rst b/docs/source/pydatastructs/strings/algorithms.rst new file mode 100644 index 000000000..aec29a31a --- /dev/null +++ b/docs/source/pydatastructs/strings/algorithms.rst @@ -0,0 +1,4 @@ +Algorithms +========== + +.. autofunction:: pydatastructs.find \ No newline at end of file diff --git a/docs/source/pydatastructs/strings/strings.rst b/docs/source/pydatastructs/strings/strings.rst new file mode 100644 index 000000000..51be4e50b --- /dev/null +++ b/docs/source/pydatastructs/strings/strings.rst @@ -0,0 +1,8 @@ +Strings +======= + +.. toctree:: + :maxdepth: 1 + + trie.rst + algorithms.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/strings/trie.rst b/docs/source/pydatastructs/strings/trie.rst new file mode 100644 index 000000000..e6dc31ea9 --- /dev/null +++ b/docs/source/pydatastructs/strings/trie.rst @@ -0,0 +1,4 @@ +Trie +==== + +.. autoclass:: pydatastructs.Trie \ No newline at end of file diff --git a/pydatastructs/strings/algorithms.py b/pydatastructs/strings/algorithms.py index 5122cf661..a982acbf0 100644 --- a/pydatastructs/strings/algorithms.py +++ b/pydatastructs/strings/algorithms.py @@ -23,7 +23,9 @@ def find(text, query, algorithm): searching. Currently the following algorithms are supported, + 'kmp' -> Knuth-Morris-Pratt as given in [1]. + 'rabin_karp' -> Rabin–Karp algorithm as given in [2]. Returns @@ -54,7 +56,7 @@ def find(text, query, algorithm): References ========== - .. [1] https://en.wikipedia.org/wiki/Knuth–Morris–Pratt_algorithm + .. [1] https://en.wikipedia.org/wiki/Knuth%E2%80%93Morris%E2%80%93Pratt_algorithm .. [2] https://en.wikipedia.org/wiki/Rabin%E2%80%93Karp_algorithm """ import pydatastructs.strings.algorithms as algorithms From 272e72afff5da455062383b4dab107ae99a12542 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 13:20:58 +0530 Subject: [PATCH 09/11] Added trees --- docs/source/pydatastructs/pydatastructs.rst | 4 +++- .../pydatastructs/trees/binary_trees.rst | 20 +++++++++++++++++++ docs/source/pydatastructs/trees/heaps.rst | 10 ++++++++++ .../pydatastructs/trees/m_ary_trees.rst | 3 +++ .../trees/space_partitioning_trees.rst | 4 ++++ docs/source/pydatastructs/trees/trees.rst | 10 ++++++++++ pydatastructs/trees/binary_trees.py | 4 ++-- 7 files changed, 52 insertions(+), 3 deletions(-) create mode 100644 docs/source/pydatastructs/trees/binary_trees.rst create mode 100644 docs/source/pydatastructs/trees/heaps.rst create mode 100644 docs/source/pydatastructs/trees/m_ary_trees.rst create mode 100644 docs/source/pydatastructs/trees/space_partitioning_trees.rst create mode 100644 docs/source/pydatastructs/trees/trees.rst diff --git a/docs/source/pydatastructs/pydatastructs.rst b/docs/source/pydatastructs/pydatastructs.rst index 325e1be60..cb33622c7 100644 --- a/docs/source/pydatastructs/pydatastructs.rst +++ b/docs/source/pydatastructs/pydatastructs.rst @@ -8,4 +8,6 @@ Modules linear_data_structures/linear_data_structures.rst graphs/graphs.rst - strings/strings.rst \ No newline at end of file + strings/strings.rst + trees/trees.rst + miscellaneous_data_structures/miscellaneous_data_structures.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/trees/binary_trees.rst b/docs/source/pydatastructs/trees/binary_trees.rst new file mode 100644 index 000000000..f24e21621 --- /dev/null +++ b/docs/source/pydatastructs/trees/binary_trees.rst @@ -0,0 +1,20 @@ +Binary Trees +============ + +.. autoclass:: pydatastructs.BinaryTree + +.. autoclass:: pydatastructs.BinarySearchTree + +.. autoclass:: pydatastructs.AVLTree + +.. autoclass:: pydatastructs.BinaryIndexedTree + +.. autoclass:: pydatastructs.CartesianTree + +.. autoclass:: pydatastructs.Treap + +.. autoclass:: pydatastructs.SplayTree + +.. autoclass:: pydatastructs.RedBlackTree + +.. autoclass:: pydatastructs.BinaryTreeTraversal diff --git a/docs/source/pydatastructs/trees/heaps.rst b/docs/source/pydatastructs/trees/heaps.rst new file mode 100644 index 000000000..b2848ad91 --- /dev/null +++ b/docs/source/pydatastructs/trees/heaps.rst @@ -0,0 +1,10 @@ +Heaps +===== + +.. autoclass:: pydatastructs.BinaryHeap + +.. autoclass:: pydatastructs.TernaryHeap + +.. autoclass:: pydatastructs.DHeap + +.. autoclass:: pydatastructs.BinomialHeap diff --git a/docs/source/pydatastructs/trees/m_ary_trees.rst b/docs/source/pydatastructs/trees/m_ary_trees.rst new file mode 100644 index 000000000..a191643f3 --- /dev/null +++ b/docs/source/pydatastructs/trees/m_ary_trees.rst @@ -0,0 +1,3 @@ +M-ary Trees +=========== + diff --git a/docs/source/pydatastructs/trees/space_partitioning_trees.rst b/docs/source/pydatastructs/trees/space_partitioning_trees.rst new file mode 100644 index 000000000..4f15692ee --- /dev/null +++ b/docs/source/pydatastructs/trees/space_partitioning_trees.rst @@ -0,0 +1,4 @@ +Space Partitioning Trees +======================== + +.. autoclass:: pydatastructs.OneDimensionalSegmentTree \ No newline at end of file diff --git a/docs/source/pydatastructs/trees/trees.rst b/docs/source/pydatastructs/trees/trees.rst new file mode 100644 index 000000000..0b92bdd56 --- /dev/null +++ b/docs/source/pydatastructs/trees/trees.rst @@ -0,0 +1,10 @@ +Trees +===== + +.. toctree:: + :maxdepth: 1 + + binary_trees.rst + heaps.rst + m_ary_trees.rst + space_partitioning_trees.rst \ No newline at end of file diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index 089d4c0a4..198d5ad51 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -689,7 +689,7 @@ class CartesianTree(SelfBalancingBinaryTree): See Also ======== - pydatastructs.trees.binary_tree.SelfBalancingBinaryTree + pydatastructs.trees.binary_trees.SelfBalancingBinaryTree """ @classmethod def methods(cls): @@ -1083,7 +1083,7 @@ class RedBlackTree(SelfBalancingBinaryTree): See Also ======== - pydatastructs.trees.binary_tree.SelfBalancingBinaryTree + pydatastructs.trees.binary_trees.SelfBalancingBinaryTree """ @classmethod From b29926962edf23f4192fe7fa56a49d95fed81033 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 13:28:32 +0530 Subject: [PATCH 10/11] Added misc data structure --- .../miscellaneous_data_structures/binomial_trees.rst | 4 ++++ .../miscellaneous_data_structures/disjoint_set.rst | 4 ++++ .../miscellaneous_data_structures.rst | 10 ++++++++++ .../miscellaneous_data_structures/queue.rst | 6 ++++++ .../miscellaneous_data_structures/stack.rst | 4 ++++ 5 files changed, 28 insertions(+) create mode 100644 docs/source/pydatastructs/miscellaneous_data_structures/binomial_trees.rst create mode 100644 docs/source/pydatastructs/miscellaneous_data_structures/disjoint_set.rst create mode 100644 docs/source/pydatastructs/miscellaneous_data_structures/miscellaneous_data_structures.rst create mode 100644 docs/source/pydatastructs/miscellaneous_data_structures/queue.rst create mode 100644 docs/source/pydatastructs/miscellaneous_data_structures/stack.rst diff --git a/docs/source/pydatastructs/miscellaneous_data_structures/binomial_trees.rst b/docs/source/pydatastructs/miscellaneous_data_structures/binomial_trees.rst new file mode 100644 index 000000000..902a2d084 --- /dev/null +++ b/docs/source/pydatastructs/miscellaneous_data_structures/binomial_trees.rst @@ -0,0 +1,4 @@ +Binomial Tree +============= + +.. autoclass:: pydatastructs.BinomialTree \ No newline at end of file diff --git a/docs/source/pydatastructs/miscellaneous_data_structures/disjoint_set.rst b/docs/source/pydatastructs/miscellaneous_data_structures/disjoint_set.rst new file mode 100644 index 000000000..361dd0f1c --- /dev/null +++ b/docs/source/pydatastructs/miscellaneous_data_structures/disjoint_set.rst @@ -0,0 +1,4 @@ +Disjoint Set +============ + +.. autoclass:: pydatastructs.DisjointSetForest \ No newline at end of file diff --git a/docs/source/pydatastructs/miscellaneous_data_structures/miscellaneous_data_structures.rst b/docs/source/pydatastructs/miscellaneous_data_structures/miscellaneous_data_structures.rst new file mode 100644 index 000000000..e1f6c5e85 --- /dev/null +++ b/docs/source/pydatastructs/miscellaneous_data_structures/miscellaneous_data_structures.rst @@ -0,0 +1,10 @@ +Miscellaneous Data Structures +============================= + +.. toctree:: + :maxdepth: 1 + + stack.rst + queue.rst + binomial_trees.rst + disjoint_set.rst \ No newline at end of file diff --git a/docs/source/pydatastructs/miscellaneous_data_structures/queue.rst b/docs/source/pydatastructs/miscellaneous_data_structures/queue.rst new file mode 100644 index 000000000..476e648b3 --- /dev/null +++ b/docs/source/pydatastructs/miscellaneous_data_structures/queue.rst @@ -0,0 +1,6 @@ +Queues +====== + +.. autoclass:: pydatastructs.Queue + +.. autoclass:: pydatastructs.PriorityQueue \ No newline at end of file diff --git a/docs/source/pydatastructs/miscellaneous_data_structures/stack.rst b/docs/source/pydatastructs/miscellaneous_data_structures/stack.rst new file mode 100644 index 000000000..572742056 --- /dev/null +++ b/docs/source/pydatastructs/miscellaneous_data_structures/stack.rst @@ -0,0 +1,4 @@ +Stack +===== + +.. autoclass:: pydatastructs.Stack \ No newline at end of file From 51baa9039babcc4135c61fb921ae0e4e925ab830 Mon Sep 17 00:00:00 2001 From: Gagandeep Singh Date: Mon, 18 Oct 2021 13:33:10 +0530 Subject: [PATCH 11/11] Added docs/requirements.txt --- .travis.yml | 3 +-- docs/requirements.txt | 2 ++ 2 files changed, 3 insertions(+), 2 deletions(-) create mode 100644 docs/requirements.txt diff --git a/.travis.yml b/.travis.yml index 0b58d3d74..8235d1312 100644 --- a/.travis.yml +++ b/.travis.yml @@ -6,8 +6,7 @@ python: - "3.8" install: - travis_wait 60 pip install -r requirements.txt - - pip install sphinx==4.2.0 - - pip install sphinx-readable-theme==1.3.0 + - travis_wait 60 pip install -r docs/requirements.txt script: - travis_wait 60 python -m pytest --doctest-modules --cov=./ --cov-report=xml -s diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 000000000..b3ecdb274 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,2 @@ +sphinx==4.2.0 +sphinx-readable-theme==1.3.0 \ No newline at end of file