Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into link_selections_ref…
Browse files Browse the repository at this point in the history
…actor
  • Loading branch information
jonmmease committed Sep 25, 2020
2 parents 59c3ede + 8f7c67f commit b1998aa
Show file tree
Hide file tree
Showing 17 changed files with 112 additions and 41 deletions.
11 changes: 8 additions & 3 deletions .travis.yml
Expand Up @@ -12,6 +12,9 @@ os:

dist: xenial

addons:
firefox: latest

notifications:
email:
on_failure: change # [always|never|change] default: always
Expand All @@ -23,6 +26,7 @@ env:
- CHANS="-c pyviz"
- MPLBACKEND="Agg"
- PYTHON_VERSION=3.7
- MOZ_HEADLESS=1

stages:
- test
Expand Down Expand Up @@ -66,6 +70,7 @@ jobs:
- source activate test-environment
- travis_wait 30 doit develop_install $CHANS_DEV -o $HV_REQUIREMENTS
- doit env_capture
- hash -r
script:
- doit test_all_recommended
after_success: coveralls
Expand All @@ -88,10 +93,11 @@ jobs:
<<: *default
stage: docs_dev
env: DESC="docs" HV_DOC_GALLERY="false" HV_DOC_REF_GALLERY="true" HV_REQUIREMENTS="doc" PANEL_EMBED="true" PANEL_EMBED_JSON="true" PANEL_EMBED_JSON_PREFIX="json" CHANS_DEV="-c pyviz/label/dev -c bokeh -c conda-forge"
before-script:
- conda install -c conda-forge geckodriver selenium
script:
- conda install $CHANS_DEV firefox geckodriver mpl_sample_data
- bokeh sampledata
- nbsite generate-rst --org pyviz --project-name holoviews --skip ^reference
- nbsite generate-rst --org holoviz --project-name holoviews --skip ^reference
- python ./doc/generate_modules.py holoviews -d ./doc/reference_manual -n holoviews -e tests
- nbsite build --what=html --output=builtdocs
after_success:
Expand All @@ -102,7 +108,6 @@ jobs:
stage: gallery_dev
env: DESC="gallery" HV_DOC_GALLERY="true" HV_DOC_REF_GALLERY="false" BUCKET="dev." HV_REQUIREMENTS="doc" PANEL_EMBED="true" PANEL_EMBED_JSON="true" PANEL_EMBED_JSON_PREFIX="json" CHANS_DEV="-c pyviz/label/dev -c bokeh -c conda-forge"
script:
- conda install $CHANS_DEV firefox geckodriver mpl_sample_data
- bokeh sampledata
- aws s3 sync --quiet s3://holoviews-doc-builds/$TRAVIS_BUILD_NUMBER ./
- git reset --hard --recurse-submodule
Expand Down
14 changes: 7 additions & 7 deletions doc/FAQ.rst
Expand Up @@ -62,7 +62,7 @@ set the ``xlim`` and ``ylim`` plot options:

.. code:: python
hv.Curve(df, 'x_col', 'y_col').options(xlim=(0, None), ylim=(0, 10))
hv.Curve(df, 'x_col', 'y_col').opts(xlim=(0, None), ylim=(0, 10))
This approach allows you to customize objects easily as a final step, but note that the values won't be applied to the underlying data, and thus won't be inherited if this object is subsequently used in an operation or data selection command.

