Skip to content

Commit 915297a

Browse files
committed
Fix formatting to correct black version
1 parent 7bd50f6 commit 915297a

File tree

8 files changed

+86
-225
lines changed

8 files changed

+86
-225
lines changed

run_reg_test.py

Lines changed: 8 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@
1212

1313

1414
# pylint: disable=wrong-import-position, import-error
15-
sys.path.insert(
16-
0, str(Path(__file__).resolve().parent / "vtr_flow/scripts/python_libs")
17-
)
15+
sys.path.insert(0, str(Path(__file__).resolve().parent / "vtr_flow/scripts/python_libs"))
1816
sys.path.insert(0, str(Path(__file__).resolve().parent / "vtr_flow/scripts"))
1917
from run_vtr_task import vtr_command_main as run_vtr_task
2018
from vtr import (
@@ -56,10 +54,7 @@ def vtr_command_argparser(prog=None):
5654
)
5755

5856
parser = argparse.ArgumentParser(
59-
prog=prog,
60-
description=description,
61-
epilog=epilog,
62-
formatter_class=RawDefaultHelpFormatter,
57+
prog=prog, description=description, epilog=epilog, formatter_class=RawDefaultHelpFormatter,
6358
)
6459

6560
#
@@ -101,10 +96,7 @@ def vtr_command_argparser(prog=None):
10196
)
10297

10398
parser.add_argument(
104-
"-skip_qor",
105-
default=False,
106-
action="store_true",
107-
help="Skips running the Qor tests",
99+
"-skip_qor", default=False, action="store_true", help="Skips running the Qor tests",
108100
)
109101

110102
parser.add_argument(
@@ -130,10 +122,7 @@ def vtr_command_argparser(prog=None):
130122
)
131123

132124
parser.add_argument(
133-
"-long_task_names",
134-
default=False,
135-
action="store_true",
136-
help="Display long task names",
125+
"-long_task_names", default=False, action="store_true", help="Display long task names",
137126
)
138127

139128
return parser
@@ -157,9 +146,7 @@ def vtr_command_main(arg_list, prog=None):
157146
num_qor_failures = parse_single_test(collect_task_list(reg_test))
158147
elif args.check_golden:
159148
tests_run = True
160-
num_qor_failures = parse_single_test(
161-
collect_task_list(reg_test), check=True
162-
)
149+
num_qor_failures = parse_single_test(collect_task_list(reg_test), check=True)
163150
elif args.create_golden:
164151
# Create golden results
165152
num_qor_failures = 0
@@ -190,14 +177,8 @@ def vtr_command_main(arg_list, prog=None):
190177
num_qor_failures += parse_single_test(
191178
vtr_task_list_files, check=True, calculate=True
192179
)
193-
print(
194-
"\nTest '{}' had {} qor test failures".format(
195-
reg_test, num_qor_failures
196-
)
197-
)
198-
print(
199-
"\nTest '{}' had {} run failures\n".format(reg_test, num_func_failures)
200-
)
180+
print("\nTest '{}' had {} qor test failures".format(reg_test, num_qor_failures))
181+
print("\nTest '{}' had {} run failures\n".format(reg_test, num_func_failures))
201182
total_num_func_failures += num_func_failures
202183
total_num_qor_failures += num_qor_failures
203184
# Final summary
@@ -208,11 +189,7 @@ def vtr_command_main(arg_list, prog=None):
208189
):
209190
print("All tests passed")
210191
elif tests_run and total_num_func_failures != 0 or total_num_qor_failures != 0:
211-
print(
212-
"Error: {} tests failed".format(
213-
total_num_func_failures + total_num_qor_failures
214-
)
215-
)
192+
print("Error: {} tests failed".format(total_num_func_failures + total_num_qor_failures))
216193

217194
sys.exit(total_num_func_failures + total_num_qor_failures)
218195

vtr_flow/scripts/python_libs/vtr/flow.py

Lines changed: 8 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,9 @@ def run(
139139
circuit_file = vtr.util.verify_file(circuit_file, "Circuit")
140140
if architecture_file.suffix != ".xml":
141141
raise vtr.VtrError(
142-
"Expected Architecture file as second argument (was {})".format(
143-
architecture_file.name
144-
)
142+
"Expected Architecture file as second argument (was {})".format(architecture_file.name)
145143
)
146-
power_tech_file = (
147-
vtr.util.verify_file(power_tech_file, "Power") if power_tech_file else None
148-
)
144+
power_tech_file = vtr.util.verify_file(power_tech_file, "Power") if power_tech_file else None
149145
temp_dir = Path(temp_dir)
150146
temp_dir.mkdir(parents=True, exist_ok=True)
151147
netlist_ext = ".blif" if ".eblif" not in circuit_file.suffixes else ".eblif"
@@ -162,9 +158,7 @@ def run(
162158
lec_base_netlist = circuit_file.name if "blif" in circuit_file.suffixes else None
163159
# Reference netlist for LEC
164160

165-
gen_postsynthesis_netlist = temp_dir / (
166-
circuit_file.stem + "_post_synthesis" + netlist_ext
167-
)
161+
gen_postsynthesis_netlist = temp_dir / (circuit_file.stem + "_post_synthesis" + netlist_ext)
168162

169163
# Copy the circuit and architecture
170164
circuit_copy = temp_dir / circuit_file.name
@@ -180,10 +174,7 @@ def run(
180174
#
181175
# RTL Elaboration & Synthesis
182176
#
183-
if (
184-
should_run_stage(VtrStage.odin, start_stage, end_stage)
185-
and circuit_file.suffixes != ".blif"
186-
):
177+
if should_run_stage(VtrStage.odin, start_stage, end_stage) and circuit_file.suffixes != ".blif":
187178
vtr.odin.run(
188179
architecture_copy,
189180
next_stage_netlist,
@@ -197,9 +188,7 @@ def run(
197188

198189
next_stage_netlist = post_odin_netlist
199190

200-
lec_base_netlist = (
201-
post_odin_netlist if not lec_base_netlist else lec_base_netlist
202-
)
191+
lec_base_netlist = post_odin_netlist if not lec_base_netlist else lec_base_netlist
203192

204193
#
205194
# Logic Optimization & Technology Mapping
@@ -217,9 +206,7 @@ def run(
217206
)
218207

219208
next_stage_netlist = post_abc_netlist
220-
lec_base_netlist = (
221-
post_abc_netlist if not lec_base_netlist else lec_base_netlist
222-
)
209+
lec_base_netlist = post_abc_netlist if not lec_base_netlist else lec_base_netlist
223210

224211
#
225212
# Power Activity Estimation
@@ -243,9 +230,7 @@ def run(
243230

244231
# Use ACE's output netlist
245232
next_stage_netlist = post_ace_netlist
246-
lec_base_netlist = (
247-
post_ace_netlist if not lec_base_netlist else lec_base_netlist
248-
)
233+
lec_base_netlist = post_ace_netlist if not lec_base_netlist else lec_base_netlist
249234

250235
# Enable power analysis in VPR
251236
vpr_args["power"] = True
@@ -352,11 +337,7 @@ def run(
352337

353338

354339
def delete_intermediate_files(
355-
next_stage_netlist,
356-
post_ace_activity_file,
357-
keep_result_files,
358-
temp_dir,
359-
power_tech_file,
340+
next_stage_netlist, post_ace_activity_file, keep_result_files, temp_dir, power_tech_file,
360341
):
361342
"""
362343
delete intermediate files

vtr_flow/scripts/python_libs/vtr/inspect.py

Lines changed: 14 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,7 @@ def __init__(self, metric, min_value=None, max_value=None):
8888
super().__init__(metric)
8989

9090
if max_value < min_value:
91-
raise InspectError(
92-
"Invalid range specification (max value larger than min value)"
93-
)
91+
raise InspectError("Invalid range specification (max value larger than min value)")
9492

9593
self._min_value = min_value
9694
self._max_value = max_value
@@ -115,16 +113,10 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):
115113
ret_str = "both golden and check are None"
116114
elif check_value is None:
117115
ret_value = False
118-
ret_str = (
119-
"{} is {}, but check value is None".format(
120-
check_string, golden_value
121-
),
122-
)
116+
ret_str = ("{} is {}, but check value is None".format(check_string, golden_value),)
123117
else:
124118
ret_value = False
125-
ret_str = "{} is None, but check value is {}".format(
126-
check_string, check_value
127-
)
119+
ret_str = "{} is None, but check value is {}".format(check_string, check_value)
128120
return (ret_value, ret_str)
129121

130122
assert golden_value is not None
@@ -163,11 +155,7 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):
163155
False,
164156
"relative value {} outside of range [{},{}] "
165157
"and not equal to {} value: {}".format(
166-
norm_check_value,
167-
self.min_value(),
168-
self.max_value(),
169-
check_string,
170-
golden_value,
158+
norm_check_value, self.min_value(), self.max_value(), check_string, golden_value,
171159
),
172160
)
173161

@@ -179,9 +167,7 @@ def __init__(self, metric, min_value=None, max_value=None, abs_threshold=None):
179167
super().__init__(metric)
180168

181169
if max_value < min_value:
182-
raise InspectError(
183-
"Invalid range specification (max value larger than min value)"
184-
)
170+
raise InspectError("Invalid range specification (max value larger than min value)")
185171

186172
self._min_value = min_value
187173
self._max_value = max_value
@@ -216,14 +202,10 @@ def check_passed(self, golden_value, check_value, check_string="golden value"):
216202
ret_str = "both {} and check are None".format(check_string)
217203
elif golden_value is None:
218204
ret_value = False
219-
ret_str = "{} is None, but check value is {}".format(
220-
check_string, check_value
221-
)
205+
ret_str = "{} is None, but check value is {}".format(check_string, check_value)
222206
else:
223207
ret_value = False
224-
ret_str = "{} is {}, but check value is None".format(
225-
check_string, golden_value
226-
)
208+
ret_str = "{} is {}, but check value is None".format(check_string, golden_value)
227209

228210
return (ret_value, ret_str)
229211

@@ -343,13 +325,10 @@ def load_parse_patterns(parse_config_filepath):
343325
default_value = components[3]
344326

345327
if name not in parse_patterns:
346-
parse_patterns[name] = ParsePattern(
347-
name, filepath, regex_str, default_value
348-
)
328+
parse_patterns[name] = ParsePattern(name, filepath, regex_str, default_value)
349329
else:
350330
raise InspectError(
351-
"Duplicate parse pattern name '{}'".format(name),
352-
parse_config_filepath,
331+
"Duplicate parse pattern name '{}'".format(name), parse_config_filepath,
353332
)
354333

355334
else:
@@ -384,8 +363,7 @@ def load_pass_requirements(pass_requirements_filepath):
384363

385364
if metric in parse_patterns:
386365
raise InspectError(
387-
"Duplicate pass requirement for '{}'".format(metric),
388-
pass_requirements_filepath,
366+
"Duplicate pass requirement for '{}'".format(metric), pass_requirements_filepath,
389367
)
390368

391369
func, params_str = expr.split("(")
@@ -424,9 +402,7 @@ def load_pass_requirements(pass_requirements_filepath):
424402
parse_patterns[metric] = EqualPassRequirement(metric)
425403
else:
426404
raise InspectError(
427-
"Unexpected pass requirement function '{}' for metric '{}'".format(
428-
func, metric
429-
),
405+
"Unexpected pass requirement function '{}' for metric '{}'".format(func, metric),
430406
pass_requirements_filepath,
431407
)
432408

@@ -505,9 +481,7 @@ def determine_lut_size(architecture_file):
505481
lut_size = max(lut_size, input_width)
506482

507483
if saw_blif_names and lut_size == 0:
508-
raise InspectError(
509-
"Could not identify valid LUT size (K)", filename=architecture_file
510-
)
484+
raise InspectError("Could not identify valid LUT size (K)", filename=architecture_file)
511485

512486
return lut_size
513487

@@ -534,9 +508,7 @@ def determine_memory_addr_width(architecture_file):
534508
mem_addr_width = max(mem_addr_width, input_width)
535509

536510
if saw_ram and mem_addr_width == 0:
537-
raise InspectError(
538-
"Could not identify RAM block address width", filename=architecture_file
539-
)
511+
raise InspectError("Could not identify RAM block address width", filename=architecture_file)
540512

541513
return mem_addr_width
542514

@@ -545,9 +517,7 @@ def determine_min_w(log_filename):
545517
"""
546518
determines the miniumum width.
547519
"""
548-
min_w_regex = re.compile(
549-
r"\s*Best routing used a channel width factor of (?P<min_w>\d+)."
550-
)
520+
min_w_regex = re.compile(r"\s*Best routing used a channel width factor of (?P<min_w>\d+).")
551521
with open(log_filename) as file:
552522
for line in file:
553523
match = min_w_regex.match(line)

vtr_flow/scripts/python_libs/vtr/parse_vtr_flow.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,11 @@
66
from pathlib import Path
77
import glob
88
from collections import OrderedDict
9+
910
# pylint: disable=wrong-import-position
1011
sys.path.insert(0, str(Path(__file__).resolve().parent.parent))
1112
import vtr
13+
1214
# pylint: enable=wrong-import-position
1315
def parse_vtr_flow(arg_list):
1416
"""
@@ -36,9 +38,7 @@ def parse_vtr_flow(arg_list):
3638
# Set defaults
3739
for parse_pattern in parse_patterns.values():
3840
metrics[parse_pattern.name()] = (
39-
parse_pattern.default_value()
40-
if parse_pattern.default_value() is not None
41-
else ""
41+
parse_pattern.default_value() if parse_pattern.default_value() is not None else ""
4242
)
4343
print(parse_pattern.name(), end="\t")
4444
print("")

0 commit comments

Comments
 (0)