param icon indicating copy to clipboard operation
param copied to clipboard

set_dynamic_time_fn() does not set dynamic time_fn

Open AQ18 opened this issue 3 years ago • 1 comments

ALL software version info

param 1.12.2

Description of expected behavior and the observed behavior

From the API reference:

set_dynamic_time_fn(time_fn, sublistattr=None)[source] Set time_fn for all Dynamic Parameters of this class or instance object that are currently being dynamically generated.

Either I am completely misunderstanding this/using it wrong, or it just doesn't do that. The time_fn is unaffected.

Additionally, sets _Dynamic_time_fn=time_fn on this class or instance object, ...

This is true.

... so that any future changes to Dynamic Parmeters can inherit time_fn (e.g. if a Number is changed from a float to a number generator, the number generator will inherit time_fn).

But this is not.

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

import param
import numbergen as ng

class Foo(param.Parameterized):
    a = param.Dynamic()

print(Foo.param.a.time_fn)
    
foo = Foo()
print(foo.param.a.time_fn)

time = param.Time()
print(time)

Foo.param.set_dynamic_time_fn(time)
print(Foo.param.a.time_fn) # This has not changed

foo.param.set_dynamic_time_fn(time)
print(foo.param.a.time_fn) # This has not changed

print(Foo._Dynamic_time_fn) # This did get set
foo2 = Foo()
print(foo2.param.a.time_fn) # But was not set on the new instance parameter
foo2.a = ng.UniformRandom()
print(foo2.param.a.time_fn) # Nor set on change
<Time Time00001>
<Time Time00001>
<Time Time00003>
<Time Time00001>
<Time Time00001>
<Time Time00003>
<Time Time00001>
<Time Time00001>

AQ18 avatar Dec 16 '22 18:12 AQ18

That does look very strange. I'm way overloaded with other things right now and can't look into it directly, but it would be worth studying param/tests/API1/testdynamicparams.py to see what's being tested about that function and whether that testing indicates a usage issue or a serious gap in testing!

jbednar avatar Dec 16 '22 20:12 jbednar