New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
param.watch cannot handle parameters from Parameterized, unlike @param.depends #721
Comments
Thanks for the issue report, I can indeed reproduce it with this simplified version: import param
class Other(param.Parameterized):
x = param.Integer(1)
other = Other()
class P(param.Parameterized):
other = param.Parameter(other)
def __init__(self, **params):
super().__init__(**params)
self.param.watch(self.debug, ['other.x'])
def debug(self, *events):
print('DEBUG')
p = P() Traceback:
|
Hi @maximlt what I did find out in the meantime is that defining the watch on the objects param instead of the class param does work. I don't know if that is the intended behaviour, which is more for you to decide. import param
class Other(param.Parameterized):
x = param.Integer(1)
other = Other()
class P(param.Parameterized):
other_ = param.Parameter(other)
def __init__(self, **params):
super().__init__(**params)
self.other_.param.watch(self.debug, ['x'])
def debug(self, *events):
print('DEBUG')
p = P()
other.x=2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
ALL software version info
param 1.12.2
run in powershell prompt using panel serve running Bokeh server 2.4.3 on Tornado 6.2
run in VS Code jupyter notebook
Version: 1.76.2 (user setup)
Commit: ee2b180d582a7f601fa6ecfdad8d9fd269ab1884
Date: 2023-03-14T17:55:54.936Z
Electron: 19.1.11
Chromium: 102.0.5005.196
Node.js: 16.14.2
V8: 10.2.154.26-electron.0
OS: Windows_NT x64 10.0.19045
Sandboxed: No
Description of expected behavior and the observed behavior
When using the decorator @param.depends() it is possible to use a parameter from another class that is stored as a Parameterized instance in the current class, similar as described in this thread --> Holoviz Discourse: Shared Parameter?
However, trying the same with the lower-level self.param.watch() yields an error message.
In the example below, the decorated function works, while the param.watched throws an error on executing the cell comprising
anB = Bclass(otherclass=anA)
. If the "param.watch'ed" function is changed to a decorated, then again everything works fine.Am I missing something? Should the behaviour not be the same?
Complete, minimal, self-contained example code that reproduces the issue
Stack traceback and/or browser JavaScript console output
Screenshots or screencasts of the bug in action
The text was updated successfully, but these errors were encountered: