|
@@ 138-151 (lines=14) @@
|
| 135 |
|
[0.4127191, 0.0270573], [0.1486231, 0.3121822], [0.2607670, 0.4886657], |
| 136 |
|
[0.7132257, 0.2827587], [0.4371954, 0.5660840], [0.1318544, 0.6468250], |
| 137 |
|
[0.6230519, 0.0682618], [0.5069460, 0.2326285], [0.1324301, 0.5609478], |
| 138 |
|
[0.7975495, 0.2109974], [0.7513574, 0.9870045], [0.9305814, 0.0685815], |
| 139 |
|
[0.5271641, 0.7276889], [0.8116574, 0.4795037], [0.7017868, 0.5875983], |
| 140 |
|
[0.5591604, 0.5579290], [0.1284860, 0.0968003], [0.2857064, 0.3862123]]) |
| 141 |
|
return xy |
| 142 |
|
|
| 143 |
|
|
| 144 |
|
@pytest.mark.parametrize('radius, truth', |
| 145 |
|
[(2.0, np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 146 |
|
0, 0, 0, 0, 0, 0, 0, 0, 0, 0], dtype=np.bool)), |
| 147 |
|
(1.0, np.array([1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, |
| 148 |
|
0, 0, 0, 0, 0, 0, 0, 0, 1, 0], dtype=np.bool)), |
| 149 |
|
(0.3, np.array([1, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, |
| 150 |
|
0, 0, 0, 0, 0, 1, 0, 0, 0, 0], dtype=np.bool)), |
| 151 |
|
(0.1, np.array([1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, |
| 152 |
|
0, 1, 1, 1, 1, 1, 1, 1, 1, 1], dtype=np.bool)) |
| 153 |
|
]) |
| 154 |
|
def test_reduce_point_density(thin_point_data, radius, truth): |
|
@@ 123-135 (lines=13) @@
|
| 120 |
|
([False, True, True, False, False], 3, 3), |
| 121 |
|
([False, True, True, True, True], None, None) |
| 122 |
|
]) |
| 123 |
|
def test_non_masked_elements(mask, expected_idx, expected_element): |
| 124 |
|
"""Test with a valid element.""" |
| 125 |
|
a = ma.masked_array(np.arange(5), mask=mask) |
| 126 |
|
idx, element = _next_non_masked_element(a, 1) |
| 127 |
|
assert idx == expected_idx |
| 128 |
|
assert element == expected_element |
| 129 |
|
|
| 130 |
|
|
| 131 |
|
@pytest.fixture |
| 132 |
|
def thin_point_data(): |
| 133 |
|
r"""Provide scattered points for testing.""" |
| 134 |
|
xy = np.array([[0.8793620, 0.9005706], [0.5382446, 0.8766988], [0.6361267, 0.1198620], |
| 135 |
|
[0.4127191, 0.0270573], [0.1486231, 0.3121822], [0.2607670, 0.4886657], |
| 136 |
|
[0.7132257, 0.2827587], [0.4371954, 0.5660840], [0.1318544, 0.6468250], |
| 137 |
|
[0.6230519, 0.0682618], [0.5069460, 0.2326285], [0.1324301, 0.5609478], |
| 138 |
|
[0.7975495, 0.2109974], [0.7513574, 0.9870045], [0.9305814, 0.0685815], |