Skip to content

Commit

Permalink
Merge bb12d5e into f7a9230
Browse files Browse the repository at this point in the history
  • Loading branch information
jlstevens committed Jul 16, 2021
2 parents f7a9230 + bb12d5e commit a377453
Show file tree
Hide file tree
Showing 13 changed files with 399 additions and 294 deletions.
5 changes: 4 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,10 @@ def __cmp__(self, other):
if pd:
pandas_version = LooseVersion(pd.__version__)
try:
if pandas_version >= '0.24.0':
if pandas_version >= '1.3.0':
from pandas.core.dtypes.dtypes import DatetimeTZDtype as DatetimeTZDtypeType
from pandas.core.dtypes.generic import ABCSeries, ABCIndex as ABCIndexClass
elif pandas_version >= '0.24.0':
from pandas.core.dtypes.dtypes import DatetimeTZDtype as DatetimeTZDtypeType
from pandas.core.dtypes.generic import ABCSeries, ABCIndexClass
elif pandas_version > '0.20.0':
Expand Down
4 changes: 3 additions & 1 deletion holoviews/element/tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
from ..util.transform import lon_lat_to_easting_northing, easting_northing_to_lon_lat


WEB_MERCATOR_LIMITS=(-20037508.342789244, 20037508.342789244)

class Tiles(Element2D):
"""
The Tiles element represents tile sources, specified as URL
Expand Down Expand Up @@ -190,4 +192,4 @@ def wikimedia_replacement():

tile_sources = {k: v for k, v in locals().items() if isinstance(v, FunctionType) and k not in
['ESRI', 'lon_lat_to_easting_northing', 'easting_northing_to_lon_lat',
'deprecation_warning', 'wikimedia_replacement']}
'deprecation_warning', 'wikimedia_replacement', 'WEB_MERCATOR_LIMITS']}
7 changes: 6 additions & 1 deletion holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,8 @@ def _plot_properties(self, key, element):
return plot_props

def _update_size(self, width, height, scale):
if self.renderer.mode == 'server':
return
self.state.frame_width = width
self.state.frame_height = height

Expand Down Expand Up @@ -853,8 +855,11 @@ def _update_ranges(self, element, ranges):
frame_aspect = 1
elif self.aspect and self.aspect != 'equal':
frame_aspect = self.aspect
else:
elif plot.frame_height and plot.frame_width:
frame_aspect = plot.frame_height/plot.frame_width
else:
# Cannot force an aspect until we know the frame size
return

range_streams = [s for s in self.streams if isinstance(s, RangeXY)]
if self.drawn:
Expand Down
12 changes: 7 additions & 5 deletions holoviews/plotting/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@
from ..core.operation import Operation
from ..core.ndmapping import item_check
from ..core.spaces import get_nested_streams
from ..core.util import (match_spec, wrap_tuple, basestring, get_overlay_spec,
unique_iterator, closest_match, is_number, isfinite,
python2sort, disable_constant, arraylike_types)
from ..streams import LinkedStream
from ..core.util import (
match_spec, wrap_tuple, basestring, get_overlay_spec,
unique_iterator, closest_match, is_number, isfinite,
python2sort, disable_constant, arraylike_types)
from ..streams import LinkedStream, Params
from ..util.transform import dim


Expand Down Expand Up @@ -181,7 +182,8 @@ def compute_overlayable_zorders(obj, path=[]):
# If object branches but does not declare inputs (e.g. user defined
# DynamicMaps returning (Nd)Overlay) add the items on the DynamicMap.last
found = any(isinstance(p, DynamicMap) and p.callback._is_overlay for p in path)
linked = any(isinstance(s, LinkedStream) and s.linked for s in obj.streams)
linked = any(isinstance(s, (LinkedStream, Params)) and s.linked
for s in obj.streams)
if (found or linked) and isoverlay and not isdynoverlay:
offset = max(zorder_map.keys())
for z, o in enumerate(obj.last):
Expand Down
21 changes: 21 additions & 0 deletions holoviews/selection.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,6 +327,27 @@ def selection_param(self, data):
self._datasets.append((pipe, data, raw))
return pipe.param.data

def filter(self, data, selection_expr=None):
"""
Filters the provided data based on the current state of the
current selection expression.
Args:
data: A Dataset type or data which can be cast to a Dataset
selection_expr: Optionally provide your own selection expression
Returns:
The filtered data
"""
expr = self.selection_expr if selection_expr is None else selection_expr
if expr is None:
return data
is_dataset = isinstance(data, Dataset)
if not is_dataset:
data = Dataset(data)
filtered = data[expr.apply(data)]
return filtered if is_dataset else filtered.data

@bothmethod
def _install_param_callbacks(self_or_cls, inst):
def update_selection_mode(*_):
Expand Down
6 changes: 5 additions & 1 deletion holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -694,6 +694,11 @@ def __init__(self, parameterized=None, parameters=None, watch=True, watch_only=F
rename.update({(o, k): v for o in owners})
params['rename'] = rename

if 'linked' not in params:
for p in parameters:
if isinstance(p.owner, (LinkedStream, Params)) and p.owner.linked:
params['linked'] = True

self._watch_only = watch_only
super(Params, self).__init__(parameterized=parameterized, parameters=parameters, **params)
self._memoize_counter = 0
Expand All @@ -713,7 +718,6 @@ def unwatch(self):
watcher.inst.param.unwatch(watcher)
self._watchers.clear()


@classmethod
def from_params(cls, params, **kwargs):
"""Returns Params streams given a dictionary of parameters
Expand Down
Loading

0 comments on commit a377453

Please sign in to comment.