@@ -75,7 +75,7 @@ def __call__(self):
7575
7676
7777def suggest_from (callback : Callable ) -> Suggester :
78- """ Suggest parameter from a callback function
78+ """Suggest parameter from a callback function
7979
8080 Examples
8181 --------
@@ -104,6 +104,7 @@ def wrapper(*args, **kwargs):
104104 if isinstance (retval , Suggester ):
105105 return retval ()
106106 return retval
107+
107108 return wrapper
108109
109110
@@ -252,10 +253,12 @@ def __getattr__(self, name: str) -> Any:
252253 def __getitem__ (self , index ):
253254 return lazy_dispatch (self ._obj , self ._name , index )
254255
256+
255257def lazy_dispatch (obj , name = None , index = None ):
256258 """Wraps an object for lazy dispatch"""
257259 return LazyDispatch (obj , name , index )
258260
261+
259262class HyperParameter (dict ):
260263 """HyperParameter is an extended dict designed for parameter storage.
261264
@@ -489,6 +492,13 @@ class _param_scope(HyperParameter):
489492 >>> with param_scope(**{"a.b.c": [1,2]}) as ps:
490493 ... ps.a.b.c
491494 [1, 2]
495+
496+ access parameter with `param_scope`
497+ >>> with param_scope(x=1):
498+ ... param_scope.x(2)
499+ ... param_scope.y(2)
500+ 1
501+ 2
492502 """
493503
494504 tls = threading .local ()
@@ -590,9 +600,11 @@ def __getitem__(self, index):
590600 def current (self ):
591601 return _param_scope .current ()
592602
603+ def __getattr__ (self , name ):
604+ return _param_scope ()().__getattr__ (name )
593605
594- param_scope = _ParamScopeWrapper ()
595606
607+ param_scope = _ParamScopeWrapper ()
596608
597609"""
598610Tracker callback for auto_param
0 commit comments