Skip to content

Commit 694654b

Browse files
make format-py
1 parent a210310 commit 694654b

34 files changed

+127
-95
lines changed

dev/pylint_check.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ def expand_paths():
132132
"""Build a list of all python files to process by going through 'paths_to_lint'"""
133133

134134
paths = []
135-
for (path, is_recursive) in paths_to_lint:
135+
for path, is_recursive in paths_to_lint:
136136
# Make sure all hard-coded paths point to .py files
137137
if path.is_file():
138138
if path.suffix.lower() != ".py":

dev/submit_slurm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ def get_resource_estimates(filepath):
188188
mem_bytes = float(match.groupdict()["mem_bytes"])
189189

190190
time_minutes = time_sec / 60
191-
mem_mb = mem_bytes / (1024 ** 2)
191+
mem_mb = mem_bytes / (1024**2)
192192

193193
return time_minutes, mem_mb
194194

dev/vtr_gdb_pretty_printers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
88
https://docs.verilogtorouting.org/en/latest/dev/developing#vtr-pretty-printers
99
"""
10+
1011
import re
1112

13+
1214
# VTR related
1315
class VtrStrongIdPrinter:
1416
def __init__(self, val, typename="vtr::StrongId"):

odin_ii/regression_test/tools/8_bit_arithmetic_power_output.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ def make_output_vector(power):
1111
print("c")
1212
next_a = 0
1313
for i in range(0, 512):
14-
value = next_a ** power
14+
value = next_a**power
1515
output = f"{value:#0{4}x}"
1616
print(output[0:2] + output[-2:])
1717
if i % 2 == 1:
1818
next_a += 1
19-
value = next_a ** power
19+
value = next_a**power
2020
output = f"{value:#0{4}x}"
2121
print(output[0:2] + output[-2:])
2222
print("0x00")

odin_ii/regression_test/tools/asr_vector_maker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ def make_input_vector(bits):
6767
# One for each value (2^bits)
6868
# a rising edge for each line ( * 2)
6969
# a line for reset ( + 1)
70-
lines = ((2 ** bits) * 2) + 2
70+
lines = ((2**bits) * 2) + 2
7171
for i in range(0, lines):
7272
if i < (lines - 1):
7373
inputs[0].append(value)

vpr/scripts/profile/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import socket
66
import getpass
77

8+
89
# working on the task directory
910
def sort_runs(runs):
1011
natural_sort(runs)

vtr_flow/benchmarks/system_verilog/f4pga/make_sv_flattened.py

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,51 @@
11
"""
22
Module for flattening the SV design files.
33
"""
4+
45
import os
56
import re
67

8+
79
def find_verilog_files():
810
"""Find all Verilog (.sv, .v) files in the current directory."""
9-
return [f for f in os.listdir('.') if f.endswith(('.sv', '.v'))]
11+
return [f for f in os.listdir(".") if f.endswith((".sv", ".v"))]
12+
1013

1114
def identify_top_module(file_list):
1215
"""Identify the file containing the top module definition."""
1316
top_module_regex = re.compile(r"module\s+top\s*\(")
1417
for file in file_list:
15-
with open(file, 'r') as f:
18+
with open(file, "r") as f:
1619
for line in f:
1720
if top_module_regex.search(line):
1821
return file
1922
return None
2023

24+
2125
def create_flattened_file(top_file, file_list):
2226
"""Create a flattened Verilog file with all file contents."""
2327
current_dir = os.path.basename(os.getcwd())
2428
output_file_name = f"flattened_{current_dir}.sv"
2529

26-
with open(output_file_name, 'w') as output_file:
30+
with open(output_file_name, "w") as output_file:
2731
if top_file:
2832
# Write the top module first
29-
with open(top_file, 'r') as top_module:
33+
with open(top_file, "r") as top_module:
3034
output_file.write(f"// Content from {top_file}\n")
3135
output_file.write(top_module.read())
3236
output_file.write("\n\n")
3337

3438
# Write the rest of the files
3539
for file in file_list:
3640
if file != top_file:
37-
with open(file, 'r') as verilog_file:
41+
with open(file, "r") as verilog_file:
3842
output_file.write(f"// Content from {file}\n")
3943
output_file.write(verilog_file.read())
4044
output_file.write("\n\n")
4145

4246
print(f"Flattened file created: {output_file_name}")
4347

48+
4449
def main():
4550
"""Main function to generate the flattened Verilog file."""
4651
print("Searching for Verilog files...")
@@ -61,5 +66,6 @@ def main():
6166
print("Creating flattened file...")
6267
create_flattened_file(top_file, verilog_files)
6368

69+
6470
if __name__ == "__main__":
6571
main()

vtr_flow/scripts/arch_gen/arch_gen.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def xLUT(LUT_size, num_LUT):
172172

173173

174174
def xCLB(k_LUT, N_BLE, I_CLB, I_BLE, fracture_level, num_FF, crossbar_str):
175-
O_LUT = 2 ** fracture_level
175+
O_LUT = 2**fracture_level
176176
O_soft = O_LUT
177177
O_ble = O_soft
178178
O_CLB = N_BLE * O_ble
@@ -430,7 +430,7 @@ def xCLB(k_LUT, N_BLE, I_CLB, I_BLE, fracture_level, num_FF, crossbar_str):
430430
else:
431431
special_stage = False
432432

433-
num_LUT = 2 ** frac_stage
433+
num_LUT = 2**frac_stage
434434
LUT_size = k_LUT - frac_stage
435435

436436
idx = "[" + str(LUT_size - 1) + ":0]"

vtr_flow/scripts/benchtracker/flask_cors/six.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -687,7 +687,6 @@ def reraise(tp, value, tb=None):
687687
raise value.with_traceback(tb)
688688
raise value
689689

690-
691690
else:
692691

693692
def exec_(_code_, _globs_=None, _locs_=None):
@@ -809,13 +808,13 @@ def wrapper(f):
809808

810809
return wrapper
811810

812-
813811
else:
814812
wraps = functools.wraps
815813

816814

817815
def with_metaclass(meta, *bases):
818816
"""Create a base class with a metaclass."""
817+
819818
# This requires a bit of explanation: the basic idea is to make a dummy
820819
# metaclass for one level of class instantiation that replaces itself with
821820
# the actual metaclass.

vtr_flow/scripts/benchtracker/populate_db.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
nullval = "-1"
2626
type_map = {int: "INT", float: "REAL", str: "TEXT"}
2727

28+
2829
# main program sequence
2930
def main():
3031
params = Params()
@@ -59,6 +60,7 @@ def update_db(params, db):
5960
# check if table for task exists; if not then create it
6061
task_table_name = params.task_table_name
6162
create_table(params, db, task_table_name)
63+
6264
# load up latest run and parsed date for task
6365
def check_last_runs_table(runs):
6466
natural_sort(runs)

vtr_flow/scripts/blif_splicer.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,11 @@
8888
# and is not 're') with the name of the circuit.
8989

9090
sections[sectionNumber] += " ".join(
91-
name + "_" + word
92-
if word != "re" and any(char not in nonNetChars for char in word)
93-
else word
91+
(
92+
name + "_" + word
93+
if word != "re" and any(char not in nonNetChars for char in word)
94+
else word
95+
)
9496
for word in line.split(" ")
9597
)
9698

vtr_flow/scripts/download_noc_mlp.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import shutil
1818
import errno
1919

20+
2021
class ExtractionError(Exception):
2122
"""
2223
Raised when extracting the downlaoded file fails
@@ -39,8 +40,9 @@ def parse_args():
3940
does nothing (unless --force is specified).
4041
"""
4142
)
42-
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
43-
description=description)
43+
parser = argparse.ArgumentParser(
44+
formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=description
45+
)
4446

4547
parser.add_argument(
4648
"--vtr_flow_dir",
@@ -132,7 +134,7 @@ def extract_to_vtr_flow_dir(args, tar_gz_filename):
132134
raise ExtractionError("{} should be a directory".format(directory))
133135

134136
# Create a temporary working directory
135-
tmpdir = tempfile.mkdtemp(suffix="download_NoC_MLP", dir= os.path.abspath("."))
137+
tmpdir = tempfile.mkdtemp(suffix="download_NoC_MLP", dir=os.path.abspath("."))
136138
try:
137139
# Extract the contents of the .tar.gz archive directly into the destination directory
138140
with tarfile.open(tar_gz_filename, "r:gz") as tar:

vtr_flow/scripts/download_titan.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@ def parse_args():
4141
does nothing (unless --force is specified).
4242
"""
4343
)
44-
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter,
45-
description=description)
44+
parser = argparse.ArgumentParser(
45+
formatter_class=argparse.ArgumentDefaultsHelpFormatter, description=description
46+
)
4647

