Skip to content

Commit

Permalink
Preserve cols when overlaying on layout
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Nov 16, 2021
1 parent 403c1aa commit f835751
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion holoviews/core/layout.py
Expand Up @@ -570,7 +570,9 @@ def __mul__(self, other, reverse=False):
from .spaces import HoloMap
if not isinstance(other, (ViewableElement, HoloMap)):
return NotImplemented
return Layout([other*v if reverse else v*other for v in self])
layout = Layout([other*v if reverse else v*other for v in self])
layout._max_cols = self._max_cols
return layout

def __rmul__(self, other):
return self.__mul__(other, reverse=True)
Expand Down
6 changes: 6 additions & 0 deletions holoviews/tests/core/test_layouts.py
Expand Up @@ -29,6 +29,12 @@ def test_add_unicode(self):
elements = list(layout)
self.assertEqual(len(elements), 2)

def test_layout_overlay_ncols_preserved(self):
assert ((self.view1 + self.view2).cols(1) * self.view3)._max_cols == 1

def test_layout_rmul_overlay_ncols_preserved(self):
assert (self.view3 * (self.view1 + self.view2).cols(1))._max_cols == 1


class AdjointLayoutTest(CompositeTest):

Expand Down

0 comments on commit f835751

Please sign in to comment.