-
Notifications
You must be signed in to change notification settings - Fork 188
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
Fermi pulsar catalogs base class #5056
Conversation
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5056 +/- ##
==========================================
- Coverage 75.24% 75.11% -0.13%
==========================================
Files 232 234 +2
Lines 34318 34944 +626
==========================================
+ Hits 25822 26248 +426
- Misses 8496 8696 +200 ☔ View full report in Codecov by Sentry. |
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.
Thanks @MRegeard, maybe some of the code in the base class could be moved in private functions that can be redefined in the sub classes.
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
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.
Thanks @MRegeard ... In addition to my small comments, there is no dedicated test to these new functionalities?
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
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.
Thanks for the effort @MRegeard.
Do some tests need to be added for this?
Also a correction throughout: dictionnary --> dictionary
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.
Thanks @MRegeard . This is nice. I have left a number of comments inline
gammapy/catalog/core.py
Outdated
def _get_spectral_table_source_name_key(self): | ||
return self._source_name_key |
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.
This does not seem necessary. The result is longer than the direct call.
If this is there for daughter classes, maybe it could be a simple attribute rather than a function?
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 honestly cannot remember why I did that.
names = [_.strip() for _ in self.spectral_table[source_name_key]] | ||
idx = range(len(names)) | ||
return dict(zip(names, idx)) |
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 code is very similar between _lookup_spectral_source_idx
and _lookup_extended_source_idx
. It could be turned a single function taking either self.spectral_table[source_name_key]
or self.extended_sources_table[self._source_name_key]
as argument
Signed-off-by: Maxime Regeard <regeard@apc.in2p3.fr>
@Astro-Kirsty, I don't think test are needed because the base class is never other than by the daughter classes. So the tests happen in the daughter class. That is also the scheme for the other Fermi base class. |
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.
Thanks @MRegeard . Looks good to me.
Split of PR #4699. Here is the base class part.
This introduces a base class for object of the pulsar catalog of Fermi (both 2PC and 3PC).
The part where I modify the core class
SourceCatalog
could be extracted into another base class, saySourceCatalogPC
, but it will add another level of inheritance. I don't have a strong opinion on that.