From 8bdf9f1af029bedc341ac5f4e4ca2f463b459640 Mon Sep 17 00:00:00 2001 From: nilfm Date: Fri, 14 Jun 2024 11:43:23 -0400 Subject: [PATCH] Clean up: remove support for python2 --- python/vmaf/core/cross_validation.py | 9 ++------- python/vmaf/core/raw_extractor.py | 6 +----- python/vmaf/tools/misc.py | 7 ------- python/vmaf/tools/scanf.py | 8 +------- 4 files changed, 4 insertions(+), 26 deletions(-) diff --git a/python/vmaf/core/cross_validation.py b/python/vmaf/core/cross_validation.py index 1092ea2ee..790a2a4f4 100644 --- a/python/vmaf/core/cross_validation.py +++ b/python/vmaf/core/cross_validation.py @@ -8,11 +8,6 @@ import sys -# TODO: remove this once python2 support is dropped, in python3 all int are as long as you want -if sys.version_info[0] == 3: - long = int - - class ModelCrossValidation(object): @staticmethod @@ -66,7 +61,7 @@ def run_kfold_cross_validation(cls, :return: output """ - if isinstance(kfold, (int, long)): + if isinstance(kfold, int): kfold_type = 'int' elif isinstance(kfold, (list, tuple)): kfold_type = 'list' @@ -158,7 +153,7 @@ def run_nested_kfold_cross_validation(cls, :return: output """ - if isinstance(kfold, (int, long)): + if isinstance(kfold, int): kfold_type = 'int' elif isinstance(kfold, (list, tuple)): kfold_type = 'list' diff --git a/python/vmaf/core/raw_extractor.py b/python/vmaf/core/raw_extractor.py index 6fb05c6d0..5b29a68fa 100644 --- a/python/vmaf/core/raw_extractor.py +++ b/python/vmaf/core/raw_extractor.py @@ -13,10 +13,6 @@ __copyright__ = "Copyright 2016-2020, Netflix, Inc." __license__ = "BSD+Patent" -# TODO: remove this once python2 support is dropped -if sys.version_info[0] == 3: - basestring = str - class RawExtractor(Executor): @@ -85,7 +81,7 @@ def channels(self): return 'yuv' else: channels = self.optional_dict['channels'] - assert isinstance(channels, basestring) + assert isinstance(channels, str) channels = set(channels.lower()) assert channels.issubset(set('yuv')) return ''.join(channels) diff --git a/python/vmaf/tools/misc.py b/python/vmaf/tools/misc.py index 24eacaf5a..a550c80a6 100644 --- a/python/vmaf/tools/misc.py +++ b/python/vmaf/tools/misc.py @@ -22,13 +22,6 @@ __license__ = "BSD+Patent" -try: - unicode # noqa, remove this once python2 support is dropped - -except NameError: - unicode = str - - try: multiprocessing.set_start_method('fork') except ValueError: # noqa, If platform does not support, just ignore diff --git a/python/vmaf/tools/scanf.py b/python/vmaf/tools/scanf.py index 0085a52c6..7b1b49490 100644 --- a/python/vmaf/tools/scanf.py +++ b/python/vmaf/tools/scanf.py @@ -173,13 +173,7 @@ import sys import unittest -try: - import StringIO - - StringIO = StringIO.StringIO # TODO: remove this once python2 support is dropped - -except ImportError: - from io import StringIO +from io import StringIO __all__ = ['scanf', 'sscanf', 'fscanf']