From 16af5d95979147b3f0632032401994175939ca07 Mon Sep 17 00:00:00 2001 From: Jürgen Knödlseder Date: Fri, 28 Jul 2017 21:23:41 +0200 Subject: [PATCH] Add Python typemaps for GObservation::likelihood() output argument (#2126) --- ChangeLog | 1 + NEWS | 2 +- doc/source/admin/release_history/1.4.rst | 4 +++- inst/cta/pyext/GCTAOnOffObservation.i | 13 +++++++++++++ pyext/GObservation.i | 13 +++++++++++++ 5 files changed, 31 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9d7203c..6b05da4 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ Write response information into simulated observation definition file (#2170) Normalise phase curves by default (#2154, #2172) Support Python list slicing for container classes (#2128) + Add Python typemaps for GObservation::likelihood() output argument (#2126) Add GSkyRegions::overlaps() and GSkyMap::overlaps() classes (#1980) diff --git a/NEWS b/NEWS index c2b38bb..adadece 100644 --- a/NEWS +++ b/NEWS @@ -1,6 +1,6 @@ New Features and Important Changes in GammaLib 1.4.0 -27 July 2017 +28 July 2017 1. Introduction diff --git a/doc/source/admin/release_history/1.4.rst b/doc/source/admin/release_history/1.4.rst index a18a5c7..7a696d2 100644 --- a/doc/source/admin/release_history/1.4.rst +++ b/doc/source/admin/release_history/1.4.rst @@ -16,6 +16,9 @@ In particular, this release provides: Bug fixes --------- +* [`2126 `_] - + Add Python typemaps for ``GObservation::likelihood()`` output argument + Improvements ------------ @@ -37,6 +40,5 @@ New features Support Python list slicing for container classes - Clean up -------- diff --git a/inst/cta/pyext/GCTAOnOffObservation.i b/inst/cta/pyext/GCTAOnOffObservation.i index d1e124f..af4dde1 100644 --- a/inst/cta/pyext/GCTAOnOffObservation.i +++ b/inst/cta/pyext/GCTAOnOffObservation.i @@ -53,6 +53,19 @@ } +/* + * Convert double output argument from and into a Python float object. This + * typemap is needed for the likelihood() method. + */ +%typemap(in) double *npred (double temp) { + temp = PyFloat_AsDouble($input); + $1 = &temp; +} +%typemap(argout) double *npred { + $result = PyFloat_FromDouble(*$1); +} + + /***********************************************************************//** * @class GCTAOnOffObservation * diff --git a/pyext/GObservation.i b/pyext/GObservation.i index a27c1ea..9268d8a 100644 --- a/pyext/GObservation.i +++ b/pyext/GObservation.i @@ -32,6 +32,19 @@ #include "GTools.hpp" %} +/* __ Typemaps ___________________________________________________________ */ +/* + * Convert double output argument from and into a Python float object. This + * typemap is needed for the likelihood() method. + */ +%typemap(in) double *npred (double temp) { + temp = PyFloat_AsDouble($input); + $1 = &temp; +} +%typemap(argout) double *npred { + $result = PyFloat_FromDouble(*$1); +} + /***********************************************************************//** * @class GObservation -- libgit2 0.21.4