Skip to content

Commit

Permalink
Instantiate parameter object on instance when setting value
Browse files Browse the repository at this point in the history
  • Loading branch information
jbednar committed Sep 8, 2023
1 parent 7fcf8d4 commit 6ce1ef3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 4 additions & 1 deletion param/parameterized.py
Original file line number Diff line number Diff line change
Expand Up @@ -426,6 +426,9 @@ def _f(self, obj, val):
params = obj._param__private.params
instance_param = None if params is None else params.get(self.name)

if (params is not None and instance_param is None):
instance_param = _instantiated_parameter(obj, self)

if instance_param is not None and self is not instance_param:
instance_param.__set__(obj, val)
return
Expand Down Expand Up @@ -1404,7 +1407,7 @@ def __set__(self, obj, val):
warnings.warn(
'Number.set_hook has been deprecated.',
category=_ParamDeprecationWarning,
stacklevel=5,
stacklevel=6,
)

self._validate(val)
Expand Down
1 change: 0 additions & 1 deletion tests/testselector.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,5 +459,4 @@ class B(A):
b.p = 3

assert A.param.p.objects == [1, 2]
assert B.param.p.objects == [1, 2, 3]
assert b.param.p.objects == [1, 2, 3]

0 comments on commit 6ce1ef3

Please sign in to comment.