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

Consistent random number handling and improve sample_sphere #283

Merged
merged 10 commits into from Jul 30, 2015

Conversation

Projects
None yet
2 participants
@mapazarr
Member

mapazarr commented Jul 21, 2015

~gammapy.utils.random.sample_sphere should use astropy Angle objects for better handling / less error prone.
TODO:

  • decide if we use Angle or Longitude and Latitude objects
  • update/revise other functions using sample_sphere
  • finish applying issue #238 (random_state parameters)

@mapazarr mapazarr changed the title from `~gammapy.utils.random.sample_sphere` should use `~astropy.Qauntity` objects to `~gammapy.utils.random.sample_sphere` should use `~astropy.Quantity` objects Jun 9, 2015

@cdeil cdeil added the cleanup label Jun 10, 2015

@cdeil cdeil added this to the 0.3 milestone Jun 10, 2015

@cdeil cdeil changed the title from `~gammapy.utils.random.sample_sphere` should use `~astropy.Quantity` objects to sample_sphere should use Quantity objects Jun 10, 2015

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 10, 2015

Member

@mapazarr - I assigned this issue to you. And I shortened the title and removed the RST markup, which is not supported in Github issue titles. The goal should be that https://github.com/gammapy/gammapy/issues and https://gammapy.readthedocs.org/en/latest/changelog.html#id4 look nice if I just copy & paste the PR titles.

Member

cdeil commented Jun 10, 2015

@mapazarr - I assigned this issue to you. And I shortened the title and removed the RST markup, which is not supported in Github issue titles. The goal should be that https://github.com/gammapy/gammapy/issues and https://gammapy.readthedocs.org/en/latest/changelog.html#id4 look nice if I just copy & paste the PR titles.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jun 10, 2015

Member

It can also be useful to link to docs / source code in the issue description, in this case to gammapy.utils.random.sample_sphere, which I typed as

[gammapy.utils.random.sample_sphere](https://gammapy.readthedocs.org/en/latest/api/gammapy.utils.random.sample_sphere.html)

To be more specific, this function should probably use astropy.coordinates.Longitude and astropy.coordinates.Latitude objects, which are Quantity sub-classes.

Member

cdeil commented Jun 10, 2015

It can also be useful to link to docs / source code in the issue description, in this case to gammapy.utils.random.sample_sphere, which I typed as

[gammapy.utils.random.sample_sphere](https://gammapy.readthedocs.org/en/latest/api/gammapy.utils.random.sample_sphere.html)

To be more specific, this function should probably use astropy.coordinates.Longitude and astropy.coordinates.Latitude objects, which are Quantity sub-classes.

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 21, 2015

Member

Implemented. Merge?

Member

mapazarr commented Jul 21, 2015

Implemented. Merge?

@cdeil cdeil assigned cdeil and unassigned mapazarr Jul 21, 2015

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jul 21, 2015

Member

I'd prefer it if we use the more explicit Longitude and Latitude objects from astropy.coordinates.
They have convenience methods for angle wrapping.
I've never used them much, so if that doesn't work well for some reason, please at least use Angle objects.

Member

cdeil commented Jul 21, 2015

I'd prefer it if we use the more explicit Longitude and Latitude objects from astropy.coordinates.
They have convenience methods for angle wrapping.
I've never used them much, so if that doesn't work well for some reason, please at least use Angle objects.

Show outdated Hide outdated gammapy/utils/random.py Outdated
Show outdated Hide outdated gammapy/utils/random.py Outdated
Show outdated Hide outdated gammapy/utils/random.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jul 21, 2015

Member

Can you please look at the tests for this function and see if they cover the common and some edge cases well, and if not, please add a test or two?

Member

cdeil commented Jul 21, 2015

Can you please look at the tests for this function and see if they cover the common and some edge cases well, and if not, please add a test or two?

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 22, 2015

Member

Sorry, I missed the Longitude Latitude part of the comment. I tried to use them, but it's not straightforward (the function call in the test returns (0, 0)), and would need deeper debugging, for which I have no time right now. Indeed, Angle would be much more appropriate as Quantity. I am using Angle right now.

Member

mapazarr commented Jul 22, 2015

Sorry, I missed the Longitude Latitude part of the comment. I tried to use them, but it's not straightforward (the function call in the test returns (0, 0)), and would need deeper debugging, for which I have no time right now. Indeed, Angle would be much more appropriate as Quantity. I am using Angle right now.

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 22, 2015

Member

I added a few more tests.

Member

mapazarr commented Jul 22, 2015

I added a few more tests.

Show outdated Hide outdated gammapy/utils/tests/test_random.py Outdated
Show outdated Hide outdated gammapy/utils/tests/test_random.py Outdated
Show outdated Hide outdated gammapy/utils/random.py Outdated
Show outdated Hide outdated CHANGES.rst Outdated

@mapazarr mapazarr changed the title from sample_sphere should use Quantity objects to sample_sphere should use Angle objects Jul 23, 2015

@mapazarr mapazarr changed the title from sample_sphere should use Angle objects to Change sample_sphere to use Angle objects Jul 23, 2015

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 23, 2015

Member

Ok, the new version uses Longitude and Latitude, but please look at my comments and the TODO list I just added at the beginning of the issue.

#283 (comment)
#283 (comment)

Member

mapazarr commented Jul 23, 2015

Ok, the new version uses Longitude and Latitude, but please look at my comments and the TODO list I just added at the beginning of the issue.

#283 (comment)
#283 (comment)

Show outdated Hide outdated gammapy/utils/tests/test_random.py Outdated
@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 29, 2015

Member

I am applying the fixes for issue #238 here. I started adding random_state parameters to some of the functions, and added the entry in the high-level doc.

Member

mapazarr commented Jul 29, 2015

I am applying the fixes for issue #238 here. I started adding random_state parameters to some of the functions, and added the entry in the high-level doc.

Show outdated Hide outdated CHANGES.rst Outdated

@mapazarr mapazarr changed the title from Change sample_sphere to use Angle objects to Consistent random number handling and improve sample_sphere Jul 30, 2015

@mapazarr

This comment has been minimized.

Show comment
Hide comment
@mapazarr

mapazarr Jul 30, 2015

Member

@cdeil I am done with this PR. Ready for final review and evtly. merge.

Member

mapazarr commented Jul 30, 2015

@cdeil I am done with this PR. Ready for final review and evtly. merge.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jul 30, 2015

Member

Thanks!

Member

cdeil commented Jul 30, 2015

Thanks!

cdeil added a commit that referenced this pull request Jul 30, 2015

Merge pull request #283 from mapazarr/sample_sphere_cleanup
Consistent random number handling and improve sample_sphere

@cdeil cdeil merged commit 4504ec0 into gammapy:master Jul 30, 2015

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil Jul 30, 2015

Member

I'm continuing with this a bit in #310.

Member

cdeil commented Jul 30, 2015

I'm continuing with this a bit in #310.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment