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

Update contour line calculations to use ContourPy's LineType.ChunkCombinedNan #5985

Merged
merged 2 commits into from
Nov 16, 2023

Conversation

ianthomas23
Copy link
Member

Fixes #5957.

ContourPy 1.2.0 includes a new LineType called ChunkCombinedNan that returns the coordinates of multiple contour lines as a single 2D array with nan used as a separator between different lines. This is the format used internally by HoloViews for contour lines, and it is faster and uses less RAM if ContourPy inserts the nan when the contours are calculated rather than HoloViews doing it afterwards.

There is a version check for ContourPy and if >= 1.2 then LineType.ChunkCombinedNan is used, otherwise the original LineType.ChunkCombinedOffset is used and HoloViews inserts the nan. The new complexity is that if we are using datetime coordinates then we cannot pass nan to Matplotlib's num2date function, so here such nan are identified and set to zero using a mask, then num2date is called and the mask used again to set those values back to nan. This is unfortunate but I cannot see a better way that doesn't involve writing a new version of num2date.

Locally tested using both ContourPy 1.1.1 and 1.2.0.

@codecov-commenter
Copy link

codecov-commenter commented Nov 16, 2023

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (a3b419a) 88.58% compared to head (2c43d93) 88.43%.
Report is 1 commits behind head on main.

Files Patch % Lines
holoviews/operation/element.py 75.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5985      +/-   ##
==========================================
- Coverage   88.58%   88.43%   -0.16%     
==========================================
  Files         315      315              
  Lines       65554    65567      +13     
==========================================
- Hits        58074    57987      -87     
- Misses       7480     7580     +100     
Flag Coverage Δ
ui-tests ?

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@ianthomas23
Copy link
Member Author

The reduction in coverage is the contourpy < 1.2 code path that we aren't explicitly testing in CI when we use contourpy >= 1.2.

@hoxbro
Copy link
Member

hoxbro commented Nov 16, 2023

LGTM, thank you for the PR 👍

@hoxbro hoxbro merged commit 232d312 into main Nov 16, 2023
10 checks passed
@hoxbro hoxbro deleted the contourpy-1.2.0 branch November 16, 2023 15:34
@hoxbro hoxbro added the type: enhancement Minor feature or improvement to an existing feature label Nov 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement Minor feature or improvement to an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update contour line calculations to use ContourPy's LineType.ChunkCombinedNan
3 participants