Skip to content

Commit f10f12a

Browse files
committed
Shorter code
1 parent ff1e246 commit f10f12a

File tree

1 file changed

+5
-20
lines changed

1 file changed

+5
-20
lines changed

scripts/tools/file_size_from_nm.py

+5-20
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
import subprocess
4747
from dataclasses import dataclass, replace
4848
from enum import Enum, auto
49-
from typing import Optional, Tuple
49+
from typing import Callable, Optional, Tuple
5050

5151
import click
5252
import coloredlogs
@@ -63,16 +63,10 @@
6363
}
6464

6565

66-
class ChartStyle(Enum):
67-
TREE_MAP = auto()
68-
SUNBURST = auto()
69-
ICICLE = auto()
70-
71-
7266
__CHART_STYLES__ = {
73-
"treemap": ChartStyle.TREE_MAP,
74-
"sunburst": ChartStyle.SUNBURST,
75-
"icicle": ChartStyle.ICICLE,
67+
"treemap": px.treemap,
68+
"sunburst": px.sunburst,
69+
"icicle": px.icicle,
7670
}
7771

7872

@@ -363,7 +357,7 @@ def build_treemap(
363357
name: str,
364358
symbols: list[Symbol],
365359
separator: str,
366-
style: ChartStyle,
360+
figure_generator: Callable,
367361
max_depth: int,
368362
zoom: Optional[str],
369363
strip: Optional[str],
@@ -465,15 +459,6 @@ def build_treemap(
465459

466460
data["name_with_size"][idx] = f"{short_name}: {data["size"][idx]}"
467461

468-
469-
match style:
470-
case ChartStyle.TREE_MAP:
471-
figure_generator = px.treemap
472-
case ChartStyle.SUNBURST:
473-
figure_generator = px.sunburst
474-
case ChartStyle.ICICLE:
475-
figure_generator = px.icicle
476-
477462
fig = figure_generator(
478463
data,
479464
names="name_with_size",

0 commit comments

Comments
 (0)