-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow no super().__init__() call in childern class
Signed-off-by: Zhiyuan Chen <[email protected]>
- Loading branch information
1 parent
1dee88e
commit 36f77ca
Showing
5 changed files
with
76 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from chanfig import Config, Variable | ||
|
||
|
||
class TestConfig(Config): | ||
__test__ = False | ||
def __init__(self, *args, **kwargs): | ||
num_classes = Variable(10) | ||
self.name = "CHANfiG" | ||
self.seed = Variable(1013) | ||
self.network.name = "ResNet18" | ||
self.network.num_classes = num_classes | ||
self.dataset.num_classes = num_classes | ||
|
||
|
||
class Test: | ||
|
||
config = TestConfig() | ||
|
||
def test_value(self): | ||
assert self.config.name == "CHANfiG" | ||
|
||
def test_nested(self): | ||
assert self.config.network.name == "ResNet18" | ||
|
||
def test_variable(self): | ||
assert self.config.network.num_classes == 10 | ||
self.config.network.num_classes += 1 | ||
assert self.config.dataset.num_classes == 11 | ||
|
||
def test_fstring(self): | ||
assert f"seed{self.config.seed}" == "seed1013" |