From f773da10ae21fae1d65eb8e268ca5e2431fe54ef Mon Sep 17 00:00:00 2001 From: Julian Hammer Date: Wed, 6 Dec 2017 17:15:49 +0100 Subject: [PATCH] Removed legacy imports and six and changed shebang python3 --- .travis.yml | 1 - kerncraft/cacheprediction.py | 8 +-- kerncraft/cachetile.py | 11 +--- kerncraft/iaca.py | 11 +--- kerncraft/iaca_get.py | 6 +-- kerncraft/intervals.py | 2 +- kerncraft/kerncraft.py | 51 ++++++++----------- kerncraft/kernel.py | 20 ++------ kerncraft/likwid_bench_auto.py | 14 +---- kerncraft/machinemodel.py | 6 +-- kerncraft/models/benchmark.py | 20 ++------ kerncraft/models/ecm.py | 13 ++--- kerncraft/models/layer_condition.py | 35 +------------ kerncraft/models/roofline.py | 7 +-- kerncraft/picklemerge.py | 6 +-- kerncraft/prefixedunit.py | 13 ++--- kerncraft/roofline-plot.py | 7 +-- likwid-counter-packing.py | 7 +-- setup.py | 7 +-- tests/all_tests.py | 2 +- tests/test_files/dummy_likwid/likwid-bench | 4 +- tests/test_files/dummy_likwid/likwid-perfctr | 4 +- tests/test_files/dummy_likwid/likwid-topology | 4 +- tests/test_intervals.py | 4 +- tests/test_kerncraft.py | 37 ++++++-------- tests/test_kernel.py | 18 +------ tests/test_layer_condition.py | 11 +--- tests/test_likwid_bench_auto.py | 17 +------ tox.ini | 2 +- 29 files changed, 76 insertions(+), 272 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8923584..12d60f8 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,5 @@ language: python python: -- '2.7' - '3.4' - '3.5' - '3.6' diff --git a/kerncraft/cacheprediction.py b/kerncraft/cacheprediction.py index 98ae734..67e3d4d 100755 --- a/kerncraft/cacheprediction.py +++ b/kerncraft/cacheprediction.py @@ -1,11 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Cache prediction interface classes are gathered in this module.""" - -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - from itertools import chain import sympy diff --git a/kerncraft/cachetile.py b/kerncraft/cachetile.py index 1e00f5e..dd93307 100755 --- a/kerncraft/cachetile.py +++ b/kerncraft/cachetile.py @@ -1,15 +1,8 @@ -#!/usr/bin/env python - -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - +#!/usr/bin/env python3 import argparse import sys import sympy -import six from ruamel import yaml from . import models @@ -55,7 +48,7 @@ def run(parser, args): machine = MachineModel(args.machine.name) # process kernel description - description = six.text_type(args.description_file.read()) + description = str(args.description_file.read()) kernel = KernelDescription(yaml.load(description)) # Add constants from define arguments diff --git a/kerncraft/iaca.py b/kerncraft/iaca.py index b50d9da..afacfb9 100755 --- a/kerncraft/iaca.py +++ b/kerncraft/iaca.py @@ -1,22 +1,13 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Helper functions to instumentalize assembly code for and analyze with IACA.""" -from __future__ import print_function -from __future__ import absolute_import - # Version check import sys -if sys.version_info[0] == 2 and sys.version_info < (2, 7) or \ - sys.version_info[0] == 3 and sys.version_info < (3, 4): - print("Must use python 2.7 or 3.4 and greater.", file=sys.stderr) - sys.exit(1) - import re import subprocess import os from copy import copy from distutils.spawn import find_executable -from six.moves import input from kerncraft import iaca_get diff --git a/kerncraft/iaca_get.py b/kerncraft/iaca_get.py index 47511bf..299a9f5 100755 --- a/kerncraft/iaca_get.py +++ b/kerncraft/iaca_get.py @@ -1,7 +1,4 @@ -#!/usr/bin/env python -from __future__ import print_function -from __future__ import absolute_import - +#!/usr/bin/env python3 import os import sys import stat @@ -11,7 +8,6 @@ import tempfile import shutil import platform -import errno import requests diff --git a/kerncraft/intervals.py b/kerncraft/intervals.py index f1e6a3e..a2f77ee 100755 --- a/kerncraft/intervals.py +++ b/kerncraft/intervals.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """A simple interval implementation.""" diff --git a/kerncraft/kerncraft.py b/kerncraft/kerncraft.py index d65d49c..f17fb4f 100755 --- a/kerncraft/kerncraft.py +++ b/kerncraft/kerncraft.py @@ -1,16 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Comand line interface of Kerncraft.""" -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - # Version check import sys -if sys.version_info[0] == 2 and sys.version_info < (2, 7) or \ - sys.version_info[0] == 3 and sys.version_info < (3, 4): - print("Must use python 2.7 or 3.4 and greater.", file=sys.stderr) - sys.exit(1) import argparse import os.path import pickle @@ -20,8 +11,6 @@ import itertools from .pycparser import clean_code -import six -from six.moves import range from ruamel import yaml from . import models @@ -34,7 +23,7 @@ def space(start, stop, num, endpoint=True, log=False, base=10): """ Return list of evenly spaced integers over an interval. - Numbers can either be evenlty distributed in a linear space (if *log* is False) or in a log + Numbers can either be evenly distributed in a linear space (if *log* is False) or in a log space (if *log* is True). If *log* is True, base is used to define the log space basis. If *endpoint* is True, *stop* will be the last retruned value, as long as *num* >= 2. @@ -48,16 +37,16 @@ def space(start, stop, num, endpoint=True, log=False, base=10): stop = math.log(stop, base) if endpoint: - steplength = float((stop-start))/float(num-1) + step_length = float((stop - start)) / float(num - 1) else: - steplength = float((stop-start))/float(num) + step_length = float((stop - start)) / float(num) i = 0 while i < num: if log: - yield int(round(base**(start + i*steplength))) + yield int(round(base ** (start + i * step_length))) else: - yield int(round(start + i*steplength)) + yield int(round(start + i * step_length)) i += 1 @@ -73,11 +62,11 @@ class AppendStringRange(argparse.Action): """ Argparse Action to append integer range from string. - A range discription must have the following format: start[-stop[:num[log[base]]]] + A range description must have the following format: start[-stop[:num[log[base]]]] if stop is given, a list of integers is compiled - if num is given, an evently spaced lsit of intergers from start to stop is compiled + if num is given, an evenly spaced list of integers from start to stop is compiled if log is given, the integers are evenly spaced on a log space - if base is given, the integers are evently spaced on that base (default: 10) + if base is given, the integers are evenly spaced on that base (default: 10) """ def __call__(self, parser, namespace, values, option_string=None): @@ -94,7 +83,7 @@ def __call__(self, parser, namespace, values, option_string=None): if gd['stop'] is None: values[1] = [int(gd['start'])] elif gd['num'] is None: - values[1] = list(range(int(gd['start']), int(gd['stop'])+1)) + values[1] = list(range(int(gd['start']), int(gd['stop']) + 1)) else: log = gd['log'] is not None base = int(gd['base']) if gd['base'] is not None else 10 @@ -116,7 +105,7 @@ def create_parser(): """Return argparse parser.""" parser = argparse.ArgumentParser( description='Analytical performance modelling and benchmarking toolkit.', - epilog='For help, examples, documenataion and bug reports go to:\nhttps://github.com' + epilog='For help, examples, documentation and bug reports go to:\nhttps://github.com' '/RRZE-HPC/kerncraft\nLicense: AGPLv3') parser.add_argument('--version', action='version', version='%(prog)s {}'.format(__version__)) parser.add_argument('--machine', '-m', type=argparse.FileType('r'), required=True, @@ -163,7 +152,7 @@ def create_parser(): 'description file (-std=c99 is always added).') for m in models.__all__: - ag = parser.add_argument_group('arguments for '+m+' model', getattr(models, m).name) + ag = parser.add_argument_group('arguments for ' + m + ' model', getattr(models, m).name) getattr(models, m).configure_arggroup(ag) return parser @@ -196,11 +185,11 @@ def run(parser, args, output_file=sys.stdout): # process kernel if not args.kernel_description: - code = six.text_type(args.code_file.read()) + code = str(args.code_file.read()) code = clean_code(code) kernel = KernelCode(code, filename=args.code_file.name, machine=machine) else: - description = six.text_type(args.code_file.read()) + description = str(args.code_file.read()) kernel = KernelDescription(yaml.load(description, Loader=yaml.Loader), machine=machine) # if no defines were given, guess suitable defines in-mem # TODO support in-cache @@ -241,11 +230,11 @@ def run(parser, args, output_file=sys.stdout): for model_name in set(args.pmodel): # print header - print('{:=^80}'.format(' kerncraft '), file=output_file) - print('{:<40}{:>40}'.format(args.code_file.name, '-m '+args.machine.name), + print('{:^80}'.format(' kerncraft '), file=output_file) + print('{:<40}{:>40}'.format(args.code_file.name, '-m ' + args.machine.name), file=output_file) print(' '.join(['-D {} {}'.format(k, v) for k, v in define]), file=output_file) - print('{:-^80}'.format(' '+model_name+' '), file=output_file) + print('{:-^80}'.format(' ' + model_name + ' '), file=output_file) if args.verbose > 1: if not args.kernel_description: @@ -274,10 +263,10 @@ def run(parser, args, output_file=sys.stdout): # Save storage to file (if requested) if args.store: - tempname = args.store.name + '.tmp' - with open(tempname, 'wb+') as f: + temp_name = args.store.name + '.tmp' + with open(temp_name, 'wb+') as f: pickle.dump(result_storage, f) - shutil.move(tempname, args.store.name) + shutil.move(temp_name, args.store.name) def main(): diff --git a/kerncraft/kernel.py b/kerncraft/kernel.py index 1c21a90..3e082e3 100755 --- a/kerncraft/kernel.py +++ b/kerncraft/kernel.py @@ -1,11 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Representation of computational kernel for performance model analysis and helper functions.""" - -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - from copy import deepcopy import operator import tempfile @@ -19,16 +13,12 @@ import string from itertools import chain from collections import defaultdict +from itertools import zip_longest, lru_cache import sympy from sympy.utilities.lambdify import implemented_function from sympy.parsing.sympy_parser import parse_expr import numpy -from six.moves import filter -from six.moves import map -from six.moves import zip_longest -import six -from pylru import lrudecorator from .pycparser import CParser, c_ast, plyparser from .pycparser.c_generator import CGenerator @@ -186,7 +176,7 @@ def set_constant(self, name, value): :param name: may be a str or a sympy.Symbol :param value: must be an int """ - assert isinstance(name, six.string_types) or isinstance(name, sympy.Symbol), \ + assert isinstance(name, str) or isinstance(name, sympy.Symbol), \ "constant name needs to be of type str, unicode or a sympy.Symbol" assert type(value) is int, "constant value needs to be of type int" if isinstance(name, sympy.Symbol): @@ -214,7 +204,7 @@ def clear_state(self): self.constants = {} self.subs_consts.clear() # clear LRU cache of function - @lrudecorator(40) + @lru_cache(40) def subs_consts(self, expr): """Substitute constants in expression unless it is already a number.""" if isinstance(expr, numbers.Number): @@ -711,7 +701,7 @@ def _get_basename(cls, aref): """ if isinstance(aref.name, c_ast.ArrayRef): return cls._get_basename(aref.name) - elif isinstance(aref.name, six.string_types): + elif isinstance(aref.name, str): return aref.name else: return aref.name.name diff --git a/kerncraft/likwid_bench_auto.py b/kerncraft/likwid_bench_auto.py index 06940fe..f171ac0 100755 --- a/kerncraft/likwid_bench_auto.py +++ b/kerncraft/likwid_bench_auto.py @@ -1,16 +1,5 @@ -#!/usr/bin/env python -from __future__ import print_function -from __future__ import absolute_import -from __future__ import unicode_literals -from __future__ import division - -# Version check +#!/usr/bin/env python3 import sys -if sys.version_info[0] == 2 and sys.version_info < (2, 6) or \ - sys.version_info[0] == 3 and sys.version_info < (3, 4): - print("Must use python 2.6 or 3.4 and greater.", file=sys.stderr) - sys.exit(1) - import subprocess import re from copy import copy @@ -19,7 +8,6 @@ from ruamel import yaml from .prefixedunit import PrefixedUnit -from six.moves import range def get_match_or_break(regex, haystack, flags=re.MULTILINE): diff --git a/kerncraft/machinemodel.py b/kerncraft/machinemodel.py index 6a7ca0f..fe99eca 100755 --- a/kerncraft/machinemodel.py +++ b/kerncraft/machinemodel.py @@ -1,9 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Machine model and helper functions.""" - -from __future__ import absolute_import -from __future__ import division - from distutils.spawn import find_executable import re import sys diff --git a/kerncraft/models/benchmark.py b/kerncraft/models/benchmark.py index 6fc9403..00f0089 100644 --- a/kerncraft/models/benchmark.py +++ b/kerncraft/models/benchmark.py @@ -1,9 +1,5 @@ +#!/usr/bin/env python3 """Benchmark model and helper functions.""" -from __future__ import print_function -from __future__ import division -from __future__ import unicode_literals -from __future__ import absolute_import - import subprocess from functools import reduce import operator @@ -12,16 +8,8 @@ import re from collections import defaultdict import string -try: - # Python 3 - from itertools import zip_longest -except ImportError: - from itertools import izip_longest as zip_longest from pprint import pprint -import six -import sympy - from kerncraft.prefixedunit import PrefixedUnit @@ -276,7 +264,7 @@ def analyze(self): element_size = self.kernel.datatypes_size[self.kernel.datatype] # Build arguments to pass to command: - args = [bench] + [six.text_type(s) for s in list(self.kernel.constants.values())] + args = [bench] + [str(s) for s in list(self.kernel.constants.values())] # Determine base runtime with 100 iterations runtime = 0.0 @@ -289,7 +277,7 @@ def analyze(self): else: repetitions *= 10 - mem_results = self.perfctr(args+[six.text_type(repetitions)], group="MEM") + mem_results = self.perfctr(args+[str(repetitions)], group="MEM") runtime = mem_results['Runtime (RDTSC) [s]'] time_per_repetition = runtime/float(repetitions) raw_results = [mem_results] @@ -315,7 +303,7 @@ def analyze(self): measured_ctrs = {} for run in minimal_runs: ctrs = ','.join([eventstr(e) for e in run]) - r = self.perfctr(args+[six.text_type(repetitions)], group=ctrs) + r = self.perfctr(args+[str(repetitions)], group=ctrs) raw_results.append(r) measured_ctrs.update(r) # Match measured counters to symbols diff --git a/kerncraft/models/ecm.py b/kerncraft/models/ecm.py index 1174187..c80d143 100755 --- a/kerncraft/models/ecm.py +++ b/kerncraft/models/ecm.py @@ -1,17 +1,10 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Execution-Cache-Memory model class and helper functions.""" - -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - import copy import sys import math from pprint import pformat -import six try: import matplotlib matplotlib.use('Agg') @@ -346,8 +339,8 @@ def report(self, output_file=sys.stdout): print('', file=output_file) if self.verbose > 1: - print('Ports and cycles:', six.text_type(self.results['port cycles']), file=output_file) - print('Uops:', six.text_type(self.results['uops']), file=output_file) + print('Ports and cycles:', str(self.results['port cycles']), file=output_file) + print('Uops:', str(self.results['uops']), file=output_file) print('Throughput: {}'.format( self.conv_cy(self.results['cl throughput'], self._args.unit)), diff --git a/kerncraft/models/layer_condition.py b/kerncraft/models/layer_condition.py index abf1d54..85ea5f0 100755 --- a/kerncraft/models/layer_condition.py +++ b/kerncraft/models/layer_condition.py @@ -1,45 +1,14 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Layer condition model and helper functions""" - -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - import sys from itertools import chain from pprint import pprint from collections import defaultdict +from functools import cmp_to_key import sympy -# Not useing functools.cmp_to_key, because it does not exit in python 2.x -def cmp_to_key(mycmp): - """Convert a cmp= function into a key= function""" - class K(object): - def __init__(self, obj, *args): - self.obj = obj - - def __lt__(self, other): - return mycmp(self.obj, other.obj) < 0 - - def __gt__(self, other): - return mycmp(self.obj, other.obj) > 0 - - def __eq__(self, other): - return mycmp(self.obj, other.obj) == 0 - - def __le__(self, other): - return mycmp(self.obj, other.obj) <= 0 - - def __ge__(self, other): - return mycmp(self.obj, other.obj) >= 0 - - def __ne__(self, other): - return mycmp(self.obj, other.obj) != 0 - - class LC(object): """ Representation of the layer condition model. diff --git a/kerncraft/models/roofline.py b/kerncraft/models/roofline.py index 6b24fec..825e0cd 100755 --- a/kerncraft/models/roofline.py +++ b/kerncraft/models/roofline.py @@ -1,10 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Roofline model and helper functions.""" -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - import sys from pprint import pformat # Do not use pprint, breaks in combination with --store and StringIO diff --git a/kerncraft/picklemerge.py b/kerncraft/picklemerge.py index 112b2a4..e2bf290 100755 --- a/kerncraft/picklemerge.py +++ b/kerncraft/picklemerge.py @@ -1,9 +1,5 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 """Merge two pickle files containing dictionarys recursively.""" - -from __future__ import print_function -from __future__ import absolute_import - import argparse import pickle import collections diff --git a/kerncraft/prefixedunit.py b/kerncraft/prefixedunit.py index 279f30d..73cc490 100755 --- a/kerncraft/prefixedunit.py +++ b/kerncraft/prefixedunit.py @@ -1,12 +1,7 @@ -#!/usr/bin/env python -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division +#!/usr/bin/env python3 +import re from ruamel import yaml -import re -import six class PrefixedUnit(yaml.YAMLObject): @@ -26,11 +21,11 @@ def from_yaml(cls, loader, node): @classmethod def to_yaml(cls, dumper, data): - return dumper.represent_scalar(cls.yaml_tag, six.text_type(data)) + return dumper.represent_scalar(cls.yaml_tag, str(data)) def __init__(self, *args): if len(args) == 1: - if isinstance(args[0], six.string_types): + if isinstance(args[0], str): m = re.match( r'^(?P(?:[0-9]+(?:\.[0-9]+)?|inf)) (?P[kMGTP])?(?P.*)$', args[0]) diff --git a/kerncraft/roofline-plot.py b/kerncraft/roofline-plot.py index 56db8ad..70f4afb 100755 --- a/kerncraft/roofline-plot.py +++ b/kerncraft/roofline-plot.py @@ -1,15 +1,10 @@ -#!/usr/bin/env python - -from __future__ import absolute_import - +#!/usr/bin/env python3 from pprint import pprint -# matplotlib.use('Agg') import matplotlib.pyplot as plt from ruamel import yaml from .prefixedunit import PrefixedUnit -from six.moves import range def frange(start, stop, step=1.0): diff --git a/likwid-counter-packing.py b/likwid-counter-packing.py index 5d77ba5..f0ec1e8 100755 --- a/likwid-counter-packing.py +++ b/likwid-counter-packing.py @@ -1,12 +1,7 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from pprint import pprint import re import string -try: - # Python 3 - from itertools import zip_longest -except ImportError: - from itertools import izip_longest as zip_longest def group_iterator(group): diff --git a/setup.py b/setup.py index afe8c58..adeca9f 100755 --- a/setup.py +++ b/setup.py @@ -1,6 +1,4 @@ -#!/usr/bin/env python -from __future__ import absolute_import - +#!/usr/bin/env python3 # Always prefer setuptools over distutils from setuptools import setup, find_packages from setuptools.command.build_py import build_py as _build_py @@ -107,8 +105,6 @@ def make_release_tree(self, base_dir, files): # Specify the Python versions you support here. In particular, ensure # that you indicate whether you support Python 2, Python 3 or both. - 'Programming Language :: Python :: 2', - 'Programming Language :: Python :: 2.7', 'Programming Language :: Python :: 3', 'Programming Language :: Python :: 3.4', ], @@ -129,7 +125,6 @@ def make_release_tree(self, base_dir, files): # https://packaging.python.org/en/latest/requirements.html install_requires=[ 'ruamel.yaml>=0.13.4,<0.14.0', - 'six', 'sympy>=0.7.7', 'pycachesim>=0.1.5', 'pylru', diff --git a/tests/all_tests.py b/tests/all_tests.py index 20544c7..995cdfe 100755 --- a/tests/all_tests.py +++ b/tests/all_tests.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import unittest import sys diff --git a/tests/test_files/dummy_likwid/likwid-bench b/tests/test_files/dummy_likwid/likwid-bench index b7e77f7..8e1ef54 100755 --- a/tests/test_files/dummy_likwid/likwid-bench +++ b/tests/test_files/dummy_likwid/likwid-bench @@ -1,6 +1,4 @@ -#!/usr/bin/env python -from __future__ import print_function - +#!/usr/bin/env python3 import sys import re diff --git a/tests/test_files/dummy_likwid/likwid-perfctr b/tests/test_files/dummy_likwid/likwid-perfctr index 22aaed3..e7bcdf3 100755 --- a/tests/test_files/dummy_likwid/likwid-perfctr +++ b/tests/test_files/dummy_likwid/likwid-perfctr @@ -1,6 +1,4 @@ -#!/usr/bin/env python -from __future__ import print_function - +#!/usr/bin/env python3 import sys import re diff --git a/tests/test_files/dummy_likwid/likwid-topology b/tests/test_files/dummy_likwid/likwid-topology index c44da4c..1691b6d 100755 --- a/tests/test_files/dummy_likwid/likwid-topology +++ b/tests/test_files/dummy_likwid/likwid-topology @@ -1,6 +1,4 @@ -#!/usr/bin/env python -from __future__ import print_function - +#!/usr/bin/env python3 import sys import re diff --git a/tests/test_intervals.py b/tests/test_intervals.py index f9d013f..d0c36c0 100644 --- a/tests/test_intervals.py +++ b/tests/test_intervals.py @@ -1,9 +1,7 @@ +#!/usr/bin/env python3 """ Unit tests for intervals module """ -from __future__ import print_function - -import sys import unittest from kerncraft.intervals import Intervals diff --git a/tests/test_kerncraft.py b/tests/test_kerncraft.py index 53a9032..c2490d9 100644 --- a/tests/test_kerncraft.py +++ b/tests/test_kerncraft.py @@ -1,23 +1,16 @@ +#!/usr/bin/env python3 """ High-level tests for the overall functionallity and things in kc.py """ -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - -import sys import os import unittest import tempfile import shutil import pickle -from pprint import pprint from io import StringIO from distutils.spawn import find_executable import platform -import six import sympy from kerncraft import kerncraft as kc @@ -61,7 +54,7 @@ def test_2d5pt_ECMData_SIM(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [ ((sympy.var('M'), 50), (sympy.var('N'), 1000)), ((sympy.var('M'), 50), @@ -71,7 +64,7 @@ def test_2d5pt_ECMData_SIM(self): result = results['2d-5pt.c'][[k for k in results['2d-5pt.c'] if (sympy.var('N'), 1000) in k][0]] - six.assertCountEqual(self, result, ['ECMData']) + self.assertCountEqual(result, ['ECMData']) ecmd = result['ECMData'] # 2 arrays * 1000*50 doubles/array * 8 Bytes/double = 781kB @@ -104,7 +97,7 @@ def test_2d5pt_ECMData_LC(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [ ((sympy.var('M'), 50), (sympy.var('N'), 1000)), ((sympy.var('M'), 50), @@ -113,7 +106,7 @@ def test_2d5pt_ECMData_LC(self): # Output of first result: result = results['2d-5pt.c'][[k for k in results['2d-5pt.c'] if (sympy.var('N'), 1000) in k][0]] - six.assertCountEqual(self, result, ['ECMData']) + self.assertCountEqual(result, ['ECMData']) ecmd = result['ECMData'] # 2 arrays * 1000*50 doubles/array * 8 Bytes/double = 781kB @@ -143,7 +136,7 @@ def test_2d5pt_Roofline(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [ ((sympy.var('M'), 50), (sympy.var('N'), 1024)), ((sympy.var('M'), 50), (sympy.var('N'), 2048)), ((sympy.var('M'), 50), (sympy.var('N'), 4096))]]) @@ -151,7 +144,7 @@ def test_2d5pt_Roofline(self): # Output of first result: result = results['2d-5pt.c'][[k for k in results['2d-5pt.c'] if (sympy.var('N'), 4096) in k][0]] - six.assertCountEqual(self, result, ['Roofline']) + self.assertCountEqual(result, ['Roofline']) roofline = result['Roofline'] self.assertAlmostEqual(roofline['min performance'], 5802500000.0, places=0) @@ -285,14 +278,14 @@ def test_2d5pt_ECMCPU(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [((sympy.var('M'), 1000), (sympy.var('N'), 2000))]]) # Output of first result: result = list(results['2d-5pt.c'].values())[0] - six.assertCountEqual(self, result, ['ECMCPU']) + self.assertCountEqual(result, ['ECMCPU']) ecmd = result['ECMCPU'] self.assertAlmostEqual(ecmd['T_OL'], 12, places=1) @@ -322,14 +315,14 @@ def test_2d5pt_ECM(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [((sympy.var('M'), 1000), (sympy.var('N'), 2000))]]) # Output of first result: result = list(results['2d-5pt.c'].values())[0] - six.assertCountEqual(self, result, ['ECM']) + self.assertCountEqual(result, ['ECM']) ecmd = result['ECM'] # 2 * 2000*1000 * 8 = 31MB @@ -367,14 +360,14 @@ def test_2d5pt_RooflineIACA(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [((sympy.var('M'), 1000), (sympy.var('N'), 4000))]]) # Output of first result: result = list(results['2d-5pt.c'].values())[0] - six.assertCountEqual(self, result, ['RooflineIACA']) + self.assertCountEqual(result, ['RooflineIACA']) roofline = result['RooflineIACA'] self.assertAlmostEqual(roofline['min performance'], 2900000000.0, places=0) @@ -414,14 +407,14 @@ def test_2d5pt_Benchmark(self): self.assertEqual(list(results), ['2d-5pt.c']) # Check for correct variations of constants - six.assertCountEqual(self, + self.assertCountEqual( [sorted(map(str, r)) for r in results['2d-5pt.c']], [sorted(map(str, r)) for r in [((sympy.var('M'), 1000), (sympy.var('N'), 1000))]]) # Output of first result: result = list(results['2d-5pt.c'].values())[0] - six.assertCountEqual(self, result, ['Benchmark']) + self.assertCountEqual(result, ['Benchmark']) roofline = result['Benchmark'] correct_results = { diff --git a/tests/test_kernel.py b/tests/test_kernel.py index 9ad81a9..9241ce3 100644 --- a/tests/test_kernel.py +++ b/tests/test_kernel.py @@ -1,26 +1,13 @@ +#!/usr/bin/env python3 """ High-level tests for the overall functionallity and things in kc.py """ -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - -import sys import os import unittest -import tempfile -import shutil -import pickle -from pprint import pprint -from io import StringIO -from itertools import chain -import six -import sympy from ruamel import yaml -from kerncraft.kernel import Kernel, KernelCode, KernelDescription +from kerncraft.kernel import KernelCode, KernelDescription class TestKernel(unittest.TestCase): @@ -111,6 +98,5 @@ def test_from_description(self): self.assertEqual(k_descr._loop_stack, k_code._loop_stack) if __name__ == '__main__': - #unittest.main() suite = unittest.TestLoader().loadTestsFromTestCase(TestKernel) unittest.TextTestRunner(verbosity=2).run(suite) diff --git a/tests/test_layer_condition.py b/tests/test_layer_condition.py index fd1107b..e6a9b64 100644 --- a/tests/test_layer_condition.py +++ b/tests/test_layer_condition.py @@ -1,23 +1,14 @@ +#!/usr/bin/env python3 """ High-level tests for the overall functionallity and things in kc.py """ -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - -import sys import os import unittest import tempfile import shutil import pickle -from pprint import pprint from io import StringIO -from distutils.spawn import find_executable -import platform -import six import sympy from kerncraft import kerncraft as kc diff --git a/tests/test_likwid_bench_auto.py b/tests/test_likwid_bench_auto.py index b965003..496a2f1 100644 --- a/tests/test_likwid_bench_auto.py +++ b/tests/test_likwid_bench_auto.py @@ -1,24 +1,9 @@ +#!/usr/bin/env python3 """ High-level tests for the overall functionallity and things in kc.py """ -from __future__ import print_function -from __future__ import unicode_literals -from __future__ import absolute_import -from __future__ import division - -import sys import os import unittest -import tempfile -import shutil -import pickle -from pprint import pprint -from io import StringIO -from distutils.spawn import find_executable -import platform - -import six -import sympy from kerncraft import likwid_bench_auto as lba from kerncraft.prefixedunit import PrefixedUnit diff --git a/tox.ini b/tox.ini index 210dc69..e0af49e 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py27,py34,py35,py36 +envlist = py34,py35,py36 [testenv] install_command = pip install {opts} {packages}