holoviz / holoviz/param

Dependencies on a method name is not invoking

Open
#731 3 comments 0 reactions 0 assignees View on GitHub
status: discussion
Dominant language
Python
Stars
521
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
35

Description

#### ALL software version info
param.__version__ : 1.13.0

#### Description of expected behavior and the observed behavior
Following the tutorial in the official reference
https://pyviz-dev.github.io/param/user_guide/Dependencies_and_Watchers.html#dependency-specs
Under dependency specs, it is stated that a method can depends on another method by another method's name.

However, cb4 does not execute after invoking cb3

#### Complete, minimal, self-contained example code that reproduces the issue

```
# code goes here between backticks
import param

class C(param.Parameterized):
_countries = {'Africa': ['Ghana', 'Togo', 'South Africa'],
'Asia' : ['China', 'Thailand', 'Japan', 'Singapore'],
'Europe': ['Austria', 'Bulgaria', 'Greece', 'Switzerland']}

continent = param.Selector(list(_countries.keys()), default='Asia')
country = param.Selector(_countries['Asia'])

@param.depends('continent', watch=True)
def _update_countries(self):
countries = self._countries[self.continent]
self.param['country'].objects = countries
if self.country not in countries:
self.country = countries[0]

c = C()

class D(param.Parameterized):
x = param.Number(7)
s = param.String("never")
i = param.Integer(-5)
o = param.Selector(['red', 'green', 'blue'])
n = param.ClassSelector(param.Parameterized, c, instantiate=False)

@param.depends('x', 's', 'n.country', 's:constant', watch=True)
def cb1(self):
print(f"cb1 x={self.x} s={self.s} "
f"param.s.constant={self.param.s.constant} n.country={self.n.country}")

@param.depends('n.param', watch=True)
def cb2(self):
print(f"cb2 n={self.n}")

@param.depends('x', 'i', watch=True)
def cb3(self):
print(f"cb3 x={self.x} i={self.i}")

@param.depends('cb3', watch=True)
def cb4(self):
print(f"cb4 x={self.x} i={self.i}")

d = D()
d
```

#### Stack traceback and/or browser JavaScript console output

#### Screenshots or screencasts of the bug in action
![image](https://user-images.githubusercontent.com/55838817/230928463-72184e2d-8a79-4744-8b3e-357ee12c89bd.png)

Changing d.x works as expected but calling d.cb3 does not invoke d.cb4

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.