Skip to content

Commit

Permalink
refactor: Update ObjectSelector to Selector (#7493)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored Nov 15, 2024
1 parent e24f443 commit 7015943
Show file tree
Hide file tree
Showing 37 changed files with 75 additions and 75 deletions.
2 changes: 1 addition & 1 deletion doc/how_to/custom_components/examples/table_viewer.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This example demonstrates Panel's reactive programming paradigm using the Param
```{pyodide}
class ReactiveTables(Viewer):
dataset = param.ObjectSelector(default='iris', objects=['iris', 'autompg', 'population'])
dataset = param.Selector(default='iris', objects=['iris', 'autompg', 'population'])
rows = param.Integer(default=10, bounds=(0, 19))
Expand Down
4 changes: 2 additions & 2 deletions doc/how_to/param/dependencies.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ We also define a ``view`` method that returns an HTML iframe displaying the coun
```{pyodide}
class GoogleMapViewer(param.Parameterized):
continent = param.ObjectSelector(default='Asia', objects=['Africa', 'Asia', 'Europe'])
continent = param.Selector(default='Asia', objects=['Africa', 'Asia', 'Europe'])
country = param.ObjectSelector(default='China', objects=['China', 'Thailand', 'Japan'])
country = param.Selector(default='China', objects=['China', 'Thailand', 'Japan'])
_countries = {'Africa': ['Ghana', 'Togo', 'South Africa', 'Tanzania'],
'Asia' : ['China', 'Thailand', 'Japan'],
Expand Down
2 changes: 1 addition & 1 deletion doc/how_to/param/examples/subobjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ Having defined our basic domain model (of shapes in this case), we can now make
```{pyodide}
class ShapeViewer(param.Parameterized):
shape = param.ObjectSelector(default=shapes[0], objects=shapes)
shape = param.Selector(default=shapes[0], objects=shapes)
@param.depends('shape', 'shape.param')
def view(self):
Expand Down
2 changes: 1 addition & 1 deletion doc/how_to/param/subobjects.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ shapes = [NGon(), Circle()]
class ShapeViewer(param.Parameterized):
shape = param.ObjectSelector(default=shapes[0], objects=shapes)
shape = param.Selector(default=shapes[0], objects=shapes)
@param.depends('shape')
def view(self):
Expand Down
4 changes: 2 additions & 2 deletions doc/how_to/param/uis.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ class Example(BaseClass):
date = param.Date(default=dt.datetime(2017, 1, 1),
bounds=(dt.datetime(2017, 1, 1), dt.datetime(2017, 2, 1)))
dataframe = param.DataFrame(default=pd.DataFrame({'A': [1, 2, 3]}))
select_string = param.ObjectSelector(default="yellow", objects=["red", "yellow", "green"])
select_fn = param.ObjectSelector(default=list,objects=[list, set, dict])
select_string = param.Selector(default="yellow", objects=["red", "yellow", "green"])
select_fn = param.Selector(default=list,objects=[list, set, dict])
int_list = param.ListSelector(default=[3, 5], objects=[1, 3, 5, 7, 9], precedence=0.5)
single_file = param.FileSelector(path='../../*/*.py*', precedence=0.5)
multiple_files = param.MultiFileSelector(path='../../*/*.py?', precedence=0.5)
Expand Down
4 changes: 2 additions & 2 deletions panel/chat/feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ class ChatFeed(ListPanel):
the previous message value `contents`, the previous `user` name,
and the component `instance`.""")

callback_exception = param.ObjectSelector(
callback_exception = param.Selector(
default="summary", objects=["raise", "summary", "verbose", "ignore"], doc="""
How to handle exceptions raised by the callback.
If "raise", the exception will be raised.
Expand Down Expand Up @@ -199,7 +199,7 @@ class ChatFeed(ListPanel):
The placeholder wrapped in a ChatMessage object;
primarily to prevent recursion error in _update_placeholder.""")

_callback_state = param.ObjectSelector(objects=list(CallbackState), doc="""
_callback_state = param.Selector(objects=list(CallbackState), doc="""
The current state of the callback.""")

_prompt_trigger = param.Event(doc="Triggers the prompt input.")
Expand Down
2 changes: 1 addition & 1 deletion panel/chat/input.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class ChatAreaInput(_PnTextAreaInput):
of rows the input area can grow.""",
)

resizable = param.ObjectSelector(
resizable = param.Selector(
default="height",
objects=["both", "width", "height", False],
doc="""
Expand Down
2 changes: 1 addition & 1 deletion panel/chat/step.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class ChatStep(Card):
collapsed_on_success = param.Boolean(default=True, doc="""
Whether to collapse the card on completion.""")

context_exception = param.ObjectSelector(
context_exception = param.Selector(
default="raise", objects=["raise", "summary", "verbose", "ignore"], doc="""
How to handle exceptions raised upon exiting the context manager.
If "raise", the exception will be raised.
Expand Down
12 changes: 6 additions & 6 deletions panel/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,12 @@ class _config(_base_config):
information about user sessions. A value of -1 indicates an
unlimited history.""")

sizing_mode = param.ObjectSelector(default=None, objects=[
sizing_mode = param.Selector(default=None, objects=[
'fixed', 'stretch_width', 'stretch_height', 'stretch_both',
'scale_width', 'scale_height', 'scale_both', None], doc="""
Specify the default sizing mode behavior of panels.""")

template = param.ObjectSelector(default=None, doc="""
template = param.Selector(default=None, doc="""
The default template to render served applications into.""")

throttled = param.Boolean(default=False, doc="""
Expand All @@ -222,12 +222,12 @@ class _config(_base_config):
default='DEBUG', objects=['DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'],
doc="Log level of the Admin Panel logger")

_comms = param.ObjectSelector(
_comms = param.Selector(
default='default', objects=['default', 'ipywidgets', 'vscode', 'colab'], doc="""
Whether to render output in Jupyter with the default Jupyter
extension or use the jupyter_bokeh ipywidget model.""")

_console_output = param.ObjectSelector(default='accumulate', allow_None=True,
_console_output = param.Selector(default='accumulate', allow_None=True,
objects=['accumulate', 'replace', 'disable',
False], doc="""
How to log errors and stdout output triggered by callbacks
Expand Down Expand Up @@ -271,7 +271,7 @@ class _config(_base_config):
or filepath containing JSON to use with the basic auth
provider.""")

_oauth_provider = param.ObjectSelector(
_oauth_provider = param.Selector(
default=None, allow_None=True, objects=[], doc="""
Select between a list of authentication providers.""")

Expand Down Expand Up @@ -310,7 +310,7 @@ class _config(_base_config):
Whether to inline JS and CSS resources. If disabled, resources
are loaded from CDN if one is available.""")

_theme = param.ObjectSelector(default=None, objects=['default', 'dark'], allow_None=True, doc="""
_theme = param.Selector(default=None, objects=['default', 'dark'], allow_None=True, doc="""
The theme to apply to components.""")

# Global parameters that are shared across all sessions
Expand Down
2 changes: 1 addition & 1 deletion panel/layout/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ class NamedListPanel(NamedListLike, Panel):
active = param.Integer(default=0, bounds=(0, None), doc="""
Index of the currently displayed objects.""")

scroll = param.ObjectSelector(
scroll = param.Selector(
default=False,
objects=[False, True, "both-auto", "y-auto", "x-auto", "both", "x", "y"],
doc="""Whether to add scrollbars if the content overflows the size
Expand Down
2 changes: 1 addition & 1 deletion panel/layout/grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ class GridSpec(Panel):
objects = ChildDict(default={}, doc="""
The dictionary of child objects that make up the grid.""")

mode = param.ObjectSelector(default='warn', objects=['warn', 'error', 'override'], doc="""
mode = param.Selector(default='warn', objects=['warn', 'error', 'override'], doc="""
Whether to warn, error or simply override on overlapping assignment.""")

ncols = param.Integer(default=None, bounds=(0, None), doc="""
Expand Down
2 changes: 1 addition & 1 deletion panel/layout/spacer.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ class Divider(Reactive):
>>> )
"""

width_policy = param.ObjectSelector(default="fit", readonly=True)
width_policy = param.Selector(default="fit", readonly=True)

_bokeh_model = BkDiv

Expand Down
2 changes: 1 addition & 1 deletion panel/layout/tabs.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Tabs(NamedListPanel):
dynamic = param.Boolean(default=False, doc="""
Dynamically populate only the active tab.""")

tabs_location = param.ObjectSelector(
tabs_location = param.Selector(
default='above', objects=['above', 'below', 'left', 'right'], doc="""
The location of the tabs relative to the tab contents.""")

Expand Down
2 changes: 1 addition & 1 deletion panel/pane/alert.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Alert(Markdown):
>>> Alert('Some important message', alert_type='warning')
"""

alert_type = param.ObjectSelector(default="primary", objects=ALERT_TYPES)
alert_type = param.Selector(default="primary", objects=ALERT_TYPES)

priority: ClassVar[float | bool | None] = 0

Expand Down
4 changes: 2 additions & 2 deletions panel/pane/echarts.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,10 @@ class ECharts(ModelPane):
the `objects` with a value containing a smaller number of series.
""")

renderer = param.ObjectSelector(default="canvas", objects=["canvas", "svg"], doc="""
renderer = param.Selector(default="canvas", objects=["canvas", "svg"], doc="""
Whether to render as HTML canvas or SVG""")

theme = param.ObjectSelector(default="default", objects=["default", "light", "dark"], doc="""
theme = param.Selector(default="default", objects=["default", "light", "dark"], doc="""
Theme to apply to plots.""")

priority: ClassVar[float | bool | None] = None
Expand Down
2 changes: 1 addition & 1 deletion panel/pane/equation.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ class LaTeX(ModelPane):
... )
"""

renderer = param.ObjectSelector(default=None, allow_None=True,
renderer = param.Selector(default=None, allow_None=True,
objects=['katex', 'mathjax'], doc="""
The JS renderer used to render the LaTeX expression. Defaults to katex.""")

Expand Down
8 changes: 4 additions & 4 deletions panel/pane/holoviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class HoloViews(Pane):
>>> HoloViews(some_holoviews_object)
"""

backend = param.ObjectSelector(
backend = param.Selector(
default=None, objects=['bokeh', 'matplotlib', 'plotly'], doc="""
The HoloViews backend used to render the plot (if None defaults
to the currently selected renderer).""")
Expand All @@ -81,18 +81,18 @@ class HoloViews(Pane):
allow_None=True, doc="""
Bokeh theme to apply to the HoloViews plot.""")

widget_location = param.ObjectSelector(default='right_top', objects=[
widget_location = param.Selector(default='right_top', objects=[
'left', 'bottom', 'right', 'top', 'top_left', 'top_right',
'bottom_left', 'bottom_right', 'left_top', 'left_bottom',
'right_top', 'right_bottom'], doc="""
The layout of the plot and the widgets. The value refers to the
position of the widgets relative to the plot.""")

widget_layout = param.ObjectSelector(
widget_layout = param.Selector(
objects=[WidgetBox, Row, Column], constant=True, default=WidgetBox, doc="""
The layout object to display the widgets in.""")

widget_type = param.ObjectSelector(default='individual',
widget_type = param.Selector(default='individual',
objects=['individual', 'scrubber'], doc=""")
Whether to generate individual widgets for each dimension or
on global scrubber.""")
Expand Down
2 changes: 1 addition & 1 deletion panel/pane/ipywidget.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def _get_model(

class IPyLeaflet(IPyWidget):

sizing_mode = param.ObjectSelector(default='stretch_width', objects=[
sizing_mode = param.Selector(default='stretch_width', objects=[
'fixed', 'stretch_width', 'stretch_height', 'stretch_both',
'scale_width', 'scale_height', 'scale_both', None])

Expand Down
4 changes: 2 additions & 2 deletions panel/pane/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ class DataFrame(HTML):
index_names = param.Boolean(default=True, doc="""
Prints the names of the indexes.""")

justify = param.ObjectSelector(default=None, allow_None=True, objects=[
justify = param.Selector(default=None, allow_None=True, objects=[
'left', 'right', 'center', 'justify', 'justify-all', 'start',
'end', 'inherit', 'match-parent', 'initial', 'unset'], doc="""
How to justify the column labels.""")
Expand Down Expand Up @@ -505,7 +505,7 @@ class JSON(HTMLBasePane):
hover_preview = param.Boolean(default=False, doc="""
Whether to display a hover preview for collapsed nodes.""")

theme = param.ObjectSelector(default="dark", objects=["light", "dark"], doc="""
theme = param.Selector(default="dark", objects=["light", "dark"], doc="""
Whether the JSON tree view is expanded by default.""")

priority: ClassVar[float | bool | None] = None
Expand Down
4 changes: 2 additions & 2 deletions panel/pane/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ class Perspective(ModelPane, ReactiveData):
sort = param.List(default=None, doc="""
How to sort. For example[["x","desc"]]""")

plugin = param.ObjectSelector(default=Plugin.GRID.value, objects=Plugin.options(), doc="""
plugin = param.Selector(default=Plugin.GRID.value, objects=Plugin.options(), doc="""
The name of a plugin to display the data. For example hypergrid or d3_xy_scatter.""")

plugin_config = param.Dict(default={}, nested_refs=True, doc="""
Expand All @@ -314,7 +314,7 @@ class Perspective(ModelPane, ReactiveData):
settings = param.Boolean(default=True, doc="""
Whether to show the settings menu.""")

theme = param.ObjectSelector(default='pro', objects=THEMES, doc="""
theme = param.Selector(default='pro', objects=THEMES, doc="""
The style of the PerspectiveViewer. For example pro-dark""")

title = param.String(default=None, doc="""
Expand Down
2 changes: 1 addition & 1 deletion panel/pane/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class Folium(HTML):
The Folium pane wraps Folium map components.
"""

sizing_mode = param.ObjectSelector(default='stretch_width', objects=[
sizing_mode = param.Selector(default='stretch_width', objects=[
'fixed', 'stretch_width', 'stretch_height', 'stretch_both',
'scale_width', 'scale_height', 'scale_both', None])

Expand Down
2 changes: 1 addition & 1 deletion panel/pane/vega.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ class Vega(ModelPane):
show_actions = param.Boolean(default=False, doc="""
Whether to show Vega actions.""")

theme = param.ObjectSelector(default=None, allow_None=True, objects=[
theme = param.Selector(default=None, allow_None=True, objects=[
'excel', 'ggplot2', 'quartz', 'vox', 'fivethirtyeight', 'dark',
'latimes', 'urbaninstitute', 'googlecharts'])

Expand Down
2 changes: 1 addition & 1 deletion panel/template/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,7 +671,7 @@ class BasicTemplate(BaseTemplate):
Specifies the base URL for all relative URLs in a
page. Default is '', i.e. not the domain.""")

base_target = param.ObjectSelector(default="_self",
base_target = param.Selector(default="_self",
objects=["_blank", "_self", "_parent", "_top"], doc="""
Specifies the base Target for all relative URLs in a page.""")

Expand Down
2 changes: 1 addition & 1 deletion panel/template/react/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ReactTemplate(BasicTemplate):
ReactTemplate is built on top of React Grid Layout web components.
"""

compact = param.ObjectSelector(default=None, objects=[None, 'vertical', 'horizontal', 'both'])
compact = param.Selector(default=None, objects=[None, 'vertical', 'horizontal', 'both'])

cols = param.Dict(default={'lg': 12, 'md': 10, 'sm': 6, 'xs': 4, 'xxs': 2})

Expand Down
2 changes: 1 addition & 1 deletion panel/tests/layout/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ def test_widgetbox(document, comm):
def test_layout_with_param_setitem(document, comm):
import param
class TestClass(param.Parameterized):
select = param.ObjectSelector(default=0, objects=[0,1])
select = param.Selector(default=0, objects=[0,1])

def __init__(self, **params):
super().__init__(**params)
Expand Down
6 changes: 3 additions & 3 deletions panel/tests/test_param.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ class Test(param.Parameterized):

def test_object_selector_param(document, comm):
class Test(param.Parameterized):
a = param.ObjectSelector(default='b', objects=[1, 'b', 'c'])
a = param.Selector(default='b', objects=[1, 'b', 'c'])

test = Test()
test_pane = Param(test)
Expand Down Expand Up @@ -420,7 +420,7 @@ class Test(param.Parameterized):

def test_object_selector_param_overrides(document, comm):
class Test(param.Parameterized):
a = param.ObjectSelector(default='b', objects=[1, 'b', 'c'])
a = param.Selector(default='b', objects=[1, 'b', 'c'])

test = Test()
test_pane = Param(test, widgets={'a': {'options': ['b', 'c'], 'value': 'c'}})
Expand Down Expand Up @@ -953,7 +953,7 @@ class Test(param.Parameterized):

def test_switch_param_subobject(document, comm):
class Test(param.Parameterized):
a = param.ObjectSelector()
a = param.Selector()

o1 = Test(name='Subobject 1')
o2 = Test(name='Subobject 2')
Expand Down
8 changes: 4 additions & 4 deletions panel/viewable.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Layoutable(param.Parameterized):
css_classes = param.List(default=[], nested_refs=True, doc="""
CSS classes to apply to the layout.""")

design = param.ObjectSelector(default=None, objects=[], doc="""
design = param.Selector(default=None, objects=[], doc="""
The design system to use to style components.""")

height = param.Integer(default=None, bounds=(0, None), doc="""
Expand Down Expand Up @@ -127,7 +127,7 @@ class Layoutable(param.Parameterized):
The width of the component (in pixels). This can be either
fixed or preferred width, depending on width sizing policy.""")

width_policy = param.ObjectSelector(
width_policy = param.Selector(
default="auto", objects=['auto', 'fixed', 'fit', 'min', 'max'], doc="""
Describes how the component should maintain its width.
Expand Down Expand Up @@ -159,7 +159,7 @@ class Layoutable(param.Parameterized):
management and other factors.
""")

height_policy = param.ObjectSelector(
height_policy = param.Selector(
default="auto", objects=['auto', 'fixed', 'fit', 'min', 'max'], doc="""
Describes how the component should maintain its height.
Expand Down Expand Up @@ -191,7 +191,7 @@ class Layoutable(param.Parameterized):
management and other factors.
""")

sizing_mode = param.ObjectSelector(default=None, objects=[
sizing_mode = param.Selector(default=None, objects=[
'fixed', 'stretch_width', 'stretch_height', 'stretch_both',
'scale_width', 'scale_height', 'scale_both', None], doc="""
How the component should size itself.
Expand Down
4 changes: 2 additions & 2 deletions panel/widgets/button.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@

class _ButtonBase(Widget):

button_type = param.ObjectSelector(default='default', objects=BUTTON_TYPES, doc="""
button_type = param.Selector(default='default', objects=BUTTON_TYPES, doc="""
A button theme; should be one of 'default' (white), 'primary'
(blue), 'success' (green), 'info' (yellow), 'light' (light),
or 'danger' (red).""")

button_style = param.ObjectSelector(default='solid', objects=BUTTON_STYLES, doc="""
button_style = param.Selector(default='solid', objects=BUTTON_STYLES, doc="""
A button style to switch between 'solid', 'outline'.""")

_rename: ClassVar[Mapping[str, str | None]] = {'name': 'label', 'button_style': None}
Expand Down
Loading

0 comments on commit 7015943

Please sign in to comment.