Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 67505c4

Browse files
authoredJul 15, 2020
#273: Remove nose dependency for math_probability/ (#281)
1 parent 76cb650 commit 67505c4

21 files changed

+212
-280
lines changed
 

‎math_probability/add_digits/add_digits_challenge.ipynb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,7 @@
7676
{
7777
"cell_type": "code",
7878
"execution_count": null,
79-
"metadata": {
80-
"collapsed": false
81-
},
79+
"metadata": {},
8280
"outputs": [],
8381
"source": [
8482
"class Solution(object):\n",
@@ -105,24 +103,22 @@
105103
{
106104
"cell_type": "code",
107105
"execution_count": null,
108-
"metadata": {
109-
"collapsed": false
110-
},
106+
"metadata": {},
111107
"outputs": [],
112108
"source": [
113109
"# %load test_add_digits.py\n",
114-
"from nose.tools import assert_equal, assert_raises\n",
110+
"import unittest\n",
115111
"\n",
116112
"\n",
117-
"class TestAddDigits(object):\n",
113+
"class TestAddDigits(unittest.TestCase):\n",
118114
"\n",
119115
" def test_add_digits(self, func):\n",
120-
" assert_raises(TypeError, func, None)\n",
121-
" assert_raises(ValueError, func, -1)\n",
122-
" assert_equal(func(0), 0)\n",
123-
" assert_equal(func(9), 9)\n",
124-
" assert_equal(func(138), 3)\n",
125-
" assert_equal(func(65536), 7) \n",
116+
" self.assertRaises(TypeError, func, None)\n",
117+
" self.assertRaises(ValueError, func, -1)\n",
118+
" self.assertEqual(func(0), 0)\n",
119+
" self.assertEqual(func(9), 9)\n",
120+
" self.assertEqual(func(138), 3)\n",
121+
" self.assertEqual(func(65536), 7) \n",
126122
" print('Success: test_add_digits')\n",
127123
"\n",
128124
"\n",
@@ -168,9 +164,9 @@
168164
"name": "python",
169165
"nbconvert_exporter": "python",
170166
"pygments_lexer": "ipython3",
171-
"version": "3.5.0"
167+
"version": "3.7.2"
172168
}
173169
},
174170
"nbformat": 4,
175-
"nbformat_minor": 0
171+
"nbformat_minor": 1
176172
}

‎math_probability/add_digits/add_digits_solution.ipynb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,7 @@
8989
{
9090
"cell_type": "code",
9191
"execution_count": 1,
92-
"metadata": {
93-
"collapsed": false
94-
},
92+
"metadata": {},
9593
"outputs": [],
9694
"source": [
9795
"class Solution(object):\n",
@@ -134,9 +132,7 @@
134132
{
135133
"cell_type": "code",
136134
"execution_count": 2,
137-
"metadata": {
138-
"collapsed": false
139-
},
135+
"metadata": {},
140136
"outputs": [
141137
{
142138
"name": "stdout",
@@ -148,18 +144,18 @@
148144
],
149145
"source": [
150146
"%%writefile test_add_digits.py\n",
151-
"from nose.tools import assert_equal, assert_raises\n",
147+
"import unittest\n",
152148
"\n",
153149
"\n",
154-
"class TestAddDigits(object):\n",
150+
"class TestAddDigits(unittest.TestCase):\n",
155151
"\n",
156152
" def test_add_digits(self, func):\n",
157-
" assert_raises(TypeError, func, None)\n",
158-
" assert_raises(ValueError, func, -1)\n",
159-
" assert_equal(func(0), 0)\n",
160-
" assert_equal(func(9), 9)\n",
161-
" assert_equal(func(138), 3)\n",
162-
" assert_equal(func(65536), 7) \n",
153+
" self.assertRaises(TypeError, func, None)\n",
154+
" self.assertRaises(ValueError, func, -1)\n",
155+
" self.assertEqual(func(0), 0)\n",
156+
" self.assertEqual(func(9), 9)\n",
157+
" self.assertEqual(func(138), 3)\n",
158+
" self.assertEqual(func(65536), 7) \n",
163159
" print('Success: test_add_digits')\n",
164160
"\n",
165161
"\n",
@@ -182,9 +178,7 @@
182178
{
183179
"cell_type": "code",
184180
"execution_count": 3,
185-
"metadata": {
186-
"collapsed": false
187-
},
181+
"metadata": {},
188182
"outputs": [
189183
{
190184
"name": "stdout",
@@ -216,9 +210,9 @@
216210
"name": "python",
217211
"nbconvert_exporter": "python",
218212
"pygments_lexer": "ipython3",
219-
"version": "3.4.3"
213+
"version": "3.7.2"
220214
}
221215
},
222216
"nbformat": 4,
223-
"nbformat_minor": 0
217+
"nbformat_minor": 1
224218
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestAddDigits(object):
4+
class TestAddDigits(unittest.TestCase):
55

66
def test_add_digits(self, func):
7-
assert_raises(TypeError, func, None)
8-
assert_raises(ValueError, func, -1)
9-
assert_equal(func(0), 0)
10-
assert_equal(func(9), 9)
11-
assert_equal(func(138), 3)
12-
assert_equal(func(65536), 7)
7+
self.assertRaises(TypeError, func, None)
8+
self.assertRaises(ValueError, func, -1)
9+
self.assertEqual(func(0), 0)
10+
self.assertEqual(func(9), 9)
11+
self.assertEqual(func(138), 3)
12+
self.assertEqual(func(65536), 7)
1313
print('Success: test_add_digits')
1414

1515

@@ -26,4 +26,4 @@ def main():
2626

2727

2828
if __name__ == '__main__':
29-
main()
29+
main()

‎math_probability/check_prime/check_prime_challenge.ipynb

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@
7373
{
7474
"cell_type": "code",
7575
"execution_count": null,
76-
"metadata": {
77-
"collapsed": false
78-
},
76+
"metadata": {},
7977
"outputs": [],
8078
"source": [
8179
"class Math(object):\n",
@@ -102,24 +100,22 @@
102100
{
103101
"cell_type": "code",
104102
"execution_count": null,
105-
"metadata": {
106-
"collapsed": false
107-
},
103+
"metadata": {},
108104
"outputs": [],
109105
"source": [
110106
"# %load test_check_prime.py\n",
111-
"from nose.tools import assert_equal, assert_raises\n",
107+
"import unittest\n",
112108
"\n",
113109
"\n",
114-
"class TestMath(object):\n",
110+
"class TestMath(unittest.TestCase):\n",
115111
"\n",
116112
" def test_check_prime(self):\n",
117113
" math = Math()\n",
118-
" assert_raises(TypeError, math.check_prime, None)\n",
119-
" assert_raises(TypeError, math.check_prime, 98.6)\n",
120-
" assert_equal(math.check_prime(0), False)\n",
121-
" assert_equal(math.check_prime(1), False)\n",
122-
" assert_equal(math.check_prime(97), True)\n",
114+
" self.assertRaises(TypeError, math.check_prime, None)\n",
115+
" self.assertRaises(TypeError, math.check_prime, 98.6)\n",
116+
" self.assertEqual(math.check_prime(0), False)\n",
117+
" self.assertEqual(math.check_prime(1), False)\n",
118+
" self.assertEqual(math.check_prime(97), True)\n",
123119
" print('Success: test_check_prime')\n",
124120
"\n",
125121
"\n",
@@ -158,9 +154,9 @@
158154
"name": "python",
159155
"nbconvert_exporter": "python",
160156
"pygments_lexer": "ipython3",
161-
"version": "3.5.0"
157+
"version": "3.7.2"
162158
}
163159
},
164160
"nbformat": 4,
165-
"nbformat_minor": 0
161+
"nbformat_minor": 1
166162
}

‎math_probability/check_prime/check_prime_solution.ipynb

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,7 @@
8484
{
8585
"cell_type": "code",
8686
"execution_count": 1,
87-
"metadata": {
88-
"collapsed": false
89-
},
87+
"metadata": {},
9088
"outputs": [],
9189
"source": [
9290
"import math\n",
@@ -125,9 +123,7 @@
125123
{
126124
"cell_type": "code",
127125
"execution_count": 2,
128-
"metadata": {
129-
"collapsed": false
130-
},
126+
"metadata": {},
131127
"outputs": [
132128
{
133129
"name": "stdout",
@@ -139,18 +135,18 @@
139135
],
140136
"source": [
141137
"%%writefile test_check_prime.py\n",
142-
"from nose.tools import assert_equal, assert_raises\n",
138+
"import unittest\n",
143139
"\n",
144140
"\n",
145-
"class TestMath(object):\n",
141+
"class TestMath(unittest.TestCase):\n",
146142
"\n",
147143
" def test_check_prime(self):\n",
148144
" math = Math()\n",
149-
" assert_raises(TypeError, math.check_prime, None)\n",
150-
" assert_raises(TypeError, math.check_prime, 98.6)\n",
151-
" assert_equal(math.check_prime(0), False)\n",
152-
" assert_equal(math.check_prime(1), False)\n",
153-
" assert_equal(math.check_prime(97), True)\n",
145+
" self.assertRaises(TypeError, math.check_prime, None)\n",
146+
" self.assertRaises(TypeError, math.check_prime, 98.6)\n",
147+
" self.assertEqual(math.check_prime(0), False)\n",
148+
" self.assertEqual(math.check_prime(1), False)\n",
149+
" self.assertEqual(math.check_prime(97), True)\n",
154150
" print('Success: test_check_prime')\n",
155151
"\n",
156152
"\n",
@@ -166,9 +162,7 @@
166162
{
167163
"cell_type": "code",
168164
"execution_count": 3,
169-
"metadata": {
170-
"collapsed": false
171-
},
165+
"metadata": {},
172166
"outputs": [
173167
{
174168
"name": "stdout",
@@ -199,9 +193,9 @@
199193
"name": "python",
200194
"nbconvert_exporter": "python",
201195
"pygments_lexer": "ipython3",
202-
"version": "3.5.0"
196+
"version": "3.7.2"
203197
}
204198
},
205199
"nbformat": 4,
206-
"nbformat_minor": 0
200+
"nbformat_minor": 1
207201
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestMath(object):
4+
class TestMath(unittest.TestCase):
55

66
def test_check_prime(self):
77
math = Math()
8-
assert_raises(TypeError, math.check_prime, None)
9-
assert_raises(TypeError, math.check_prime, 98.6)
10-
assert_equal(math.check_prime(0), False)
11-
assert_equal(math.check_prime(1), False)
12-
assert_equal(math.check_prime(97), True)
8+
self.assertRaises(TypeError, math.check_prime, None)
9+
self.assertRaises(TypeError, math.check_prime, 98.6)
10+
self.assertEqual(math.check_prime(0), False)
11+
self.assertEqual(math.check_prime(1), False)
12+
self.assertEqual(math.check_prime(97), True)
1313
print('Success: test_check_prime')
1414

1515

@@ -19,4 +19,4 @@ def main():
1919

2020

2121
if __name__ == '__main__':
22-
main()
22+
main()

‎math_probability/generate_primes/check_prime_challenge.ipynb

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,7 @@
7272
{
7373
"cell_type": "code",
7474
"execution_count": 3,
75-
"metadata": {
76-
"collapsed": false
77-
},
75+
"metadata": {},
7876
"outputs": [],
7977
"source": [
8078
"class PrimeGenerator(object):\n",
@@ -101,22 +99,20 @@
10199
{
102100
"cell_type": "code",
103101
"execution_count": null,
104-
"metadata": {
105-
"collapsed": false
106-
},
102+
"metadata": {},
107103
"outputs": [],
108104
"source": [
109105
"# %load test_generate_primes.py\n",
110-
"from nose.tools import assert_equal, assert_raises\n",
106+
"import unittest\n",
111107
"\n",
112108
"\n",
113-
"class TestMath(object):\n",
109+
"class TestMath(unittest.TestCase):\n",
114110
"\n",
115111
" def test_generate_primes(self):\n",
116112
" prime_generator = PrimeGenerator()\n",
117-
" assert_raises(TypeError, prime_generator.generate_primes, None)\n",
118-
" assert_raises(TypeError, prime_generator.generate_primes, 98.6)\n",
119-
" assert_equal(prime_generator.generate_primes(20), [False, False, True, \n",
113+
" self.assertRaises(TypeError, prime_generator.generate_primes, None)\n",
114+
" self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)\n",
115+
" self.assertEqual(prime_generator.generate_primes(20), [False, False, True, \n",
120116
" True, False, True, \n",
121117
" False, True, False, \n",
122118
" False, False, True, \n",
@@ -161,9 +157,9 @@
161157
"name": "python",
162158
"nbconvert_exporter": "python",
163159
"pygments_lexer": "ipython3",
164-
"version": "3.5.0"
160+
"version": "3.7.2"
165161
}
166162
},
167163
"nbformat": 4,
168-
"nbformat_minor": 0
164+
"nbformat_minor": 1
169165
}

‎math_probability/generate_primes/check_prime_solution.ipynb

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@
8888
{
8989
"cell_type": "code",
9090
"execution_count": 1,
91-
"metadata": {
92-
"collapsed": false
93-
},
91+
"metadata": {},
9492
"outputs": [],
9593
"source": [
9694
"import math\n",
@@ -134,9 +132,7 @@
134132
{
135133
"cell_type": "code",
136134
"execution_count": 2,
137-
"metadata": {
138-
"collapsed": false
139-
},
135+
"metadata": {},
140136
"outputs": [
141137
{
142138
"name": "stdout",
@@ -148,16 +144,16 @@
148144
],
149145
"source": [
150146
"%%writefile test_generate_primes.py\n",
151-
"from nose.tools import assert_equal, assert_raises\n",
147+
"import unittest\n",
152148
"\n",
153149
"\n",
154-
"class TestMath(object):\n",
150+
"class TestMath(unittest.TestCase):\n",
155151
"\n",
156152
" def test_generate_primes(self):\n",
157153
" prime_generator = PrimeGenerator()\n",
158-
" assert_raises(TypeError, prime_generator.generate_primes, None)\n",
159-
" assert_raises(TypeError, prime_generator.generate_primes, 98.6)\n",
160-
" assert_equal(prime_generator.generate_primes(20), [False, False, True, \n",
154+
" self.assertRaises(TypeError, prime_generator.generate_primes, None)\n",
155+
" self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)\n",
156+
" self.assertEqual(prime_generator.generate_primes(20), [False, False, True, \n",
161157
" True, False, True, \n",
162158
" False, True, False, \n",
163159
" False, False, True, \n",
@@ -179,9 +175,7 @@
179175
{
180176
"cell_type": "code",
181177
"execution_count": 3,
182-
"metadata": {
183-
"collapsed": false
184-
},
178+
"metadata": {},
185179
"outputs": [
186180
{
187181
"name": "stdout",
@@ -212,9 +206,9 @@
212206
"name": "python",
213207
"nbconvert_exporter": "python",
214208
"pygments_lexer": "ipython3",
215-
"version": "3.5.0"
209+
"version": "3.7.2"
216210
}
217211
},
218212
"nbformat": 4,
219-
"nbformat_minor": 0
213+
"nbformat_minor": 1
220214
}

‎math_probability/generate_primes/test_generate_primes.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestMath(object):
4+
class TestMath(unittest.TestCase):
55

66
def test_generate_primes(self):
77
prime_generator = PrimeGenerator()
8-
assert_raises(TypeError, prime_generator.generate_primes, None)
9-
assert_raises(TypeError, prime_generator.generate_primes, 98.6)
10-
assert_equal(prime_generator.generate_primes(20), [False, False, True,
8+
self.assertRaises(TypeError, prime_generator.generate_primes, None)
9+
self.assertRaises(TypeError, prime_generator.generate_primes, 98.6)
10+
self.assertEqual(prime_generator.generate_primes(20), [False, False, True,
1111
True, False, True,
1212
False, True, False,
1313
False, False, True,
@@ -23,4 +23,4 @@ def main():
2323

2424

2525
if __name__ == '__main__':
26-
main()
26+
main()

‎math_probability/math_ops/math_ops_challenge.ipynb

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@
8282
{
8383
"cell_type": "code",
8484
"execution_count": null,
85-
"metadata": {
86-
"collapsed": false
87-
},
85+
"metadata": {},
8886
"outputs": [],
8987
"source": [
9088
"class Solution(object):\n",
@@ -115,20 +113,18 @@
115113
{
116114
"cell_type": "code",
117115
"execution_count": null,
118-
"metadata": {
119-
"collapsed": false
120-
},
116+
"metadata": {},
121117
"outputs": [],
122118
"source": [
123119
"# %load test_math_ops.py\n",
124-
"from nose.tools import assert_equal, assert_true, assert_raises\n",
120+
"import unittest\n",
125121
"\n",
126122
"\n",
127-
"class TestMathOps(object):\n",
123+
"class TestMathOps(unittest.TestCase):\n",
128124
"\n",
129125
" def test_math_ops(self):\n",
130126
" solution = Solution()\n",
131-
" assert_raises(TypeError, solution.insert, None)\n",
127+
" self.assertRaises(TypeError, solution.insert, None)\n",
132128
" solution.insert(5)\n",
133129
" solution.insert(2)\n",
134130
" solution.insert(7)\n",
@@ -140,10 +136,10 @@
140136
" solution.insert(3)\n",
141137
" solution.insert(3)\n",
142138
" solution.insert(2)\n",
143-
" assert_equal(solution.max, 9)\n",
144-
" assert_equal(solution.min, 2)\n",
145-
" assert_equal(solution.mean, 5)\n",
146-
" assert_true(solution.mode in (2, 9))\n",
139+
" self.assertEqual(solution.max, 9)\n",
140+
" self.assertEqual(solution.min, 2)\n",
141+
" self.assertEqual(solution.mean, 5)\n",
142+
" self.assertTrue(solution.mode in (2, 9))\n",
147143
" print('Success: test_math_ops')\n",
148144
"\n",
149145
"\n",
@@ -182,9 +178,9 @@
182178
"name": "python",
183179
"nbconvert_exporter": "python",
184180
"pygments_lexer": "ipython3",
185-
"version": "3.5.0"
181+
"version": "3.7.2"
186182
}
187183
},
188184
"nbformat": 4,
189-
"nbformat_minor": 0
185+
"nbformat_minor": 1
190186
}

‎math_probability/math_ops/math_ops_solution.ipynb

Lines changed: 12 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@
9393
{
9494
"cell_type": "code",
9595
"execution_count": 1,
96-
"metadata": {
97-
"collapsed": false
98-
},
96+
"metadata": {},
9997
"outputs": [],
10098
"source": [
10199
"from __future__ import division\n",
@@ -143,9 +141,7 @@
143141
{
144142
"cell_type": "code",
145143
"execution_count": 2,
146-
"metadata": {
147-
"collapsed": false
148-
},
144+
"metadata": {},
149145
"outputs": [
150146
{
151147
"name": "stdout",
@@ -157,14 +153,14 @@
157153
],
158154
"source": [
159155
"%%writefile test_math_ops.py\n",
160-
"from nose.tools import assert_equal, assert_true, assert_raises\n",
156+
"import unittest\n",
161157
"\n",
162158
"\n",
163-
"class TestMathOps(object):\n",
159+
"class TestMathOps(unittest.TestCase):\n",
164160
"\n",
165161
" def test_math_ops(self):\n",
166162
" solution = Solution()\n",
167-
" assert_raises(TypeError, solution.insert, None)\n",
163+
" self.assertRaises(TypeError, solution.insert, None)\n",
168164
" solution.insert(5)\n",
169165
" solution.insert(2)\n",
170166
" solution.insert(7)\n",
@@ -176,10 +172,10 @@
176172
" solution.insert(3)\n",
177173
" solution.insert(3)\n",
178174
" solution.insert(2)\n",
179-
" assert_equal(solution.max, 9)\n",
180-
" assert_equal(solution.min, 2)\n",
181-
" assert_equal(solution.mean, 5)\n",
182-
" assert_true(solution.mode in (2, 9))\n",
175+
" self.assertEqual(solution.max, 9)\n",
176+
" self.assertEqual(solution.min, 2)\n",
177+
" self.assertEqual(solution.mean, 5)\n",
178+
" self.assertTrue(solution.mode in (2, 9))\n",
183179
" print('Success: test_math_ops')\n",
184180
"\n",
185181
"\n",
@@ -195,9 +191,7 @@
195191
{
196192
"cell_type": "code",
197193
"execution_count": 3,
198-
"metadata": {
199-
"collapsed": false
200-
},
194+
"metadata": {},
201195
"outputs": [
202196
{
203197
"name": "stdout",
@@ -228,9 +222,9 @@
228222
"name": "python",
229223
"nbconvert_exporter": "python",
230224
"pygments_lexer": "ipython3",
231-
"version": "3.5.0"
225+
"version": "3.7.2"
232226
}
233227
},
234228
"nbformat": 4,
235-
"nbformat_minor": 0
229+
"nbformat_minor": 1
236230
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
from nose.tools import assert_equal, assert_true, assert_raises
1+
import unittest
22

33

4-
class TestMathOps(object):
4+
class TestMathOps(unittest.TestCase):
55

66
def test_math_ops(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.insert, None)
8+
self.assertRaises(TypeError, solution.insert, None)
99
solution.insert(5)
1010
solution.insert(2)
1111
solution.insert(7)
@@ -17,10 +17,10 @@ def test_math_ops(self):
1717
solution.insert(3)
1818
solution.insert(3)
1919
solution.insert(2)
20-
assert_equal(solution.max, 9)
21-
assert_equal(solution.min, 2)
22-
assert_equal(solution.mean, 5)
23-
assert_true(solution.mode in (2, 9))
20+
self.assertEqual(solution.max, 9)
21+
self.assertEqual(solution.min, 2)
22+
self.assertEqual(solution.mean, 5)
23+
self.assertTrue(solution.mode in (2, 9))
2424
print('Success: test_math_ops')
2525

2626

@@ -30,4 +30,4 @@ def main():
3030

3131

3232
if __name__ == '__main__':
33-
main()
33+
main()

‎math_probability/power_two/power_two_challenge.ipynb

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@
7777
{
7878
"cell_type": "code",
7979
"execution_count": null,
80-
"metadata": {
81-
"collapsed": false
82-
},
80+
"metadata": {},
8381
"outputs": [],
8482
"source": [
8583
"class Solution(object):\n",
@@ -106,25 +104,23 @@
106104
{
107105
"cell_type": "code",
108106
"execution_count": null,
109-
"metadata": {
110-
"collapsed": false
111-
},
107+
"metadata": {},
112108
"outputs": [],
113109
"source": [
114110
"# %load test_is_power_of_two.py\n",
115-
"from nose.tools import assert_equal, assert_raises\n",
111+
"import unittest\n",
116112
"\n",
117113
"\n",
118-
"class TestSolution(object):\n",
114+
"class TestSolution(unittest.TestCase):\n",
119115
"\n",
120116
" def test_is_power_of_two(self):\n",
121117
" solution = Solution()\n",
122-
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
123-
" assert_equal(solution.is_power_of_two(0), False)\n",
124-
" assert_equal(solution.is_power_of_two(1), True)\n",
125-
" assert_equal(solution.is_power_of_two(2), True)\n",
126-
" assert_equal(solution.is_power_of_two(15), False)\n",
127-
" assert_equal(solution.is_power_of_two(16), True)\n",
118+
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
119+
" self.assertEqual(solution.is_power_of_two(0), False)\n",
120+
" self.assertEqual(solution.is_power_of_two(1), True)\n",
121+
" self.assertEqual(solution.is_power_of_two(2), True)\n",
122+
" self.assertEqual(solution.is_power_of_two(15), False)\n",
123+
" self.assertEqual(solution.is_power_of_two(16), True)\n",
128124
" print('Success: test_is_power_of_two')\n",
129125
"\n",
130126
"\n",
@@ -163,9 +159,9 @@
163159
"name": "python",
164160
"nbconvert_exporter": "python",
165161
"pygments_lexer": "ipython3",
166-
"version": "3.5.0"
162+
"version": "3.7.2"
167163
}
168164
},
169165
"nbformat": 4,
170-
"nbformat_minor": 0
166+
"nbformat_minor": 1
171167
}

‎math_probability/power_two/power_two_solution.ipynb

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -98,9 +98,7 @@
9898
{
9999
"cell_type": "code",
100100
"execution_count": 1,
101-
"metadata": {
102-
"collapsed": false
103-
},
101+
"metadata": {},
104102
"outputs": [],
105103
"source": [
106104
"class Solution(object):\n",
@@ -123,9 +121,7 @@
123121
{
124122
"cell_type": "code",
125123
"execution_count": 2,
126-
"metadata": {
127-
"collapsed": false
128-
},
124+
"metadata": {},
129125
"outputs": [
130126
{
131127
"name": "stdout",
@@ -137,19 +133,19 @@
137133
],
138134
"source": [
139135
"%%writefile test_is_power_of_two.py\n",
140-
"from nose.tools import assert_equal, assert_raises\n",
136+
"import unittest\n",
141137
"\n",
142138
"\n",
143-
"class TestSolution(object):\n",
139+
"class TestSolution(unittest.TestCase):\n",
144140
"\n",
145141
" def test_is_power_of_two(self):\n",
146142
" solution = Solution()\n",
147-
" assert_raises(TypeError, solution.is_power_of_two, None)\n",
148-
" assert_equal(solution.is_power_of_two(0), False)\n",
149-
" assert_equal(solution.is_power_of_two(1), True)\n",
150-
" assert_equal(solution.is_power_of_two(2), True)\n",
151-
" assert_equal(solution.is_power_of_two(15), False)\n",
152-
" assert_equal(solution.is_power_of_two(16), True)\n",
143+
" self.assertRaises(TypeError, solution.is_power_of_two, None)\n",
144+
" self.assertEqual(solution.is_power_of_two(0), False)\n",
145+
" self.assertEqual(solution.is_power_of_two(1), True)\n",
146+
" self.assertEqual(solution.is_power_of_two(2), True)\n",
147+
" self.assertEqual(solution.is_power_of_two(15), False)\n",
148+
" self.assertEqual(solution.is_power_of_two(16), True)\n",
153149
" print('Success: test_is_power_of_two')\n",
154150
"\n",
155151
"\n",
@@ -165,9 +161,7 @@
165161
{
166162
"cell_type": "code",
167163
"execution_count": 3,
168-
"metadata": {
169-
"collapsed": false
170-
},
164+
"metadata": {},
171165
"outputs": [
172166
{
173167
"name": "stdout",
@@ -198,9 +192,9 @@
198192
"name": "python",
199193
"nbconvert_exporter": "python",
200194
"pygments_lexer": "ipython3",
201-
"version": "3.5.0"
195+
"version": "3.7.2"
202196
}
203197
},
204198
"nbformat": 4,
205-
"nbformat_minor": 0
199+
"nbformat_minor": 1
206200
}
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestSolution(object):
4+
class TestSolution(unittest.TestCase):
55

66
def test_is_power_of_two(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.is_power_of_two, None)
9-
assert_equal(solution.is_power_of_two(0), False)
10-
assert_equal(solution.is_power_of_two(1), True)
11-
assert_equal(solution.is_power_of_two(2), True)
12-
assert_equal(solution.is_power_of_two(15), False)
13-
assert_equal(solution.is_power_of_two(16), True)
8+
self.assertRaises(TypeError, solution.is_power_of_two, None)
9+
self.assertEqual(solution.is_power_of_two(0), False)
10+
self.assertEqual(solution.is_power_of_two(1), True)
11+
self.assertEqual(solution.is_power_of_two(2), True)
12+
self.assertEqual(solution.is_power_of_two(15), False)
13+
self.assertEqual(solution.is_power_of_two(16), True)
1414
print('Success: test_is_power_of_two')
1515

1616

@@ -20,4 +20,4 @@ def main():
2020

2121

2222
if __name__ == '__main__':
23-
main()
23+
main()

‎math_probability/sub_two/sub_two_challenge.ipynb

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,7 @@
7474
{
7575
"cell_type": "code",
7676
"execution_count": null,
77-
"metadata": {
78-
"collapsed": false
79-
},
77+
"metadata": {},
8078
"outputs": [],
8179
"source": [
8280
"class Solution(object):\n",
@@ -103,24 +101,22 @@
103101
{
104102
"cell_type": "code",
105103
"execution_count": null,
106-
"metadata": {
107-
"collapsed": false
108-
},
104+
"metadata": {},
109105
"outputs": [],
110106
"source": [
111107
"# %load test_sub_two.py\n",
112-
"from nose.tools import assert_equal, assert_raises\n",
108+
"import unittest\n",
113109
"\n",
114110
"\n",
115-
"class TestSubTwo(object):\n",
111+
"class TestSubTwo(unittest.TestCase):\n",
116112
"\n",
117113
" def test_sub_two(self):\n",
118114
" solution = Solution()\n",
119-
" assert_raises(TypeError, solution.sub_two, None)\n",
120-
" assert_equal(solution.sub_two(7, 5), 2)\n",
121-
" assert_equal(solution.sub_two(-5, -7), 2)\n",
122-
" assert_equal(solution.sub_two(-5, 7), -12)\n",
123-
" assert_equal(solution.sub_two(5, -7), 12)\n",
115+
" self.assertRaises(TypeError, solution.sub_two, None)\n",
116+
" self.assertEqual(solution.sub_two(7, 5), 2)\n",
117+
" self.assertEqual(solution.sub_two(-5, -7), 2)\n",
118+
" self.assertEqual(solution.sub_two(-5, 7), -12)\n",
119+
" self.assertEqual(solution.sub_two(5, -7), 12)\n",
124120
" print('Success: test_sub_two')\n",
125121
"\n",
126122
"\n",
@@ -159,9 +155,9 @@
159155
"name": "python",
160156
"nbconvert_exporter": "python",
161157
"pygments_lexer": "ipython3",
162-
"version": "3.5.0"
158+
"version": "3.7.2"
163159
}
164160
},
165161
"nbformat": 4,
166-
"nbformat_minor": 0
162+
"nbformat_minor": 1
167163
}

‎math_probability/sub_two/sub_two_solution.ipynb

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,7 @@
9696
{
9797
"cell_type": "code",
9898
"execution_count": 1,
99-
"metadata": {
100-
"collapsed": false
101-
},
99+
"metadata": {},
102100
"outputs": [],
103101
"source": [
104102
"class Solution(object):\n",
@@ -123,9 +121,7 @@
123121
{
124122
"cell_type": "code",
125123
"execution_count": 2,
126-
"metadata": {
127-
"collapsed": false
128-
},
124+
"metadata": {},
129125
"outputs": [
130126
{
131127
"name": "stdout",
@@ -137,18 +133,18 @@
137133
],
138134
"source": [
139135
"%%writefile test_sub_two.py\n",
140-
"from nose.tools import assert_equal, assert_raises\n",
136+
"import unittest\n",
141137
"\n",
142138
"\n",
143-
"class TestSubTwo(object):\n",
139+
"class TestSubTwo(unittest.TestCase):\n",
144140
"\n",
145141
" def test_sub_two(self):\n",
146142
" solution = Solution()\n",
147-
" assert_raises(TypeError, solution.sub_two, None)\n",
148-
" assert_equal(solution.sub_two(7, 5), 2)\n",
149-
" assert_equal(solution.sub_two(-5, -7), 2)\n",
150-
" assert_equal(solution.sub_two(-5, 7), -12)\n",
151-
" assert_equal(solution.sub_two(5, -7), 12)\n",
143+
" self.assertRaises(TypeError, solution.sub_two, None)\n",
144+
" self.assertEqual(solution.sub_two(7, 5), 2)\n",
145+
" self.assertEqual(solution.sub_two(-5, -7), 2)\n",
146+
" self.assertEqual(solution.sub_two(-5, 7), -12)\n",
147+
" self.assertEqual(solution.sub_two(5, -7), 12)\n",
152148
" print('Success: test_sub_two')\n",
153149
"\n",
154150
"\n",
@@ -165,7 +161,6 @@
165161
"cell_type": "code",
166162
"execution_count": 3,
167163
"metadata": {
168-
"collapsed": false,
169164
"scrolled": true
170165
},
171166
"outputs": [
@@ -198,9 +193,9 @@
198193
"name": "python",
199194
"nbconvert_exporter": "python",
200195
"pygments_lexer": "ipython3",
201-
"version": "3.5.0"
196+
"version": "3.7.2"
202197
}
203198
},
204199
"nbformat": 4,
205-
"nbformat_minor": 0
200+
"nbformat_minor": 1
206201
}
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestSubTwo(object):
4+
class TestSubTwo(unittest.TestCase):
55

66
def test_sub_two(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.sub_two, None)
9-
assert_equal(solution.sub_two(7, 5), 2)
10-
assert_equal(solution.sub_two(-5, -7), 2)
11-
assert_equal(solution.sub_two(-5, 7), -12)
12-
assert_equal(solution.sub_two(5, -7), 12)
8+
self.assertRaises(TypeError, solution.sub_two, None)
9+
self.assertEqual(solution.sub_two(7, 5), 2)
10+
self.assertEqual(solution.sub_two(-5, -7), 2)
11+
self.assertEqual(solution.sub_two(-5, 7), -12)
12+
self.assertEqual(solution.sub_two(5, -7), 12)
1313
print('Success: test_sub_two')
1414

1515

@@ -19,4 +19,4 @@ def main():
1919

2020

2121
if __name__ == '__main__':
22-
main()
22+
main()

‎math_probability/sum_two/sum_two_challenge.ipynb

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,7 @@
6868
{
6969
"cell_type": "code",
7070
"execution_count": null,
71-
"metadata": {
72-
"collapsed": false
73-
},
71+
"metadata": {},
7472
"outputs": [],
7573
"source": [
7674
"class Solution(object):\n",
@@ -97,23 +95,21 @@
9795
{
9896
"cell_type": "code",
9997
"execution_count": null,
100-
"metadata": {
101-
"collapsed": false
102-
},
98+
"metadata": {},
10399
"outputs": [],
104100
"source": [
105101
"# %load test_sum_two.py\n",
106-
"from nose.tools import assert_equal, assert_raises\n",
102+
"import unittest\n",
107103
"\n",
108104
"\n",
109-
"class TestSumTwo(object):\n",
105+
"class TestSumTwo(unittest.TestCase):\n",
110106
"\n",
111107
" def test_sum_two(self):\n",
112108
" solution = Solution()\n",
113-
" assert_raises(TypeError, solution.sum_two, None)\n",
114-
" assert_equal(solution.sum_two(5, 7), 12)\n",
115-
" assert_equal(solution.sum_two(-5, -7), -12)\n",
116-
" assert_equal(solution.sum_two(5, -7), -2)\n",
109+
" self.assertRaises(TypeError, solution.sum_two, None)\n",
110+
" self.assertEqual(solution.sum_two(5, 7), 12)\n",
111+
" self.assertEqual(solution.sum_two(-5, -7), -12)\n",
112+
" self.assertEqual(solution.sum_two(5, -7), -2)\n",
117113
" print('Success: test_sum_two')\n",
118114
"\n",
119115
"\n",
@@ -152,9 +148,9 @@
152148
"name": "python",
153149
"nbconvert_exporter": "python",
154150
"pygments_lexer": "ipython3",
155-
"version": "3.5.0"
151+
"version": "3.7.2"
156152
}
157153
},
158154
"nbformat": 4,
159-
"nbformat_minor": 0
155+
"nbformat_minor": 1
160156
}

‎math_probability/sum_two/sum_two_solution.ipynb

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -112,9 +112,7 @@
112112
{
113113
"cell_type": "code",
114114
"execution_count": 1,
115-
"metadata": {
116-
"collapsed": false
117-
},
115+
"metadata": {},
118116
"outputs": [],
119117
"source": [
120118
"class Solution(object):\n",
@@ -139,9 +137,7 @@
139137
{
140138
"cell_type": "code",
141139
"execution_count": 2,
142-
"metadata": {
143-
"collapsed": false
144-
},
140+
"metadata": {},
145141
"outputs": [
146142
{
147143
"name": "stdout",
@@ -153,17 +149,17 @@
153149
],
154150
"source": [
155151
"%%writefile test_sum_two.py\n",
156-
"from nose.tools import assert_equal, assert_raises\n",
152+
"import unittest\n",
157153
"\n",
158154
"\n",
159-
"class TestSumTwo(object):\n",
155+
"class TestSumTwo(unittest.TestCase):\n",
160156
"\n",
161157
" def test_sum_two(self):\n",
162158
" solution = Solution()\n",
163-
" assert_raises(TypeError, solution.sum_two, None)\n",
164-
" assert_equal(solution.sum_two(5, 7), 12)\n",
165-
" assert_equal(solution.sum_two(-5, -7), -12)\n",
166-
" assert_equal(solution.sum_two(5, -7), -2)\n",
159+
" self.assertRaises(TypeError, solution.sum_two, None)\n",
160+
" self.assertEqual(solution.sum_two(5, 7), 12)\n",
161+
" self.assertEqual(solution.sum_two(-5, -7), -12)\n",
162+
" self.assertEqual(solution.sum_two(5, -7), -2)\n",
167163
" print('Success: test_sum_two')\n",
168164
"\n",
169165
"\n",
@@ -180,7 +176,6 @@
180176
"cell_type": "code",
181177
"execution_count": 3,
182178
"metadata": {
183-
"collapsed": false,
184179
"scrolled": true
185180
},
186181
"outputs": [
@@ -213,9 +208,9 @@
213208
"name": "python",
214209
"nbconvert_exporter": "python",
215210
"pygments_lexer": "ipython3",
216-
"version": "3.5.0"
211+
"version": "3.7.2"
217212
}
218213
},
219214
"nbformat": 4,
220-
"nbformat_minor": 0
215+
"nbformat_minor": 1
221216
}
Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
from nose.tools import assert_equal, assert_raises
1+
import unittest
22

33

4-
class TestSumTwo(object):
4+
class TestSumTwo(unittest.TestCase):
55

66
def test_sum_two(self):
77
solution = Solution()
8-
assert_raises(TypeError, solution.sum_two, None)
9-
assert_equal(solution.sum_two(5, 7), 12)
10-
assert_equal(solution.sum_two(-5, -7), -12)
11-
assert_equal(solution.sum_two(5, -7), -2)
8+
self.assertRaises(TypeError, solution.sum_two, None)
9+
self.assertEqual(solution.sum_two(5, 7), 12)
10+
self.assertEqual(solution.sum_two(-5, -7), -12)
11+
self.assertEqual(solution.sum_two(5, -7), -2)
1212
print('Success: test_sum_two')
1313

1414

@@ -18,4 +18,4 @@ def main():
1818

1919

2020
if __name__ == '__main__':
21-
main()
21+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.