def test_Q1_d(self): a = m2day.make_2D_array(5, 3, 1, 15).T.reshape(1, 15)[0][2:11] b = np.array([3., 4., 5., 6., 7., 8., 9., 10., 11.]) self.assertTrue(np.array_equal(a, b))
from mandelbrot import * # Author: Sida Ye # DS-GA 1007 HW7 # Main program """ This is the main program to generate answer for assignment7 """ try: # Question 1 #a print "\n The answer of Question 1, (a) is" print m2day.make_2D_array(5, 3, 1, 15)[[1, 3], ] #b print "\n The answer of Question 1, (b) is" print m2day.make_2D_array(5, 3, 1, 15)[:, 1:2] #c 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)
def test_Q1_b(self): a = m2day.make_2D_array(5, 3, 1, 15)[:, 1] b = np.array([6., 7., 8., 9., 10.]) self.assertTrue(np.array_equal(a, b))
def test_Q1_c(self): a = m2day.make_2D_array(5, 3, 1, 15)[1:4, :3] b = np.array([[2., 7., 12.], [3., 8., 13.], [4., 9., 14.]]) self.assertTrue(np.array_equal(a, b))
def test_Q1_a(self): a = m2day.make_2D_array(5, 3, 1, 15)[[1, 3], ] b = np.array([[2., 7., 12.], [4., 9., 14.]]) self.assertTrue(np.array_equal(a, b))
def test_Q1_d(self): a = m2day.make_2D_array(5, 3, 1, 15).T.reshape(1,15)[0][2:11] b = np.array([3., 4., 5., 6., 7., 8., 9., 10., 11.]) self.assertTrue(np.array_equal(a,b))
def test_Q1_c(self): a = m2day.make_2D_array(5, 3, 1, 15)[1:4, :3] b = np.array([[2., 7., 12.], [3., 8., 13.], [4., 9., 14.]]) self.assertTrue(np.array_equal(a,b))
def test_Q1_b(self): a = m2day.make_2D_array(5, 3, 1, 15)[:, 1] b = np.array([ 6., 7., 8., 9., 10.]) self.assertTrue(np.array_equal(a,b))
def test_Q1_a(self): a = m2day.make_2D_array(5, 3, 1, 15)[[1, 3], ] b = np.array([[2., 7., 12.],[4., 9., 14.]]) self.assertTrue(np.array_equal(a,b))