Skip to content

Commit c3f65f8

Browse files
committed
add more doctest
Signed-off-by: reiase <[email protected]>
1 parent 7587e51 commit c3f65f8

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

hyperparameter/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@
1414
"set_auto_param_callback",
1515
]
1616

17-
VERSION = "0.3.1"
17+
VERSION = "0.3.2"

hyperparameter/hyperparameter.py

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -432,26 +432,43 @@ def __exit__(self, exc_type, exc_value, traceback):
432432
def __call__(self, scope=None) -> Any:
433433
"""
434434
>>> @auto_param('myns.foo.params')
435-
... def foo(a, b=2, c='c', d=None):
436-
... print(a, b, c, d)
435+
... def foo(a, b=2):
436+
... print(f"a={a}, b={b}")
437437
438438
>>> def test():
439439
... with param_scope["sec1"]():
440440
... with param_scope["sec2"]():
441441
... foo(1)
442442
443443
>>> test()
444-
1 2 c None
444+
a=1, b=2
445445
446446
>>> with param_scope(**{"myns.foo.params.b": 1}):
447447
... test()
448-
1 1 c None
448+
a=1, b=1
449449
450450
>>> with param_scope(**{"[email protected]": 3}) as ps:
451451
... print(f"ps = {ps}")
452452
... test()
453453
ps = {'myns': {'foo': {'params': {'[email protected]': 3}}}}
454-
1 3 c None
454+
a=1, b=3
455+
456+
>>> with param_scope(**{
457+
... "myns.foo.params.b@sec1": 4,
458+
... }) as ps:
459+
... print(f"ps = {ps}")
460+
... test()
461+
ps = {'myns': {'foo': {'params': {'b@sec1': 4}}}}
462+
a=1, b=4
463+
464+
>>> with param_scope(**{
465+
... "myns.foo.params.b@sec1": 4,
466+
467+
... }) as ps:
468+
... print(f"ps = {ps}")
469+
... test()
470+
ps = {'myns': {'foo': {'params': {'b@sec1': 4, '[email protected]': 3}}}}
471+
a=1, b=3
455472
"""
456473
scope = dict.get(self, "_scope", None) if scope is None else scope
457474
return _Accessor(self, scope=scope)

0 commit comments

Comments
 (0)