def test_class_is_mandelbrot_set(self): '''test the is_mandelbrot_set function generates the right return.''' a = np.arange(1, 3) b = np.array([[False, False], [False, False]], dtype=bool) mandelbrot_init = mandelbrot(a, a) mandelbrot_is_set = mandelbrot_init.is_mandelbrot_set() self.assertTrue(np.array_equal(mandelbrot_is_set, b))
def test_class_mandelbrot_set(self): '''test the mandelbrot_set function generates the right return.''' a = np.arange(1, 3) b = np.array([[1 + 1j * 1, 1 + 1j * 2], [2 + 1j * 1, 2 + 1j * 2]]) mandelbrot_init = mandelbrot(a, a) mandelbrot_set_1 = mandelbrot_init.mandelbrot_set() self.assertTrue(np.array_equal(mandelbrot_set_1, b))
def test_class_mandelbrot_interation(self): '''test the mandelbrot_interation function generates the right return.''' a = np.arange(1, 3) b = np.array([[1. - 97.j, 478. + 1366.j], [2. + 51.j, -94. + 42.j]]) mandelbrot_init = mandelbrot(a, a) mandelbrot_interation_1 = mandelbrot_init.mandelbrot_interation() self.assertTrue(np.array_equal(mandelbrot_interation_1, b))
def test_class_is_mandelbrot_set(self): '''test the is_mandelbrot_set function generates the right return.''' a = np.arange(1,3) b = np.array([[False, False], [False, False]], dtype=bool) mandelbrot_init = mandelbrot(a, a) mandelbrot_is_set = mandelbrot_init.is_mandelbrot_set() self.assertTrue(np.array_equal(mandelbrot_is_set, b))
def test_class_mandelbrot_interation(self): '''test the mandelbrot_interation function generates the right return.''' a = np.arange(1,3) b = np.array([[1.-97.j,478.+1366.j],[2.+51.j,-94.+42.j]]) mandelbrot_init = mandelbrot(a, a) mandelbrot_interation_1 = mandelbrot_init.mandelbrot_interation() self.assertTrue(np.array_equal(mandelbrot_interation_1, b))
def test_class_mandelbrot_set(self): '''test the mandelbrot_set function generates the right return.''' a = np.arange(1,3) b = np.array([[1+1j*1, 1+1j*2],[2+1j*1, 2+1j*2]]) mandelbrot_init = mandelbrot(a, a) mandelbrot_set_1 = mandelbrot_init.mandelbrot_set() self.assertTrue(np.array_equal(mandelbrot_set_1, b))
def test_class_init(self): '''test the class argument of two arrays is valid.''' a = np.arange(0, 10) b = np.arange(0, 5) mandelbrot_init = mandelbrot(a, b) self.assertTrue(np.array_equal(mandelbrot_init.x_coordinate, a)) self.assertTrue(np.array_equal(mandelbrot_init.y_coordinate, b))
print 'Generate a new array that contains only elements with values that are between 3 and 11:' print generatearray.array_values(array_new) #problem 2 print 'Problem 2:' print dividedarray.array_divide() #problem 3 print 'Problem 3:' print valuechosen.value_choose() #problem 4 print 'problem 4:' array1 = np.arange(-2, 1, 0.01) array2 = np.arange(-1.5, 1.5, 0.01) mandelbrot_set_generate = mandelbrot(array1, array2) mask = mandelbrot_set_generate.is_mandelbrot_set() #plot the graph and save it to 'mandelbrot.png' plt.imshow(mask.T, extent = [-2, 1, -1.5, 1.5]) plt.gray() plt.savefig('mandelbrot.png') except KeyboardInterrupt: print '\n Error: Interrupted by user' except ArithmeticError: print '\n Mathematic Error: Arithmetic' except OverflowError: print '\n Mathematic Error: Overflow' except ZeroDivisionError: print '\n Mathematic Error: Divided by Zero' except ValueError:
print 'Generate a new array that contains only elements with values that are between 3 and 11:' print generatearray.array_values(array_new) #problem 2 print 'Problem 2:' print dividedarray.array_divide() #problem 3 print 'Problem 3:' print valuechosen.value_choose() #problem 4 print 'problem 4:' array1 = np.arange(-2, 1, 0.01) array2 = np.arange(-1.5, 1.5, 0.01) mandelbrot_set_generate = mandelbrot(array1, array2) mask = mandelbrot_set_generate.is_mandelbrot_set() #plot the graph and save it to 'mandelbrot.png' plt.imshow(mask.T, extent=[-2, 1, -1.5, 1.5]) plt.gray() plt.savefig('mandelbrot.png') except KeyboardInterrupt: print '\n Error: Interrupted by user' except ArithmeticError: print '\n Mathematic Error: Arithmetic' except OverflowError: print '\n Mathematic Error: Overflow' except ZeroDivisionError: print '\n Mathematic Error: Divided by Zero' except ValueError: