def test_Q3(self): a = cl5.close_to_5() b = np.array([ 0.43773, 0.27259, 0.27646, 0.501, 0.37025, 0.50308, 0.36489, 0.6154, 0.3972, 0.5681 ]) self.assertTrue(np.array_equal(a, b))
print "\n The answer of Question 1, (c) is" print m2day.make_2D_array(5, 3, 1, 15)[1:4, :3] #d print "\n The answer of Question 1, (d) is" print m2day.make_2D_array(5, 3, 1, 15).T.reshape(1,15)[0][2:11] # Question 2 a = np.arange(25).reshape(5, 5) b = np.array([1., 5, 10, 15, 20]) print "\n The answer of Question 2 is" print md.matrix_divide(a,b) # Question 3 print "\n The answer of Question 3 is" print cl5.close_to_5() # Question 4 print "\n Generating plot.........." mask = mand.mandelbort_set(-2, 1, -1.5, 1.5) print "\n The plot of question 4 is saved as 'mandelbrot.png' in the current dictory." plt.imshow(mask.T, extent=[-2, 1, -1.5, 1.5]) plt.gray() plt.savefig('mandelbrot.png') except KeyboardInterrupt, ValueError: print "\n Interrupted!" except ArithmeticError, OverflowError: print "\n Math Error" except ZeroDivisionError: print "\n Math Error"
def test_Q3(self): a = cl5.close_to_5() b = np.array([0.43773, 0.27259, 0.27646, 0.501, 0.37025, 0.50308, 0.36489, 0.6154, 0.3972, 0.5681]) self.assertTrue(np.array_equal(a,b))