8000 Fix regression in param depends execution ordering by philippjfr · Pull Request #628 · holoviz/param · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix regression in param depends execution ordering #628

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

Merged
merged 1 commit into from
May 17, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -2651,6 +2651,7 @@ def __init__(mcs, name, bases, dict_):
dependers = [(n, m, m._dinfo) for (n, m) in dict_.items()
if hasattr(m, '_dinfo')]

# Resolve dependencies of current class
_watch = []
for name, method, dinfo in dependers:
watch = dinfo.get('watch', False)
Expand All @@ -2662,18 +2663,19 @@ def __init__(mcs, name, bases, dict_):
deps, dynamic_deps = _params_depended_on(minfo, dynamic=False)
_watch.append((name, watch == 'queued', on_init, deps, dynamic_deps))

# Resolve other dependencies in remainder of class hierarchy
# Resolve dependencies in class hierarchy
_inherited = []
for cls in classlist(mcs)[:-1][::-1]:
if not hasattr(cls, '_param'):
continue
for dep in cls.param._depends['watch']:
method = getattr(mcs, dep[0], None)
dinfo = getattr(method, '_dinfo', {'watch': False})
if (not any(dep[0] == w[0] for w in _watch)
if (not any(dep[0] == w[0] for w in _watch+_inherited)
and dinfo.get('watch')):
_watch.append(dep)
_inherited.append(dep)

mcs.param._depends = {'watch': _watch}
mcs.param._depends = {'watch': _inherited+_watch}

if docstring_signature:
mcs.__class_docstring_signature()
Expand Down
23 changes: 23 additions & 0 deletions tests/API1/testparamdepends.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,30 @@ def test(self):
assert len(b.param.params_depended_on('test')) == 3
assert len(B.param._depends['watch']) == 0

def test_param_depends_subclass_ordering(self):

values = []

class A(param.Parameterized):
a = param.String()

@param.depends('a', watch=True)
def test(self):
values.append(self.a)

class B(A):

@param.depends('a', watch=True)
def more_test(self):
values.append(self.a.upper())

b = B()

b.a = 'a'

assert values == ['a', 'A']



class TestParamDepends(API1TestCase):

Expand Down
0