Skip to content

Commit 38fc479

Browse files
author
Winter Deng
committed
reformat changed code
1 parent 4c5459c commit 38fc479

File tree

2 files changed

+21
-18
lines changed

2 files changed

+21
-18
lines changed

docs/cli/classifier.py

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
lib_path = os.path.abspath(os.path.join(current_dir, "..", ".."))
1010
sys.path.insert(0, lib_path)
1111

12+
1213
def classify_file_category(path):
1314

1415
relative_path = Path(path).relative_to(lib_path)
@@ -30,28 +31,25 @@ def fetch_option_flags(flags):
3031

3132
for flag in flags:
3233
flag_list.append(
33-
{
34-
"name": flag["name"].replace("\\", ""),
35-
"instruction": flag["name"].split("-")[-1],
36-
"description": flag["description"]
37-
}
38-
)
34+
{
35+
"name": flag["name"].replace("\\", ""),
36+
"instruction": flag["name"].split("-")[-1],
37+
"description": flag["description"],
38+
}
39+
)
3940

4041
return flag_list
4142

4243

4344
def fetch_all_files():
44-
main_files = [
45-
os.path.join(lib_path, "linear_trainer.py"),
46-
os.path.join(lib_path, "torch_trainer.py")
47-
]
45+
main_files = [os.path.join(lib_path, "linear_trainer.py"), os.path.join(lib_path, "torch_trainer.py")]
4846
lib_files = glob.glob(os.path.join(lib_path, "libmultilabel/**/*.py"), recursive=True)
4947
file_set = set(map(os.path.abspath, main_files + lib_files))
5048
return file_set
5149

5250

5351
def find_config_usages_in_file(file_path, allowed_keys):
54-
pattern = re.compile(r'\bconfig\.([a-zA-Z_][a-zA-Z0-9_]*)')
52+
pattern = re.compile(r"\bconfig\.([a-zA-Z_][a-zA-Z0-9_]*)")
5553
detailed_results = {}
5654
try:
5755
with open(file_path, "r", encoding="utf-8") as f:
@@ -77,7 +75,7 @@ def move_duplicates_together(data, keep):
7775
duplicates = set()
7876

7977
for i, key1 in enumerate(all_keys):
80-
for key2 in all_keys[i+1:]:
78+
for key2 in all_keys[i + 1 :]:
8179
duplicates |= data[key1] & data[key2]
8280

8381
data[keep] |= duplicates
@@ -99,7 +97,7 @@ def classify(raw_flags):
9997
collected = {}
10098

10199
for file_path in file_set:
102-
detailed_results = find_config_usages_in_file(file_path, allowed_keys)
100+
detailed_results = find_config_usages_in_file(file_path, allowed_keys)
103101
if detailed_results:
104102
usage_map[file_path] = set(detailed_results.keys())
105103
for k, v in detailed_results.items():
@@ -125,7 +123,9 @@ def classify(raw_flags):
125123
for flag in flags:
126124
if flag["category"] not in result:
127125
result[flag["category"]] = []
128-
result[flag["category"]].append({"name": flag["name"].replace("--", r"\-\-"), "description": flag["description"]})
126+
result[flag["category"]].append(
127+
{"name": flag["name"].replace("--", r"\-\-"), "description": flag["description"]}
128+
)
129129

130130
result["details"] = []
131131
for k, v in collected.items():

docs/cli/genflags.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,11 @@ def add_argument(
3434

3535
classified = classify(parser.flags)
3636

37+
3738
def width_title(key, title):
3839
return max(map(lambda f: len(f[key]), classified[title]))
3940

41+
4042
def print_table(title, flags, intro):
4143
print()
4244
print(intro)
@@ -53,21 +55,22 @@ def print_table(title, flags, intro):
5355
print("=" * wn, "=" * wd)
5456
print()
5557

58+
5659
print_table(
5760
"general",
5861
classified["general"],
5962
intro="**General options**:\n\
60-
Common configurations shared across both linear and neural network trainers."
63+
Common configurations shared across both linear and neural network trainers.",
6164
)
6265
print_table(
6366
"linear",
6467
classified["linear"],
6568
intro="**Linear options**:\n\
66-
Configurations specific to linear trainer."
69+
Configurations specific to linear trainer.",
6770
)
6871
print_table(
6972
"nn",
7073
classified["nn"],
7174
intro="**Neural network options**:\n\
72-
Configurations specific to torch (neural networks) trainer."
73-
)
75+
Configurations specific to torch (neural networks) trainer.",
76+
)

0 commit comments

Comments
 (0)