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

Add ObservationTableSummary class #531

Merged
merged 9 commits into from May 19, 2016

Conversation

Projects
None yet
3 participants
@jjlk
Contributor

jjlk commented May 18, 2016

Hi,
This is my first pull request as we discussed with @cdeil. Adding a new class to summarize and plots the content of an ObservationTable. The test part will come later.

@cdeil cdeil added the feature label May 18, 2016

@cdeil cdeil added this to the 0.5 milestone May 18, 2016

@cdeil cdeil self-assigned this May 18, 2016

Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 18, 2016

Member

@jjlk - Thanks!

It mostly looks good ... I've left a bunch of minor inline comments.
I would prefer if you add tests in this PR instead of a follow-up PR.
OK?

Member

cdeil commented May 18, 2016

@jjlk - Thanks!

It mostly looks good ... I've left a bunch of minor inline comments.
I would prefer if you add tests in this PR instead of a follow-up PR.
OK?

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 18, 2016

Contributor

Yes, I'm working on it! I will add the tests in this request.

Contributor

jjlk commented May 18, 2016

Yes, I'm working on it! I will add the tests in this request.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 18, 2016

Member

I will add the tests in this request.

Thanks!

Note that you have to leave a comment here if you want me to have another look.
Github doesn't send notifications if someone pushes extra commits to a pull request (PR).

Member

cdeil commented May 18, 2016

I will add the tests in this request.

Thanks!

Note that you have to leave a comment here if you want me to have another look.
Github doesn't send notifications if someone pushes extra commits to a pull request (PR).

Fix doc format, add property to offset function, raise exception for …
…to be implemented function and add default binning for plots
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 18, 2016

Contributor

Hi, I pushed the test functions and I made the offset function public. Tell me if it's ok for you ++

Contributor

jjlk commented May 18, 2016

Hi, I pushed the test functions and I made the offset function public. Tell me if it's ok for you ++

