Replace deprecated log.warn with log.warning
Fix validity data type for Python 3