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

Fix clim_percentile #5495

Merged
merged 4 commits into from
Jan 12, 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
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