This file is indexed.

/usr/lib/python2.7/dist-packages/fabio/test/testopenimage.py is in python-fabio 0.3.0+dfsg-1build1.

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

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
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
#    Project: Fable Input Output
#             https://github.com/kif/fabio
#
#    Copyright (C) European Synchrotron Radiation Facility, Grenoble, France
#
#    Principal author:       Jérôme Kieffer (Jerome.Kieffer@ESRF.eu)
#
#    This program is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program.  If not, see <http://www.gnu.org/licenses/>.
#
"""
# Unit tests

builds on stuff from ImageD11.test.testpeaksearch
Jerome Kieffer 04/12/2014
"""
from __future__ import print_function, with_statement, division, absolute_import
import unittest
import sys
import os
import numpy

if __name__ == '__main__':
    import pkgutil
    __path__ = pkgutil.extend_path([os.path.dirname(__file__)], "fabio.test")
from .utilstest import UtilsTest


logger = UtilsTest.get_logger(__file__)
fabio = sys.modules["fabio"]

from fabio.openimage import openimage
from fabio.edfimage import edfimage
from fabio.marccdimage import marccdimage
from fabio.fit2dmaskimage import fit2dmaskimage
from fabio.OXDimage import OXDimage
from fabio.brukerimage import brukerimage
from fabio.adscimage import adscimage


class testopenedf(unittest.TestCase):
    """openimage opening edf"""
    fname = "F2K_Seb_Lyso0675.edf.bz2"
    def setUp(self):
        self.fname = UtilsTest.getimage(self.__class__.fname)

    def testcase(self):
        """ check we can read EDF image with openimage"""
        obj = openimage(self.fname)
        obj2 = edfimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testedfgz(testopenedf):
    """openimage opening edf gzip"""
    fname = "F2K_Seb_Lyso0675.edf.gz"


class testedfbz2(testopenedf):
    """openimage opening edf bzip"""
    fname = "F2K_Seb_Lyso0675.edf.bz2"


class testopenmccd(unittest.TestCase):
    """openimage opening mccd"""
    fname = "somedata_0001.mccd"

    def setUp(self):
        self.fname = UtilsTest.getimage(self.__class__.fname)

    def testcase(self):
        """ check we can read it"""
        obj = openimage(self.fname)
        obj2 = marccdimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testmccdgz(testopenmccd):
    """openimage opening mccd gzip"""
    fname = "somedata_0001.mccd.gz"


class testmccdbz2(testopenmccd):
    """openimage opening mccd bzip"""
    fname = "somedata_0001.mccd.bz2"


class testmask(unittest.TestCase):
    """openimage opening mccd"""
    fname = "face.msk"

    def setUp(self):
        """ check file exists """
        self.fname = UtilsTest.getimage(self.__class__.fname)

    def testcase(self):
        """ check we can read Fit2D mask with openimage"""
        obj = openimage(self.fname)
        obj2 = fit2dmaskimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testmaskgz(testmask):
    """openimage opening mccd gzip"""
    fname = "face.msk.gz"


class testmaskbz2(testmask):
    """openimage opening mccd bzip"""
    fname = "face.msk.bz2"


class testbruker(unittest.TestCase):
    """openimage opening bruker"""
    fname = "Cr8F8140k103.0026"

    def setUp(self):
        self.fname = UtilsTest.getimage(self.__class__.fname)

    def testcase(self):
        """ check we can read it"""
        obj = openimage(self.fname)
        obj2 = brukerimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testbrukergz(testbruker):
    """openimage opening bruker gzip"""
    fname = "Cr8F8140k103.0026.gz"

class testbrukerbz2(testbruker):
    """openimage opening bruker bzip"""
    fname = "Cr8F8140k103.0026.bz2"


class testadsc(unittest.TestCase):
    """openimage opening adsc"""
    fname = os.path.join("testimages", "mb_LP_1_001.img")

    def setUp(self):
        self.fname = UtilsTest.getimage("mb_LP_1_001.img.bz2")

    def testcase(self):
        """ check we can read it"""
        obj = openimage(self.fname)
        obj2 = adscimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testadscgz(testadsc):
    """openimage opening adsc gzip"""
    fname = os.path.join("testimages", "mb_LP_1_001.img.gz")


class testadscbz2(testadsc):
    """openimage opening adsc bzip"""
    fname = os.path.join("testimages", "mb_LP_1_001.img.bz2")


class testOXD(unittest.TestCase):
    """openimage opening adsc"""
    fname = "b191_1_9_1.img.bz2"

    def setUp(self):
        self.fname = UtilsTest.getimage(self.__class__.fname)[:-4]

    def testcase(self):
        """ check we can read OXD images with openimage"""
        obj = openimage(self.fname)
        obj2 = OXDimage()
        obj2.read(self.fname)
        self.assertEqual(obj.data[10, 10], obj2.data[10, 10])
        self.assertEqual(type(obj), type(obj2))
        self.assertEqual(abs(obj.data.astype(int) - obj2.data.astype(int)).sum(), 0)


class testOXDUNC(testOXD):
    """openimage opening oxd"""
    fname = "b191_1_9_1_uncompressed.img.bz2"

    def setUp(self):
        self.fname = UtilsTest.getimage(self.__class__.fname)[:-4]


def suite():
    testsuite = unittest.TestSuite()
    testsuite.addTest(testedfbz2("testcase"))
    testsuite.addTest(testopenedf("testcase"))
    testsuite.addTest(testedfgz("testcase"))

    testsuite.addTest(testmccdbz2("testcase"))
    testsuite.addTest(testopenmccd("testcase"))
    testsuite.addTest(testmccdgz("testcase"))

    testsuite.addTest(testmaskbz2("testcase"))
    testsuite.addTest(testmask("testcase"))
    testsuite.addTest(testmaskgz("testcase"))

    testsuite.addTest(testbrukerbz2("testcase"))
    testsuite.addTest(testbruker("testcase"))
    testsuite.addTest(testbrukergz("testcase"))

    testsuite.addTest(testadscbz2("testcase"))
    testsuite.addTest(testadsc("testcase"))
    testsuite.addTest(testadscgz("testcase"))

    testsuite.addTest(testOXD("testcase"))
    testsuite.addTest(testOXDUNC("testcase"))

    return testsuite

if __name__ == '__main__':
    runner = unittest.TextTestRunner()
    runner.run(suite())