source: misc/tools/acceptance_tests/mandelbrot/test_calculate_region.py @ 7276

Last change on this file since 7276 was 7276, checked in by ole, 15 years ago

Merged numpy branch back into the trunk.

In ~/sandpit/anuga/anuga_core/source
svn merge -r 6246:HEAD ../../branches/numpy .

In ~/sandpit/anuga/anuga_validation
svn merge -r 6417:HEAD ../branches/numpy_anuga_validation .

In ~/sandpit/anuga/misc
svn merge -r 6809:HEAD ../branches/numpy_misc .

For all merges, I used numpy version where conflicts existed

The suites test_all.py (in source/anuga) and validate_all.py passed using Python2.5 with numpy on my Ubuntu Linux box.

  • Property svn:executable set to *
File size: 1.8 KB
Line 
1"""
2  Test of calculate_region within mandelbrot.py
3"""
4
5import unittest
6import numpy
7from mandelbrot import calculate_region
8
9
10#-------------------------------------------------------------
11
12class TestCase(unittest.TestCase):
13
14    def setUp(self):
15        pass
16
17       
18    def test1(self):
19        kmax = 16
20        M = N = 5
21       
22        real_min = -2.0
23        real_max =  1.0
24        imag_min = -1.5
25        imag_max =  1.5
26        A = calculate_region(real_min, real_max, 
27                imag_min, imag_max, kmax, M, N)
28
29        assert numpy.allclose(A,               
30        [[ 1,  1,  1,  1,  1],
31        [ 1,  3,  5,  5,  3],
32        [ 2,  4,  9,  9,  4],
33        [ 2,  9, 16, 16,  9],
34        [ 2,  3, 15, 15,  3]])
35
36
37    def test2(self):
38        kmax = 32
39        M = N = 5
40       
41        real_min = -2.0
42        real_max =  1.0
43        imag_min = -1.5
44        imag_max =  1.5
45        A = calculate_region(real_min, real_max, 
46                imag_min, imag_max, kmax, M, N)
47
48        assert numpy.allclose(A,               
49        [[ 1,  1,  1,  1,  1],
50        [ 1,  3,  5,  5,  3],
51        [ 2,  4,  9,  9,  4],
52        [ 2,  9, 32, 32,  9],
53        [ 2,  3, 15, 15,  3]])
54       
55
56    def test3(self):
57        kmax = 32
58        M = N = 100
59       
60        real_min = -2.0
61        real_max =  1.0
62        imag_min = -1.5
63        imag_max =  1.5
64        A = calculate_region(real_min, real_max, 
65                imag_min, imag_max, kmax, M, N)
66
67        assert numpy.allclose(A[:, 50], 
68        [32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 
69         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32,
70         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 
71         32, 32, 32, 32, 32, 32, 32, 32,
72         32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 
73         32, 32, 32, 32, 32, 32, 32, 32,
74         32, 32, 16, 11,  9,  7,  7,  6,  5,  5,  5,  4,  4,  4,  4,  4, 
75         3, 3,  3,  3,  3,  3,  3,  3, 3,  3])
76
77       
78#-------------------------------------------------------------
79if __name__ == "__main__":
80
81    mysuite = unittest.makeSuite(TestCase,'test')
82    runner = unittest.TextTestRunner()
83    runner.run(mysuite)
Note: See TracBrowser for help on using the repository browser.