Skip to content

Commit

Permalink
Fix clim_percentile (#5495)
Browse files Browse the repository at this point in the history
  • Loading branch information
maximlt committed Jan 12, 2023
1 parent 733af92 commit ccd0bc8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -705,11 +705,11 @@ def _compute_group_range(cls, group, elements, ranges, framewise,
data_range = el.range(el_dim, dimension_range=False)

data_ranges[(el, el_dim)] = data_range
if dtype is not None and dtype.kind == 'uif' and robust:
if dtype is not None and dtype.kind in 'uif' and robust:
percentile = 2 if isinstance(robust, bool) else robust
robust_ranges[(el, el_dim)] = (
dim(el_dim, np.nanpercentile, percentile).apply(el),
dim(el_dim, np.nanpercentile, percentile).apply(el)
dim(el_dim, np.nanpercentile, 100 - percentile).apply(el)
)

if (any(isinstance(r, str) for r in data_range) or
Expand Down
11 changes: 11 additions & 0 deletions holoviews/tests/plotting/bokeh/test_elementplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -971,3 +971,14 @@ def test_categorical_overlay_dimension_values_skip_factor(self):
plot = bokeh_renderer.get_plot((curve*scatter).redim.values(x=['A', 'C']))
x_range = plot.handles['x_range']
self.assertEqual(x_range.factors, ['A', 'C'])

def test_clim_percentile(self):
arr = np.random.rand(10,10)
arr[0, 0] = -100
arr[-1, -1] = 100
im = Image(arr).opts(clim_percentile=True)

plot = bokeh_renderer.get_plot(im)
low, high = plot.ranges[('Image',)]['z']['robust']
assert low > 0
assert high < 1

0 comments on commit ccd0bc8

Please sign in to comment.