Skip to content

Commit b0b95e3

Browse files
committed
refactor: reformatted using black
1 parent 380200f commit b0b95e3

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

benchmarks/streamson-bench

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ def memory(strategy: str, input_path: str):
140140

141141
def call(limit) -> int:
142142
retval = subprocess.call(
143-
args + ["--memory-limit", str(limit)], stderr=subprocess.DEVNULL, stdout=subprocess.DEVNULL,
143+
args + ["--memory-limit", str(limit)],
144+
stderr=subprocess.DEVNULL,
145+
stdout=subprocess.DEVNULL,
144146
)
145147
print(f"{limit}MB - {retval == 0}", file=sys.stderr)
146148
return retval
@@ -218,11 +220,18 @@ if __name__ == "__main__":
218220
mem_parser.add_argument("-i", "--input-file", help="input json file", required=True)
219221
mem_parser.add_argument("-s", "--strategy", help="parse strategy", choices=STRATEGIES.keys(), required=True)
220222

221-
time_parser = subparsers.add_parser("time", help="performs several measurements and calculates the average",)
223+
time_parser = subparsers.add_parser(
224+
"time",
225+
help="performs several measurements and calculates the average",
226+
)
222227
time_parser.add_argument("-i", "--input-file", help="input json file", required=True)
223228
time_parser.add_argument("-s", "--strategy", help="parse strategy", choices=STRATEGIES.keys(), required=True)
224229
time_parser.add_argument(
225-
"-a", "--attempts", help="number of attempts (default=10)", type=int, default=10,
230+
"-a",
231+
"--attempts",
232+
help="number of attempts (default=10)",
233+
type=int,
234+
default=10,
226235
)
227236

228237
bench_parser = subparsers.add_parser("_bench", help="performs a signle benchmark (outputs consumed time)")
@@ -231,7 +240,11 @@ if __name__ == "__main__":
231240
bench_parser.add_argument("-o", "--output-file", help="output csv file", default=None)
232241
bench_parser.add_argument("-l", "--memory-limit", help="memory limit (in MB)", default=0, type=int)
233242
bench_parser.add_argument(
234-
"-c", "--check-total", help="check total group and user count", default=None, type=int,
243+
"-c",
244+
"--check-total",
245+
help="check total group and user count",
246+
default=None,
247+
type=int,
235248
)
236249

237250
options = parser.parse_args()
@@ -241,7 +254,11 @@ if __name__ == "__main__":
241254
"memory": lambda: memory(options.strategy, options.input_file),
242255
"time": lambda: times(options.strategy, options.input_file, options.attempts),
243256
"_bench": lambda: bench(
244-
options.strategy, options.input_file, options.output_file, options.memory_limit, options.check_total,
257+
options.strategy,
258+
options.input_file,
259+
options.output_file,
260+
options.memory_limit,
261+
options.check_total,
245262
),
246263
}
247264

tests/test_extract.py

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@
99

1010

1111
@pytest.mark.parametrize(
12-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
12+
"convert",
13+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
14+
ids=["raw", "json", "hyperjson"],
1315
)
1416
def test_simple(convert):
1517
matcher = streamson.SimpleMatcher('{"users"}[]')
@@ -23,7 +25,9 @@ def test_simple(convert):
2325

2426

2527
@pytest.mark.parametrize(
26-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
28+
"convert",
29+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
30+
ids=["raw", "json", "hyperjson"],
2731
)
2832
def test_depth(convert):
2933
matcher = streamson.DepthMatcher(1)
@@ -45,7 +49,9 @@ def test_depth(convert):
4549

4650

4751
@pytest.mark.parametrize(
48-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
52+
"convert",
53+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
54+
ids=["raw", "json", "hyperjson"],
4955
)
5056
def test_invert(convert):
5157
matcher = ~streamson.DepthMatcher(2)
@@ -55,7 +61,9 @@ def test_invert(convert):
5561

5662

5763
@pytest.mark.parametrize(
58-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
64+
"convert",
65+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
66+
ids=["raw", "json", "hyperjson"],
5967
)
6068
def test_all(convert):
6169
matcher = streamson.SimpleMatcher('{"users"}[]') & streamson.SimpleMatcher("{}[1]")
@@ -68,7 +76,9 @@ def test_all(convert):
6876

6977

7078
@pytest.mark.parametrize(
71-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
79+
"convert",
80+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
81+
ids=["raw", "json", "hyperjson"],
7282
)
7383
def test_any(convert):
7484
matcher = streamson.DepthMatcher(2, 2) | streamson.SimpleMatcher('{"users"}')
@@ -84,7 +94,9 @@ def test_any(convert):
8494

8595

8696
@pytest.mark.parametrize(
87-
"convert", [lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)], ids=["raw", "json", "hyperjson"],
97+
"convert",
98+
[lambda x: x, lambda x: json.dumps(x), lambda x: hyperjson.dumps(x)],
99+
ids=["raw", "json", "hyperjson"],
88100
)
89101
def test_complex(convert):
90102
matcher = (streamson.DepthMatcher(2, 2) | streamson.SimpleMatcher('{"users"}')) & ~streamson.SimpleMatcher(

0 commit comments

Comments
 (0)