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

Add new LineType ChunkCombinedNan #296

Merged
merged 1 commit into from Oct 20, 2023
Merged

Add new LineType ChunkCombinedNan #296

merged 1 commit into from Oct 20, 2023

Conversation

ianthomas23
Copy link
Member

This adds a new LineType ChunkCombinedNan to the serial and threaded algorithms which returns a single numpy array per chunk containing the x, y coordinates of all the points in that chunk with lines separated by NaN. This is the internal format used in both Bokeh and HoloViews so it will simplify and improve the performance of those libraries for contour lines. Closes #289.

Example:

from contourpy import contour_generator
z = [[0, 0], [1, 1], [0, 0]]
cont_gen = contour_generator(z=z, line_type="ChunkCombinedNan")
cont_gen.lines(0.5)

produces

([array([[0. , 0.5],
         [1. , 0.5],
         [nan, nan],
         [1. , 1.5],
         [0. , 1.5]])],)

The returned tuple only ever contains one list so strictly speaking the tuple is not required, but it is used here for consistency with all other ChunkCombined line and fill types.

The value of nan used is taken from numpy when first required rather than the standard C++ NaN value. These are nearly always the same, but this approach ensures that np.isnan will give the expected results on all platforms and compliers that numpy supports.

To do (in separate PRs):

  1. Add to benchmarks.
  2. Consider removing line offset calculation and storage for this line type. Currently they are always calculated and stored even though this is not necessary for ChunkCombinedNan. This needs investigating and the effect of performance measured.

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

Successfully merging this pull request may close these issues.

Possible new LineType of nan-separated points
1 participant