/usr/lib/python3/dist-packages/photutils/utils/tests/test_stats.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 | # 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 ..stats import std_blocksum
from ...datasets import make_noise_image
def test_std_blocksum():
stddev = 5
data = make_noise_image((100, 100), mean=0, stddev=stddev,
random_state=12345)
block_sizes = np.array([5, 7, 10])
stds = std_blocksum(data, block_sizes)
expected = np.array([stddev, stddev, stddev])
assert_allclose(stds / block_sizes, expected, atol=0.2)
mask = np.zeros_like(data, dtype=np.bool)
mask[25:50, 25:50] = True
stds2 = std_blocksum(data, block_sizes, mask=mask)
assert_allclose(stds2 / block_sizes, expected, atol=0.3)
def test_std_blocksum_mask_shape():
with pytest.raises(ValueError):
data = np.ones((10, 10))
mask = np.ones((2, 2))
std_blocksum(data, 10, mask=mask)
|