From cde16010fe34eba8ad18e136a627b2903ae52a82 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Sun, 23 Feb 2020 19:49:56 +0530 Subject: [PATCH 01/33] improved tests --- pydatastructs/graphs/tests/test_adjacency_list.py | 1 + pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pydatastructs/graphs/tests/test_adjacency_list.py b/pydatastructs/graphs/tests/test_adjacency_list.py index 5581e1430..1234c16cd 100644 --- a/pydatastructs/graphs/tests/test_adjacency_list.py +++ b/pydatastructs/graphs/tests/test_adjacency_list.py @@ -32,3 +32,4 @@ def test_adjacency_list(): g.remove_vertex('v') assert g.is_adjacent('v_2', 'v') is False assert g.is_adjacent('v_3', 'v') is False + assert raises(NotImplementedError, lambda: AdjacencyList(implementation='')) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index b6f9c3faf..ae7168f57 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -19,3 +19,4 @@ def test_AdjacencyMatrix(): assert neighbors == [v_1] g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False + assert raises(NotImplementedError, lambda: AdjacencyMatrix(implementation='')) From 3789a662fd0fb54a194b05641eecc36427f1dc2a Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Sun, 23 Feb 2020 19:56:25 +0530 Subject: [PATCH 02/33] imported raises --- pydatastructs/graphs/tests/test_adjacency_list.py | 1 + pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 + 2 files changed, 2 insertions(+) diff --git a/pydatastructs/graphs/tests/test_adjacency_list.py b/pydatastructs/graphs/tests/test_adjacency_list.py index 1234c16cd..41a51a1e8 100644 --- a/pydatastructs/graphs/tests/test_adjacency_list.py +++ b/pydatastructs/graphs/tests/test_adjacency_list.py @@ -1,5 +1,6 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyListGraphNode +from pydatastructs.utils.raises_util import raises def test_adjacency_list(): v_1 = AdjacencyListGraphNode('v_1', 1) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index ae7168f57..888afc43b 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -1,5 +1,6 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyMatrixGraphNode +from pydatastructs.utils.raises_util import raises def test_AdjacencyMatrix(): v_0 = AdjacencyMatrixGraphNode(0, 0) From d10f50bf86ddc1f852533880b4195a3fecee3088 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Sun, 23 Feb 2020 20:02:27 +0530 Subject: [PATCH 03/33] improved raises --- pydatastructs/graphs/tests/test_adjacency_list.py | 2 +- pydatastructs/graphs/tests/test_adjacency_matrix.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pydatastructs/graphs/tests/test_adjacency_list.py b/pydatastructs/graphs/tests/test_adjacency_list.py index 41a51a1e8..98cbc34d3 100644 --- a/pydatastructs/graphs/tests/test_adjacency_list.py +++ b/pydatastructs/graphs/tests/test_adjacency_list.py @@ -33,4 +33,4 @@ def test_adjacency_list(): g.remove_vertex('v') assert g.is_adjacent('v_2', 'v') is False assert g.is_adjacent('v_3', 'v') is False - assert raises(NotImplementedError, lambda: AdjacencyList(implementation='')) + assert raises(NotImplementedError, lambda: Graph(implementation='')) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 888afc43b..515f93de0 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -20,4 +20,4 @@ def test_AdjacencyMatrix(): assert neighbors == [v_1] g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False - assert raises(NotImplementedError, lambda: AdjacencyMatrix(implementation='')) + assert raises(NotImplementedError, lambda: Graph(implementation='')) From f82517d377d3b7a8d749f1b7d913f4b6414f85c2 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Sun, 23 Feb 2020 22:08:43 +0530 Subject: [PATCH 04/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 515f93de0..34e878679 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -21,3 +21,4 @@ def test_AdjacencyMatrix(): g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False assert raises(NotImplementedError, lambda: Graph(implementation='')) + assert raises(NotImplementedError, lambda: AdjacencyMatrixGraphNode(implementation='')) From c9a5682530da7fa01d6e39f939d10726cb63b392 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 00:41:41 +0530 Subject: [PATCH 05/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/tests/test_adjacency_matrix.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 34e878679..91ae867b0 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -1,6 +1,7 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyMatrixGraphNode from pydatastructs.utils.raises_util import raises +from pydatastructs.graphs import AdjacencyMatrix def test_AdjacencyMatrix(): v_0 = AdjacencyMatrixGraphNode(0, 0) @@ -21,4 +22,4 @@ def test_AdjacencyMatrix(): g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False assert raises(NotImplementedError, lambda: Graph(implementation='')) - assert raises(NotImplementedError, lambda: AdjacencyMatrixGraphNode(implementation='')) + assert raises(NotImplementedError, lambda: AdjacencyMatrix(implementation='')) From 569daa2b43bd3ecf094fa6522033ca10913e0e13 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 00:48:31 +0530 Subject: [PATCH 06/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pydatastructs/graphs/__init__.py b/pydatastructs/graphs/__init__.py index a484339a9..181521b19 100644 --- a/pydatastructs/graphs/__init__.py +++ b/pydatastructs/graphs/__init__.py @@ -11,3 +11,9 @@ AdjacencyList ) __all__.extend(adjacency_list.__all__) + +from . import adjacency_matrix +from .adjacency_matrix import ( + AdjacencyMatrix +) +__all__.extend(adjacency_matrix.__all__) From efeaeb8320c9f3f9670373de8bef4f925058accd Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 00:58:23 +0530 Subject: [PATCH 07/33] increased coverage in adjacency_matrix.py --- pydatastructs/utils/tests/test_misc_util.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydatastructs/utils/tests/test_misc_util.py b/pydatastructs/utils/tests/test_misc_util.py index 0dc1d5610..b7b568c25 100644 --- a/pydatastructs/utils/tests/test_misc_util.py +++ b/pydatastructs/utils/tests/test_misc_util.py @@ -19,6 +19,7 @@ def test_AdjacencyListGraphNode(): def test_AdjacencyMatrixGraphNode(): g = AdjacencyMatrixGraphNode(1, 3) assert str(g) == "(1, 3)" + assert raises(NotImplementedError, lambda: AdjacencyMatrixGraphNode(implementation='')) def test_GraphEdge(): g_1 = AdjacencyListGraphNode('g_1', 1) From 268c4e0fd400a46fdc428088602101fbec114061 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 01:02:19 +0530 Subject: [PATCH 08/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 - pydatastructs/utils/tests/test_misc_util.py | 1 - 2 files changed, 2 deletions(-) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 91ae867b0..b7eb34755 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -22,4 +22,3 @@ def test_AdjacencyMatrix(): g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False assert raises(NotImplementedError, lambda: Graph(implementation='')) - assert raises(NotImplementedError, lambda: AdjacencyMatrix(implementation='')) diff --git a/pydatastructs/utils/tests/test_misc_util.py b/pydatastructs/utils/tests/test_misc_util.py index b7b568c25..0dc1d5610 100644 --- a/pydatastructs/utils/tests/test_misc_util.py +++ b/pydatastructs/utils/tests/test_misc_util.py @@ -19,7 +19,6 @@ def test_AdjacencyListGraphNode(): def test_AdjacencyMatrixGraphNode(): g = AdjacencyMatrixGraphNode(1, 3) assert str(g) == "(1, 3)" - assert raises(NotImplementedError, lambda: AdjacencyMatrixGraphNode(implementation='')) def test_GraphEdge(): g_1 = AdjacencyListGraphNode('g_1', 1) From 72e9536c285978cccee40c75a7c426e91d30f829 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 01:05:33 +0530 Subject: [PATCH 09/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pydatastructs/graphs/__init__.py b/pydatastructs/graphs/__init__.py index 181521b19..a484339a9 100644 --- a/pydatastructs/graphs/__init__.py +++ b/pydatastructs/graphs/__init__.py @@ -11,9 +11,3 @@ AdjacencyList ) __all__.extend(adjacency_list.__all__) - -from . import adjacency_matrix -from .adjacency_matrix import ( - AdjacencyMatrix -) -__all__.extend(adjacency_matrix.__all__) From 384809d82fea75ea82375aa3ea484d01ab3101b5 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 01:08:05 +0530 Subject: [PATCH 10/33] increased coverage in queue --- pydatastructs/miscellaneous_data_structures/tests/test_queue.py | 1 + 1 file changed, 1 insertion(+) diff --git a/pydatastructs/miscellaneous_data_structures/tests/test_queue.py b/pydatastructs/miscellaneous_data_structures/tests/test_queue.py index 18f8030f0..f355e28cf 100644 --- a/pydatastructs/miscellaneous_data_structures/tests/test_queue.py +++ b/pydatastructs/miscellaneous_data_structures/tests/test_queue.py @@ -18,3 +18,4 @@ def test_Queue(): q1 = Queue() raises(ValueError, lambda: q1.popleft()) + assert raises(NotImplementedError, lambda: Queue(implementation='')) From 38225002834c3435f92d21eb867865955bbb93e9 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 01:14:42 +0530 Subject: [PATCH 11/33] increased coverage in adjacency_matrix.py --- pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 - 1 file changed, 1 deletion(-) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index b7eb34755..515f93de0 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -1,7 +1,6 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyMatrixGraphNode from pydatastructs.utils.raises_util import raises -from pydatastructs.graphs import AdjacencyMatrix def test_AdjacencyMatrix(): v_0 = AdjacencyMatrixGraphNode(0, 0) From 526c45de365a29f55f3ddfddfa7c6e1022a7279e Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 01:34:07 +0530 Subject: [PATCH 12/33] removed adjacencylist from global namespace --- pydatastructs/graphs/__init__.py | 6 ------ 1 file changed, 6 deletions(-) diff --git a/pydatastructs/graphs/__init__.py b/pydatastructs/graphs/__init__.py index a484339a9..423345946 100644 --- a/pydatastructs/graphs/__init__.py +++ b/pydatastructs/graphs/__init__.py @@ -5,9 +5,3 @@ Graph ) __all__.extend(graph.__all__) - -from . import adjacency_list -from .adjacency_list import ( - AdjacencyList -) -__all__.extend(adjacency_list.__all__) From 5aae92b8779df4aab615791b8339e7bf18d8754f Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:09:10 +0530 Subject: [PATCH 13/33] improved coverage in heaps.py --- pydatastructs/trees/heaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydatastructs/trees/heaps.py b/pydatastructs/trees/heaps.py index 66f7f4b7b..a90f031b3 100644 --- a/pydatastructs/trees/heaps.py +++ b/pydatastructs/trees/heaps.py @@ -77,7 +77,7 @@ def __new__(cls, elements=None, heap_property="min"): elif heap_property == "max": obj._comp = lambda key_parent, key_child: key_parent >= key_child else: - raise ValueError("%s is invalid heap property"%(heap_property)) + raise TypeError("%s is invalid heap property"%(heap_property)) if elements is None: elements = [] obj.heap = elements From 9887a249f1f5ea206590fca48a8ee15a32004f74 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:12:01 +0530 Subject: [PATCH 14/33] improved coverage in heaps.py --- pydatastructs/trees/heaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydatastructs/trees/heaps.py b/pydatastructs/trees/heaps.py index a90f031b3..05ec48013 100644 --- a/pydatastructs/trees/heaps.py +++ b/pydatastructs/trees/heaps.py @@ -77,7 +77,7 @@ def __new__(cls, elements=None, heap_property="min"): elif heap_property == "max": obj._comp = lambda key_parent, key_child: key_parent >= key_child else: - raise TypeError("%s is invalid heap property"%(heap_property)) + raise TypeError("invalid heap property") if elements is None: elements = [] obj.heap = elements From 92c82ecfc8d022fd2ab25b3bd65ee765771de354 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:22:18 +0530 Subject: [PATCH 15/33] reverted code in heaps.py --- pydatastructs/trees/heaps.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydatastructs/trees/heaps.py b/pydatastructs/trees/heaps.py index 05ec48013..66f7f4b7b 100644 --- a/pydatastructs/trees/heaps.py +++ b/pydatastructs/trees/heaps.py @@ -77,7 +77,7 @@ def __new__(cls, elements=None, heap_property="min"): elif heap_property == "max": obj._comp = lambda key_parent, key_child: key_parent >= key_child else: - raise TypeError("invalid heap property") + raise ValueError("%s is invalid heap property"%(heap_property)) if elements is None: elements = [] obj.heap = elements From 22b566cbc4313a33055abd75e4e7feaf397fd235 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:49:21 +0530 Subject: [PATCH 16/33] improved coverage in binary trees --- pydatastructs/trees/tests/test_binary_trees.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index 15bb2f79a..4393be539 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -55,6 +55,7 @@ def test_BinarySearchTree(): assert b.delete(-3) is True assert b.delete(-13) is None raises(ValueError, lambda: BST(root_data=6)) + assert raises(NotImplementedError, lambda: BinarySearchTree(implementation='')) def test_BinaryTreeTraversal(): BST = BinarySearchTree @@ -99,6 +100,7 @@ def test_BinaryTreeTraversal(): assert raises(NotImplementedError, lambda: trav.breadth_first_search(strategy='iddfs')) assert raises(NotImplementedError, lambda: trav.depth_first_search(order='in_out_order')) assert raises(TypeError, lambda: BTT(1)) + assert raises(NotImplementedError, lambda: BinaryTreeTraversal(implementation='')) def test_AVLTree(): a = AVLTree('M', 'M') @@ -274,3 +276,4 @@ def test_select_rank(expected_output): test_select_rank([2]) a5.delete(2) test_select_rank([]) + assert raises(NotImplementedError, lambda: AVLTree(implementation='')) From 9f2612a4e3d02453aa1dd6d2d646c3e858a19bd0 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:53:29 +0530 Subject: [PATCH 17/33] improved coverage in binary trees --- pydatastructs/trees/tests/test_binary_trees.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index 4393be539..68a661f57 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -55,7 +55,7 @@ def test_BinarySearchTree(): assert b.delete(-3) is True assert b.delete(-13) is None raises(ValueError, lambda: BST(root_data=6)) - assert raises(NotImplementedError, lambda: BinarySearchTree(implementation='')) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) def test_BinaryTreeTraversal(): BST = BinarySearchTree @@ -100,7 +100,7 @@ def test_BinaryTreeTraversal(): assert raises(NotImplementedError, lambda: trav.breadth_first_search(strategy='iddfs')) assert raises(NotImplementedError, lambda: trav.depth_first_search(order='in_out_order')) assert raises(TypeError, lambda: BTT(1)) - assert raises(NotImplementedError, lambda: BinaryTreeTraversal(implementation='')) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) def test_AVLTree(): a = AVLTree('M', 'M') @@ -276,4 +276,4 @@ def test_select_rank(expected_output): test_select_rank([2]) a5.delete(2) test_select_rank([]) - assert raises(NotImplementedError, lambda: AVLTree(implementation='')) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) From 33af38f08dde5683fe366646f60882a40149021c Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 02:57:37 +0530 Subject: [PATCH 18/33] improved coverage in binary trees --- pydatastructs/trees/tests/test_binary_trees.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index 68a661f57..90d6d4fe4 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -1,6 +1,6 @@ from pydatastructs.trees.binary_trees import ( BinarySearchTree, BinaryTreeTraversal, AVLTree, - ArrayForTrees) + ArrayForTrees, BinaryTree) from pydatastructs.utils.raises_util import raises from pydatastructs.utils.misc_util import TreeNode from copy import deepcopy From 25dba7c37cfb376a3cdd3a1164c7e9564e209c42 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:00:45 +0530 Subject: [PATCH 19/33] improved coverage in binary trees --- pydatastructs/trees/tests/test_binary_trees.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index 90d6d4fe4..fc59ec89a 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -1,6 +1,6 @@ from pydatastructs.trees.binary_trees import ( BinarySearchTree, BinaryTreeTraversal, AVLTree, - ArrayForTrees, BinaryTree) + ArrayForTrees) from pydatastructs.utils.raises_util import raises from pydatastructs.utils.misc_util import TreeNode from copy import deepcopy @@ -55,7 +55,7 @@ def test_BinarySearchTree(): assert b.delete(-3) is True assert b.delete(-13) is None raises(ValueError, lambda: BST(root_data=6)) - assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) + assert raises(NotImplementedError, lambda: binary_trees(implementation='')) def test_BinaryTreeTraversal(): BST = BinarySearchTree @@ -100,7 +100,7 @@ def test_BinaryTreeTraversal(): assert raises(NotImplementedError, lambda: trav.breadth_first_search(strategy='iddfs')) assert raises(NotImplementedError, lambda: trav.depth_first_search(order='in_out_order')) assert raises(TypeError, lambda: BTT(1)) - assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) + assert raises(NotImplementedError, lambda: binary_trees(implementation='')) def test_AVLTree(): a = AVLTree('M', 'M') @@ -276,4 +276,4 @@ def test_select_rank(expected_output): test_select_rank([2]) a5.delete(2) test_select_rank([]) - assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) + assert raises(NotImplementedError, lambda: binary_trees(implementation='')) From 170f71a25d54480bfbbcf799edb09394c406e833 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:08:55 +0530 Subject: [PATCH 20/33] improved coverage in binary trees --- pydatastructs/trees/binary_trees.py | 3 +-- pydatastructs/trees/tests/test_binary_trees.py | 3 --- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index 91fb96528..575aceecc 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -374,8 +374,7 @@ def select(self, i): left_walk = self.tree[walk].left right_walk = self.tree[walk].right if left_walk is None and right_walk is None: - raise IndexError("The traversal is terminated " - "due to no child nodes ahead.") + raise IndexError("The traversal is terminated due to no child nodes ahead.") if i < l: if left_walk is not None and \ self.comparator(self.tree[left_walk].key, diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index fc59ec89a..15bb2f79a 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -55,7 +55,6 @@ def test_BinarySearchTree(): assert b.delete(-3) is True assert b.delete(-13) is None raises(ValueError, lambda: BST(root_data=6)) - assert raises(NotImplementedError, lambda: binary_trees(implementation='')) def test_BinaryTreeTraversal(): BST = BinarySearchTree @@ -100,7 +99,6 @@ def test_BinaryTreeTraversal(): assert raises(NotImplementedError, lambda: trav.breadth_first_search(strategy='iddfs')) assert raises(NotImplementedError, lambda: trav.depth_first_search(order='in_out_order')) assert raises(TypeError, lambda: BTT(1)) - assert raises(NotImplementedError, lambda: binary_trees(implementation='')) def test_AVLTree(): a = AVLTree('M', 'M') @@ -276,4 +274,3 @@ def test_select_rank(expected_output): test_select_rank([2]) a5.delete(2) test_select_rank([]) - assert raises(NotImplementedError, lambda: binary_trees(implementation='')) From ab076856470d03e11af3e174c5f73ecf690b7d24 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:14:23 +0530 Subject: [PATCH 21/33] improved coverage in binary trees --- pydatastructs/trees/tests/test_binary_trees.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index 15bb2f79a..90d6d4fe4 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -1,6 +1,6 @@ from pydatastructs.trees.binary_trees import ( BinarySearchTree, BinaryTreeTraversal, AVLTree, - ArrayForTrees) + ArrayForTrees, BinaryTree) from pydatastructs.utils.raises_util import raises from pydatastructs.utils.misc_util import TreeNode from copy import deepcopy @@ -55,6 +55,7 @@ def test_BinarySearchTree(): assert b.delete(-3) is True assert b.delete(-13) is None raises(ValueError, lambda: BST(root_data=6)) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) def test_BinaryTreeTraversal(): BST = BinarySearchTree @@ -99,6 +100,7 @@ def test_BinaryTreeTraversal(): assert raises(NotImplementedError, lambda: trav.breadth_first_search(strategy='iddfs')) assert raises(NotImplementedError, lambda: trav.depth_first_search(order='in_out_order')) assert raises(TypeError, lambda: BTT(1)) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) def test_AVLTree(): a = AVLTree('M', 'M') @@ -274,3 +276,4 @@ def test_select_rank(expected_output): test_select_rank([2]) a5.delete(2) test_select_rank([]) + assert raises(NotImplementedError, lambda: BinaryTree(implementation='')) From a180cb2a7c0c29eb33711307cea37d1708b2c54a Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:36:14 +0530 Subject: [PATCH 22/33] improved coverage in binary trees --- pydatastructs/trees/binary_trees.py | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index 575aceecc..d11e76143 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -47,10 +47,23 @@ class BinaryTree(object): 'is_order_statistic'] def __new__(cls, key=None, root_data=None, comp=None, - is_order_statistic=False): + is_order_statistic=False,*args, **kwargs): obj = object.__new__(cls) if key is None and root_data is not None: raise ValueError('Key required.') + implementation = kwargs.get('implementation', 'BinarySearchTree') + if implementation is 'BinarySearchTree': + from pydatastructs.trees.binary_trees import BinarySearchTree + return BinarySearchTree(*args) + elif implementation is 'BinaryTreeTraversal': + from pydatastructs.trees.binary_trees import BinaryTreeTraversal + return BinaryTreeTraversal(*args) + elif implementation is 'AVLTree': + from pydatastructs.trees.binary_trees import AVLTree + return AVLTree(*args) + else: + raise NotImplementedError("%s implementation is not a part " + "of the library currently."%(implementation)) key = None if root_data is None else key root = TreeNode(key, root_data) root.is_root = True @@ -374,7 +387,8 @@ def select(self, i): left_walk = self.tree[walk].left right_walk = self.tree[walk].right if left_walk is None and right_walk is None: - raise IndexError("The traversal is terminated due to no child nodes ahead.") + raise IndexError("The traversal is terminated " + "due to no child nodes ahead.") if i < l: if left_walk is not None and \ self.comparator(self.tree[left_walk].key, From 2491551537253714d6a34bca47e24e88d3a2ee02 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:40:53 +0530 Subject: [PATCH 23/33] improved coverage in binary trees --- pydatastructs/trees/binary_trees.py | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index d11e76143..4da2bace1 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -47,20 +47,10 @@ class BinaryTree(object): 'is_order_statistic'] def __new__(cls, key=None, root_data=None, comp=None, - is_order_statistic=False,*args, **kwargs): + is_order_statistic=False): obj = object.__new__(cls) if key is None and root_data is not None: raise ValueError('Key required.') - implementation = kwargs.get('implementation', 'BinarySearchTree') - if implementation is 'BinarySearchTree': - from pydatastructs.trees.binary_trees import BinarySearchTree - return BinarySearchTree(*args) - elif implementation is 'BinaryTreeTraversal': - from pydatastructs.trees.binary_trees import BinaryTreeTraversal - return BinaryTreeTraversal(*args) - elif implementation is 'AVLTree': - from pydatastructs.trees.binary_trees import AVLTree - return AVLTree(*args) else: raise NotImplementedError("%s implementation is not a part " "of the library currently."%(implementation)) From ba6e7d39ece163af07e6e00a0264b278e2412fba Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 03:43:01 +0530 Subject: [PATCH 24/33] improved coverage in binary trees --- pydatastructs/trees/binary_trees.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/pydatastructs/trees/binary_trees.py b/pydatastructs/trees/binary_trees.py index 4da2bace1..91fb96528 100644 --- a/pydatastructs/trees/binary_trees.py +++ b/pydatastructs/trees/binary_trees.py @@ -51,9 +51,6 @@ def __new__(cls, key=None, root_data=None, comp=None, obj = object.__new__(cls) if key is None and root_data is not None: raise ValueError('Key required.') - else: - raise NotImplementedError("%s implementation is not a part " - "of the library currently."%(implementation)) key = None if root_data is None else key root = TreeNode(key, root_data) root.is_root = True From 76b9a2a7fcdc8c1387be9421400392a203bce587 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 21:40:07 +0530 Subject: [PATCH 25/33] added .coveragerc and improved coverage --- .coveragerc | 9 +++++++++ .../graphs/tests/test_adjacency_list.py | 1 - .../graphs/tests/test_adjacency_matrix.py | 1 - pydatastructs/trees/.DS_Store | Bin 0 -> 6148 bytes pydatastructs/trees/tests/.DS_Store | Bin 0 -> 6148 bytes pydatastructs/trees/tests/test_binary_trees.py | 5 +---- 6 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .coveragerc create mode 100644 pydatastructs/trees/.DS_Store create mode 100644 pydatastructs/trees/tests/.DS_Store diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 000000000..70b46af80 --- /dev/null +++ b/.coveragerc @@ -0,0 +1,9 @@ +[report] +exclude_lines = + pragma: no cover + + raise AssertionError + raise NotImplementedError + raise IOError + raise ValueError + \ No newline at end of file diff --git a/pydatastructs/graphs/tests/test_adjacency_list.py b/pydatastructs/graphs/tests/test_adjacency_list.py index 98cbc34d3..28dabcbb5 100644 --- a/pydatastructs/graphs/tests/test_adjacency_list.py +++ b/pydatastructs/graphs/tests/test_adjacency_list.py @@ -33,4 +33,3 @@ def test_adjacency_list(): g.remove_vertex('v') assert g.is_adjacent('v_2', 'v') is False assert g.is_adjacent('v_3', 'v') is False - assert raises(NotImplementedError, lambda: Graph(implementation='')) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 515f93de0..49ca81886 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -20,4 +20,3 @@ def test_AdjacencyMatrix(): assert neighbors == [v_1] g.remove_edge(0, 1) assert g.is_adjacent(0, 1) is False - assert raises(NotImplementedError, lambda: Graph(implementation='')) diff --git a/pydatastructs/trees/.DS_Store b/pydatastructs/trees/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..eaadb8dcfd99f55bb44f569cdac1f92831b23dc0 GIT binary patch literal 6148 zcmeHKO>Wab6n@jD)TTns0;!eQc!R_uLa9ROqC&DlS#*bF1Pef^-B^t!^-#*|x$eU=>(51^C_FQSWR*87;rR)6-O*N2!dE!P~a<9m;>w=1$Z%)YR_nlDfSv{M~xCRW!3F| z6C0bYtsC2p>p0FW=XEfWlb{N#aoG=xm;CfJtVWTEpGleiio@u65>E#0+mB^dg-I3{ ziku8%q`Z2OWJ5XW%W*a=RX>4la2?lm2krgYtk*m2c)i2!yyMM|j=CN1LGR&w?mByS z4<4PKy_vq7UC!Ts!g62&o4c}IgA4eKU}=eOgCa|1c7fUjW07fb4HYndlC!ghbF)*j z3RngHtpdD1cyLDFV69PY9VpZl0N6scGQ|9`z#Pw@Z?M*g7MRdfpr#6Q#Sof~de7wf z25XI)PQqM1gc(_w8;Ve)qkm7Olkhd#(kfsTxT?UWer)sk|K#`g|EnbXWEHRq{8tKy z)=6;E$CAw1y0SPvYd!cGoQ?Bpjf#T89LFl)qj(>#3~e3m6CxVH1qbISj+pd|_iW%TLm=xI1#M}L>z3Yn(b4c9 z6_B|b>zox-QhWY(kLzlYud5spvOMnLH{WWg5nW=gmsIPF=U|qU(S~*yYYSXzpR9w< zIQ-EW=b|;vD_9vgwXUEp^Q*(WZZT`HGFpH?*V+bsl1)LC=2g7=>ev|Srvrr^0f6!wsfN1zED9%aOdT6T z^uXAtK%=rBG1%y6PdqMlYz&P~?1vBbC$pbWSf7sZ6AdR$4WkSNLV-gC&g^y~`~So5 z=l?@e+=T+6z)2~ Date: Mon, 24 Feb 2020 21:48:01 +0530 Subject: [PATCH 26/33] removed unwanted codes --- pydatastructs/graphs/tests/test_adjacency_list.py | 1 - pydatastructs/graphs/tests/test_adjacency_matrix.py | 1 - pydatastructs/miscellaneous_data_structures/tests/test_queue.py | 1 - 3 files changed, 3 deletions(-) diff --git a/pydatastructs/graphs/tests/test_adjacency_list.py b/pydatastructs/graphs/tests/test_adjacency_list.py index 28dabcbb5..5581e1430 100644 --- a/pydatastructs/graphs/tests/test_adjacency_list.py +++ b/pydatastructs/graphs/tests/test_adjacency_list.py @@ -1,6 +1,5 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyListGraphNode -from pydatastructs.utils.raises_util import raises def test_adjacency_list(): v_1 = AdjacencyListGraphNode('v_1', 1) diff --git a/pydatastructs/graphs/tests/test_adjacency_matrix.py b/pydatastructs/graphs/tests/test_adjacency_matrix.py index 49ca81886..b6f9c3faf 100644 --- a/pydatastructs/graphs/tests/test_adjacency_matrix.py +++ b/pydatastructs/graphs/tests/test_adjacency_matrix.py @@ -1,6 +1,5 @@ from pydatastructs.graphs import Graph from pydatastructs.utils import AdjacencyMatrixGraphNode -from pydatastructs.utils.raises_util import raises def test_AdjacencyMatrix(): v_0 = AdjacencyMatrixGraphNode(0, 0) diff --git a/pydatastructs/miscellaneous_data_structures/tests/test_queue.py b/pydatastructs/miscellaneous_data_structures/tests/test_queue.py index f355e28cf..18f8030f0 100644 --- a/pydatastructs/miscellaneous_data_structures/tests/test_queue.py +++ b/pydatastructs/miscellaneous_data_structures/tests/test_queue.py @@ -18,4 +18,3 @@ def test_Queue(): q1 = Queue() raises(ValueError, lambda: q1.popleft()) - assert raises(NotImplementedError, lambda: Queue(implementation='')) From f2066fa4491b4cb3156ebf2a465c83903135594f Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 21:53:16 +0530 Subject: [PATCH 27/33] removed unwanted codes --- .coveragerc | 3 --- 1 file changed, 3 deletions(-) diff --git a/.coveragerc b/.coveragerc index 70b46af80..d837cf4e0 100644 --- a/.coveragerc +++ b/.coveragerc @@ -2,8 +2,5 @@ exclude_lines = pragma: no cover - raise AssertionError raise NotImplementedError - raise IOError raise ValueError - \ No newline at end of file From 936a680201693a2a1b80a89267c267f87491fd88 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 22:35:02 +0530 Subject: [PATCH 28/33] removed unwanted codes --- .coveragerc | 1 - 1 file changed, 1 deletion(-) diff --git a/.coveragerc b/.coveragerc index d837cf4e0..36260d1a0 100644 --- a/.coveragerc +++ b/.coveragerc @@ -3,4 +3,3 @@ exclude_lines = pragma: no cover raise NotImplementedError - raise ValueError From 33e023fd514b41c3df237c9b051c1d593933f560 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Mon, 24 Feb 2020 23:10:20 +0530 Subject: [PATCH 29/33] merged coveragerc_travis in .coveragerc --- .coveragerc | 6 ++++++ coveragerc_travis | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) delete mode 100644 coveragerc_travis diff --git a/.coveragerc b/.coveragerc index 36260d1a0..07491451b 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,3 +1,9 @@ +[run] +parallel = True +source = pydatastructs +omit = + */tests/* + [report] exclude_lines = pragma: no cover diff --git a/coveragerc_travis b/coveragerc_travis deleted file mode 100644 index cdbc4d842..000000000 --- a/coveragerc_travis +++ /dev/null @@ -1,5 +0,0 @@ -[run] -parallel = True -source = pydatastructs -omit = - */tests/* From 119ffbf39ff10cd388dd693e9be9bc180ef08ddf Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Tue, 25 Feb 2020 15:08:56 +0530 Subject: [PATCH 30/33] removed unwanted files --- pydatastructs/trees/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 pydatastructs/trees/.DS_Store diff --git a/pydatastructs/trees/.DS_Store b/pydatastructs/trees/.DS_Store deleted file mode 100644 index eaadb8dcfd99f55bb44f569cdac1f92831b23dc0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO>Wab6n@jD)TTns0;!eQc!R_uLa9ROqC&DlS#*bF1Pef^-B^t!^-#*|x$eU=>(51^C_FQSWR*87;rR)6-O*N2!dE!P~a<9m;>w=1$Z%)YR_nlDfSv{M~xCRW!3F| z6C0bYtsC2p>p0FW=XEfWlb{N#aoG=xm;CfJtVWTEpGleiio@u65>E#0+mB^dg-I3{ ziku8%q`Z2OWJ5XW%W*a=RX>4la2?lm2krgYtk*m2c)i2!yyMM|j=CN1LGR&w?mByS z4<4PKy_vq7UC!Ts!g62&o4c}IgA4eKU}=eOgCa|1c7fUjW07fb4HYndlC!ghbF)*j z3RngHtpdD1cyLDFV69PY9VpZl0N6scGQ|9`z#Pw@Z?M*g7MRdfpr#6Q#Sof~de7wf z25XI)PQqM1gc(_w8;Ve)qkm7Olkhd#(kfsTxT?UWer)sk|K#`g|EnbXWEHRq{8tKy z)=6;E$CAw1y0SPvYd!cGoQ?Bpjf#T89LFl)qj(>#3~e3 Date: Tue, 25 Feb 2020 19:35:44 +0530 Subject: [PATCH 31/33] updated .gitignore --- .gitignore | 61 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 52 insertions(+), 9 deletions(-) diff --git a/.gitignore b/.gitignore index 917ba6634..8f52aaee4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,12 +1,55 @@ -*.swp +# Compiled source # +################### +*.com +*.class +*.dll +*.exe +*.o +*.so +*.gch + +# Packages # +############ +# it's better to unpack these files and commit the raw source +# git has its own built in compression methods +*.7z +*.dmg +*.gz +*.iso +*.jar +*.rar +*.tar +*.zip + +# Logs and databases # +###################### +*.log +*.sql +*.sqlite + +# OS generated files # +###################### +.DS_Store +.DS_Store? +._* +.Spotlight-V100 +.Trashes +ehthumbs.db +Thumbs.db + +# Python Files # +################ *.pyc -__pycache__/ *.pyo -*.vs -.vs/ +*~ +__pycache__/ + +# Backup Files # +################ +*.bak +*.swp + +# Editor Files # +################ .vscode/ -.pytest_cache/ -pre_commit.ps1 -htmlcov -*coverage* -*.egg-info/ +.vs/ From 65b09a2f100d5de133401084f83281e292167c3d Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Tue, 25 Feb 2020 19:47:23 +0530 Subject: [PATCH 32/33] updated .gitignore --- .gitignore | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.gitignore b/.gitignore index 8f52aaee4..52b147513 100644 --- a/.gitignore +++ b/.gitignore @@ -36,6 +36,10 @@ .Trashes ehthumbs.db Thumbs.db +pre_commit.ps1 +htmlcov +*coverage* +*.egg-info/ # Python Files # ################ @@ -43,6 +47,7 @@ Thumbs.db *.pyo *~ __pycache__/ +.pytest_cache/ # Backup Files # ################ From d2458b9ae0d8d5498ce53db3c3cd855ba71ee8e0 Mon Sep 17 00:00:00 2001 From: Rajiv Ranjan Singh Date: Tue, 25 Feb 2020 19:52:57 +0530 Subject: [PATCH 33/33] deleted unwanted files --- pydatastructs/trees/tests/.DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 pydatastructs/trees/tests/.DS_Store diff --git a/pydatastructs/trees/tests/.DS_Store b/pydatastructs/trees/tests/.DS_Store deleted file mode 100644 index 7eea70ab3f3da56d4c81c7c73e764a3991fd828a..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKyH3ME5ZnzZf+D086m+m6CxVH1qbISj+pd|_iW%TLm=xI1#M}L>z3Yn(b4c9 z6_B|b>zox-QhWY(kLzlYud5spvOMnLH{WWg5nW=gmsIPF=U|qU(S~*yYYSXzpR9w< zIQ-EW=b|;vD_9vgwXUEp^Q*(WZZT`HGFpH?*V+bsl1)LC=2g7=>ev|Srvrr^0f6!wsfN1zED9%aOdT6T z^uXAtK%=rBG1%y6PdqMlYz&P~?1vBbC$pbWSf7sZ6AdR$4WkSNLV-gC&g^y~`~So5 z=l?@e+=T+6z)2~