Take care of user-supplied function by checking whether mode_compute is numeric

Fixes #508

(cherry picked from commit 8ce11bc8486aa89680837f6a50970e6ffdcd446f)