BF: For some (older?) versions of python, take care of cases in which inputs
are nans (?).