cvangysel / pytrec_eval

pytrec_eval is an Information Retrieval evaluation tool for Python, based on the popular trec_eval.
http://ilps.science.uva.nl/
MIT License
290 stars 32 forks source link

Matching scores cannot be ints #6

Closed cmacdonald closed 5 years ago

cmacdonald commented 6 years ago

This works evaluator.evaluate({'151': {'clueweb09-en0027-05-20087': float(10000)}}) This does not: evaluator.evaluate({'151': {'clueweb09-en0027-05-20087': 10000}})

There's no valid reason why a matching score cannot be an int, so I think the check at https://github.com/cvangysel/pytrec_eval/blob/6440d7e07ef18443a7423e531368091aac474eb5/src/pytrec_eval.cpp#L270 is too strict.

The error message is not too clear: `

TypeError Traceback (most recent call last)

in () ----> 1 evaluator.evaluate({'151': {'clueweb09-en0027-05-20087': 10000}}) TypeError: Unable to extract query/object scores. ` I think that the exact problem is being overwritten by the calling code that checks the return value.
cvangysel commented 6 years ago

I agree. Feel free to send a PR to fix this.

cmacdonald commented 6 years ago

PR sent a few days ago. Good to go?

cvangysel commented 5 years ago

Sorry for the delayed response. PR merged!

nightlessbaron commented 1 year ago

Just leaving this comment here in case this helps anyone else. I got this error while using evaluator.evaluate(). The reason I got the error was because one of my variable was of the type np.float32 whereas I am assuming the builder expects it be of type float. Changing type to float resolved the error.