Skip to content

Commit

Permalink
Update test and deprecations (#4300)
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro authored and philippjfr committed Feb 8, 2023
1 parent ba46e32 commit 691367a
Show file tree
Hide file tree
Showing 20 changed files with 59 additions and 123 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
with:
name: unit_test_suite
python-version: ${{ matrix.python-version }}
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
channels: pyviz/label/dev,bokeh/label/dev,conda-forge,nodefaults
# Remove when Python 3.11 is well supported on latest conda/conda-forge.
conda-update: ${{ matrix.python-version == '3.11' && 'false' || 'true' }}
nodejs: true
Expand All @@ -80,7 +80,7 @@ jobs:
- name: Install bokeh 3.0 compatibility packages
run: |
conda activate test-environment
conda uninstall holoviews jupyter_bokeh --force -y --offline
conda uninstall holoviews jupyter_bokeh --force -y --offline || echo "packages already removed"
pip install "git+https://github.com/holoviz/[email protected]"
pip install "git+https://github.com/bokeh/jupyter_bokeh.git"
- name: doit env_capture
Expand Down
3 changes: 1 addition & 2 deletions panel/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
Accordion, Card, Column, FlexBox, GridBox, GridSpec, Row, Spacer, Tabs,
WidgetBox,
)
from .pane import Pane, panel # noqa
from .pane import panel # noqa
from .param import Param # noqa
from .template import Template # noqa
from .widgets import indicators, widget # noqa
Expand All @@ -76,7 +76,6 @@
"FlexBox",
"GridBox",
"GridSpec",
"Pane", # deprecated
"Param",
"Row",
"Spacer",
Expand Down
4 changes: 2 additions & 2 deletions panel/models/vtk.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from bokeh.core.has_props import abstract
from bokeh.core.properties import (
Any, Bool, Dict, Enum, Float, Instance, Int, List, Nullable, Override,
PositiveInt, String,
Positive, String,
)
from bokeh.models import ColorMapper, Model

Expand All @@ -25,7 +25,7 @@ class VTKAxes(Model):

digits = Int(default=1)

fontsize = PositiveInt(default=12)
fontsize = Positive(Int, default=12)

grid_opacity = Float(default=0.1)

Expand Down
14 changes: 7 additions & 7 deletions panel/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion panel/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"url": "https://github.com/holoviz/panel.git"
},
"dependencies": {
"@bokeh/bokehjs": "^3.0.0",
"@bokeh/bokehjs": "^3.1.0-dev.1",
"@luma.gl/constants": "^8.0.3",
"@types/debounce": "^1.2.0",
"@types/gl-matrix": "^2.4.5",
Expand Down
3 changes: 1 addition & 2 deletions panel/pane/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
https://panel.holoviz.org/getting_started/index.html
"""
from .alert import Alert # noqa
from .base import Pane, PaneBase, panel # noqa
from .base import PaneBase, panel # noqa
from .deckgl import DeckGL # noqa
from .echarts import ECharts # noqa
from .equation import LaTeX # noqa
Expand Down Expand Up @@ -75,7 +75,6 @@
"LaTeX",
"Markdown",
"Matplotlib",
"Pane",
"PaneBase",
"panel",
"PDF",
Expand Down
11 changes: 0 additions & 11 deletions panel/pane/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
from ..models import ReactiveHTML as _BkReactiveHTML
from ..reactive import Reactive
from ..util import param_reprs
from ..util.warnings import deprecated
from ..viewable import (
Layoutable, ServableMixin, Viewable, Viewer,
)
Expand All @@ -35,16 +34,6 @@
from pyviz_comms import Comm


def Pane(obj: Any, **kwargs) -> 'PaneBase':
"""
Converts any object to a Pane if a matching Pane class exists.
"""
deprecated("1.0", "panel.Pane", "panel.panel")
if isinstance(obj, Viewable):
return obj
return PaneBase.get_pane_type(obj, **kwargs)(obj, **kwargs)


def panel(obj: Any, **kwargs) -> Viewable:
"""
Creates a panel from any supplied object by wrapping it in a pane
Expand Down
4 changes: 2 additions & 2 deletions panel/pane/holoviews.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
)
from ..viewable import Layoutable, Viewable
from ..widgets import Player
from .base import Pane, PaneBase, RerenderError
from .base import PaneBase, RerenderError, panel
from .plot import Bokeh, Matplotlib
from .plotly import Plotly

