From 46cfce4e3920ad2b5d75af41f640df6eda40343a Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Wed, 26 Jun 2019 16:38:29 +0530 Subject: [PATCH 1/3] increased coverage --- .coverage | 1 + pydatastructs/linear_data_structures/tests/test_arrays.py | 5 ++++- pydatastructs/miscellaneous_data_structures/stack.py | 2 +- .../miscellaneous_data_structures/tests/test_stack.py | 5 ++++- pydatastructs/trees/tests/test_binary_trees.py | 3 +++ pydatastructs/trees/tests/test_space_partitioning_tree.py | 3 +-- 6 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 .coverage diff --git a/.coverage b/.coverage new file mode 100644 index 000000000..ca6cb0dd8 --- /dev/null +++ b/.coverage @@ -0,0 +1 @@ +!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/__init__.py":[1,2,3,4],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/__init__.py":[1,3,7,10],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/arrays.py":[1,2,5,8,11,12,14,64,65,100,105,111,66,69,70,71,86,87,88,89,90,98,112,113,114,101,103,106,109,72,75,76,77,81,84,73,74,91,92,93,102,67,79,95,82,83,107],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/__init__.py":[1,3,4,7],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/misc_util.py":[1,4,7,8,10,25,27,29,36,30,31,32,33,34,40],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/__init__.py":[1,3,8,11,13,16],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/binary_trees.py":[1,2,5,6,7,10,35,37,39,52,57,88,89,132,175,40,41,43,44,45,46,47,48,50,107,108,109,110,111,112,113,114,117,49,118,119,120,121,122,160,161,162,163,165,166,167,173,168,169,170,202,203,205,206,216,228,231,232,233,234,235,236,237,238,245,207,208,209,164,125,126,127,128,129,130,123,53,54,172,211,212,240,243,217,218,219,220,221,222,223,224,225,204,115,116,42],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/space_partitioning_trees.py":[1,2,3,6,9,43,45,47,59,66,84,101,121,177,216,48,49,50,52,53,54,55,56,57,126,128,129,130,131,133,134,135,136,137,138,139,140,141,143,144,145,146,147,148,149,64,150,151,152,153,154,155,156,157,159,160,161,162,164,165,166,167,168,169,89,91,93,95,97,99,174,107,110,111,114,115,71,73,74,117,75,76,78,80,82,118,119,77,116,79,108,112,72,94,170,171,172,173,98,175,202,204,205,206,207,208,209,210,211,213,212,214,220,221,222,223,224,225,228,227,229,203,92,96,51],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/__init__.py":[1,3,7,10],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/stack.py":[2,3,4,7,10,11,13,57,59,69,73,77,79,96,102,110,1,60,61,62,63,64,65,80,82,84,85,86,88,91,93,94,97,99,100,114,103,105,106,107,108,98,104,81,83,87,89,90,66,67],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/tests/test_arrays.py":[1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/raises_util.py":[1,3,15,16],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/tests/test_stack.py":[1,2,3,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/test_binary_trees.py":[1,2,4,5,6,7,8,9,10,11,12,13,14,15,19,20,21,22,23,24,25,26,27,28,32,33,34],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/test_space_partitioning_tree.py":[1,2,4,5,6,7,8,9,16,17,18,19,20]}} \ No newline at end of file diff --git a/pydatastructs/linear_data_structures/tests/test_arrays.py b/pydatastructs/linear_data_structures/tests/test_arrays.py index d9799679b..fe3adf0e4 100644 --- a/pydatastructs/linear_data_structures/tests/test_arrays.py +++ b/pydatastructs/linear_data_structures/tests/test_arrays.py @@ -4,10 +4,13 @@ def test_OneDimensionalArray(): ODA = OneDimensionalArray - assert ODA(int, 5, [1, 2, 3, 4, 5], init=6) + A = ODA(int, 5, [1, 2, 3, 4, 5], init=6) + assert A assert ODA(int, (1, 2, 3, 4, 5), 5) assert ODA(int, 5) assert ODA(int, [1, 2, 3]) + raises(IndexError, lambda: A[7]) + raises(IndexError, lambda: A[-1]) raises(ValueError, lambda: ODA()) raises(ValueError, lambda: ODA(int, 1, 2, 3)) raises(TypeError, lambda: ODA(int, 5.0, set([1, 2, 3]))) diff --git a/pydatastructs/miscellaneous_data_structures/stack.py b/pydatastructs/miscellaneous_data_structures/stack.py index b840cedd4..79dba575d 100644 --- a/pydatastructs/miscellaneous_data_structures/stack.py +++ b/pydatastructs/miscellaneous_data_structures/stack.py @@ -80,7 +80,7 @@ def __new__(cls, maxsize=None, top=0, items=None, dtype=int): if not _check_type(maxsize, int): raise ValueError("maxsize is missing.") if not _check_type(top, int): - raise ValueError("top is missing.") + raise TypeError("top is not of type int.") if items == None: items = OneDimensionalArray(dtype, maxsize) if not _check_type(items, OneDimensionalArray): diff --git a/pydatastructs/miscellaneous_data_structures/tests/test_stack.py b/pydatastructs/miscellaneous_data_structures/tests/test_stack.py index ce0343d22..614b51637 100644 --- a/pydatastructs/miscellaneous_data_structures/tests/test_stack.py +++ b/pydatastructs/miscellaneous_data_structures/tests/test_stack.py @@ -17,6 +17,9 @@ def test_Stack(): assert s.top == 0 raises(ValueError, lambda: s.pop()) raises(ValueError, lambda: Stack()) + raises(TypeError, lambda: Stack(maxsize=8, top=3.5)) raises(ValueError, lambda: Stack(maxsize=5, top=0, items=[1, 2, 3])) raises(ValueError, lambda: Stack(maxsize=5, top=0, - items=OneDimensionalArray(6))) + items=OneDimensionalArray(int, 6))) + raises(NotImplementedError, lambda: Stack(implementation='', + maxsize=5, top=0)) diff --git a/pydatastructs/trees/tests/test_binary_trees.py b/pydatastructs/trees/tests/test_binary_trees.py index ca64f6c3c..8152105c3 100644 --- a/pydatastructs/trees/tests/test_binary_trees.py +++ b/pydatastructs/trees/tests/test_binary_trees.py @@ -24,8 +24,11 @@ def test_BinarySearchTree(): assert b.search(10) == None assert b.delete(3) == True assert b.search(3) == None + assert b.delete(13) == None assert str(b) == \ ("[(1, 8, 8, 7), (3, 4, 4, 4), (None, 10, 10, 7), (None, 1, 1, None), " "(None, 6, 6, 6), (None, 4, 4, None), (None, 7, 7, None), (None, 14, 14, None), " "(None, 13, 13, None)]") + bc = BST(1, 1) + assert bc.insert(1, 2) == None raises(ValueError, lambda: BST(root_data=6)) diff --git a/pydatastructs/trees/tests/test_space_partitioning_tree.py b/pydatastructs/trees/tests/test_space_partitioning_tree.py index 40263e69f..586ced204 100644 --- a/pydatastructs/trees/tests/test_space_partitioning_tree.py +++ b/pydatastructs/trees/tests/test_space_partitioning_tree.py @@ -5,8 +5,6 @@ def test_OneDimensionalSegmentTree(): ODST = OneDimensionalSegmentTree segt = ODST([(0, 5), (1, 6), (9, 13), (1, 2), (3, 8), (9, 20)]) assert segt.cache == False - segt.build() - assert segt.cache == True segt2 = ODST([(1, 4)]) assert str(segt2) == ("[(None, [False, 0, 1, False], None, None), " "(None, [True, 1, 1, True], ['(None, [True, 1, 4, True], None, None)'], " @@ -16,6 +14,7 @@ def test_OneDimensionalSegmentTree(): "None, 5), (None, [False, 4, 5, False], None, None), (-3, [False, 0, 5, " "False], None, -2)]") assert len(segt.query(1.5)) == 3 + assert segt.cache == True assert len(segt.query(-1)) == 0 assert len(segt.query(2.8)) == 2 raises(ValueError, lambda: ODST([(1, 2, 3)])) From 068fec95025e2c8353f8bd40cabdb44eb5f17c03 Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Wed, 26 Jun 2019 16:38:56 +0530 Subject: [PATCH 2/3] ignore coverage --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 2d5590d69..999995a84 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,4 @@ __pycache__/ .vscode/ .pytest_cache/ pre_commit.ps1 +.coverage From 51e4bd55b65d24d8fbbf8e570d70259ec3e3a780 Mon Sep 17 00:00:00 2001 From: czgdp1807 Date: Wed, 26 Jun 2019 16:41:39 +0530 Subject: [PATCH 3/3] removed undesired file --- .coverage | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .coverage diff --git a/.coverage b/.coverage deleted file mode 100644 index ca6cb0dd8..000000000 --- a/.coverage +++ /dev/null @@ -1 +0,0 @@ -!coverage.py: This is a private format, don't read it directly!{"lines":{"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/__init__.py":[1,2,3,4],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/__init__.py":[1,3,7,10],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/arrays.py":[1,2,5,8,11,12,14,64,65,100,105,111,66,69,70,71,86,87,88,89,90,98,112,113,114,101,103,106,109,72,75,76,77,81,84,73,74,91,92,93,102,67,79,95,82,83,107],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/__init__.py":[1,3,4,7],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/misc_util.py":[1,4,7,8,10,25,27,29,36,30,31,32,33,34,40],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/__init__.py":[1,3,8,11,13,16],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/binary_trees.py":[1,2,5,6,7,10,35,37,39,52,57,88,89,132,175,40,41,43,44,45,46,47,48,50,107,108,109,110,111,112,113,114,117,49,118,119,120,121,122,160,161,162,163,165,166,167,173,168,169,170,202,203,205,206,216,228,231,232,233,234,235,236,237,238,245,207,208,209,164,125,126,127,128,129,130,123,53,54,172,211,212,240,243,217,218,219,220,221,222,223,224,225,204,115,116,42],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/space_partitioning_trees.py":[1,2,3,6,9,43,45,47,59,66,84,101,121,177,216,48,49,50,52,53,54,55,56,57,126,128,129,130,131,133,134,135,136,137,138,139,140,141,143,144,145,146,147,148,149,64,150,151,152,153,154,155,156,157,159,160,161,162,164,165,166,167,168,169,89,91,93,95,97,99,174,107,110,111,114,115,71,73,74,117,75,76,78,80,82,118,119,77,116,79,108,112,72,94,170,171,172,173,98,175,202,204,205,206,207,208,209,210,211,213,212,214,220,221,222,223,224,225,228,227,229,203,92,96,51],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/__init__.py":[1,3,7,10],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/stack.py":[2,3,4,7,10,11,13,57,59,69,73,77,79,96,102,110,1,60,61,62,63,64,65,80,82,84,85,86,88,91,93,94,97,99,100,114,103,105,106,107,108,98,104,81,83,87,89,90,66,67],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/linear_data_structures/tests/test_arrays.py":[1,2,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/utils/raises_util.py":[1,3,15,16],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/miscellaneous_data_structures/tests/test_stack.py":[1,2,3,5,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/__init__.py":[1],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/test_binary_trees.py":[1,2,4,5,6,7,8,9,10,11,12,13,14,15,19,20,21,22,23,24,25,26,27,28,32,33,34],"/home/gagandeep/Extras/codezonediitj/pydatastructs/pydatastructs/trees/tests/test_space_partitioning_tree.py":[1,2,4,5,6,7,8,9,16,17,18,19,20]}} \ No newline at end of file