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

Fix clim_percentile #5495

merged 4 commits into from
Jan 12, 2023

Conversation

maximlt
Copy link
Member

@maximlt maximlt commented Oct 28, 2022

The clim_percentile option was added in #4712 but not tested and contained two small bugs, the first one making the option never available basically. I've tested clim_percentile as I was trying to run the plotting guide of xarray and was wondering if we had something similar to their robust=True option.

I'd like to write a test for this now. I'm not sure how to obtain the ranges so here's what I came up with:

import holoviews as hv
import numpy as np

hv.extension('bokeh')

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

bk_renderer = hv.Store.renderers['bokeh']
plot = bk_renderer.get_plot(im)

low, high = plot.ranges[('Image',)]['z']['robust']

assert low > 0
assert high < 1

The second issue I have is, if this test is alright, where to save it?

@jlstevens jlstevens added the type: bug Something isn't correct or isn't working label Oct 28, 2022
@codecov-commenter
Copy link

codecov-commenter commented Oct 28, 2022

Codecov Report

Merging #5495 (79f521a) into main (55ddbcb) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5495   +/-   ##
=======================================
  Coverage   88.23%   88.23%           
=======================================
  Files         302      302           
  Lines       62211    62234   +23     
=======================================
+ Hits        54889    54914   +25     
+ Misses       7322     7320    -2     
Impacted Files Coverage Δ
holoviews/plotting/plot.py 93.52% <100.00%> (+0.26%) ⬆️
holoviews/tests/plotting/bokeh/test_elementplot.py 96.82% <100.00%> (+0.03%) ⬆️
holoviews/ipython/display_hooks.py 59.70% <0.00%> (-0.61%) ⬇️
holoviews/tests/plotting/bokeh/test_layoutplot.py 100.00% <0.00%> (ø)
holoviews/tests/operation/test_operation.py 99.19% <0.00%> (+0.01%) ⬆️
holoviews/plotting/bokeh/element.py 89.39% <0.00%> (+0.06%) ⬆️
holoviews/operation/element.py 71.79% <0.00%> (+0.10%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@jlstevens
Copy link
Contributor

Looks good to me! Does look like the original implementation was rather buggy...

@maximlt Ready to merge? All tests are passing except on macos...

@jlstevens
Copy link
Contributor

Ah, I guess you want to add some docs first!

@maximlt
Copy link
Member Author

maximlt commented Oct 31, 2022

This was previously untested and I'd like to add at least a test before merging. The thing is that I'm not quite sure where to write the test, and if the test I suggest (in the OP) is right.

Sure why not documenting that properly. Where would you recommend adding that?

@jlstevens
Copy link
Contributor

I'm ok with testings this as part of the bokeh plotting tests only. Technically the change applies to all backends, so arguably there should a similar test for matplotlib and plotly but I would say that is entirely optional.

The approach you've suggested above looks ok to me. Happy to see this fix merged as soon as the tests goes in!

@philippjfr
Copy link
Member

The second issue I have is, if this test is alright, where to save it?

I'd suggest putting it in holoviews/tests/plotting/bokeh/test_elementplot.py:TestColorbarPlot

@hoxbro
Copy link
Member

hoxbro commented Jan 12, 2023

I will merge this as I want this fix into the next release.

@hoxbro hoxbro merged commit ccd0bc8 into main Jan 12, 2023
@hoxbro hoxbro deleted the fix_clim_percentile branch January 12, 2023 08:52
Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 23, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't correct or isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants