I use most of the holoviz libraries, and I want to port a library I’m developing to Param, as it would make it integrate way better with every visualization I make (and waaay more robust, specially with the ability to have bounds).
The only thing I don’t know what to do is how to make a parameter dependent on another if I don’t say otherwise. A quick example would be this:
class B(): def __init__(self, a=2, b=None): self.a = a self.b = b if b else a
This would make it so the value of b is always equal to the value of a, unless I give a specific distinct value for b. So if I called
obj = B(a=6) obj.b would be 6, but if I ran
obj = B(b=3) obj.a would be 2 and obj.b would be 6.
Is there any easy way to implement this with the existing parameter types? I’ve tried the following
class A(param.Parameterized): a = param.Integer(default=4) b = param.Parameter(default=a)
This almost works, as I set the default value to be a. The thing is, instead of getting the same value for my b variable, I get a pointer to the parameter itself (so in this example a would be an int, while b would be an Integer, which are different types). What am I missing?
Thanks in advance!