@property
def offset(self):
"""

This comment has been minimized.

@cdeil

cdeil May 18, 2016

Member

For this I would suggest a shorter docstring as described here:
http://docs.gammapy.org/en/latest/development/howto.html#functions-or-class-methods-that-return-a-single-object

@property
def offset(self):
    """Offset of observations relative to the target position (`astropy.coordinates.Angle`)."""
@cdeil

cdeil May 18, 2016

Member

For this I would suggest a shorter docstring as described here:
http://docs.gammapy.org/en/latest/development/howto.html#functions-or-class-methods-that-return-a-single-object

@property
def offset(self):
    """Offset of observations relative to the target position (`astropy.coordinates.Angle`)."""
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
return ax
def __str__(self):

This comment has been minimized.

@cdeil

cdeil May 18, 2016

Member

Please add a test for __str__.
It should look something like this:

def test_str(self):

The main point is to call str(obs_summary) somewhere to execute this.
Otherwise what will happen for such code that isn't covered is that someone changes the class and this method breaks.
It would be nice to have an assert, it could just be this:

text = str(obs_table)
assert 'Summary report' in text

although if you want to assert on more or other parts of the text, that's fine as well of course.

@cdeil

cdeil May 18, 2016

Member

Please add a test for __str__.
It should look something like this:

def test_str(self):

The main point is to call str(obs_summary) somewhere to execute this.
Otherwise what will happen for such code that isn't covered is that someone changes the class and this method breaks.
It would be nice to have an assert, it could just be this:

text = str(obs_table)
assert 'Summary report' in text

although if you want to assert on more or other parts of the text, that's fine as well of course.

Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 18, 2016

Member

@jjlk - I've done another round of inline comments. A bunch of little stuff, nothing major.

Member

cdeil commented May 18, 2016

@jjlk - I've done another round of inline comments. A bunch of little stuff, nothing major.

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 19, 2016

Contributor

Hi @cdeil, sorry for the tests, in fact they weren't done on my machine. I fixed the problems and I took into account your comments. Is it ok now ?

Contributor

jjlk commented May 19, 2016

Hi @cdeil, sorry for the tests, in fact they weren't done on my machine. I fixed the problems and I took into account your comments. Is it ok now ?

Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 19, 2016

Member

I've done a final review. My main comment is that you should use a pytest fixture.
This is a bit magical Python code ... it works because pytest is running the tests, not normal Python.

Once that change is made, this is ready to be merged.

Member

cdeil commented May 19, 2016

I've done a final review. My main comment is that you should use a pytest fixture.
This is a bit magical Python code ... it works because pytest is running the tests, not normal Python.

Once that change is made, this is ready to be merged.

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 19, 2016

Contributor

Thanks @cdeil, job done !

Contributor

jjlk commented May 19, 2016

Thanks @cdeil, job done !

Show outdated Hide outdated gammapy/data/observation_summary.py Outdated
@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 19, 2016

Contributor

@cdeil: ok done.

Contributor

jjlk commented May 19, 2016

@cdeil: ok done.

If None, uses the current `~matplotlib.axes.Axes`.
bins : integer or array_like, optional
Binning specification, passed to `matplotlib.pyplot.hist`.
By default, 30 bins from 0 deg to max zenith + 5 deg is used.

This comment has been minimized.

@cdeil

cdeil May 19, 2016

Member

Copy & paste error ... describe offset binning here.

@cdeil

cdeil May 19, 2016

Member

Copy & paste error ... describe offset binning here.

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 19, 2016

Member

Very close now ... :-)

Member

cdeil commented May 19, 2016

Very close now ... :-)

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 19, 2016

Member

About the @requires_data('gammapy-extra') decorator I was mistaken.
This now fails in continuous integration:
https://ci.appveyor.com/project/cdeil/gammapy/build/1.0.656/job/4hwmk6j8u9v0a832#L1095
Apparently it has to be added to every test function that accesses data from gammapy-extra, not just the fixture. I'll try to fix this at some point, but for now, please add the decorator back to all your tests.
Sorry for misleading you there ...

Member

cdeil commented May 19, 2016

About the @requires_data('gammapy-extra') decorator I was mistaken.
This now fails in continuous integration:
https://ci.appveyor.com/project/cdeil/gammapy/build/1.0.656/job/4hwmk6j8u9v0a832#L1095
Apparently it has to be added to every test function that accesses data from gammapy-extra, not just the fixture. I'll try to fix this at some point, but for now, please add the decorator back to all your tests.
Sorry for misleading you there ...

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 19, 2016

Contributor

@cdeil: I guess that this is the one !

Contributor

jjlk commented May 19, 2016

@cdeil: I guess that this is the one !

@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 19, 2016

Member

Looks good.
Merging this now.

Congratulations on your patience with the code review!
😄

Member

cdeil commented May 19, 2016

Looks good.
Merging this now.

Congratulations on your patience with the code review!
😄

@cdeil cdeil merged commit 398ebe1 into gammapy:master May 19, 2016

0 of 2 checks passed

continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
@cdeil

This comment has been minimized.

Show comment
Hide comment
@cdeil

cdeil May 19, 2016

Member

Just to wrap this up:

I use https://www.jetbrains.com/pycharm/ as Python IDE and I can recommend it. It has a free edition. It points out errors and completions as you type, has nice code navigation features and does such cleanup by pressing a shortcut.

Member

cdeil commented May 19, 2016

Just to wrap this up:

I use https://www.jetbrains.com/pycharm/ as Python IDE and I can recommend it. It has a free edition. It points out errors and completions as you type, has nice code navigation features and does such cleanup by pressing a shortcut.

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 20, 2016

Contributor

Hi @cdeil, thanks for correcting the typos and for the tips.

Contributor

jjlk commented May 20, 2016

Hi @cdeil, thanks for correcting the typos and for the tips.

@joleroi

This comment has been minimized.

Show comment
Hide comment
Contributor

joleroi commented May 20, 2016

@jjlk

This comment has been minimized.

Show comment
Hide comment
@jjlk

jjlk May 20, 2016

Contributor

@joleroi
I'm emacs-biased =). So I might have a try to this one https://github.com/jorgenschaefer/elpy

Contributor

jjlk commented May 20, 2016

@joleroi
I'm emacs-biased =). So I might have a try to this one https://github.com/jorgenschaefer/elpy

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