-
-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #26 from joleroi/compound
Implement compound regions
- Loading branch information
Showing
11 changed files
with
114 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Licensed under a 3-clause BSD style license - see LICENSE.rst | ||
""" | ||
This packages contains affiliated package tests. | ||
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
[run] | ||
source = {packagename} | ||
omit = | ||
{packagename}/_astropy_init* | ||
{packagename}/conftest* | ||
{packagename}/cython_version* | ||
{packagename}/setup_package* | ||
{packagename}/*/setup_package* | ||
{packagename}/*/*/setup_package* | ||
{packagename}/tests/* | ||
{packagename}/*/tests/* | ||
{packagename}/*/*/tests/* | ||
{packagename}/version* | ||
|
||
[report] | ||
exclude_lines = | ||
# Have to re-enable the standard pragma | ||
pragma: no cover | ||
|
||
# Don't complain about packages we have installed | ||
except ImportError | ||
|
||
# Don't complain if tests don't hit assertions | ||
raise AssertionError | ||
raise NotImplementedError | ||
|
||
# Don't complain about script hooks | ||
def main\(.*\): | ||
|
||
# Ignore branches that don't pertain to this version of Python | ||
pragma: py{ignore_python_version} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import astropy.units as u | ||
from astropy.coordinates import SkyCoord | ||
|
||
from regions.shapes import CircleSkyRegion | ||
|
||
|
||
def test_compound(): | ||
|
||
skycoord1 = SkyCoord(0 * u.deg, 0 * u.deg, frame='galactic') | ||
c1 = CircleSkyRegion(skycoord1, 1 * u.deg) | ||
|
||
skycoord2 = SkyCoord(1 * u.deg, 1 * u.deg, frame='galactic') | ||
c2 = CircleSkyRegion(skycoord2, 0.5 * u.deg) | ||
|
||
test_coord1 = SkyCoord(1.2 * u.deg, 1.2 * u.deg, frame='galactic') | ||
test_coord2 = SkyCoord(0.5 * u.deg, 0.5 * u.deg, frame='galactic') | ||
test_coord3 = SkyCoord(0.7 * u.deg, 0.7 * u.deg, frame='galactic') | ||
test_coord4 = SkyCoord(2 * u.deg, 5 * u.deg, frame='galactic') | ||
|
||
assert test_coord1 in c2 and test_coord1 not in c1 | ||
assert test_coord2 not in c2 and test_coord2 in c1 | ||
assert test_coord3 in c1 and test_coord3 in c2 | ||
assert test_coord4 not in c2 and test_coord4 not in c1 | ||
|
||
coords = SkyCoord([test_coord1, test_coord2, test_coord3, test_coord4], frame='galactic') | ||
|
||
union = c1 | c2 | ||
assert (union.contains(coords) == [True, True, True, False]).all() | ||
|
||
intersection = c1 & c2 | ||
assert (intersection.contains(coords) == [False, False, True, False]).all() | ||
|
||
diff = c1 ^ c2 | ||
assert (diff.contains(coords) == [True, True, False, False]).all() | ||
|
||
|
||
c3 = CircleSkyRegion(test_coord4, 0.1 * u.deg) | ||
|
||
union = c1 | c2 | c3 | ||
assert (union.contains(coords) == [True, True, True, True]).all() | ||
|
||
intersection = c1 & c2 & c3 | ||
assert (intersection.contains(coords) == [False, False, False, False]).all() | ||
|
||
diff = c1 ^ c2 ^ c3 | ||
assert (diff.contains(coords) == [True, True, False, True]).all() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters