Feature #833
Add functions to public Gammalib API
Status: | Closed | Start date: | 04/12/2013 | ||
---|---|---|---|---|---|
Priority: | Normal | Due date: | |||
Assigned To: | Knödlseder Jürgen | % Done: | 50% | ||
Category: | - | ||||
Target version: | 00-08-00 | ||||
Duration: |
Description
As discussed in issues #558 and #832, the gammalib API will contain functions (currently it only contains classes).
Here’s an example of a function that should be available, as it’s used all the time for gamma-ray data analysis:
https://github.com/cdeil/gammalib/compare/significance
- Decide on naming convention for functions and how to expose them in C++ (namespace or prefix).
- Expose the function in Python (add Swig wrapper)
- Document function coding conventions.
For the Li & Ma significance function specifically I can write unit tests (I just adapted some Python code I had, I didn’t even check yet if it works).
Recurrence
No recurrence.
Subtasks
History
#1 Updated by Deil Christoph over 11 years ago
In the significance
branch I linked to the li_ma_significance
function works:
In [3]: gammalib.li_ma_significance(10, 20, 0.1) Out[3]: 3.6850322319420274
I’ll now try to put it in a gamma
namespace and see if the Makefiles work.
#2 Updated by Knödlseder Jürgen over 11 years ago
- % Done changed from 0 to 10
I just wrote up a Naming conventions draft in the Wiki.
#3 Updated by Knödlseder Jürgen over 11 years ago
- Target version set to 00-08-00
#4 Updated by Knödlseder Jürgen over 11 years ago
Christoph Deil wrote:
TODOs:
- Decide on naming convention for functions and how to expose them in C++ (namespace or prefix).
- Expose the function in Python (add Swig wrapper)
- Document function coding conventions.
TODOs are “Actions” in the Redmine tracker that are appended to a feature. Just created these actions, can now be easily see in the Agile taskboard: https://cta-redmine.irap.omp.eu/rb/taskboards/23
#5 Updated by Deil Christoph over 11 years ago
I just updated https://github.com/cdeil/gammalib/compare/significance .
It was just for me to play around with tough ... we don’t have to merge it.
I can add this function properly once the functions in gammalib issues have been decided.
One question I have is whether e.g. the gammln
function in GNumerics
should be in the gammalib
namespace and if it should be part of the public GammaLib API. I think it currently is included by GammaLib.hpp
, but maybe it shouldn’t, because it is an internal implementation detail?
#6 Updated by Knödlseder Jürgen over 11 years ago
I would make it public using the gammalib
namespace, as somebody may need it for his own calculations. For the moment there is just a single function in GNumerics
, but the idea was to add more ... (for example your Li and Ma function).
#7 Updated by Knödlseder Jürgen over 11 years ago
Created branch function-namespace
where all GTools
constants are now in gammalib
namespace.
Port now the GTools
into the gammalib
namespace.
#8 Updated by Knödlseder Jürgen over 11 years ago
Christoph Deil wrote:
I just updated https://github.com/cdeil/gammalib/compare/significance .
It was just for me to play around with tough ... we don’t have to merge it.
I can add this function properly once the functions in gammalib issues have been decided.One question I have is whether e.g. the
gammln
function inGNumerics
should be in thegammalib
namespace and if it should be part of the public GammaLib API. I think it currently is included byGammaLib.hpp
, but maybe it shouldn’t, because it is an internal implementation detail?
I now placed all constants and functions in the gammalib
namespace. Pushed in devel
.
You may now add your function, the only question being: where? In fact, I renamed GNumerics
to GMath
, as the only function that was in there was an elementary mathematical functions. I also added a bunch of other mathematical functions that were in GTools
and GWcslib
, so that they are now centralized. I also moved all mathematical constants from GTools
to GMath
.
The Li and Ma function would not be a mathematical function. It could go in GTools
(there are still other functions in there, mostly string and conversion function, but also functions for analytical power law integrations, for example).
#9 Updated by Knödlseder Jürgen over 11 years ago
- Status changed from In Progress to Feedback
#10 Updated by Deil Christoph over 11 years ago
Is it possible to make the C++ and Python API consistent by putting the functions and constants also in a gammalib namespace?
At the moment they are in the top-level namespace (and not reachable via `from gammalib import *` I believe):
```
In [8]: import gammalib
In [9]: gammalib.gammln(42)
Out9: 114.03421178150786
In [10]: gammalib.gammalib
Out10: <module 'gammalib’ from '/usr/local/gamma/lib/python2.7/site-packages/gammalib/__init__.pyc’>
```
#11 Updated by Knödlseder Jürgen over 11 years ago
Christoph Deil wrote:
Is it possible to make the C++ and Python API consistent by putting the functions and constants also in a gammalib namespace?
At the moment they are in the top-level namespace (and not reachable via `from gammalib import *` I believe):
```
In [8]: import gammalibIn [9]: gammalib.gammln(42)
Out9: 114.03421178150786In [10]: gammalib.gammalib
Out10: <module 'gammalib’ from '/usr/local/gamma/lib/python2.7/site-packages/gammalib/__init__.pyc’>
```
This is done now, and merged in the devel
branch. Have a look at the new matrix_howto.py
file in the examples/python
folder to see this at work.
#12 Updated by Knödlseder Jürgen almost 11 years ago
- Status changed from Feedback to Closed
- Assigned To set to Knödlseder Jürgen