8000 Fix `.values()/get_value_generator()` dealing with Dynamic params and an updated default value by maximlt · Pull Request #1058 · holoviz/param · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix .values()/get_value_generator() dealing with Dynamic params and an updated default value #1058

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
Jun 11, 2025
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
2 changes: 2 additions & 0 deletions param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -3282,6 +3282,8 @@ def get_value_generator(self_,name: str) -> Any: # pylint: disable-msg=E0213
if isinstance(cls_or_slf, Parameterized) and name in cls_or_slf._param__private.values:
# dealing with object and it's been set on this object
value = cls_or_slf._param__private.values[name]
elif not callable(param_obj.default):
value = getattr(cls_or_slf, name)
else:
# dealing with class or isn't set on the object
value = param_obj.default
Expand Down
16 changes: 16 additions & 0 deletions tests/testparameterizedobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,14 @@ def test_values_name_ignored_for_instances_and_onlychanged(self):
# name not ignored when set
assert param.Parameterized(name='foo').param.values( == 'foo'

def test_values_dyn(self):
# See https://github.com/holoviz/param/issues/1057
t = TestPO()
orig_default = t.param.dyn.default
t.param.dyn.default = 3290432424
values = t.param.values()
assert values['dyn'] == orig_default

def test_param_iterator(self):
self.assertEqual(set(TestPO.param), {'name', 'inst', 'notinst', 'const', 'dyn',
'ro', 'ro2', 'ro_label', 'ro_format'})
Expand Down Expand Up @@ -671,6 +679,14 @@ def test_state_saving(self):
t.param._state_pop()
assert t.param.inspect_value('dyn')==orig

def test_get_value_generator_dyn(self):
# See https://github.com/holoviz/param/issues/1057
t = TestPO()
orig_default = t.param.dyn.default
t.param.dyn.default = 9594323423
vg = t.param.get_value_generator('dyn')
assert vg == orig_default

def test_label(self):
t = TestPO()
assert t.param['ro_label'].label == 'Ro Label'
Expand Down
Loading
0