Skip to content

Commit

Permalink
Run flynt
Browse files Browse the repository at this point in the history
  • Loading branch information
jarrodmillman committed Sep 14, 2023
1 parent 821dc77 commit 4201828
Show file tree
Hide file tree
Showing 12 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion demo/cwt_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
ax.contourf(time, np.log2(period), np.log2(power), np.log2(levels),
extend='both')

ax.set_title('{} Wavelet Power Spectrum ({})'.format('Nino1+2', wavelet))
ax.set_title(f'Nino1+2 Wavelet Power Spectrum ({wavelet})')
ax.set_ylabel('Period (years)')
Yticks = 2 ** np.arange(np.ceil(np.log2(period.min())),
np.ceil(np.log2(period.max())))
Expand Down
2 changes: 1 addition & 1 deletion demo/image_blender.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ def main():
options.mode, options.base_gain, options.texture_gain)

if options.timeit:
print("%.3fs" % (clock() - t))
print(f"{clock() - t:.3f}s")

im.save(options.output)

Expand Down
2 changes: 1 addition & 1 deletion demo/swt2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
ax.imshow(a, origin='upper', interpolation="nearest", cmap=plt.cm.gray)
ax.set_title(titles[i], fontsize=12)

fig.suptitle("SWT2 coefficients, level %s" % level, fontsize=14)
fig.suptitle(f"SWT2 coefficients, level {level}", fontsize=14)
level += 1


Expand Down
2 changes: 1 addition & 1 deletion doc/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@

# General information about the project.
project = 'PyWavelets'
copyright = '2006-%s, The PyWavelets Developers' % datetime.date.today().year
copyright = f'2006-{datetime.date.today().year}, The PyWavelets Developers'

# 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
4 changes: 2 additions & 2 deletions pywt/_dwt.py
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ def downcoef(part, data, wavelet, mode='symmetric', level=1):
if data.ndim > 1:
raise ValueError("downcoef only supports 1d data.")
if part not in 'ad':
raise ValueError("Argument 1 must be 'a' or 'd', not '%s'." % part)
raise ValueError(f"Argument 1 must be 'a' or 'd', not '{part}'.")
mode = Modes.from_object(mode)
wavelet = _as_wavelet(wavelet)
return np.asarray(_downcoef(part == 'a', data, wavelet, mode, level))
Expand Down Expand Up @@ -397,7 +397,7 @@ def upcoef(part, coeffs, wavelet, level=1, take=0):
raise ValueError("upcoef only supports 1d coeffs.")
wavelet = _as_wavelet(wavelet)
if part not in 'ad':
raise ValueError("Argument 1 must be 'a' or 'd', not '%s'." % part)
raise ValueError(f"Argument 1 must be 'a' or 'd', not '{part}'.")
return np.asarray(_upcoef(part == 'a', coeffs, wavelet, level, take))


Expand Down
4 changes: 2 additions & 2 deletions pywt/_pytesttester.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
def _show_pywt_info():
import pywt
from pywt._c99_config import _have_c99_complex
print("PyWavelets version %s" % pywt.__version__)
print(f"PyWavelets version {pywt.__version__}")
if _have_c99_complex:
print("Compiled with C99 complex support.")
else:
Expand Down Expand Up @@ -145,7 +145,7 @@ def __call__(self, label='fast', verbose=1, extra_argv=None,
pytest_args += ["-m", label]

if durations >= 0:
pytest_args += ["--durations=%s" % durations]
pytest_args += [f"--durations={durations}"]

if tests is None:
tests = [self.module_name]
Expand Down
6 changes: 3 additions & 3 deletions pywt/_wavelet_packets.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def _delete_node(self, part):

def _validate_node_name(self, part):
if part not in self.PARTS:
raise ValueError("Subnode name must be in [{}], not '{}'.".format(', '.join("'%s'" % p for p in self.PARTS), part))
raise ValueError("Subnode name must be in [{}], not '{}'.".format(', '.join(f"'{p}'" for p in self.PARTS), part))

@property
def path_tuple(self):
Expand Down Expand Up @@ -608,7 +608,7 @@ def _delete_node(self, part):
def _validate_node_name(self, part):
if part not in self.PARTS:
raise ValueError(
"Subnode name must be in [{}], not '{}'.".format(', '.join("'%s'" % p for p in list(self.PARTS.keys())), part))
"Subnode name must be in [{}], not '{}'.".format(', '.join(f"'{p}'" for p in list(self.PARTS.keys())), part))

def _create_subnode(self, part, data=None, overwrite=True):
return self._create_subnode_base(node_cls=NodeND, part=part, data=data,
Expand Down Expand Up @@ -803,7 +803,7 @@ def collect(node):
graycode_order = get_graycode_order(level)
return [result[path] for path in graycode_order if path in result]
else:
raise ValueError("Invalid order name - %s." % order)
raise ValueError(f"Invalid order name - {order}.")


class WaveletPacket2D(Node2D):
Expand Down
6 changes: 2 additions & 4 deletions pywt/tests/data/generate_matlab_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
mlab_code = ("[ma, md] = dwt(data, Lo_D, Hi_D, "
"'mode', '%s');" % mmode)
else:
mlab_code = ("[ma, md] = dwt(data, wavelet, "
"'mode', '%s');" % mmode)
mlab_code = f"[ma, md] = dwt(data, wavelet, 'mode', '{mmode}');"
res = mlab.run_code(mlab_code)
if not res['success']:
raise RuntimeError(
Expand All @@ -76,8 +75,7 @@
# Matlab result
mlab.set_variable('Lo_D', w.dec_lo)
mlab.set_variable('Hi_D', w.dec_hi)
mlab_code = ("[ma, md] = dwt(data, Lo_D, Hi_D, "
"'mode', '%s');" % mmode)
mlab_code = f"[ma, md] = dwt(data, Lo_D, Hi_D, 'mode', '{mmode}');"
res = mlab.run_code(mlab_code)
if not res['success']:
raise RuntimeError(
Expand Down
4 changes: 2 additions & 2 deletions pywt/tests/test_matlab_compatibility.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def _compute_matlab_result(data, wavelet, mmode, mlab):
w = pywt.Wavelet(wavelet)
mlab.set_variable('Lo_D', w.dec_lo)
mlab.set_variable('Hi_D', w.dec_hi)
mlab_code = ("[ma, md] = dwt(data, Lo_D, Hi_D, 'mode', '%s');" % mmode)
mlab_code = f"[ma, md] = dwt(data, Lo_D, Hi_D, 'mode', '{mmode}');"
else:
mlab_code = "[ma, md] = dwt(data, wavelet, 'mode', '%s');" % mmode
mlab_code = f"[ma, md] = dwt(data, wavelet, 'mode', '{mmode}');"
res = mlab.run_code(mlab_code)
if not res['success']:
raise RuntimeError("Matlab failed to execute the provided code. "
Expand Down
14 changes: 7 additions & 7 deletions util/authors.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def analyze_line(line, names, disp=False):
name = NAME_MAP.get(name, name)
if disp:
if name not in names:
stdout_b.write((" - Author: %s\n" % name).encode('utf-8'))
stdout_b.write(f" - Author: {name}\n".encode('utf-8'))
names.add(name)

# Look for "thanks to" messages in the commit log
Expand All @@ -63,7 +63,7 @@ def analyze_line(line, names, disp=False):
name = m.group(2)
if name not in ('this',):
if disp:
stdout_b.write(" - Log : %s\n" % line.strip().encode('utf-8'))
stdout_b.write(f" - Log : {line.strip().encode('utf-8')}\n")
name = NAME_MAP.get(name, name)
names.add(name)

Expand Down Expand Up @@ -107,7 +107,7 @@ def name_key(fullname):
# Print some empty lines to separate
stdout_b.write(b"\n\n")
for author in n_authors:
stdout_b.write(("- %s\n" % author).encode('utf-8'))
stdout_b.write(f"- {author}\n".encode('utf-8'))
# return for early exit so we only print new authors
return

Expand All @@ -123,9 +123,9 @@ def name_key(fullname):

for author in authors:
if author in all_authors:
stdout_b.write(("* %s\n" % author).encode('utf-8'))
stdout_b.write(f"* {author}\n".encode('utf-8'))
else:
stdout_b.write(("* %s +\n" % author).encode('utf-8'))
stdout_b.write(f"* {author} +\n".encode('utf-8'))

stdout_b.write(("""
A total of %(count)d people contributed to this release.
Expand Down Expand Up @@ -191,7 +191,7 @@ def _call(self, command, args, kw, repository=None, call=False):
def __call__(self, command, *a, **kw):
ret = self._call(command, a, {}, call=True, **kw)
if ret != 0:
raise RuntimeError("%s failed" % self.executable)
raise RuntimeError(f"{self.executable} failed")

def pipe(self, command, *a, **kw):
stdin = kw.pop('stdin', None)
Expand All @@ -204,7 +204,7 @@ def read(self, command, *a, **kw):
call=False, **kw)
out, err = p.communicate()
if p.returncode != 0:
raise RuntimeError("%s failed" % self.executable)
raise RuntimeError(f"{self.executable} failed")
return out

def readlines(self, command, *a, **kw):
Expand Down
2 changes: 1 addition & 1 deletion util/gh_lists.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def __init__(self, filename, getter):

self.filename = filename
if os.path.isfile(filename):
print("[gh_lists] using {} as cache (remove it if you want fresh data)".format(filename),
print(f"[gh_lists] using {filename} as cache (remove it if you want fresh data)",
file=sys.stderr)
with open(filename, encoding='utf-8') as f:
self.cache = json.load(f)
Expand Down
8 changes: 4 additions & 4 deletions util/refguide_check.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,12 +222,12 @@ def check_items(all_dict, names, deprecated, others, module_name, dots=True):
return [(None, True, output)]
else:
if len(only_all) > 0:
output += "ERROR: objects in %s.__all__ but not in refguide::\n\n" % module_name
output += f"ERROR: objects in {module_name}.__all__ but not in refguide::\n\n"
for name in sorted(only_all):
output += " " + name + "\n"

if len(only_ref) > 0:
output += "ERROR: objects in refguide but not in %s.__all__::\n\n" % module_name
output += f"ERROR: objects in refguide but not in {module_name}.__all__::\n\n"
for name in sorted(only_ref):
output += " " + name + "\n"

Expand Down Expand Up @@ -771,7 +771,7 @@ def main(argv):
success = True
results = []

print("Running checks for %d modules:" % (len(modules),))
print(f"Running checks for {len(modules)} modules:")

if args.doctests or not args.skip_examples:
init_matplotlib()
Expand Down Expand Up @@ -806,7 +806,7 @@ def main(argv):
if not args.skip_examples:
examples_path = os.path.join(
os.getcwd(), 'doc', 'source', 'regression', '*.rst')
print('\nChecking examples files at %s:' % examples_path)
print(f'\nChecking examples files at {examples_path}:')
for filename in sorted(glob.glob(examples_path)):
if dots:
sys.stderr.write('\n')
Expand Down

0 comments on commit 4201828

Please sign in to comment.