This file is indexed.

/usr/src/WrapITK/Python/Tests/extras.py is in libinsighttoolkit3-dev 3.20.1-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env python

# also test the import callback feature
def custom_callback(name, progress):
  if progress == 0:
    print >> sys.stderr, "Loading %s..." % name,
  if progress == 1:
    print >> sys.stderr, "done"
import itkConfig
itkConfig.ImportCallback = custom_callback

import itk, sys

# test the force load function
itk.force_load()

fileName = sys.argv[1]

PType = itk.US
dim = 2
IType = itk.Image[PType, dim]
ReaderType = itk.ImageFileReader[IType]
reader = ReaderType.New(FileName=fileName)


# test echo
itk.echo(reader)
itk.echo(reader, sys.stdout)

# test class_
assert itk.class_(reader) == ReaderType
assert itk.class_(reader.GetPointer()) == ReaderType
assert itk.class_("dummy") == str

# test template
assert itk.template(ReaderType) == (itk.ImageFileReader, (IType,))
assert itk.template(reader) == (itk.ImageFileReader, (IType,))
assert itk.template(reader.GetPointer()) == (itk.ImageFileReader, (IType,))
try:
  itk.template(str)
  raise Exception("unknown class should send an exception")
except KeyError:
  pass

# test ctype
assert itk.ctype("unsigned short") == itk.US
assert itk.ctype("        unsigned      \n   short \t  ") == itk.US
try:
  itk.ctype("dummy")
  raise Exception("unknown C type should send an exception")
except KeyError:
  pass


# test image
assert repr(itk.image(reader)) == repr(reader.GetOutput().GetPointer())
assert repr(itk.image(reader.GetOutput())) == repr(reader.GetOutput().GetPointer())
assert repr(itk.image(reader.GetOutput().GetPointer())) == repr(reader.GetOutput().GetPointer())
assert itk.image(1) == 1


# test strel
# should work with the image type, an image instance or a filter
# and should work with a list, a tuple, an int or an itk.Size
for s in [2, (2, 2), [2, 2], itk.Size[2](2)] :
  st = itk.strel(dim, s)
  
  (tpl, param) = itk.template(st)
  assert tpl == itk.FlatStructuringElement
  assert param[0] == dim
  assert st.GetRadius().GetElement(0) == st.GetRadius().GetElement(1) == 2

# test size
s = itk.size(reader)
assert s.GetElement(0) == s.GetElement(1) == 256
s = itk.size(reader.GetOutput())
assert s.GetElement(0) == s.GetElement(1) == 256
s = itk.size(reader.GetOutput().GetPointer())
assert s.GetElement(0) == s.GetElement(1) == 256


# test range
assert itk.range(reader) == (0, 255)
assert itk.range(reader.GetOutput()) == (0, 255)
assert itk.range(reader.GetOutput().GetPointer()) == (0, 255)


# test write
itk.write(reader, sys.argv[2])