Expand Down Expand Up @@ -118,10 +118,10 @@ determine the appropriate axis range yourself and set that, e.g. with
.. code:: python
# for matplotlib:
hv_obj = hv_obj.options(fig_size=500)
hv_obj = hv_obj.opts(fig_size=500)
# for bokeh:
hv_obj = hv_obj.options(width=1000, height=500)
hv_obj = hv_obj.opts(width=1000, height=500)
**Q: How do I get a legend on my overlay figure?**
Expand Down Expand Up @@ -184,7 +184,7 @@ plotted, instead consider that it is possible to write so called ``hooks``:
# artist, axis, legend and in bokeh x_range, y_range, glyph, cds etc.
plot.handles
hv.Curve(df, 'x_col', 'y_col').options(hooks=[hook])
hv.Curve(df, 'x_col', 'y_col').opts(hooks=[hook])
These hooks can modify the backend specific representation, e.g. the
matplotlib figure, before it is displayed, allowing arbitrary customizations to be
Expand Down Expand Up @@ -229,7 +229,7 @@ for that HoloViews object:
b.axis[0].ticker = FixedTicker(ticks=list(range(0, 10)))
h = hv.Curve([1,2,7], 'x_col', 'y_col')
h = h.options(hooks=[update_axis])
h = h.opts(hooks=[update_axis])
h
Here, you've wrapped your Bokeh-API calls into a function, then
Expand Down Expand Up @@ -360,7 +360,7 @@ they don't get applied until the object is returned
(during IPython's "display hooks" processing). So to make sure that
options get applied, (a) return the object from a cell, and then (b)
access it (e.g. for exporting) after the object has been returned.
To avoid confusion, you may prefer to use .options() directly on the
To avoid confusion, you may prefer to use .opts() directly on the
object to ensure that the options have been applied before exporting.
Example code below:

Expand Down Expand Up @@ -451,7 +451,7 @@ element:
hv.extension('matplotlib')
Store.add_style_opts(hv.Image, ['filternorm'], backend='matplotlib')
Now you can freely use ``'filternorm'`` in ``.options()`` and in the
Now you can freely use ``'filternorm'`` in ``.opts()`` and in the
``%opts`` line/cell magic, including tab-completion!


Expand Down
5 changes: 3 additions & 2 deletions doc/conf.py
Expand Up @@ -4,8 +4,8 @@

# Declare information specific to this project.
project = u'HoloViews'
authors = u'PyViz developers'
copyright = u'2019 ' + authors
authors = u'HoloViz developers'
copyright = u'2020 ' + authors
description = 'Stop plotting your data - annotate your data and let it visualize itself.'

import param
Expand All @@ -16,6 +16,7 @@
import holoviews
version = release = holoviews.__version__

holoviews.extension.inline = False

html_theme = 'sphinx_holoviz_theme'
html_static_path += ['_static']
Expand Down
5 changes: 2 additions & 3 deletions examples/gallery/demos/bokeh/lesmis_example.ipynb
Expand Up @@ -78,10 +78,9 @@
"\n",
"combined = hv.Overlay([o.opts(cmap=cm).sort() for o, cm in zip(overlaid, cmaps)], label='LesMis Occurences')\n",
"styled = combined.opts(\n",
" opts.HeatMap(logz=True, clipping_colors={'NaN':(1,1,1,0.)},\n",
" xaxis='top', xrotation=90,\n",
" opts.HeatMap(logz=True, clim=(0.1, None), clipping_colors={'NaN':(1,1,1,0.)}, xaxis='top', xrotation=90,\n",
" fontsize={'ticks': '7pt', 'title': '18pt'}, invert_xaxis=True, tools=['hover'],\n",
" labelled=[],),\n",
" labelled=[], axiswise=True),\n",
" opts.Overlay(height=800, width=800)\n",
")\n",
"styled"
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/bokeh/Spread.ipynb
Expand Up @@ -33,7 +33,7 @@
"source": [
"``Spread`` elements have the same data format as the [``ErrorBars``](ErrorBars.ipynb) element, namely x- and y-values with associated symmetric or asymmetric errors, but are interpreted as samples from a continuous distribution (just as ``Curve`` is the continuous version of ``Scatter``). These are often paired with an overlaid ``Curve`` to show an average trend along with a corresponding spread of values; see the [Tabular Datasets](../../../user_guide/08-Tabular_Datasets.ipynb) user guide for examples. \n",
"\n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less that one, making it partially transparent. \n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less than one, making it partially transparent. \n",
"\n",
"\n",
"##### Symmetric"
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/matplotlib/Spread.ipynb
Expand Up @@ -33,7 +33,7 @@
"source": [
"``Spread`` elements have the same data format as the [``ErrorBars``](ErrorBars.ipynb) element, namely x- and y-values with associated symmetric or asymmetric errors, but are interpreted as samples from a continuous distribution (just as ``Curve`` is the continuous version of ``Scatter``). These are often paired with an overlaid ``Curve`` to show an average trend along with a corresponding spread of values; see the [Tabular Datasets](../../../user_guide/07-Tabular_Datasets.ipynb) user guide for examples.\n",
"\n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less that one, making it partially transparent. \n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less than one, making it partially transparent. \n",
"\n",
"##### Symmetric"
]
Expand Down
2 changes: 1 addition & 1 deletion examples/reference/elements/plotly/Spread.ipynb
Expand Up @@ -30,7 +30,7 @@
"source": [
"``Spread`` elements have the same data format as the [``ErrorBars``](ErrorBars.ipynb) element, namely x- and y-values with associated symmetric or asymmetric errors, but are interpreted as samples from a continuous distribution (just as ``Curve`` is the continuous version of ``Scatter``). These are often paired with an overlaid ``Curve`` to show an average trend along with a corresponding spread of values; see the [Tabular Datasets](../../../user_guide/08-Tabular_Datasets.ipynb) user guide for examples. \n",
"\n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less that one, making it partially transparent. \n",
"Note that as the ``Spread`` element is used to add information to a plot (typically a ``Curve``) the default alpha value is less than one, making it partially transparent. \n",
"\n",
"\n",
"##### Symmetric"
Expand Down
4 changes: 3 additions & 1 deletion examples/user_guide/Continuous_Coordinates.ipynb
Expand Up @@ -53,7 +53,7 @@
"|||\n",
"|:--------------:|:----------------|\n",
"| **``f(x,y)``** | a simple function that accepts a location in a 2D plane specified in millimeters (mm) |\n",
"| **``region``** | a 1mm&times;1mm square region of this 2D plane, centered at the origin, and</dd> |\n",
"| **``region``** | a 1mm&times;1mm square region of this 2D plane, centered at the origin, and |\n",
"| **``coords``** | a function returning a square (s&times;s) grid of (x,y) coordinates regularly sampling the region in the given bounds, at the centers of each grid cell |\n",
"||||\n",
"\n"
Expand Down Expand Up @@ -332,6 +332,8 @@
"\n",
"They also work the same for the n-dimensional coordinates and slicing supported by the [container](Containers) types ``HoloMap``, ``NdLayout``, and ``NdOverlay``, implemented in ``holoviews.core.dimension.Dimensioned`` and again allowing arbitrary irregular spacing. \n",
"\n",
"``QuadMesh`` elements are similar but allow more general types of mapping between the underlying array and the continuous space, with arbitrary spacing along each of the axes or even over the entire array. See the ``QuadMesh`` element for more details.\n",
"\n",
"Together, these powerful continuous-coordinate indexing and slicing operations allow you to work naturally and simply in the full *n*-dimensional space that characterizes your data and parameter values."
]
},
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/data/cudf.py
Expand Up @@ -163,7 +163,7 @@ def groupby(cls, dataset, dimensions, container_type, group_type, **kwargs):
group_kwargs['dataset'] = dataset.dataset

# Find all the keys along supplied dimensions
keys = product(*(dataset.data[dimensions[0]].unique() for d in dimensions))
keys = product(*(dataset.data[dimensions[0]].unique().values_host for d in dimensions))

# Iterate over the unique entries applying selection masks
grouped_data = []
Expand Down
14 changes: 11 additions & 3 deletions holoviews/core/util.py
Expand Up @@ -1544,10 +1544,16 @@ def resolve_dependent_value(value):
A new dictionary where any parameter dependencies have been
resolved.
"""
range_widget = False
if 'panel' in sys.modules:
from panel.widgets.base import Widget
if isinstance(value, Widget):
value = value.param.value
from panel.widgets import RangeSlider, Widget
range_widget = isinstance(value, RangeSlider)
try:
from panel.depends import param_value_if_widget
value = param_value_if_widget(value)
except Exception:
if isinstance(value, Widget):
value = value.param.value
if is_param_method(value, has_deps=True):
value = value()
elif isinstance(value, param.Parameter) and isinstance(value.owner, param.Parameterized):
Expand All @@ -1557,6 +1563,8 @@ def resolve_dependent_value(value):
args = (getattr(p.owner, p.name) for p in deps.get('dependencies', []))
kwargs = {k: getattr(p.owner, p.name) for k, p in deps.get('kw', {}).items()}
value = value(*args, **kwargs)
if isinstance(value, tuple) and range_widget:
value = slice(*value)
return value


Expand Down
10 changes: 6 additions & 4 deletions holoviews/element/raster.py
Expand Up @@ -291,9 +291,10 @@ def __init__(self, data, kdims=None, vdims=None, bounds=None, extents=None,

Dataset.__init__(self, data, kdims=kdims, vdims=vdims, extents=extents, **params)
if not self.interface.gridded:
raise DataError("%s type expects gridded data, %s is columnar."
raise DataError("%s type expects gridded data, %s is columnar. "
"To display columnar data as gridded use the HeatMap "
"element or aggregate the data." %
"element or aggregate the data (e.g. using rasterize "
"or np.histogram2d)." %
(type(self).__name__, self.interface.__name__))

dim2, dim1 = self.interface.shape(self, gridded=True)[:2]
Expand Down Expand Up @@ -783,9 +784,10 @@ def __init__(self, data, kdims=None, vdims=None, **params):
data = ([], [], np.zeros((0, 0)))
super(QuadMesh, self).__init__(data, kdims, vdims, **params)
if not self.interface.gridded:
raise DataError("%s type expects gridded data, %s is columnar."
raise DataError("%s type expects gridded data, %s is columnar. "
"To display columnar data as gridded use the HeatMap "
"element or aggregate the data." %
"element or aggregate the data (e.g. using "
"np.histogram2d)." %
(type(self).__name__, self.interface.__name__))


Expand Down
8 changes: 8 additions & 0 deletions holoviews/plotting/bokeh/callbacks.py
Expand Up @@ -111,6 +111,8 @@ def reset(self):
if self.handle_ids:
handles = self._init_plot_handles()
for handle_name in self.models:
if not (handle_name in handles):
continue
handle = handles[handle_name]
cb_hash = (id(handle), id(type(self)))
self._callbacks.pop(cb_hash, None)
Expand Down Expand Up @@ -1198,8 +1200,14 @@ def _process_msg(self, msg):
new_values = []
for vals in values:
if isinstance(vals, dict):

shape = vals.pop('shape', None)
dtype = vals.pop('dtype', None)
vals.pop('dimension', None)
vals = sorted([(int(k), v) for k, v in vals.items()])
vals = [v for k, v in vals]
if dtype is not None:
vals = np.array(vals, dtype=dtype).reshape(shape)
new_values.append(vals)
values = new_values
elif any(isinstance(v, (int, float)) for v in values):
Expand Down
3 changes: 3 additions & 0 deletions holoviews/plotting/bokeh/element.py
Expand Up @@ -1380,6 +1380,9 @@ def initialize_plot(self, ranges=None, plot=None, plots=None, source=None):
for cb in self.callbacks:
cb.initialize()

if self.top_level:
self.init_links()

if not self.overlaid:
self._set_active_tools(plot)
self._process_legend()
Expand Down
2 changes: 2 additions & 0 deletions holoviews/plotting/bokeh/stats.py
Expand Up @@ -548,6 +548,8 @@ def get_data(self, element, ranges, style):
kde_data, line_data, seg_data, bar_data, scatter_data = (defaultdict(list) for i in range(5))
for i, (key, g) in enumerate(groups.items()):
key = decode_bytes(key)
if element.kdims:
key = tuple(d.pprint_value(k) for d, k in zip(element.kdims, key))
kde, line, segs, bars, scatter = self._kde_data(element, g, key, split_dim, split_cats, **kwargs)
for k, v in segs.items():
seg_data[k] += v
Expand Down
2 changes: 2 additions & 0 deletions holoviews/plotting/plotly/renderer.py
Expand Up @@ -159,6 +159,8 @@ def load_nb(cls, inline=True):
"""
import panel.models.plotly # noqa
cls._loaded = True
if 'plotly' not in getattr(pn.extension, '_loaded_extensions', ['plotly']):
pn.extension._loaded_extensions.append('plotly')


def _activate_plotly_backend(renderer):
Expand Down

0 comments on commit b1998aa

Please sign in to comment.