holoviz-topics / EarthSim

Tools for working with and visualizing environmental simulations.
https://earthsim.holoviz.org
BSD 3-Clause "New" or "Revised" License
65 stars 21 forks source link

paramnb and parambokeh need to handle the name parameter in the same way #198

Closed sdc50 closed 5 years ago

sdc50 commented 6 years ago

It would be convenient if parambokeh and paramnb handled the name parameter in the same way so that switching between the two libraries would produce the same results.

When a parameterized object is rendered with paramnb then the name parameter is displayed:

class Pobj(param.Parameterized):
    pass
paramnb.Widgets(Pobj)

image

Whereas when then same object is rendered with parambokeh then the name object is omitted:

parambokeh.Widgets(Pobj)

image

This causes an issue when I try to manually omit the name object for paramnb and then switch to using param bokeh.

Pobj.params()['name'].precedence = -1
parambokeh.Widgets(Pobj)
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-14-462ed04fedea> in <module>()
----> 1 parambokeh.Widgets(Pobj)

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/param/parameterized.py in __new__(class_, *args, **params)
   2047         inst = class_.instance()
   2048         inst.param._set_name(class_.__name__)
-> 2049         return inst.__call__(*args,**params)
   2050 
   2051     def __call__(self,*args,**kw):

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/parambokeh/__init__.py in __call__(self, parameterized, doc, plots, **params)
    232 
    233         # Initialize widgets and populate container
--> 234         widgets, views = self.widgets()
    235         plots = views + plots
    236         widget_box.children = widgets

~/miniconda/envs/earthsim3/lib/python3.6/site-packages/parambokeh/__init__.py in widgets(self)
    485 
    486         # Format name specially
--> 487         ordered_params.pop(ordered_params.index('name'))
    488         widgets = [Div(text='<b>{0}</b>'.format(self.parameterized.name))]
    489 

ValueError: 'name' is not in list
kcpevey commented 6 years ago

I don't know anything about paramnb but to omit the name in parambokeh you'd do something like this:

class Pobj(param.Parameterized):
    x = param.Integer(default=2)

parambokeh.Widgets(Pobj(name=''))

Your approach Pobj.params()['name'].precedence = -1 appears to be affecting the base class, and not the instance. I'm no expert, but I guess paramnb and parambokeh handle that differently. I'm reminded of a conversation from a couple days ago https://github.com/ioam/parambokeh/issues/73

sdc50 commented 6 years ago

@kcpevey paramnb actually lists the name twice. Once as the tile of the widget block (in the same way that parambokeh does), but then it lists it again as one of the widgets. Setting the name of an instance to be blank, as you suggest, prevents the block title from showing up, but the parameter name is still listed in the list of widgets.

jbednar commented 6 years ago

I don't remember what we did in parambokeh to make the name not show up by default in the widgets list, but whatever we did we need to do that in paramnb as well.

This and several other recent @sdc50 tie back to what @ceball was mentioning in our last discussion, i.e. wondering whether to spend time now normalizing the underlying implementation or to focus on adding clearly needed features, and then clean up the code. We decided to focus on the visible features, but clearly the behind-the-scenes stuff is also causing issues...

philippjfr commented 5 years ago

Panel now removes the integer id from the name for display purposes and it can be disabled by setting show_name=False in the Param pane constructor.