terrier-org / pyterrier

A Python framework for performing information retrieval experiments, building on http://terrier.org/
https://pyterrier.readthedocs.io/
Mozilla Public License 2.0
412 stars 65 forks source link

improved error message pt.apply.query - from #433 #434

Closed cmacdonald closed 6 months ago

cmacdonald commented 6 months ago

Suggestion to improve researcher experience, as experienced by @bakingeol.

pt.apply.query is a wrapper around Pandas apply. If the applied function does not return a string, Pandas error message can be confusing: "ValueError: Columns must be same length as key"

This PR provides a TypeError on top that provides a more useful error message: TypeError("Could not coerce return from pt.apply.query function into a list of strings. Check your function returns a string.")