Expand Down Expand Up @@ -397,7 +397,7 @@ def _get_model(
return model

def _get_pane(self, backend, state, **kwargs):
pane_type = self._panes.get(backend, Pane)
pane_type = self._panes.get(backend, panel)
if isinstance(pane_type, type):
if issubclass(pane_type, Matplotlib):
kwargs['tight'] = True
Expand Down
8 changes: 6 additions & 2 deletions panel/pane/markup.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
import param

from ..models import HTML as _BkHTML, JSON as _BkJSON
from ..util import escape, style_to_styles
from ..util import escape
from ..util.warnings import deprecated
from ..viewable import Layoutable
from .base import PaneBase

Expand Down Expand Up @@ -43,7 +44,10 @@ class DivPaneBase(PaneBase):
__abstract = True

def __init__(self, object=None, **params):
params = style_to_styles(params)
if "style" in params:
# In Bokeh 3 'style' was changed to 'styles'.
params["styles"] = params.pop("style")
deprecated("1.1", "style", "styles")
super().__init__(object=object, **params)

def _get_properties(self):
Expand Down
33 changes: 0 additions & 33 deletions panel/pane/perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@

from ..reactive import ReactiveData
from ..util import lazy_load
from ..util.warnings import deprecated
from ..viewable import Viewable
from .base import PaneBase

Expand Down Expand Up @@ -281,16 +280,10 @@ class Perspective(PaneBase, ReactiveData):
columns = param.List(default=None, doc="""
A list of source columns to show as columns. For example ["x", "y"]""")

computed_columns = param.List(default=None, precedence=-1, doc="""
Deprecated alias for expressions.""")

expressions = param.List(default=None, doc="""
A list of expressions computing new columns from existing columns.
For example [""x"+"index""]""")

column_pivots = param.List(None, precedence=-1, doc="""
Deprecated alias of split_by.""")

split_by = param.List(None, doc="""
A list of source columns to pivot by. For example ["x", "y"]""")

Expand All @@ -306,9 +299,6 @@ class Perspective(PaneBase, ReactiveData):
group_by = param.List(default=None, doc="""
A list of source columns to group by. For example ["x", "y"]""")

row_pivots = param.List(default=None, precedence=-1, doc="""
Deprecated alias of group_by.""")

selectable = param.Boolean(default=True, allow_None=True, doc="""
Whether items are selectable.""")

Expand All @@ -334,9 +324,6 @@ class Perspective(PaneBase, ReactiveData):
_rerender_params: ClassVar[List[str]] = ['object']

_rename: ClassVar[Mapping[str, str | None]] = {
'computed_columns': None,
'row_pivots': None,
'column_pivots': None,
'selection': None,
}

Expand All @@ -348,12 +335,6 @@ class Perspective(PaneBase, ReactiveData):
'row_pivots': 'group_by'
}

def __init__(self, object=None, **params):
super().__init__(object=object, **params)
self.param.watch(self._deprecated_warning, ['computed_columns', 'column_pivots', 'row_pivots'])
ps = [deprecation for deprecation in self._deprecations if deprecation in params]
self.param.trigger(*ps)

@classmethod
def applies(cls, object):
if isinstance(object, dict) and all(isinstance(v, (list, np.ndarray)) for v in object.values()):
Expand Down Expand Up @@ -385,14 +366,6 @@ def _get_data(self):
"converted to strings.")
return df, {str(k): v for k, v in data.items()}

def _deprecated_warning(self, *events):
updates = {}
for event in events:
renamed = self._deprecations[event.name]
deprecated("1.0", event.name, renamed)
updates[renamed] = event.new
self.param.update(**updates)

def _filter_properties(self, properties):
ignored = list(Viewable.param)
return [p for p in properties if p not in ignored]
Expand Down Expand Up @@ -462,12 +435,6 @@ def _process_property_change(self, msg):
if prop not in msg:
continue
msg[prop] = [self._as_digit(col) for col in msg[prop]]
if prop == 'group_by':
msg['row_pivots'] = msg['group_by']
if prop == 'split_by':
msg['column_pivots'] = msg['split_by']
if 'expressions' in msg:
msg['computed_columns'] = msg['expressions']
if msg.get('sort'):
msg['sort'] = [[self._as_digit(col), *args] for col, *args in msg['sort']]
if msg.get('filters'):
Expand Down
4 changes: 2 additions & 2 deletions panel/tests/pane/test_deckgl.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
pydeck_available = pytest.mark.skipif(pydeck is None, reason="requires pydeck")

