Skip to content

Commit

Permalink
Merge branch 'main' into enable_boxedittool_again
Browse files Browse the repository at this point in the history
  • Loading branch information
hoxbro committed Oct 11, 2023
2 parents 41b2c98 + 8c9ce6d commit c05fac9
Show file tree
Hide file tree
Showing 23 changed files with 172 additions and 286 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,16 @@ jobs:
bash ./scripts/build_conda.sh
- name: conda dev upload
if: (github.event_name == 'push' && (contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev
run: |
VERSION="$(echo "$(ls dist/*.whl)" | cut -d- -f2)"
FILE="$CONDA_PREFIX/conda-bld/noarch/holoviews-$VERSION-py_0.tar.bz2"
anaconda --token $CONDA_UPLOAD_TOKEN upload --user pyviz --label=dev $FILE
- name: conda main upload
if: (github.event_name == 'push' && !(contains(steps.vars.outputs.tag, 'a') || contains(steps.vars.outputs.tag, 'b') || contains(steps.vars.outputs.tag, 'rc')))
run: doit package_upload --token=$CONDA_UPLOAD_TOKEN --label=dev --label=main
run: |
VERSION="$(echo "$(ls dist/*.whl)" | cut -d- -f2)"
FILE="$CONDA_PREFIX/conda-bld/noarch/holoviews-$VERSION-py_0.tar.bz2"
anaconda --token $CONDA_UPLOAD_TOKEN upload --user pyviz --label=dev --label=main $FILE
pip_build:
name: Build PyPI Packages
runs-on: 'ubuntu-latest'
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
envs: "-o flakes -o tests -o examples_tests"
envs: "-o flakes -o tests -o examples_tests -o test_ci"
cache: true
conda-update: true
id: install
Expand Down Expand Up @@ -109,7 +109,7 @@ jobs:
name: ui_test_suite
python-version: ${{ matrix.python-version }}
channels: pyviz/label/dev,bokeh,conda-forge,nodefaults
envs: "-o recommended -o tests -o build"
envs: "-o recommended -o tests -o build -o test_ci"
cache: true
playwright: true
id: install
Expand Down Expand Up @@ -150,7 +150,7 @@ jobs:
python-version: ${{ matrix.python-version }}
channel-priority: strict
channels: pyviz/label/dev,conda-forge,nodefaults
envs: "-o tests_core"
envs: "-o tests_core -o test_ci"
cache: true
conda-update: true
id: install
Expand Down
13 changes: 9 additions & 4 deletions examples/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,17 @@ def pytest_runtest_makereport(item, call):
"""
from _pytest.runner import pytest_runtest_makereport

tr = pytest_runtest_makereport(item, call)

if call.excinfo is not None:
msg = "Kernel died before replying to kernel_info"
if call.excinfo.type == RuntimeError and call.excinfo.value.args[0] == msg:
tr.outcome = 'skipped'
tr.wasxfail = f"reason: {msg}"
msgs = [
"Kernel died before replying to kernel_info",
"Kernel didn't respond in 60 seconds",
]
for msg in msgs:
if call.excinfo.type == RuntimeError and call.excinfo.value.args[0] in msg:
tr.outcome = "skipped"
tr.wasxfail = f"reason: {msg}"

return tr
9 changes: 5 additions & 4 deletions holoviews/core/data/dictionary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from collections import defaultdict
from collections import OrderedDict, defaultdict

import numpy as np

Expand All @@ -18,7 +18,7 @@ class DictInterface(Interface):
are collections representing the values in that column.
"""

types = (dict,)
types = (dict, OrderedDict)

datatype = 'dictionary'

Expand Down Expand Up @@ -109,10 +109,11 @@ def init(cls, eltype, data, kdims, vdims):

if not cls.expanded([vs for d, vs in unpacked if d in dimensions and not isscalar(vs)]):
raise ValueError('DictInterface expects data to be of uniform shape.')
if isinstance(data, dict):
# OrderedDict can't be replaced with dict: https://github.com/holoviz/holoviews/pull/5925
if isinstance(data, OrderedDict):
data.update(unpacked)
else:
data = dict(unpacked)
data = OrderedDict(unpacked)

return data, {'kdims':kdims, 'vdims':vdims}, {}

Expand Down
11 changes: 8 additions & 3 deletions holoviews/core/data/ibis.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ def ibis4():
return ibis_version() >= Version("4.0")


@lru_cache
def ibis5():
return ibis_version() >= Version("5.0")


class IbisInterface(Interface):

types = ()
Expand Down Expand Up @@ -163,16 +168,16 @@ def histogram(cls, expr, bins, density=True, weights=None):
else:
# sort_by will be removed in Ibis 5.0
hist_bins = binned.value_counts().sort_by('bucket').execute()

for b, v in zip(hist_bins['bucket'], hist_bins['count']):
metric_name = 'bucket_count' if ibis5() else 'count'
for b, v in zip(hist_bins['bucket'], hist_bins[metric_name]):
if np.isnan(b):
continue
hist[int(b)] = v
if weights is not None:
raise NotImplementedError("Weighted histograms currently "
"not implemented for IbisInterface.")
if density:
hist = hist/expr.count().execute()
hist = hist/expr.count().execute()/np.diff(bins)
return hist, bins

@classmethod
Expand Down
8 changes: 7 additions & 1 deletion holoviews/operation/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -737,10 +737,16 @@ def _process(self, element, key=None):

# Mask data
if is_ibis_expr(data):
from ..core.data.ibis import ibis5

mask = data.notnull()
if self.p.nonzero:
mask = mask & (data != 0)
data = data.to_projection()
if ibis5():
data = data.as_table()
else:
# to_projection removed in ibis 5.0.0
data = data.to_projection()
data = data[mask]
no_data = not len(data.head(1).execute())
data = data[dim.name]
Expand Down
19 changes: 1 addition & 18 deletions holoviews/plotting/bokeh/callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
BoxEdit, PointDraw, PolyDraw, PolyEdit, CDSStream, FreehandDraw,
CurveEdit, SelectionXY, Lasso, SelectMode
)
from .util import bokeh3, bokeh33, convert_timestamp
from .util import bokeh33, convert_timestamp
from ...util.warnings import warn


Expand Down Expand Up @@ -618,23 +618,6 @@ class RangeXYCallback(Callback):
'y1': 'cb_obj.y1',
}

_js_on_event = """
if (this._updating)
return
const plot = this.origin
const plots = plot.x_range.plots.concat(plot.y_range.plots)
for (const p of plots) {
const event = new this.constructor(p.x_range.start, p.x_range.end, p.y_range.start, p.y_range.end)
event._updating = true
p.trigger_event(event)
}
"""

def set_callback(self, handle):
super().set_callback(handle)
if not bokeh3:
handle.js_on_event('rangesupdate', CustomJS(code=self._js_on_event))

def _process_msg(self, msg):
if self.plot.state.x_range is not self.plot.handles['x_range']:
x_range = self.plot.handles['x_range']
Expand Down
40 changes: 13 additions & 27 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
)
from .tabular import TablePlot
from .util import (
TOOL_TYPES, bokeh_version, bokeh3, bokeh32, date_to_integer,
TOOL_TYPES, bokeh_version, bokeh32, date_to_integer,
decode_bytes, get_tab_title, glyph_order, py2js_tickformatter,
recursive_model_update, theme_attr_json, cds_column_replace,
hold_policy, match_dim_specs, compute_layout_properties,
Expand All @@ -58,12 +58,8 @@
get_scale, get_axis_class
)

if bokeh3:
from bokeh.models.formatters import CustomJSTickFormatter
from bokeh.models.layouts import TabPanel
else:
from bokeh.models.formatters import FuncTickFormatter as CustomJSTickFormatter
from bokeh.models.layouts import Panel as TabPanel
from bokeh.models.formatters import CustomJSTickFormatter
from bokeh.models.layouts import TabPanel

try:
TOOLS_MAP = Tool._known_aliases
Expand Down Expand Up @@ -685,10 +681,7 @@ def _init_plot(self, key, element, plots, ranges=None):

properties.update(**self._plot_properties(key, element))

if bokeh3:
figure = bokeh.plotting.figure
else:
figure = bokeh.plotting.Figure
figure = bokeh.plotting.figure

with warnings.catch_warnings():
# Bokeh raises warnings about duplicate tools but these
Expand Down Expand Up @@ -1721,18 +1714,13 @@ def _update_glyph(self, renderer, properties, mapping, glyph, source, data):
server = self.renderer.mode == 'server'
with hold_policy(self.document, 'collect', server=server):
empty_data = {c: [] for c in columns}
if bokeh3:
event = ModelChangedEvent(
document=self.document,
model=source,
attr='data',
new=empty_data,
setter='empty'
)
else:
event = ModelChangedEvent(
self.document, source, 'data', source.data, empty_data, empty_data, setter='empty'
)
event = ModelChangedEvent(
document=self.document,
model=source,
attr='data',
new=empty_data,
setter='empty'
)
self.document.callbacks._held_events.append(event)

if legend is not None:
Expand Down Expand Up @@ -2565,7 +2553,7 @@ def _process_legend(self, plot=None):
or not self.show_legend):
legend.items[:] = []
else:
if bokeh3 and self.legend_cols:
if self.legend_cols:
plot.legend.nrows = self.legend_cols
else:
plot.legend.orientation = 'horizontal' if self.legend_cols else 'vertical'
Expand Down Expand Up @@ -2668,8 +2656,6 @@ def _process_legend(self, overlay):
options[k] = v

pos = self.legend_position
if not bokeh3:
options['orientation'] = 'horizontal' if self.legend_cols else 'vertical'
if pos in ['top', 'bottom'] and not self.legend_cols:
options['orientation'] = 'horizontal'

Expand All @@ -2679,7 +2665,7 @@ def _process_legend(self, overlay):

options.update(self._fontsize('legend', 'label_text_font_size'))
options.update(self._fontsize('legend_title', 'title_text_font_size'))
if bokeh3 and self.legend_cols:
if self.legend_cols:
options.update({"ncols": self.legend_cols})
legend.update(**options)

Expand Down
3 changes: 0 additions & 3 deletions holoviews/plotting/bokeh/graphs.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
base_properties, line_properties, fill_properties, text_properties,
rgba_tuple
)
from .util import bokeh3


class GraphPlot(GraphMixin, CompositeElementPlot, ColorbarPlot, LegendPlot):
Expand Down Expand Up @@ -185,8 +184,6 @@ def get_data(self, element, ranges, style):
index = nodes.astype(np.int32)
layout = {k: (y, x) if self.invert_axes else (x, y)
for k, (x, y) in zip(index, node_positions)}
if not bokeh3:
layout = {str(k): v for k, v in layout.items()}

point_data = {'index': index}

Expand Down
14 changes: 2 additions & 12 deletions holoviews/plotting/bokeh/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,15 @@

from bokeh.models import CustomJS
from bokeh.models.tools import RangeTool
from bokeh.models import Toolbar

from .util import bokeh3
from ...core.util import isscalar
from ..links import (
Link, RectanglesTableLink, DataLink, RangeToolLink,
SelectionLink, VertexTableLink
)
from ..plot import GenericElementPlot, GenericOverlayPlot

if bokeh3:
from bokeh.models import Toolbar
else:
from bokeh.models import ToolbarBox as Toolbar # Not completely correct


class LinkCallback:

Expand Down Expand Up @@ -158,11 +153,8 @@ def __init__(self, root_model, link, source_plot, target_plot):

tool = RangeTool(**axes)
source_plot.state.add_tools(tool)
if bokeh3 and toolbars:
if toolbars:
toolbars[0].tools.append(tool)
elif toolbars:
toolbar = toolbars[0].toolbar
toolbar.tools.append(tool)


class DataLinkCallback(LinkCallback):
Expand Down Expand Up @@ -206,8 +198,6 @@ def __init__(self, root_model, link, source_plot, target_plot):
renderer.update(data_source=src_cds)
else:
renderer.update(source=src_cds)
if not bokeh3 and hasattr(renderer, 'view'):
renderer.view.update(source=src_cds)
target_plot.handles['source'] = src_cds
target_plot.handles['cds'] = src_cds
for callback in target_plot.callbacks:
Expand Down
Loading

0 comments on commit c05fac9

Please sign in to comment.