-
-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement compound regions #26
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason I had operator in the center is because it makes it clearer how to deal with non-symmetric cases (e.g. region 1 without region 2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a bug (e.g. https://github.com/astropy/regions/blob/master/regions/core/core.py#L67) . It was just easier to change this line instead of all the others .. Do you need the operator in the middle?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I see - I personally think it would make it more readable, but up to you :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm more the RPN guy, you know 😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
😆