From 95b8927151da4174b38a094bc08ec76a32d53b97 Mon Sep 17 00:00:00 2001 From: Craig Macdonald Date: Sun, 17 Feb 2019 14:49:31 +0000 Subject: [PATCH] support matching scores as ints (#7) * support matching scores as ints * Update pytrec_eval.cpp --- src/pytrec_eval.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/pytrec_eval.cpp b/src/pytrec_eval.cpp index e45bb50..c258684 100644 --- a/src/pytrec_eval.cpp +++ b/src/pytrec_eval.cpp @@ -273,14 +273,14 @@ class ResultRankingBuilder : public RankingBuildersim = PyFloat_AsDouble(inner_value); + } else if (PyLong_Check(inner_value)) { + pair->sim = PyLong_AsDouble(inner_value); + } else { + PyErr_SetString(PyExc_TypeError, "Expected matching score to be int, long or float."); + return false; } - - pair->sim = PyFloat_AsDouble(inner_value); - return true; } };