holoviz / holoviz/param

Callbacks not triggered when value updated at the class level before being set on an instance

Open
#773 2 comments 0 reactions 0 assignees View on GitHub
type-bug
Dominant language
Python
Stars
521
Forks
86
Avg merge
1d 13h
Merged PRs (30d)
35

Description

Param allows to [update the value of instances of a class from the class level](https://param.holoviz.org/user_guide/Parameters.html#parameter-inheritance-and-instantiation), when the value hasn't yet been set (constructor or setattr), e.g.:

```python
import param

class P(param.Parameterized):
m = param.Parameter(0)
n = param.Parameter(0)
o = param.Parameter(0)

p = P(n=1)
p.o = 1
P.m = P.n = P.o = 2
print(f'{p.m=} {p.n=} {p.o=}')
# p.m=2 p.n=1 p.o=1
```

However, watching a parameter changed at the class level doesn't trigger its callbacks, while it certainly should:

```python
import param

class P(param.Parameterized):
m = param.Parameter()

@param.depends('m', watch=True)
def update(self):
print(self.m)

p = P()
# Does NOT trigger `update`
P.m = 10
print(p.m)
# 10
```

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.