Skip to content

Commit

Permalink
Run pyupgrade --py36-plus
Browse files Browse the repository at this point in the history
  • Loading branch information
inducer committed Sep 29, 2020
1 parent c2215a2 commit 00e44a6
Show file tree
Hide file tree
Showing 99 changed files with 780 additions and 1,065 deletions.
1 change: 0 additions & 1 deletion contrib/c-integer-semantics.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#!/usr/bin/env python
# coding: utf-8

from os import system
import ctypes
Expand Down
13 changes: 6 additions & 7 deletions doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# -*- coding: utf-8 -*-
#
# loopy documentation build configuration file, created by
# sphinx-quickstart on Tue Aug 9 13:40:49 2011.
Expand Down Expand Up @@ -46,8 +45,8 @@
master_doc = 'index'

# General information about the project.
project = u'loopy'
copyright = u'2016, Andreas Klöckner'
project = 'loopy'
copyright = '2016, Andreas Klöckner'

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -206,8 +205,8 @@
# Grouping the document tree into LaTeX files. List of tuples
# (source start file, target name, title, author, documentclass [howto/manual]).
latex_documents = [
('index', 'loopy.tex', u'loopy Documentation',
u'Andreas Kloeckner', 'manual'),
('index', 'loopy.tex', 'loopy Documentation',
'Andreas Kloeckner', 'manual'),
]

# The name of an image file (relative to this directory) to place at the top of
Expand Down Expand Up @@ -239,8 +238,8 @@
# One entry per manual page. List of tuples
# (source start file, name, description, authors, manual section).
man_pages = [
('index', 'loopy', u'loopy Documentation',
[u'Andreas Kloeckner'], 1)
('index', 'loopy', 'loopy Documentation',
['Andreas Kloeckner'], 1)
]


Expand Down
2 changes: 1 addition & 1 deletion examples/fortran/matmul-driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

def main():
fn = "matmul.floopy"
with open(fn, "r") as inf:
with open(fn) as inf:
source = inf.read()

dgemm, = lp.parse_transformed_fortran(source, filename=fn)
Expand Down
2 changes: 1 addition & 1 deletion examples/python/ispc-stream-harness.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def gen_code(knl):


def main():
with open("tasksys.cpp", "r") as ts_file:
with open("tasksys.cpp") as ts_file:
tasksys_source = ts_file.read()

def make_knl(name, insn, vars):
Expand Down
13 changes: 4 additions & 9 deletions loopy/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division, absolute_import

__copyright__ = "Copyright (C) 2012 Andreas Kloeckner"

__license__ = """
Expand All @@ -23,9 +21,6 @@
"""


import six
from six.moves import range, zip

from loopy.symbolic import (
TaggedVariable, Reduction, LinearSubscript, TypeCast)
from loopy.diagnostic import LoopyError, LoopyWarning
Expand Down Expand Up @@ -314,7 +309,7 @@ def set_options(kernel, *args, **kwargs):
from loopy.options import _apply_legacy_map, Options
kwargs = _apply_legacy_map(Options._legacy_options_map, kwargs)

for key, val in six.iteritems(kwargs):
for key, val in kwargs.items():
if not hasattr(new_opt, key):
raise ValueError("unknown option '%s'" % key)

Expand Down Expand Up @@ -417,7 +412,7 @@ def set_caching_enabled(flag):
CACHING_ENABLED = flag


class CacheMode(object):
class CacheMode:
"""A context manager for setting whether :mod:`loopy` is allowed to use
disk caches.
"""
Expand Down Expand Up @@ -464,10 +459,10 @@ def make_copy_kernel(new_dim_tags, old_dim_tags=None):
shape = ["n%d" % i for i in range(rank)]
commad_indices = ", ".join(indices)
bounds = " and ".join(
"0<=%s<%s" % (ind, shape_i)
f"0<={ind}<{shape_i}"
for ind, shape_i in zip(indices, shape))

set_str = "{[%s]: %s}" % (
set_str = "{{[{}]: {}}}".format(
commad_indices,
bounds
)
Expand Down
13 changes: 5 additions & 8 deletions loopy/auto_test.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
from __future__ import division, absolute_import

__copyright__ = "Copyright (C) 2012 Andreas Kloeckner"

__license__ = """
Expand All @@ -22,7 +20,6 @@
THE SOFTWARE.
"""

from six.moves import range, zip
import os
from warnings import warn

Expand Down Expand Up @@ -454,7 +451,7 @@ def auto_test_vs_ref(
ref_sched_kernel = knl
break

logger.info("%s (ref): trying %s for the reference calculation" % (
logger.info("{} (ref): trying {} for the reference calculation".format(
ref_knl.name, dev))

ref_compiled = CompiledKernel(ref_ctx, ref_sched_kernel)
Expand Down Expand Up @@ -494,7 +491,7 @@ def auto_test_vs_ref(

ref_queue.finish()

logger.info("%s (ref): using %s for the reference calculation" % (
logger.info("{} (ref): using {} for the reference calculation".format(
ref_knl.name, dev))
logger.info("%s (ref): run" % ref_knl.name)

Expand Down Expand Up @@ -677,7 +674,7 @@ def auto_test_vs_ref(

rates = ""
for cnt, lbl in zip(op_count, op_label):
rates += " %g %s/s" % (cnt/elapsed_wall, lbl)
rates += " {:g} {}/s".format(cnt/elapsed_wall, lbl)

if not quiet:
def format_float_or_none(v):
Expand All @@ -695,9 +692,9 @@ def format_float_or_none(v):
if do_check:
ref_rates = ""
for cnt, lbl in zip(op_count, op_label):
ref_rates += " %g %s/s" % (cnt/ref_elapsed_event, lbl)
ref_rates += " {:g} {}/s".format(cnt/ref_elapsed_event, lbl)
if not quiet:
print("ref: elapsed: %g s event, %g s wall%s" % (
print("ref: elapsed: {:g} s event, {:g} s wall{}".format(
ref_elapsed_event, ref_elapsed_wall, ref_rates))

# }}}
Expand Down
Loading

0 comments on commit 00e44a6

Please sign in to comment.