An attribute of an object can be a hyperparam.
| 89 | |
| 90 | |
| 91 | class ObjAttrParam(HyperParam): |
| 92 | """ An attribute of an object can be a hyperparam. """ |
| 93 | |
| 94 | def __init__(self, obj, attrname, readable_name=None): |
| 95 | """ |
| 96 | Args: |
| 97 | obj: the object |
| 98 | attrname (str): the attribute |
| 99 | readable_name(str): The name to display and set with. Defaults to be ``attrname``. |
| 100 | """ |
| 101 | self.obj = obj |
| 102 | self.attrname = attrname |
| 103 | if readable_name is None: |
| 104 | self._readable_name = attrname |
| 105 | else: |
| 106 | self._readable_name = readable_name |
| 107 | |
| 108 | def set_value(self, v): |
| 109 | setattr(self.obj, self.attrname, v) |
| 110 | |
| 111 | def get_value(self): |
| 112 | return getattr(self.obj, self.attrname) |
| 113 | |
| 114 | |
| 115 | class HyperParamSetter(Callback): |
no outgoing calls