Fix strange float casting problems in python