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

Add display globals to notebook_extension #5947

Merged
merged 2 commits into from
Oct 18, 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
7 changes: 5 additions & 2 deletions holoviews/ipython/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,18 @@ def __call__(self, *args, **params):
resources = list(resources)
if len(resources) == 0: return

from panel import config
from panel import config, extension as panel_extension
if hasattr(config, 'comms') and comms:
config.comms = comms

same_cell_execution = getattr(self, '_repeat_execution_in_cell', False)
same_cell_execution = published = getattr(self, '_repeat_execution_in_cell', False)
for r in [r for r in resources if r != 'holoviews']:
Store.renderers[r].load_nb(inline=p.inline)
Renderer.load_nb(inline=p.inline, reloading=same_cell_execution, enable_mathjax=p.enable_mathjax)

if not published and hasattr(panel_extension, "_display_globals"):
panel_extension._display_globals()

if hasattr(ip, 'kernel') and not loaded:
Renderer.comm_manager.get_client_comm(notebook_extension._process_comm_msg,
"hv-extension-comm")
Expand Down
22 changes: 18 additions & 4 deletions holoviews/operation/resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,16 @@ class ResampleOperation1D(LinkableOperation):
height = param.Integer(default=400, doc="""
The height of the output image in pixels.""")

pixel_ratio = param.Number(default=1, bounds=(0,None),
pixel_ratio = param.Number(default=None, bounds=(0,None),
inclusive_bounds=(False,False), doc="""
Pixel ratio applied to the height and width. Useful for higher
resolution screens where the PlotSize stream reports 'nominal'
dimensions in pixels that do not match the physical pixels. For
instance, setting pixel_ratio=2 can give better results on Retina
displays. Also useful for using lower resolution for speed.""")
displays. Also useful for using lower resolution for speed.
If not set explicitly, the zoom level of the browsers will be used,
if available.""")


class ResampleOperation2D(ResampleOperation1D):
"""
Expand Down Expand Up @@ -198,10 +201,21 @@ def _get_sampling(self, element, x, y, ndim=2, default=None):
xs, ys = (np.linspace(xstart+xunit/2., xend-xunit/2., width),
np.linspace(ystart+yunit/2., yend-yunit/2., height))

width = int(width * self.p.pixel_ratio)
height = int(height * self.p.pixel_ratio)
pixel_ratio = self._get_pixel_ratio()
width = int(width * pixel_ratio)
height = int(height * pixel_ratio)
return ((xstart, xend), (ystart, yend)), (xs, ys), (width, height), (xtype, ytype)

def _get_pixel_ratio(self):
if self.p.pixel_ratio is None:
from panel import state
if state.browser_info and isinstance(state.browser_info.device_pixel_ratio, (int, float)):
return state.browser_info.device_pixel_ratio
else:
return 1
else:
return self.p.pixel_ratio

def _dt_transform(self, x_range, y_range, xs, ys, xtype, ytype):
(xstart, xend), (ystart, yend) = x_range, y_range
if xtype == 'datetime':
Expand Down
1 change: 0 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ unfixable = [

[tool.ruff.isort]
known-first-party = ["holoviews"]
force-wrap-aliases = true
combine-as-imports = true

[tool.codespell]
Expand Down