Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Renamed precedence to priority and deleted trailing whitespace #235

Merged
merged 1 commit into from Feb 8, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion panel/holoviews.py
Expand Up @@ -34,7 +34,7 @@ class HoloViews(PaneBase):
A mapping from dimension name to a widget instance which will
be used to override the default widgets.""")

precedence = 0.8
priority = 0.8

def __init__(self, object, **params):
super(HoloViews, self).__init__(object, **params)
Expand Down
46 changes: 23 additions & 23 deletions panel/pane.py
Expand Up @@ -82,10 +82,10 @@ class PaneBase(Reactive):
The object being wrapped, which will be converted into a Bokeh model.""")

# When multiple Panes apply to an object, the one with the highest
# numerical precedence is selected. The default is an intermediate value.
# If set to None, applies method will be called to get a precedence
# numerical priority is selected. The default is an intermediate value.
# If set to None, applies method will be called to get a priority
# value for a specific object type.
precedence = 0.5
priority = 0.5

# Declares whether Pane supports updates to the Bokeh model
_updates = False
Expand All @@ -96,8 +96,8 @@ class PaneBase(Reactive):
def applies(cls, obj):
"""
Given the object return a boolean indicating whether the Pane
can render the object. If the precedence of the pane is set to
None, this method may also be used to define a precedence
can render the object. If the priority of the pane is set to
None, this method may also be used to define a priority
depending on the object being rendered.
"""
return None
Expand All @@ -108,16 +108,16 @@ def get_pane_type(cls, obj):
return type(obj)
descendents = []
for p in param.concrete_descendents(PaneBase).values():
precedence = p.applies(obj) if p.precedence is None else p.precedence
if isinstance(precedence, bool) and precedence:
raise ValueError('If a Pane declares no precedence '
priority = p.applies(obj) if p.priority is None else p.priority
if isinstance(priority, bool) and priority:
raise ValueError('If a Pane declares no priority '
'the applies method should return a '
'precedence value specific to the '
'priority value specific to the '
'object type or False, but the %s pane '
'declares no precedence.' % p.__name__)
elif precedence is None or precedence is False:
'declares no priority.' % p.__name__)
elif priority is None or priority is False:
continue
descendents.append((precedence, p))
descendents.append((priority, p))
pane_types = reversed(sorted(descendents, key=lambda x: x[0]))
for _, pane_type in pane_types:
applies = pane_type.applies(obj)
Expand Down Expand Up @@ -203,7 +203,7 @@ class Bokeh(PaneBase):
Bokeh panes allow including any Bokeh model in a panel.
"""

precedence = 0.8
priority = 0.8

@classmethod
def applies(cls, obj):
Expand Down Expand Up @@ -505,8 +505,8 @@ class LaTeX(PNG):
See https://matplotlib.org/users/mathtext.html for what is supported.
"""

# Precedence is dependent on the data type
precedence = None
# Priority is dependent on the data type
priority = None

size = param.Number(default=25, bounds=(1, 100), doc="""
Size of the rendered equation.""")
Expand Down Expand Up @@ -580,8 +580,8 @@ class HTML(DivPaneBase):
allow room for whatever is being wrapped.
"""

# Precedence is dependent on the data type
precedence = None
# Priority is dependent on the data type
priority = None

@classmethod
def applies(cls, obj):
Expand All @@ -604,12 +604,12 @@ class Str(DivPaneBase):
"""
A Str pane renders any object for which `str()` can be called,
escaping any HTML markup and then wrapping the resulting string in
a bokeh Div model. Set to a low precedence because generally one
a bokeh Div model. Set to a low priority because generally one
will want a better representation, but allows arbitrary objects to
be used as a Pane (numbers, arrays, objects, etc.).
"""

precedence = 0
priority = 0

@classmethod
def applies(cls, obj):
Expand All @@ -624,12 +624,12 @@ class Markdown(DivPaneBase):
"""
A Markdown pane renders the markdown markup language to HTML and
displays it inside a bokeh Div model. It has no explicit
precedence since it cannot be easily be distinguished from a
priority since it cannot be easily be distinguished from a
standard string, therefore it has to be invoked explicitly.
"""

# Precedence depends on the data type
precedence = None
# Priority depends on the data type
priority = None

@classmethod
def applies(cls, obj):
Expand Down Expand Up @@ -660,7 +660,7 @@ class YT(HTML):
provide additional space.
"""

precedence = 0.5
priority = 0.5

@classmethod
def applies(cls, obj):
Expand Down
2 changes: 1 addition & 1 deletion panel/param.py
Expand Up @@ -104,7 +104,7 @@ class Param(PaneBase):
Dictionary of widget overrides, mapping from parameter name
to widget class.""")

precedence = 0.1
priority = 0.1

_mapping = {
param.Action: Button,
Expand Down
2 changes: 1 addition & 1 deletion panel/plotly.py
Expand Up @@ -37,7 +37,7 @@ class Plotly(PaneBase):

_updates = True

precedence = 0.8
priority = 0.8

def __init__(self, object, layout=None, **params):
super(Plotly, self).__init__(self._to_figure(object, layout),
Expand Down
14 changes: 7 additions & 7 deletions panel/tests/test_pipeline.py
Expand Up @@ -13,15 +13,15 @@
pytest.skip("skipping if param version < 1.8.2", allow_module_level=True)

class Stage1(param.Parameterized):

a = param.Number(default=5, bounds=(0, 10))

b = param.Number(default=5, bounds=(0, 10))

@param.output(c=param.Number)
def output(self):
return self.a * self.b

@param.depends('a', 'b')
def view(self):
return '%s * %s = %s' % (self.a, self.b, self.output())
Expand All @@ -31,11 +31,11 @@ def panel(self):


class Stage2(param.Parameterized):

c = param.Number(default=5, precedence=-1, bounds=(0, None))

exp = param.Number(default=0.1, bounds=(0, 3))

@param.depends('c', 'exp')
def view(self):
return '%s^%s=%.3f' % (self.c, self.exp, self.c**self.exp)
Expand All @@ -46,7 +46,7 @@ def panel(self):
@hv_available
def test_pipeline_from_classes():
import holoviews as hv

pipeline = Pipeline([('Stage 1', Stage1), ('Stage 2', Stage2)])

layout = pipeline.layout
Expand Down Expand Up @@ -197,6 +197,6 @@ def test_pipeline_getitem():
def test_pipeline_repr():
pipeline = Pipeline()
pipeline.add_stage('Stage 1', Stage1)

pipeline.add_stage('Stage 2', Stage2)
assert repr(pipeline) == 'Pipeline:\n [0] Stage 1: Stage1()\n [1] Stage 2: Stage2()'
4 changes: 2 additions & 2 deletions panel/vega.py
Expand Up @@ -46,8 +46,8 @@ class Vega(PaneBase):
the figure on bokeh server and via Comms.
"""

precedence = 0.8
priority = 0.8

_updates = True

def __init__(self, object, **params):
Expand Down