Closed maximlt closed 1 month ago
Did I already say I'd like name to be removed from Param?
That's a different issue. Maybe Parameterized
can be renamed to ParamObject
and its name handling code moved into a new subclass now named Parameterized
. That way downstream libraries can choose whether or not they wish their objects to have names, (e.g. from param import ParamObject as Parameterized
) making it easier to retain backwards compatibility while removing the special name handling in practice. Feel free to file a separate issue and/or PR!
Meanwhile, for this specific issue, I do agree the behavior is both surprising and wrong. The proposed fix seems better, but my brain starts to overheat if I try to think of whether it truly addresses the issue. I'd ask another Param developer like @philippjfr .
Maybe Parameterized can be renamed to ParamObject and its name handling code moved into a new subclass now named Parameterized.
Agreed, although not 100% aligned on the naming.
Param 1.13:
Now:
The
name
of a Parameterized instance set as thedefault
of areadonly
Parameter is unexpectedly overridden. Bisecting pointed at https://github.com/holoviz/param/pull/776 that stopped automatically settinginstantiate
toTrue
whenconstant
isTrue
.However, I'm also surprised to see the
name
being updated for aconstant
Parameter! As currently the default value of a Parameter is deep copied only wheninstantiate=True
. So in the example above,instantiate
is alwaysFalse, there's no deep copy of
a1or
a2`.https://github.com/holoviz/param/blob/dae8fc4a7b47079468ad5da0b486a779e963351b/param/parameterized.py#L1922-L1926
So the change I'd suggest would be to override the Parameter name only when a deep copy is required which doesn't break any test and would lead to this output for the example:
The piece of code in
Parameterized._instantiate_param
that overrides the name of a Parameterized class on instantiation originates from the first commit on Github. One could argue that, even when deep-copying, overridingname
isn't correct and could be left as a responsibility of the users implementing their Parameterized classes.Did I already say I'd like
name
to be removed from Param? :)