from panel.models.deckgl import DeckGLPlot
from panel.pane import DeckGL, Pane, PaneBase
from panel.pane import DeckGL, PaneBase, panel


@pydeck_available
Expand All @@ -21,7 +21,7 @@ def test_get_pydeck_pane_type_from_deck():
@pydeck_available
def test_pydeck_pane_deck(document, comm):
deck = pydeck.Deck(tooltip=True, api_keys={'mapbox': 'ABC'})
pane = Pane(deck)
pane = panel(deck)

# Create pane
model = pane.get_root(document, comm=comm)
Expand Down
18 changes: 17 additions & 1 deletion panel/tests/pane/test_holoviews.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import datetime as dt
import warnings

from collections import OrderedDict

Expand Down Expand Up @@ -29,6 +30,7 @@
from panel.layout import Column, FlexBox, Row
from panel.pane import HoloViews, PaneBase, panel
from panel.tests.util import hv_available, mpl_available
from panel.util.warnings import PanelDeprecationWarning
from panel.widgets import (
Checkbox, DiscreteSlider, FloatSlider, Select,
)
Expand Down Expand Up @@ -671,11 +673,25 @@ def test_holoviews_link_within_pane(document, comm):
assert range_tool.x_range == p2.x_range


@hv_available
def test_holoviews_property_override_old_method(document, comm):
c1 = hv.Curve([])

with warnings.catch_warnings():
warnings.simplefilter("ignore", PanelDeprecationWarning)
pane = pn.panel(c1, backend='bokeh', background='red',
css_classes=['test_class'])
model = pane.get_root(document, comm=comm)

assert model.styles["background"] == 'red'
assert model.css_classes == ['test_class']

@hv_available
def test_holoviews_property_override(document, comm):
c1 = hv.Curve([])

pane = pn.panel(c1, backend='bokeh', background='red',
pane = pn.panel(c1, backend='bokeh',
styles={'background': 'red'},
css_classes=['test_class'])
model = pane.get_root(document, comm=comm)

Expand Down
6 changes: 3 additions & 3 deletions panel/tests/pane/test_perspective.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
def test_perspective_int_cols(document, comm):
psp = Perspective(
data, columns=[0], aggregates={0: 'mean'}, sort=[[0, 'desc']],
row_pivots=[0], column_pivots=[0], filters=[[0, '==', 'None']]
group_by=[0], split_by=[0], filters=[[0, '==', 'None']]
)

model = psp.get_root(document, comm)
Expand All @@ -37,8 +37,8 @@ def test_perspective_int_cols(document, comm):
})

assert psp2.columns == [0]
assert psp2.row_pivots == [0]
assert psp2.column_pivots == [0]
assert psp2.group_by == [0]
assert psp2.split_by == [0]
assert psp2.aggregates == {0: 'mean'}
assert psp2.sort == [[0, 'desc']]
assert psp2.filters == [[0, '==', 'None']]
Expand Down
5 changes: 5 additions & 0 deletions panel/tests/widgets/test_debugger.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
"""This module contains tests of the Debugger"""
import logging

import pytest

import panel as pn


@pytest.mark.xdist_group("debugger")
def test_debugger_constructor():
debugger = pn.widgets.Debugger()

Expand All @@ -17,6 +20,7 @@ def test_debugger_constructor():
assert repr(debugger).startswith("Debugger(")


@pytest.mark.xdist_group("debugger")
def test_debugger_logging():
logger = logging.getLogger('panel.callbacks')
debugger = pn.widgets.Debugger()
Expand All @@ -36,6 +40,7 @@ def test_debugger_logging():
#TODO: test if debugger.terminal.output is cleared by JS callback.


@pytest.mark.xdist_group("debugger")
def test_debugger_logging_info():
logger = logging.getLogger('panel.callbacks')
debugger = pn.widgets.Debugger(level=logging.DEBUG)
Expand Down
4 changes: 2 additions & 2 deletions panel/tests/widgets/test_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def test_gauge_bounds():

def test_tqdm_color():
tqdm = Tqdm()
tqdm.text_pane.style={'color': 'green'}
tqdm.text_pane.styles={'color': 'green'}
for _ in tqdm(range(0,2)):
pass
assert tqdm.text_pane.style["color"]=="green"
assert tqdm.text_pane.styles["color"]=="green"
Loading

0 comments on commit 691367a

Please sign in to comment.