NaN values getting passed in as control points. The NaN values were coming from divisions by zero that were happening in the case where the min and max values passed into the min-max lookup table generator (lutGenerator_minMax in Histogram.ts) were equal. The direct lookup table generation was handling the case where min = max (b === e) but the code that generates control points was not handling that case.
Solution:
Add more assertions to tests to check that no NaN values are generated, and modify control point generation logic to deal with min and max values being equal (avoid division by zero and create a step function with an almost vertical slope)
Other changes:
Wrote tests for a few more edge cases and wrote more code to make those tests pass
Added comments (hopefully they're accurate)
@toloudis and I worked on this together.
Pull request recommendations:
[x] Name your pull request your-development-type/short-description. Ex: feature/read-tiff-files
[x] Link to any relevant issue in the PR description. Ex: Resolves [gh-##], adds tiff file format support
[x] Provide description and context of changes.
[x] Provide relevant tests for your feature or bug fix.
[x] Provide or update documentation for any feature added by your pull request.
This should fix the bug we're currently seeing in CFE / website-3d-cell-viewer: website-3d-cell-viewer crashes when trying to view volume settings for contour channels
Cause of bug:
NaN values getting passed in as control points. The NaN values were coming from divisions by zero that were happening in the case where the min and max values passed into the min-max lookup table generator (
lutGenerator_minMax
in Histogram.ts) were equal. The direct lookup table generation was handling the case where min = max (b === e
) but the code that generates control points was not handling that case.Solution:
Add more assertions to tests to check that no NaN values are generated, and modify control point generation logic to deal with min and max values being equal (avoid division by zero and create a step function with an almost vertical slope)
Other changes:
@toloudis and I worked on this together.
Pull request recommendations:
Thanks for contributing!