Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Misc changes #5717

Merged
merged 9 commits into from
Jun 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ holoviews/.version
.vscode/settings.json
holoviews/.vscode/settings.json
.venv

examples/getting_started/*.html
8 changes: 4 additions & 4 deletions examples/reference/elements/plotly/Tiles.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@
"source": [
"The ``Tiles`` element represents a so called web mapping tile source usually used for geographic plots, which fetches tiles appropriate to the current zoom level. To declare a ``Tiles`` element simply provide a URL to the tile server. A standard tile server URL has a number of templated variables that describe the location and zoom level. In the most common case of a WMTS tile source, the URL looks like this:\n",
"\n",
" 'https://maps.wikimedia.org/osm-intl/{Z}/{X}/{Y}@2x.png'\n",
" 'https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png'\n",
"\n",
"Here ``{X}``, ``{Y}`` and ``{Z}`` describe the location and zoom level of each tile.\n",
"A simple example of a WMTS tile source is the Wikipedia maps:"
"A simple example of a WMTS tile source is the OSM maps:"
]
},
{
Expand All @@ -44,7 +44,7 @@
"metadata": {},
"outputs": [],
"source": [
"hv.Tiles('https://maps.wikimedia.org/osm-intl/{Z}/{X}/{Y}@2x.png', name=\"Wikipedia\").opts(width=600, height=550)"
"hv.Tiles('https://c.tile.openstreetmap.org/{Z}/{X}/{Y}.png', name=\"OSM\").opts(width=600, height=550)"
]
},
{
Expand All @@ -53,7 +53,7 @@
"source": [
"One thing to note about tile sources is that they are always defined in the [pseudo-Mercator projection](https://epsg.io/3857), which means that if you want to overlay any data on top of a tile source the values have to be expressed as eastings and northings. If you have data in another projection, e.g. latitudes and longitudes, it may make sense to use [GeoViews](http://geoviews.org/) for it to handle the projections for you.\n",
"\n",
"Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, Stamen, OpenStreetMap, Esri and Wikipedia. These can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions that return a ``Tiles`` element:"
"Both HoloViews and GeoViews provides a number of tile sources by default, provided by CartoDB, Stamen, OpenStreetMap, and Esri. These can be imported from the ``holoviews.element.tiles`` module and are provided as callable functions that return a ``Tiles`` element:"
]
},
{
Expand Down
3 changes: 0 additions & 3 deletions holoviews/annotators.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,6 +547,3 @@ class RectangleAnnotator(_GeomAnnotator):
(Curve, CurveAnnotator),
(Rectangles, RectangleAnnotator),
])

# Alias: remove before 1.13.0 release
BoxAnnotator = RectangleAnnotator
14 changes: 7 additions & 7 deletions holoviews/core/dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,15 +234,15 @@ def __init__(self, spec, **params):

all_params = {}
if isinstance(spec, Dimension):
all_params.update(spec.param.get_param_values())
all_params.update(spec.param.values())
elif isinstance(spec, str):
if (spec, params.get('unit', None)) in self.presets.keys():
preset = self.presets[(str(spec), str(params['unit']))]
all_params.update(preset.param.get_param_values())
all_params.update(preset.param.values())
elif spec in self.presets:
all_params.update(self.presets[spec].param.get_param_values())
all_params.update(self.presets[spec].param.values())
elif (spec,) in self.presets:
all_params.update(self.presets[(spec,)].param.get_param_values())
all_params.update(self.presets[(spec,)].param.values())
all_params['name'] = spec
all_params['label'] = spec
elif isinstance(spec, tuple):
Expand Down Expand Up @@ -318,7 +318,7 @@ def clone(self, spec=None, **overrides):
Returns:
Cloned Dimension object
"""
settings = dict(self.param.get_param_values(), **overrides)
settings = dict(self.param.values(), **overrides)

if spec is None:
spec = (self.name, overrides.get('label', self.label))
Expand Down Expand Up @@ -377,7 +377,7 @@ def pprint_label(self):
return bytes_to_unicode(self.label) + bytes_to_unicode(unit)

def pprint(self):
changed = dict(self.param.get_param_values(onlychanged=True))
changed = self.param.values(onlychanged=True)
if len({changed.get(k, k) for k in ['name','label']}) == 1:
return f'Dimension({repr(self.name)})'

Expand Down Expand Up @@ -543,7 +543,7 @@ def clone(self, data=None, shared_data=True, new_type=None, link=True,
Returns:
Cloned object
"""
params = dict(self.param.get_param_values())
params = self.param.values()
if new_type is None:
clone_type = self.__class__
else:
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/ndmapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ def clone(self, data=None, shared_data=True, new_type=None, link=True,
Returns:
Cloned object
"""
settings = dict(self.param.get_param_values())
settings = self.param.values()
if settings.get('group', None) != self._group:
settings.pop('group')
if settings.get('label', None) != self._label:
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/options.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def _get_values(self):

def __call__(self, values=None, **params):
values = values if values else self.values
return self.__class__(**dict(self.param.get_param_values(), values=values, **params))
return self.__class__(**dict(self.param.values(), values=values, **params))


def __len__(self):
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/pprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def __call__(self, obj, filter_fn=None):
if isinstance(obj,type):
return class_proxy
else:
instance_params = obj.param.get_param_values()
instance_params = obj.param.values().items()
obj_proxy = class_proxy()
filtered = {k:v for k,v in instance_params
if (k in obj_proxy.param)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/core/spaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ def clone(self, callable=None, **overrides):
Returns:
Cloned Callable object
"""
old = {k: v for k, v in self.param.get_param_values()
old = {k: v for k, v in self.param.values().items()
if k not in ['callable', 'name']}
params = dict(old, **overrides)
callable = self.callable if callable is None else callable
Expand Down
1 change: 0 additions & 1 deletion holoviews/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import unicodedata
import datetime as dt

from collections.abc import Iterable # noqa
from collections import defaultdict, OrderedDict, namedtuple
from contextlib import contextmanager
from packaging.version import Version
Expand Down
4 changes: 2 additions & 2 deletions holoviews/element/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def points(self, kdims=None, vdims=None, groupby=None, **kwargs):

def raster(self, kdims=None, vdims=None, groupby=None, **kwargs):
heatmap = self.heatmap(kdims, vdims, **kwargs)
return Raster(heatmap.data, **dict(self._element.param.get_param_values(onlychanged=True)))
return Raster(heatmap.data, **self._element.param.values(onlychanged=True))

def scatter(self, kdims=None, vdims=None, groupby=None, **kwargs):
return self(Scatter, kdims, vdims, groupby, **kwargs)
Expand All @@ -83,7 +83,7 @@ def spread(self, kdims=None, vdims=None, groupby=None, **kwargs):

def surface(self, kdims=None, vdims=None, groupby=None, **kwargs):
heatmap = self.heatmap(kdims, vdims, **kwargs)
return Surface(heatmap.data, **dict(self._table.param.get_param_values(onlychanged=True)))
return Surface(heatmap.data, **self._table.param.values(onlychanged=True))

def trisurface(self, kdims=None, vdims=None, groupby=None, **kwargs):
return self(TriSurface, kdims, vdims, groupby, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/element/annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ def clone(self, *args, **overrides):
args = args[0]
# Apply name mangling for __ attribute
pos_args = getattr(self, '_' + type(self).__name__ + '__pos_params', [])
settings = {k: v for k, v in dict(self.param.get_param_values(), **overrides).items()
settings = {k: v for k, v in dict(self.param.values(), **overrides).items()
if k not in pos_args[:len(args)]}
if 'id' not in settings:
settings['id'] = self.id
Expand Down
4 changes: 2 additions & 2 deletions holoviews/element/comparison.py
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,8 @@ def compare_dimensions(cls, dim1, dim2, msg=None):
% (dim1.label, dim2.label))

# 'Deep' equality of dimension metadata (all parameters)
dim1_params = dict(dim1.param.get_param_values())
dim2_params = dict(dim2.param.get_param_values())
dim1_params = dim1.param.values()
dim2_params = dim2.param.values()

if set(dim1_params.keys()) != set(dim2_params.keys()):
raise cls.failureException("Dimension parameter sets mismatched: %s != %s"
Expand Down
2 changes: 1 addition & 1 deletion holoviews/element/path.py
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ def clone(self, *args, **overrides):
containing the specified args and kwargs.
"""
link = overrides.pop('link', True)
settings = dict(self.param.get_param_values(), **overrides)
settings = dict(self.param.values(), **overrides)
if 'id' not in settings:
settings['id'] = self.id
if not args and link:
Expand Down
4 changes: 2 additions & 2 deletions holoviews/element/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def sample(self, samples=[], bounds=None, **sample_values):
X, Y = samples
samples = zip(X, Y)

params = dict(self.param.get_param_values(onlychanged=True),
params = dict(self.param.values(onlychanged=True),
vdims=self.vdims)
if len(sample_values) == self.ndims or len(samples):
if not len(samples):
Expand Down Expand Up @@ -173,7 +173,7 @@ def reduce(self, dimensions=None, function=None, **reduce_map):
if oidx and hasattr(self, 'bounds'):
reduced = reduced[::-1]
data = zip(x_vals, reduced)
params = dict(dict(self.param.get_param_values(onlychanged=True)),
params = dict(dict(self.param.values(onlychanged=True)),
kdims=other_dimension, vdims=self.vdims)
params.pop('bounds', None)
params.pop('extents', None)
Expand Down
10 changes: 5 additions & 5 deletions holoviews/operation/datashader.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import warnings

from collections import OrderedDict
from collections.abc import Callable
from collections.abc import Callable, Iterable
from functools import partial

import param
Expand Down Expand Up @@ -30,7 +30,7 @@
Dataset, PandasInterface, XArrayInterface, DaskInterface, cuDFInterface
)
from ..core.util import (
Iterable, cast_array_to_int64, cftime_types, cftime_to_timestamp,
cast_array_to_int64, cftime_types, cftime_to_timestamp,
datetime_types, dt_to_int, get_param_values
)
from ..element import (Image, Path, Curve, RGB, Graph, TriMesh,
Expand Down Expand Up @@ -306,7 +306,7 @@ def _process(self, element, key=None):

if overlay_aggregate.applies(element, agg_fn, line_width=self.p.line_width):
params = dict(
{p: v for p, v in self.param.get_param_values() if p != 'name'},
{p: v for p, v in self.param.values().items() if p != 'name'},
dynamic=False, **{p: v for p, v in self.p.items()
if p not in ('name', 'dynamic')})
return overlay_aggregate(element, **params)
Expand Down Expand Up @@ -407,7 +407,7 @@ def _process(self, element, key=None):
info = self._get_sampling(element, x, y, ndims)
(x_range, y_range), (xs, ys), (width, height), (xtype, ytype) = info
((x0, x1), (y0, y1)), _ = self._dt_transform(x_range, y_range, xs, ys, xtype, ytype)
agg_params = dict({k: v for k, v in dict(self.param.get_param_values(),
agg_params = dict({k: v for k, v in dict(self.param.values(),
**self.p).items()
if k in aggregate.param},
x_range=(x0, x1), y_range=(y0, y1))
Expand Down Expand Up @@ -1380,7 +1380,7 @@ def _process(self, element, key=None):
all_allowed_kws = set()
all_supplied_kws = set()
for predicate, transform in self._transforms:
merged_param_values = dict(self.param.get_param_values(), **self.p)
merged_param_values = dict(self.param.values(), **self.p)

# If aggregator or interpolation are 'default', pop parameter so
# datashader can choose the default aggregator itself
Expand Down
2 changes: 1 addition & 1 deletion holoviews/operation/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class chain(Operation):
The group assigned to the result after having applied the chain.
Defaults to the group produced by the last operation in the chain""")

operations = param.List(default=[], class_=Operation, doc="""
operations = param.List(default=[], item_type=Operation, doc="""
A list of Operations (or Operation instances)
that are applied on the input from left to right.""")

Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ def __init__(self, root_model, link, source_plot, target_plot=None):
self.target_plot = target_plot
self.validate()

references = {k: v for k, v in link.param.get_param_values()
references = {k: v for k, v in link.param.values().items()
if k not in ('source', 'target', 'name')}

for sh in self.source_handles+[self.source_model]:
key = '_'.join(['source', sh])
references[key] = source_plot.handles[sh]

for p, value in link.param.get_param_values():
for p, value in link.param.values().items():
if p in ('name', 'source', 'target'):
continue
references[p] = value
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/bokeh/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ def _init_glyphs(self, plot, element, ranges, source):
return
if legend is None:
return
legend_params = {k: v for k, v in self.param.get_param_values()
legend_params = {k: v for k, v in self.param.values().items()
if k.startswith('legend')}
self._legend_plot = PointPlot(legend, keys=[], overlaid=1, **legend_params)
self._legend_plot.initialize_plot(plot=plot)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/bokeh/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ def convert_timestamp(timestamp):
"""
Converts bokehJS timestamp to datetime64.
"""
datetime = dt.datetime.utcfromtimestamp(timestamp/1000.)
datetime = dt.datetime.fromtimestamp(timestamp/1000, tz=dt.timezone.utc)
return np.datetime64(datetime.replace(tzinfo=None))


Expand Down
4 changes: 2 additions & 2 deletions holoviews/plotting/links.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ def link(self):
if self.source in self.registry:
links = self.registry[self.source]
params = {
k: v for k, v in self.param.get_param_values() if k != 'name'}
k: v for k, v in self.param.values().items() if k != 'name'}
for link in links:
link_params = {
k: v for k, v in link.param.get_param_values() if k != 'name'}
k: v for k, v in link.param.values().items() if k != 'name'}
if (type(link) is type(self) and link.source is self.source
and link.target is self.target and params == link_params):
return
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1043,7 +1043,7 @@ def _create_subplots(self, layout, positions, layout_dimensions, ranges, axes={}
override_opts = {}
sublabel_opts = {}
if pos == 'main':
own_params = self.param.get_param_values(onlychanged=True)
own_params = self.param.values(onlychanged=True).items()
sublabel_opts = {k: v for k, v in own_params
if 'sublabel_' in k}
elif pos == 'right':
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/mpl/raster.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def init_artists(self, ax, plot_args, plot_kwargs):
return handles
if legend is None:
return handles
legend_params = {k: v for k, v in self.param.get_param_values() if k.startswith('legend')}
legend_params = {k: v for k, v in self.param.values().items() if k.startswith('legend')}
self._legend_plot = PointPlot(legend, axis=ax, fig=self.state,
keys=self.keys, dimensions=self.dimensions,
overlaid=1, **legend_params)
Expand Down
2 changes: 1 addition & 1 deletion holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -1666,7 +1666,7 @@ def _create_subplot(self, key, obj, streams, ranges):
'during plotting' % obj.last)
return None
elif self.batched and 'batched' in plottype._plot_methods:
param_vals = dict(self.param.get_param_values())
param_vals = self.param.values()
propagate = {opt: param_vals[opt] for opt in self._propagate_options
if opt in param_vals}
opts['batched'] = self.batched
Expand Down
6 changes: 3 additions & 3 deletions holoviews/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ def rename(self, **mapping):
same name. Returns a new clone of the stream instance with the
specified name mapping.
"""
params = {k: v for k, v in self.param.get_param_values() if k != 'name'}
params = {k: v for k, v in self.param.values().items() if k != 'name'}
return self.__class__(rename=mapping,
source=(self._source() if self._source else None),
linked=self.linked, **params)
Expand Down Expand Up @@ -399,7 +399,7 @@ def transform(self):

@property
def contents(self):
filtered = {k: v for k, v in self.param.get_param_values() if k != 'name'}
filtered = {k: v for k, v in self.param.values().items() if k != 'name'}
return {self._rename.get(k, k): v for (k, v) in filtered.items()
if self._rename.get(k, True) is not None}

Expand Down Expand Up @@ -447,7 +447,7 @@ def update(self, **kwargs):
def __repr__(self):
cls_name = self.__class__.__name__
kwargs = ','.join(f'{k}={v!r}'
for (k, v) in self.param.get_param_values() if k != 'name')
for (k, v) in self.param.values().items() if k != 'name')
if not self._rename:
return f'{cls_name}({kwargs})'
else:
Expand Down
4 changes: 2 additions & 2 deletions holoviews/util/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ def output(cls, line=None, cell=None, cell_runner=None,
if prev_backend in Store.renderers:
prev_renderer = Store.renderers[prev_backend]
prev_backend_spec = prev_backend+':'+prev_renderer.mode
prev_params = {k: v for k, v in prev_renderer.param.get_param_values()
prev_params = {k: v for k, v in prev_renderer.param.values().items()
if k in cls.render_params}
else:
prev_renderer = None
Expand All @@ -310,7 +310,7 @@ def output(cls, line=None, cell=None, cell_runner=None,
backend_spec = prev_backend_spec
backend = backend_spec.split(':')[0]
renderer = Store.renderers[backend]
render_params = {k: v for k, v in renderer.param.get_param_values()
render_params = {k: v for k, v in renderer.param.values().items()
if k in cls.render_params}

# Set options on selected renderer and set display hook options
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[build-system]
requires = [
"param >=1.7.0",
"param >=1.12.0,<3.0",
"pyct >=0.4.4",
"setuptools >=30.3.0",
]
Expand Down