From fe59ce2342042149b9c000a12da3f58f3c8e7aed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20M=C3=BCller?= Date: Sun, 16 Jun 2024 23:56:04 +0200 Subject: [PATCH] flake8 --- .flake8 | 4 ++++ tests/helper.py | 10 ++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) create mode 100644 .flake8 diff --git a/.flake8 b/.flake8 new file mode 100644 index 0000000..c5c58a1 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +per-file-ignores = + # line too long + tests/test_ibw.py: E501, diff --git a/tests/helper.py b/tests/helper.py index 1988194..4b08d5b 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,14 +1,16 @@ import pathlib import numpy as _numpy -from pprint import pformat, PrettyPrinter +from pprint import PrettyPrinter from igor2.binarywave import load as loadibw data_dir = pathlib.Path(__file__).parent / "data" + class NumpyPrettyPrinter(PrettyPrinter): def format(self, object, context, maxlevels, level): if isinstance(object, _numpy.ndarray): - # Generate the entire array string using numpy's own mechanism but ensuring dtype is displayed + # Generate the entire array string using numpy's own mechanism but + # ensuring dtype is displayed array_repr = _numpy.array2string(object, separator=', ') # Append dtype only once for the whole array formatted_array = f"array({array_repr}, dtype='{object.dtype}')" @@ -18,11 +20,11 @@ def format(self, object, context, maxlevels, level): def custom_pformat(object, indent=1, width=80, depth=None, *, compact=False): - printer = NumpyPrettyPrinter(indent=indent, width=width, depth=depth, compact=compact) + printer = NumpyPrettyPrinter( + indent=indent, width=width, depth=depth, compact=compact) return printer.pformat(object) - def assert_equal_dump_no_whitespace_no_byte(data_a, data_b): def repl(x): for old, new in [