4748
parser.add_argument(
4849
"--titan_version", default="2.0.0", help="Titan release version to download"

vtr_flow/scripts/python_libs/vtr/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
__init__ for the VTR python module
33
"""
4+
45
from .util import (
56
load_config_lines,
67
CommandRunner,
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""
22
__init__ for abc module
33
"""
4+
45
from .abc import run, run_lec

vtr_flow/scripts/python_libs/vtr/abc/abc.py

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
"""
22
Module to run ABC with its various options
33
"""
4+
45
import shutil
56
from collections import OrderedDict
67
from pathlib import Path
78
from vtr import determine_lut_size, verify_file, CommandRunner
89
from vtr import paths
910
from vtr.error import InspectError
1011

12+
1113
# pylint: disable=too-many-arguments, too-many-locals
1214
def run(
1315
architecture_file,
@@ -186,24 +188,26 @@ def run(
186188
]
187189
)
188190
if abc_script is None
189-
else "; ".join(
190-
[
191-
"read {pre_abc_blif}".format(pre_abc_blif=pre_abc_blif.name),
192-
"time",
193-
"resyn",
194-
"resyn2",
195-
"if -K {lut_size}".format(lut_size=lut_size),
196-
"time",
197-
"scleanup",
198-
"write_hie {pre_abc_blif} {post_abc_raw_blif}".format(
199-
pre_abc_blif=pre_abc_blif.name,
200-
post_abc_raw_blif=post_abc_raw_blif.name,
201-
),
202-
"print_stats",
203-
]
191+
else (
192+
"; ".join(
193+
[
194+
"read {pre_abc_blif}".format(pre_abc_blif=pre_abc_blif.name),
195+
"time",
196+
"resyn",
197+
"resyn2",
198+
"if -K {lut_size}".format(lut_size=lut_size),
199+
"time",
200+
"scleanup",
201+
"write_hie {pre_abc_blif} {post_abc_raw_blif}".format(
202+
pre_abc_blif=pre_abc_blif.name,
203+
post_abc_raw_blif=post_abc_raw_blif.name,
204+
),
205+
"print_stats",
206+
]
207+
)
208+
if use_old_abc_script
209+
else abc_script
204210
)
205-
if use_old_abc_script
206-
else abc_script
207211
)
208212

209213
cmd = [abc_exec, "-c", abc_script]
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""
22
init for the ACE module
33
"""
4+
45
from .ace import run

vtr_flow/scripts/python_libs/vtr/ace/ace.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
"""
22
Module to run ACE with its various options
33
"""
4+
45
from pathlib import Path
56
from vtr import verify_file, CommandRunner, paths
67

8+
79
# pylint: disable=too-many-arguments
810
def run(
911
circuit_file,

vtr_flow/scripts/python_libs/vtr/flow.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Module to run the VTR flow. This module calls other modules that then access the tools like VPR.
33
"""
4+
45
import shutil
56
from pathlib import Path
67
from collections import OrderedDict
@@ -258,9 +259,9 @@ def run(
258259
if should_run_stage(VtrStage.ACE, start_stage, end_stage):
259260
vtr.ace.run(
260261
next_stage_netlist,
261-
old_netlist=post_odin_netlist
262-
if start_stage == VtrStage.ODIN
263-
else post_yosys_netlist,
262+
old_netlist=(
263+
post_odin_netlist if start_stage == VtrStage.ODIN else post_yosys_netlist
264+
),
264265
output_netlist=post_ace_netlist,
265266
output_activity_file=post_ace_activity_file,
266267
command_runner=command_runner,

vtr_flow/scripts/python_libs/vtr/log_parse.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
module that contains functions to inspect various files to determine important values
33
"""
4+
45
import re
56
from collections import OrderedDict
67
from pathlib import Path
@@ -25,7 +26,7 @@ def __init__(self, name, filename, regex_str, default_value=None):
2526
self._filename = filename
2627
# Look for the specified pattern somewhere in the line, but any characters
2728
# can occur before and after it. Detailed in GitHub Issue #2743.
28-
self._regex = re.compile(f'^.*{regex_str}.*$')
29+
self._regex = re.compile(f"^.*{regex_str}.*$")
2930
self._default_value = default_value
3031

3132
def name(self):
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""
22
init for the ODIN module
33
"""
4+
45
from .odin import run

vtr_flow/scripts/python_libs/vtr/odin/odin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Module to run ODIN II with its various arguments
33
"""
4+
45
import os
56
import shutil
67
from collections import OrderedDict
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
"""
22
init for the YOSYS module
33
"""
4+
45
from .parmys import run
56
from .parmys import YOSYS_PARSERS

vtr_flow/scripts/python_libs/vtr/parmys/parmys.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Module to run Parmys with its various arguments
33
"""
4+
45
import os
56
import shutil
67
from collections import OrderedDict

0 commit comments

Comments
 (0)