Skip to content

Commit

Permalink
#273: Remove nose dependency for graphs_trees/ (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
donnemartin committed Jul 11, 2020
1 parent 139e157 commit abf7524
Show file tree
Hide file tree
Showing 67 changed files with 863 additions and 1,030 deletions.
2 changes: 1 addition & 1 deletion graphs_trees/bst/bst.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,4 @@ def _insert(self, node, data):
node.right.parent = node
return node.right
else:
return self._insert(node.right, data)
return self._insert(node.right, data)
23 changes: 10 additions & 13 deletions graphs_trees/bst/bst_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class Node(object):\n",
Expand Down Expand Up @@ -142,18 +140,17 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_bst.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestTree(object):\n",
"class TestTree(unittest.TestCase):\n",
"\n",
" def __init__(self):\n",
" def __init__(self, *args, **kwargs):\n",
" super(TestTree, self).__init__()\n",
" self.results = Results()\n",
"\n",
" def test_tree_one(self):\n",
Expand All @@ -164,7 +161,7 @@
" bst.insert(1)\n",
" bst.insert(3)\n",
" in_order_traversal(bst.root, self.results.add_result)\n",
" assert_equal(str(self.results), '[1, 2, 3, 5, 8]')\n",
" self.assertEqual(str(self.results), '[1, 2, 3, 5, 8]')\n",
" self.results.clear_results()\n",
"\n",
" def test_tree_two(self):\n",
Expand All @@ -175,7 +172,7 @@
" bst.insert(4)\n",
" bst.insert(5)\n",
" in_order_traversal(bst.root, self.results.add_result)\n",
" assert_equal(str(self.results), '[1, 2, 3, 4, 5]')\n",
" self.assertEqual(str(self.results), '[1, 2, 3, 4, 5]')\n",
"\n",
" print('Success: test_tree')\n",
"\n",
Expand Down Expand Up @@ -216,9 +213,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
39 changes: 14 additions & 25 deletions graphs_trees/bst/bst_solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,7 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -161,9 +159,7 @@
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run bst.py"
Expand All @@ -179,9 +175,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run dfs.py"
Expand All @@ -190,9 +184,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"%run ../utils/results.py"
Expand All @@ -201,9 +193,7 @@
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -215,12 +205,13 @@
],
"source": [
"%%writefile test_bst.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"class TestTree(object):\n",
"class TestTree(unittest.TestCase):\n",
"\n",
" def __init__(self):\n",
" def __init__(self, *args, **kwargs):\n",
" super(TestTree, self).__init__()\n",
" self.results = Results()\n",
"\n",
" def test_tree_one(self):\n",
Expand All @@ -231,7 +222,7 @@
" bst.insert(1)\n",
" bst.insert(3)\n",
" in_order_traversal(bst.root, self.results.add_result)\n",
" assert_equal(str(self.results), '[1, 2, 3, 5, 8]')\n",
" self.assertEqual(str(self.results), '[1, 2, 3, 5, 8]')\n",
" self.results.clear_results()\n",
"\n",
" def test_tree_two(self):\n",
Expand All @@ -242,7 +233,7 @@
" bst.insert(4)\n",
" bst.insert(5)\n",
" in_order_traversal(bst.root, self.results.add_result)\n",
" assert_equal(str(self.results), '[1, 2, 3, 4, 5]')\n",
" self.assertEqual(str(self.results), '[1, 2, 3, 4, 5]')\n",
"\n",
" print('Success: test_tree')\n",
"\n",
Expand All @@ -260,9 +251,7 @@
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -293,9 +282,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.4.3"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
13 changes: 7 additions & 6 deletions graphs_trees/bst/test_bst.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from nose.tools import assert_equal
import unittest


class TestTree(object):
class TestTree(unittest.TestCase):

def __init__(self):
def __init__(self, *args, **kwargs):
super(TestTree, self).__init__()
self.results = Results()

def test_tree_one(self):
Expand All @@ -14,7 +15,7 @@ def test_tree_one(self):
bst.insert(1)
bst.insert(3)
in_order_traversal(bst.root, self.results.add_result)
assert_equal(str(self.results), '[1, 2, 3, 5, 8]')
self.assertEqual(str(self.results), '[1, 2, 3, 5, 8]')
self.results.clear_results()

def test_tree_two(self):
Expand All @@ -25,7 +26,7 @@ def test_tree_two(self):
bst.insert(4)
bst.insert(5)
in_order_traversal(bst.root, self.results.add_result)
assert_equal(str(self.results), '[1, 2, 3, 4, 5]')
self.assertEqual(str(self.results), '[1, 2, 3, 4, 5]')

print('Success: test_tree')

Expand All @@ -37,4 +38,4 @@ def main():


if __name__ == '__main__':
main()
main()
20 changes: 8 additions & 12 deletions graphs_trees/bst_min/bst_min_challenge.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -85,9 +85,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"class MinBst(object):\n",
Expand All @@ -113,13 +111,11 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [],
"source": [
"# %load test_bst_min.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"def height(node):\n",
Expand All @@ -129,18 +125,18 @@
" height(node.right))\n",
"\n",
"\n",
"class TestBstMin(object):\n",
"class TestBstMin(unittest.TestCase):\n",
"\n",
" def test_bst_min(self):\n",
" min_bst = MinBst()\n",
" array = [0, 1, 2, 3, 4, 5, 6]\n",
" root = min_bst.create_min_bst(array)\n",
" assert_equal(height(root), 3)\n",
" self.assertEqual(height(root), 3)\n",
"\n",
" min_bst = MinBst()\n",
" array = [0, 1, 2, 3, 4, 5, 6, 7]\n",
" root = min_bst.create_min_bst(array)\n",
" assert_equal(height(root), 4)\n",
" self.assertEqual(height(root), 4)\n",
"\n",
" print('Success: test_bst_min')\n",
"\n",
Expand Down Expand Up @@ -180,9 +176,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}
30 changes: 11 additions & 19 deletions graphs_trees/bst_min/bst_min_solution.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,16 @@
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"metadata": {},
"outputs": [],
"source": [
"%run ../bst/bst.py"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"from __future__ import division\n",
Expand Down Expand Up @@ -129,9 +125,7 @@
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand All @@ -143,7 +137,7 @@
],
"source": [
"%%writefile test_bst_min.py\n",
"from nose.tools import assert_equal\n",
"import unittest\n",
"\n",
"\n",
"def height(node):\n",
Expand All @@ -153,18 +147,18 @@
" height(node.right))\n",
"\n",
"\n",
"class TestBstMin(object):\n",
"class TestBstMin(unittest.TestCase):\n",
"\n",
" def test_bst_min(self):\n",
" min_bst = MinBst()\n",
" array = [0, 1, 2, 3, 4, 5, 6]\n",
" root = min_bst.create_min_bst(array)\n",
" assert_equal(height(root), 3)\n",
" self.assertEqual(height(root), 3)\n",
"\n",
" min_bst = MinBst()\n",
" array = [0, 1, 2, 3, 4, 5, 6, 7]\n",
" root = min_bst.create_min_bst(array)\n",
" assert_equal(height(root), 4)\n",
" self.assertEqual(height(root), 4)\n",
"\n",
" print('Success: test_bst_min')\n",
"\n",
Expand All @@ -181,9 +175,7 @@
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"metadata": {},
"outputs": [
{
"name": "stdout",
Expand Down Expand Up @@ -214,9 +206,9 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.5.0"
"version": "3.7.2"
}
},
"nbformat": 4,
"nbformat_minor": 0
"nbformat_minor": 1
}

0 comments on commit abf7524

Please sign in to comment.