Skip to content

Commit d6a9af8

Browse files
committed
Export Verbosity as an IntEnum
1 parent 2b82275 commit d6a9af8

6 files changed

Lines changed: 10 additions & 9 deletions

File tree

LICENSE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2021 Tyler Yep
3+
Copyright (c) 2022 Tyler Yep
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

tests/torchinfo_test.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
)
3030
from tests.fixtures.tmva_net import TMVANet # type: ignore[attr-defined]
3131
from torchinfo import ColumnSettings, summary
32+
from torchinfo.enums import Verbosity
3233

3334

3435
def test_basic_summary() -> None:
@@ -253,7 +254,7 @@ def test_lstm() -> None:
253254
LSTMNet(),
254255
input_size=(1, 100),
255256
dtypes=[torch.long],
256-
verbose=2,
257+
verbose=Verbosity.VERBOSE,
257258
col_width=20,
258259
col_names=("kernel_size", "output_size", "num_params", "mult_adds"),
259260
row_settings=("var_names",),

torchinfo/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" torchinfo """
2-
from .enums import ColumnSettings, RowSettings
2+
from .enums import ColumnSettings, RowSettings, Verbosity
33
from .model_statistics import ModelStatistics
44
from .torchinfo import summary
55

6-
__all__ = ("ModelStatistics", "summary", "ColumnSettings", "RowSettings")
7-
__version__ = "1.6.0"
6+
__all__ = ("summary", "ColumnSettings", "ModelStatistics", "RowSettings", "Verbosity")
7+
__version__ = "1.6.1"

torchinfo/enums.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
""" constants.py """
22
from __future__ import annotations
33

4-
from enum import Enum, unique
4+
from enum import Enum, IntEnum, unique
55

66

77
@unique
@@ -25,7 +25,7 @@ class ColumnSettings(Enum):
2525

2626

2727
@unique
28-
class Verbosity(Enum):
28+
class Verbosity(IntEnum):
2929
"""Contains verbosity levels."""
3030

3131
QUIET, DEFAULT, VERBOSE = 0, 1, 2

torchinfo/formatting.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ def layer_info_to_row(
119119
layer_name = layer_info.get_layer_name(self.show_var_name, self.show_depth)
120120
new_line = self.format_row(f"{start_str}{layer_name}", values_for_row)
121121

122-
if self.verbose == Verbosity.VERBOSE.value:
122+
if self.verbose == Verbosity.VERBOSE:
123123
for inner_name, inner_layer_info in layer_info.inner_layers.items():
124124
prefix = self.get_start_str(layer_info.depth + 1)
125125
new_line += self.format_row(f"{prefix}{inner_name}", inner_layer_info)

torchinfo/torchinfo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ class name as the key. If the forward pass is an expensive operation,
205205
results = ModelStatistics(
206206
summary_list, correct_input_size, get_total_memory_used(x), formatting
207207
)
208-
if verbose > Verbosity.QUIET.value:
208+
if verbose > Verbosity.QUIET:
209209
print(results)
210210
return results
211211

0 commit comments

Comments
 (0)