/usr/lib/python3/dist-packages/photutils/utils/tests/test_cutouts.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 | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
import numpy as np
from numpy.testing import assert_allclose
from astropy.tests.helper import pytest
from ..cutouts import cutout_footprint
XCS = [25.7]
YCS = [26.2]
XSTDDEVS = [3.2, 4.0]
YSTDDEVS = [5.7, 4.1]
THETAS = np.array([30., 45.]) * np.pi / 180.
DATA = np.zeros((3, 3))
DATA[0:2, 1] = 1.
DATA[1, 0:2] = 1.
DATA[1, 1] = 2.
class TestCutoutFootprint(object):
def test_dataonly(self):
data = np.ones((5, 5))
position = (2, 2)
result1 = cutout_footprint(data, position, 3)
result2 = cutout_footprint(data, position, footprint=np.ones((3, 3)))
assert_allclose(result1[:-2], result2[:-2])
assert result1[-2] is None
assert result2[-2] is None
assert result1[-1] == result2[-1]
def test_mask_error(self):
data = error = np.ones((5, 5))
mask = np.zeros_like(data, dtype=bool)
position = (2, 2)
box_size1 = 3
box_size2 = (3, 3)
footprint = np.ones((3, 3))
result1 = cutout_footprint(data, position, box_size1, mask=mask,
error=error)
result2 = cutout_footprint(data, position, box_size2, mask=mask,
error=error)
result3 = cutout_footprint(data, position, box_size1,
footprint=footprint, mask=mask,
error=error)
assert_allclose(result1[:-1], result2[:-1])
assert_allclose(result1[:-1], result3[:-1])
assert result1[-1] == result2[-1]
def test_position_len(self):
with pytest.raises(ValueError):
cutout_footprint(np.ones((3, 3)), [1])
def test_nofootprint(self):
with pytest.raises(ValueError):
cutout_footprint(np.ones((3, 3)), (1, 1), box_size=None,
footprint=None)
def test_wrongboxsize(self):
with pytest.raises(ValueError):
cutout_footprint(np.ones((3, 3)), (1, 1), box_size=(1, 2, 3))
|