Skip to content

Remapping notebook is broken on RTD #1542

Description

@alioacar

Summary

The remapping notebook currently renders a traceback on RTD, likely solver/env drift in HoloViews/Matplotlib stack. The failure happens at display time in the HoloViews matplotlib backend.

Details

holoviews.plotting.mpl.util.fix_aspect is computing NaN for aspect/height so matplotlib rejects the call to set_size_inches().

Potential Solution

Explicitly setting the fig_inches may be more robust here ?

Full traceback
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/core/dimension.py:1491, in Dimensioned._repr_mimebundle_(self, include, exclude)
   1484 def _repr_mimebundle_(self, include=None, exclude=None):
   1485     """Resolves the class hierarchy for the class rendering the
   1486     object using any display hooks registered on Store.display
   1487     hooks.  The output of all registered display_hooks is then
   1488     combined and returned.
   1489 
   1490     """
-> 1491     return Store.render(self)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/core/options.py:1517, in Store.render(cls, obj)
   1515 data, metadata = {}, {}
   1516 for hook in hooks:
-> 1517     ret = hook(obj)
   1518     if ret is None:
   1519         continue

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/ipython/display_hooks.py:330, in pprint_display(obj)
    328 if not ip.display_formatter.formatters["text/plain"].pprint:
    329     return None
--> 330 return display(obj, raw_output=True)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/ipython/display_hooks.py:301, in display(obj, raw_output, **kwargs)
    299 elif isinstance(obj, (Layout, NdLayout, AdjointLayout)):
    300     with option_state(obj):
--> 301         output = layout_display(obj)
    302 elif isinstance(obj, (HoloMap, DynamicMap)):
    303     with option_state(obj):

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/ipython/display_hooks.py:193, in display_hook.<locals>.wrapped(element)
    191 try:
    192     max_frames = OutputSettings.options["max_frames"]
--> 193     mimebundle = fn(element, max_frames=max_frames)
    194     if mimebundle is None:
    195         return {}, {}

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/ipython/display_hooks.py:261, in layout_display(layout, max_frames)
    258     max_frame_warning(max_frames)
    259     return None
--> 261 return render(layout)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/ipython/display_hooks.py:62, in render(obj, **kwargs)
     59 if renderer.fig == "pdf":
     60     renderer = renderer.instance(fig="png")
---> 62 return renderer.components(obj, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/renderer.py:430, in Renderer.components(self, obj, fmt, comm, **kwargs)
    428     plot = obj
    429 else:
--> 430     plot, fmt = self._validate(obj, fmt)
    432 if not isinstance(plot, Viewable):
    433     html = self._figure_data(plot, fmt, as_script=True, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/renderer.py:361, in Renderer._validate(self, obj, fmt, **kwargs)
    359     plot = HoloViewsPane(obj, center=self.center, backend=self.backend, renderer=self)
    360 else:
--> 361     plot = self.get_plot(obj, renderer=self, **kwargs)
    363 all_formats = set(fig_formats + holomap_formats)
    364 if fmt not in all_formats:

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/renderer.py:291, in Renderer.get_plot(self_or_cls, obj, doc, renderer, comm, **kwargs)
    287     defaults = [kd.default for kd in plot.dimensions]
    288     init_key = tuple(
    289         v if d is None else d for v, d in zip(plot.keys[0], defaults, strict=None)
    290     )
--> 291     plot.update(init_key)
    292 else:
    293     plot = obj

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/mpl/plot.py:335, in MPLPlot.update(self, key)
    333 def update(self, key):
    334     if len(self) == 1 and key in (0, self.keys[0]) and not self.drawn:
--> 335         return self.initialize_plot()
    336     return self.__getitem__(key)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/mpl/plot.py:64, in mpl_rc_context.<locals>.wrapper(self, *args, **kwargs)
     62 def wrapper(self, *args, **kwargs):
     63     with _rc_context(self.fig_rcparams):
---> 64         return f(self, *args, **kwargs)

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/mpl/plot.py:1283, in LayoutPlot.initialize_plot(self)
   1277 traverse_fn = lambda x: x.handles.get("bbox_extra_artists", None)
   1278 extra_artists = list(
   1279     chain.from_iterable(
   1280         artists for artists in self.traverse(traverse_fn) if artists is not None
   1281     )
   1282 )
-> 1283 fix_aspect(
   1284     fig,
   1285     self.rows,
   1286     self.cols,
   1287     title_obj,
   1288     extra_artists,
   1289     vspace=self.vspace * self.fig_scale,
   1290     hspace=self.hspace * self.fig_scale,
   1291 )
   1292 colorbars = self.traverse(specs=[lambda x: hasattr(x, "colorbar")])
   1293 for cbar_plot in colorbars:

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/holoviews/plotting/mpl/util.py:288, in fix_aspect(fig, nrows, ncols, title, extra_artists, vspace, hspace)
    286 if title and title.get_text():
    287     offset = title.get_window_extent().height / fig.dpi
--> 288 fig.set_size_inches(w, (w * aspect) + offset)
    290 # Redraw and adjust title position if defined
    291 fig.canvas.draw()

File ~/checkouts/readthedocs.org/user_builds/uxarray/conda/latest/lib/python3.14/site-packages/matplotlib/figure.py:3167, in Figure.set_size_inches(self, w, h, forward)
   3165 size = np.array([w, h])
   3166 if not np.isfinite(size).all() or (size < 0).any():
-> 3167     raise ValueError(f'figure size must be positive finite not {size}')
   3168 self.bbox_inches.p1 = size
   3169 if forward:

ValueError: figure size must be positive finite not [ 8. nan]

Metadata

Metadata

Assignees

Labels

fix upstreamTo be fixed upstream, or awaiting a fix to be merged upstream; fixing it here is not the solution.visualizationPlotting or other visualizations

Type

No type

Projects

Status
On Pause

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions