diff --git a/pytools/__init__.py b/pytools/__init__.py index 4d98418bbc61d3576e531771e7e6623f65409035..228ed61acd921b6ce47e1cd988459b9ad2bd36eb 100644 --- a/pytools/__init__.py +++ b/pytools/__init__.py @@ -375,7 +375,7 @@ class RecordWithoutPickling: def __repr__(self): return "{}({})".format( self.__class__.__name__, - ", ".join("{}={!r}".format(fld, getattr(self, fld)) + ", ".join(f"{fld}={getattr(self, fld)!r}" for fld in self.__class__.fields if hasattr(self, fld))) @@ -1843,14 +1843,14 @@ class CPyUserInterface: print() print("The following variables are recognized:") for v in sorted(self.variables): - print(" {} = {}".format(v, self.variables[v])) + print(f" {v} = {self.variables[v]}") if v in self.doc: print(" %s" % self.doc[v]) print() print("The following constants are supplied:") for c in sorted(self.constants): - print(" {} = {}".format(c, self.constants[c])) + print(f" {c} = {self.constants[c]}") if c in self.doc: print(" %s" % self.doc[c]) @@ -1925,7 +1925,7 @@ def typedump(val, max_seq=5, special_handlers=None): if isinstance(val, dict): return "{%s}" % ( ", ".join( - "{!r}: {}".format(str(k), typedump(v)) + f"{str(k)!r}: {typedump(v)}" for k, v in val.items())) try: @@ -2726,7 +2726,7 @@ def sphere_sample_equidistant(npoints_approx: int, r: float = 1.0): for m in range(M_theta): theta = np.pi * (m + 0.5) / M_theta - M_phi = int(np.ceil((2 * np.pi * np.sin(theta) / d_phi))) # noqa: N806 + M_phi = int(np.ceil(2 * np.pi * np.sin(theta) / d_phi)) # noqa: N806 for n in range(M_phi): phi = 2 * np.pi * n / M_phi points.append([r * np.sin(theta) * np.cos(phi), diff --git a/pytools/batchjob.py b/pytools/batchjob.py index d5ac7adad4da60aef6bc8f7bbefe70e3a9d61db9..d4369bb033fa82c929c61c705391ddc54ac8e6c9 100644 --- a/pytools/batchjob.py +++ b/pytools/batchjob.py @@ -146,7 +146,7 @@ class ConstructorPlaceholder: return "{}({})".format(self.classname, ",".join( [str(arg) for arg in self.args] - + ["{}={}".format(kw, repr(val)) + + [f"{kw}={repr(val)}" for kw, val in self.kwargs.items()] ) ) diff --git a/pytools/convergence.py b/pytools/convergence.py index a9e2dd4a3882fba2e6429e134b49a73506a807b5..46d8b033b2643f3fc313c81ef202de7077b977ef 100644 --- a/pytools/convergence.py +++ b/pytools/convergence.py @@ -121,7 +121,7 @@ class EOCRecorder: order = result[0, 1] outfile.write("\n") for absc, _err in self.history: - outfile.write("{:f} {:f}\n".format(absc, const * absc**(-order))) + outfile.write(f"{absc:f} {const * absc**(-order):f}\n") # }}} diff --git a/pytools/spatial_btree.py b/pytools/spatial_btree.py index f5249da7f415de9aeea074a500eaeebfc10d1dec..91e0f0d7ff1db55e7fe26089adede9b67b5a8c19 100644 --- a/pytools/spatial_btree.py +++ b/pytools/spatial_btree.py @@ -142,11 +142,11 @@ class SpatialBinaryTreeBucket: yield el def visualize(self, file): - file.write("{:f} {:f}\n".format(self.bottom_left[0], self.bottom_left[1])) - file.write("{:f} {:f}\n".format(self.top_right[0], self.bottom_left[1])) - file.write("{:f} {:f}\n".format(self.top_right[0], self.top_right[1])) - file.write("{:f} {:f}\n".format(self.bottom_left[0], self.top_right[1])) - file.write("{:f} {:f}\n\n".format(self.bottom_left[0], self.bottom_left[1])) + file.write(f"{self.bottom_left[0]:f} {self.bottom_left[1]:f}\n") + file.write(f"{self.top_right[0]:f} {self.bottom_left[1]:f}\n") + file.write(f"{self.top_right[0]:f} {self.top_right[1]:f}\n") + file.write(f"{self.bottom_left[0]:f} {self.top_right[1]:f}\n") + file.write(f"{self.bottom_left[0]:f} {self.bottom_left[1]:f}\n\n") if self.buckets: for i in self.all_buckets: i.visualize(file) diff --git a/setup.py b/setup.py index e77140cf1e7db9112e220b9be20041488f086844..c92ea983c129e4622bb3bce813a3b1e0505db30b 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,4 @@ #! /usr/bin/env python -# -*- coding: utf-8 -*- from setuptools import setup @@ -15,7 +14,7 @@ exec(compile(version_file_contents, "pytools/version.py", "exec"), ver_dic) setup(name="pytools", version=ver_dic["VERSION_TEXT"], description="A collection of tools for Python", - long_description=open("README.rst", "r").read(), + long_description=open("README.rst").read(), classifiers=[ "Development Status :: 4 - Beta", "Intended Audience :: Developers",