~ubuntu-branches/debian/sid/simpleitk/sid

« back to all changes in this revision

Viewing changes to Testing/Unit/sitkImageTests.py

  • Committer: Package Import Robot
  • Author(s): Ghislain Antony Vaillant
  • Date: 2017-11-02 08:49:18 UTC
  • Revision ID: package-import@ubuntu.com-20171102084918-7hs09ih668xq87ej
Tags: upstream-1.0.1
ImportĀ upstreamĀ versionĀ 1.0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#==========================================================================
 
2
#
 
3
#   Copyright Insight Software Consortium
 
4
#
 
5
#   Licensed under the Apache License, Version 2.0 (the "License");
 
6
#   you may not use this file except in compliance with the License.
 
7
#   You may obtain a copy of the License at
 
8
#
 
9
#          http://www.apache.org/licenses/LICENSE-2.0.txt
 
10
#
 
11
#   Unless required by applicable law or agreed to in writing, software
 
12
#   distributed under the License is distributed on an "AS IS" BASIS,
 
13
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
14
#   See the License for the specific language governing permissions and
 
15
#   limitations under the License.
 
16
#
 
17
#==========================================================================*/
 
18
 
 
19
from __future__ import print_function
 
20
import unittest
 
21
 
 
22
import SimpleITK as sitk
 
23
import sys
 
24
 
 
25
 
 
26
class ImageTests(unittest.TestCase):
 
27
    """These tests are suppose to test the python interface to the sitk::Image"""
 
28
 
 
29
 
 
30
 
 
31
    def setUp(self):
 
32
        pass
 
33
 
 
34
    def test_legacy(self):
 
35
        """ This is old testing cruft before tehe unittest enlightenment """
 
36
 
 
37
        image = sitk.Image( 10, 10, sitk.sitkInt32 )
 
38
 
 
39
        image + image
 
40
        image + 1
 
41
        1 + image
 
42
        image - image
 
43
        image - 1
 
44
        1 - image
 
45
        image * image
 
46
        image * 1
 
47
        1 * image
 
48
        image / image
 
49
        1.0 / image
 
50
        image / 1.0
 
51
        image // image
 
52
        image // 1
 
53
        1 // image
 
54
        image & image
 
55
        image | image
 
56
        image ^ image
 
57
        ~image
 
58
 
 
59
        image += image
 
60
        image -= image
 
61
        image *= image
 
62
        image /= image
 
63
        image //= image
 
64
 
 
65
        image = image * 0
 
66
 
 
67
        image.SetPixel( 0, 0, 1 )
 
68
        image[ [0,1] ]  = 2
 
69
        image[ 9,9 ]  = 3
 
70
        image.SetPixel( [0, 2], 4 )
 
71
 
 
72
        self.assertEqual(image.GetPixel(1,1), 0 )
 
73
        self.assertEqual(image.GetPixel([0,2]), 4 )
 
74
        image[1,1]
 
75
        image[ [ 1,1 ] ]
 
76
 
 
77
        self.assertEqual(sum( image ), 10)
 
78
 
 
79
        self.assertEqual(len( image ), 100)
 
80
 
 
81
 
 
82
if __name__ == '__main__':
 
83
    unittest.main()