Update metrics.py

Make PY3 compatible