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

Ensure .stack works on Areas with different vdims #5693

Merged
merged 7 commits into from
May 4, 2023
Merged

Ensure .stack works on Areas with different vdims #5693

merged 7 commits into from
May 4, 2023

Conversation

TheoMathurin
Copy link
Contributor

Fixes #5689

I have yet to try this on main, but works fine on 1.15.4.

@TheoMathurin TheoMathurin marked this pull request as draft April 25, 2023 19:39
@codecov-commenter
Copy link

codecov-commenter commented Apr 25, 2023

Codecov Report

Merging #5693 (02ac3a2) into main (5ec8e63) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##             main    #5693   +/-   ##
=======================================
  Coverage   88.30%   88.30%           
=======================================
  Files         302      302           
  Lines       62605    62630   +25     
=======================================
+ Hits        55281    55305   +24     
- Misses       7324     7325    +1     
Impacted Files Coverage Δ
holoviews/element/chart.py 96.84% <100.00%> (ø)
holoviews/tests/plotting/bokeh/test_areaplot.py 100.00% <100.00%> (ø)
...loviews/tests/plotting/matplotlib/test_areaplot.py 100.00% <100.00%> (ø)
holoviews/tests/plotting/plotly/test_areaplot.py 100.00% <100.00%> (ø)

... and 1 file with indirect coverage changes

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

@TheoMathurin TheoMathurin marked this pull request as ready for review April 26, 2023 05:48
@hoxbro
Copy link
Member

hoxbro commented May 1, 2023

Thank you. The changes look good to me. Will it be possible for you to add a unit test? You can use the original example and verify the Baseline is correct. This can be found here:
image

The test can be added here:
https://github.com/holoviz/holoviews/blob/main/holoviews/tests/plotting/bokeh/test_areaplot.py

@TheoMathurin
Copy link
Contributor Author

Ok, maybe something along these lines?

df = pd.DataFrame({'x': [1, 2, 3], 'y_1': [1, 2, 3], 'y_2': [6, 4, 2], 'y_3': [8, 1, 2]})
overlay = hv.Overlay([hv.Area(df, kdims='x', vdims=col, label=col) for col in ['y_1', 'y_2', 'y_3']])

plot = hv.Area.stack(overlay)
baselines = [np.array([0, 0, 0]), np.array([1., 2., 3.]), np.array([7., 6., 5.])]

for n, baseline in zip(plot.data, baselines):
    self.assertEqual(plot.data[n].data.Baseline, baseline)

@hoxbro
Copy link
Member

hoxbro commented May 2, 2023

Yes. That looks good to me.

@TheoMathurin
Copy link
Contributor Author

TheoMathurin commented May 2, 2023

Alright I guess the test should be included for all three backends? I see that there are test_areaplot modules for plotly and matplotlib as well.

There's also the test_operation module which already contains tests on the stack operation. I don't know if it could be an alternative.

@hoxbro
Copy link
Member

hoxbro commented May 2, 2023

Alright I guess the test should be included for all three backends?

It would be nice, but it is up to you if you want to do it.

There's also the test_operation

Just ignore this. Operations are pretty cumbersome, and we want to add a test for your simple example.

@hoxbro hoxbro merged commit 4762cc1 into holoviz:main May 4, 2023
@hoxbro
Copy link
Member

hoxbro commented May 4, 2023

Thank you for PR 👍

@TheoMathurin
Copy link
Contributor Author

You're welcome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Area stack requires individual elements to share the same vdim
3 participants