This file is indexed.

/usr/lib/python3/dist-packages/photutils/detection/tests/test_findstars.py is in python3-photutils 0.3-3.

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
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
                        unicode_literals)
import os.path as op
import itertools
import warnings

import numpy as np
from numpy.testing import assert_allclose
from astropy.tests.helper import pytest, catch_warnings
from astropy.table import Table
from astropy.utils.exceptions import AstropyUserWarning
from astropy.utils.exceptions import AstropyDeprecationWarning

from ..findstars import daofind, irafstarfind
from ..findstars import DAOStarFinder, IRAFStarFinder
from ...datasets import make_100gaussians_image

try:
    import scipy
    HAS_SCIPY = True
except ImportError:
    HAS_SCIPY = False

try:
    import skimage
    HAS_SKIMAGE = True
except ImportError:
    HAS_SKIMAGE = False


DATA = make_100gaussians_image()
THRESHOLDS = [8.0, 10.0]
FWHMS = [1.0, 1.5, 2.0]
warnings.simplefilter('always', AstropyUserWarning)


@pytest.mark.skipif('not HAS_SCIPY')
@pytest.mark.skipif('not HAS_SKIMAGE')
class TestDAOStarFinder(object):
    @pytest.mark.parametrize(('threshold', 'fwhm'),
                             list(itertools.product(THRESHOLDS, FWHMS)))
    def test_daofind(self, threshold, fwhm):
        starfinder = DAOStarFinder(threshold, fwhm, sigma_radius=1.5)
        t = starfinder(DATA)
        datafn = ('daofind_test_thresh{0:04.1f}_fwhm{1:04.1f}'
                  '.txt'.format(threshold, fwhm))
        datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn)
        t_ref = Table.read(datafn, format='ascii')
        assert_allclose(np.array(t).astype(np.float),
                        np.array(t_ref).astype(np.float))

    # test for the deprecated daofind
    @pytest.mark.parametrize(('threshold', 'fwhm'),
                             list(itertools.product(THRESHOLDS, FWHMS)))
    def test_dep_daofind(self, threshold, fwhm):
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(DATA, threshold, fwhm, sigma_radius=1.5)
        datafn = ('daofind_test_thresh{0:04.1f}_fwhm{1:04.1f}'
                  '.txt'.format(threshold, fwhm))
        datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn)
        t_ref = Table.read(datafn, format='ascii')
        assert_allclose(np.array(t).astype(np.float),
                        np.array(t_ref).astype(np.float))

    def test_daofind_include_border(self):
        starfinder = DAOStarFinder(threshold=10, fwhm=2, sigma_radius=1.5,
                                   exclude_border=False)
        t = starfinder(DATA)
        assert len(t) == 20

    # test for the deprecated daofind
    def test_dep_daofind_include_border(self):
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(DATA, threshold=10, fwhm=2, sigma_radius=1.5,
                        exclude_border=False)
        assert len(t) == 20

    def test_daofind_exclude_border(self):
        starfinder = DAOStarFinder(threshold=10, fwhm=2, sigma_radius=1.5,
                                   exclude_border=True)
        t = starfinder(DATA)
        assert len(t) == 19

    # test for the deprecated daofind
    def test_dep_daofind_exclude_border(self):
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(DATA, threshold=10, fwhm=2, sigma_radius=1.5,
                        exclude_border=True)
        assert len(t) == 19

    def test_daofind_nosources(self):
        data = np.ones((3, 3))
        starfinder = DAOStarFinder(threshold=10, fwhm=1)
        t = starfinder(data)
        assert len(t) == 0

    # test for the deprecated daofind
    def test_dep_daofind_nosources(self):
        data = np.ones((3, 3))
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(data, threshold=10, fwhm=1)
        assert len(t) == 0

    def test_daofind_sharpness(self):
        """Sources found, but none pass the sharpness criteria."""
        starfinder = DAOStarFinder(threshold=50, fwhm=1.0, sharplo=1.)
        t = starfinder(DATA)
        assert len(t) == 0

    # test for the deprecated daofind
    def test_dep_daofind_sharpness(self):
        """Sources found, but none pass the sharpness criteria."""
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(DATA, threshold=50, fwhm=1.0, sharplo=1.)
        assert len(t) == 0

    def test_daofind_roundness(self):
        """Sources found, but none pass the roundness criteria."""
        starfinder = DAOStarFinder(threshold=50, fwhm=1.0, roundlo=1.)
        t = starfinder(DATA)
        assert len(t) == 0

    # test for the deprecated daofind
    def test_dep_daofind_roundness(self):
        """Sources found, but none pass the roundness criteria."""
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(DATA, threshold=50, fwhm=1.0, roundlo=1.)
        assert len(t) == 0

    def test_daofind_flux_negative(self):
        """Test handling of negative flux (here created by large sky)."""
        data = np.ones((5, 5))
        data[2, 2] = 10.
        starfinder = DAOStarFinder(threshold=0.1, fwhm=1.0, sky=10)
        t = starfinder(data)
        assert not np.isfinite(t['mag'])

    # test for the deprecated daofind
    def test_dep_daofind_flux_negative(self):
        """Test handling of negative flux (here created by large sky)."""
        data = np.ones((5, 5))
        data[2, 2] = 10.
        with catch_warnings(AstropyDeprecationWarning):
            t = daofind(data, threshold=0.1, fwhm=1.0, sky=10)
        assert not np.isfinite(t['mag'])


@pytest.mark.skipif('not HAS_SCIPY')
@pytest.mark.skipif('not HAS_SKIMAGE')
class TestIRAFStarFinder(object):
    @pytest.mark.parametrize(('threshold', 'fwhm'),
                             list(itertools.product(THRESHOLDS, FWHMS)))
    def test_irafstarfind(self, threshold, fwhm):
        starfinder = IRAFStarFinder(threshold, fwhm, sigma_radius=1.5)
        t = starfinder(DATA)
        datafn = ('irafstarfind_test_thresh{0:04.1f}_fwhm{1:04.1f}'
                  '.txt'.format(threshold, fwhm))
        datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn)
        t_ref = Table.read(datafn, format='ascii')
        assert_allclose(np.array(t).astype(np.float),
                        np.array(t_ref).astype(np.float))

    # test for the deprecated irafstarfind
    @pytest.mark.parametrize(('threshold', 'fwhm'),
                             list(itertools.product(THRESHOLDS, FWHMS)))
    def test_dep_irafstarfind(self, threshold, fwhm):
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(DATA, threshold, fwhm, sigma_radius=1.5)
        datafn = ('irafstarfind_test_thresh{0:04.1f}_fwhm{1:04.1f}'
                  '.txt'.format(threshold, fwhm))
        datafn = op.join(op.dirname(op.abspath(__file__)), 'data', datafn)
        t_ref = Table.read(datafn, format='ascii')
        assert_allclose(np.array(t).astype(np.float),
                        np.array(t_ref).astype(np.float))

    def test_irafstarfind_nosources(self):
        data = np.ones((3, 3))
        starfinder = IRAFStarFinder(threshold=10, fwhm=1)
        t = starfinder(data)
        assert len(t) == 0

    # test for the deprecated irafstarfind
    def test_dep_irafstarfind_nosources(self):
        data = np.ones((3, 3))
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(data, threshold=10, fwhm=1)
        assert len(t) == 0

    def test_irafstarfind_sharpness(self):
        """Sources found, but none pass the sharpness criteria."""
        starfinder = IRAFStarFinder(threshold=50, fwhm=1.0, sharplo=2.)
        t = starfinder(DATA)
        assert len(t) == 0

    # test for the deprecated irafstarfind
    def test_dep_irafstarfind_sharpness(self):
        """Sources found, but none pass the sharpness criteria."""
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(DATA, threshold=50, fwhm=1.0, sharplo=2.)
        assert len(t) == 0

    def test_irafstarfind_roundness(self):
        """Sources found, but none pass the roundness criteria."""
        starfinder = IRAFStarFinder(threshold=50, fwhm=1.0, roundlo=1.)
        t = starfinder(DATA)
        assert len(t) == 0

    # test for the deprecated irafstarfind
    def test_dep_irafstarfind_roundness(self):
        """Sources found, but none pass the roundness criteria."""
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(DATA, threshold=50, fwhm=1.0, roundlo=1.)
        assert len(t) == 0

    def test_irafstarfind_sky(self):
        starfinder = IRAFStarFinder(threshold=25.0, fwhm=2.0, sky=10.)
        t = starfinder(DATA)
        assert len(t) == 4

    # test for the deprecated irafstarfind
    def test_dep_irafstarfind_sky(self):
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(DATA, threshold=25.0, fwhm=2.0, sky=10.)
        assert len(t) == 4

    def test_irafstarfind_largesky(self):
        starfinder = IRAFStarFinder(threshold=25.0, fwhm=2.0, sky=100.)
        t = starfinder(DATA)
        assert len(t) == 0

    # test for the deprecated irafstarfind
    def test_dep_irafstarfind_largesky(self):
        with catch_warnings(AstropyDeprecationWarning):
            t = irafstarfind(DATA, threshold=25.0, fwhm=2.0, sky=100.)
        assert len(t) == 0