Update rate.py

Fix bug when variable is not a float.