Should methods on Parameterizeds be treated as references by default
panel==1.4.1
When using a parameterized class methods that are not explicitly annotated with .depends my understanding is that they implicitly depend on all class parameters. Thus I should be able to use them as references just as methods marked with .depends.
I cannot when using Tabulator.
import panel as pn
import param
import pandas as pd
pn.extension()
class CustomComponent(pn.viewable.Viewer):
value = param.Integer(default=2, bounds=(1,10))
# @param.depends("value")
def data(self):
return pd.DataFrame({"x": [self.value]*self.value})
def __panel__(self):
return pn.Column(
self.param.value,
pn.widgets.Tabulator(self.data, pagination="remote", page_size=10)
)
pn.extension("tabulator")
CustomComponent().servable()
It works without the using Tabulator or if I .depends on the value.
Reference resolution happens at the param level so I've transferred this for now and marked it as a discussion point. @MarcSkovMadsen is correct that in other scenarios we do treated un-annotated methods as if they depended on all parameters so making them valid references would be consistent.
in other scenarios we do treated un-annotated methods as if they depended on all parameters
Does anyone remember the rationale for this behavior? (I'd rather have to type something explicit like param.depends('*'))
Does anyone remember the rationale for this behavior?
Yes, @jbednar strongly argued that it would be easy to forget to declare the dependencies so this was the safe default behavior. I've wavered on this in the past but think generally it was the right default behavior.