Skip to content

Commit 76fcf3c

Browse files
authored
fix: Don't select in decimate if start and end is the same (#6661)
1 parent bd6c739 commit 76fcf3c

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

holoviews/operation/element.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,8 +1010,12 @@ def _process_layer(self, element, key=None):
10101010

10111011
# Slice element to current ranges
10121012
xdim, ydim = element.dimensions(label=True)[0:2]
1013-
sliced = element.select(**{xdim: (xstart, xend),
1014-
ydim: (ystart, yend)})
1013+
select_dict = {}
1014+
if xstart != xend:
1015+
select_dict[xdim] = (xstart, xend)
1016+
if ystart != yend:
1017+
select_dict[ydim] = (ystart, yend)
1018+
sliced = element.select(**select_dict) if select_dict else element
10151019

10161020
if len(sliced) > self.p.max_samples:
10171021
prng = np.random.RandomState(self.p.random_seed)

holoviews/tests/operation/test_operation.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -719,6 +719,7 @@ def test_pre_and_postprocess_hooks(self):
719719
operation._preprocess_hooks = pre_backup
720720
operation._postprocess_hooks = post_backup
721721

722+
@pytest.mark.usefixtures("bokeh_backend")
722723
def test_decimate_ordering(self):
723724
x = np.linspace(0, 10, 100)
724725
y = np.sin(x)
@@ -729,6 +730,16 @@ def test_decimate_ordering(self):
729730
index = decimated.data[()].data.index
730731
assert np.all(index == np.sort(index))
731732

733+
@pytest.mark.usefixtures("bokeh_backend")
734+
def test_decimate_same_y(self):
735+
data = pd.DataFrame({'x': np.arange(10), 'y': np.ones(10)})
736+
points = Points(data, kdims=['x', 'y']).opts(xlim=(0, 10))
737+
decimated = decimate(points)
738+
739+
renderer("bokeh").get_plot(decimated)
740+
output = decimated.data[()].data
741+
pd.testing.assert_series_equal(data["x"], output["x"])
742+
pd.testing.assert_series_equal(data["y"], output["y"])
732743

733744
class TestDendrogramOperation:
734745

0 commit comments

Comments
 (0)