Skip to content

BUG: Reject invalid DBSCAN Epsilon and match Minimum Points checks - #1958

Merged
imikejackson merged 2 commits into
BlueQuartzSoftware:developfrom
imikejackson:fix/dbscan-epsilon-minpoints-checks
Nov 14, 2026
Merged

imikejackson merged 2 commits into
BlueQuartzSoftware:developfrom
imikejackson:fix/dbscan-epsilon-minpoints-checks

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Summary

This PR fixes the parameter checks in DBSCAN, stops a very small Epsilon from overflowing the DBSCAN search grid, and rejects coordinates that are NaN or infinite.

  • DBSCANFilter preflight compared Epsilon with <= 0.0f. That comparison is false for NaN, so a NaN Epsilon passed preflight and got to the grid sizing, where a float-to-integer conversion of a NaN is undefined behavior. Preflight now rejects each Epsilon that is not finite or not greater than 0 (-7584). An infinite Epsilon is also rejected, because it causes the same conversion problem.
  • The out-of-core path rejected a negative Minimum Points value with its own error, -54063, which is also a Compute K Means error code. That check is removed. Filter preflight stays the only Minimum Points check (-7585), as the knowledge-base rule "Run a filter, not its algorithm" (ENH: Check filter inputs once, in preflight #1959) requires.
  • A very small but finite Epsilon, or a very large coordinate range, made the grid sizing overflow. The cast of an axis cell count to usize was undefined, and the cell count of the dense grid could wrap, so the grid was too small and binning wrote past its end. Execute now computes the grid dimensions with checks in the new DBSCANCommon.hpp, before it allocates the grid, in the in-core path and in both out-of-core paths:
    • -54091: one axis would span more grid cells than a grid index can hold, or its extent padded by one grid cell leaves the 32-bit floating-point range. The two cases have different messages: only the first one is fixed by a larger Epsilon. The external out-of-core path, which keeps a sparse grid, makes only this check.
    • -54092: the cell count of the dense grid, or its byte count at one usize per cell, would be larger than memory can address.
    • The dimensions of every grid that passes are the same as before.
  • An unmasked coordinate that is NaN or infinite (after the conversion to 32-bit floating point that the grid uses) was skipped by the bounds computation and then converted to a grid index, which is undefined behavior. Execute now stops at the first such value with -54093, which names the array, the tuple and the axis. Masked tuples are not checked, so a mask can exclude tuples that have no valid position.
  • All of the new messages name the clustering array.
  • The filter documentation states that every unmasked coordinate must be finite, and when the grid-size error occurs.
  • The DBSCAN V&V report has rows for the new checks and tests.

Test Plan

  • Test SimplnxCore::DBSCAN: Reject invalid parameters in preflight: Epsilon 0, -1, NaN and infinity give -7584, and Minimum Points 0 and -1 give -7585.
  • New test SimplnxCore::DBSCAN: Reject a search grid too large to index: through the filter, on both algorithm paths, in 2D and 3D. Epsilons 1e-30 and 1e-36 give -54091 with "Increase Epsilon", and the largest 32-bit Epsilon gives -54091 with the advice to rescale. One Epsilon whose cell count does not fit in usize and one whose cell count fits but whose byte count does not both give -54092.
  • New test SimplnxCore::DBSCAN: Reject a non-finite unmasked coordinate: through the filter, on both algorithm paths, in 2D and 3D, for NaN and infinity. One unmasked value and every value give -54093 with the first bad tuple and its axis; a masked value is ignored and the run succeeds.
  • New hidden out-of-core store test SimplnxCore::DBSCAN: genuine HDF5 search grid and coordinate checks: the external out-of-core path on an HDF5-OOC store gives -54091 and -54093.
  • macOS arm64, in-core Release build (both algorithm paths): ctest -R DBSCAN, 19 of 19 passed.
  • macOS arm64, out-of-core Release build with SimplnxOoc: ctest -R DBSCAN, 27 of 27 passed. The full ooc label suite (without benchmarks) passed 1050 of 1052, including SimplnxCoreOocStoreContracts, which runs the hidden HDF5 test. The two failures are in code this PR does not change: ComputeArrayHistogramByFeature: HDF5 OOC scanline storage witness (the local SimplnxOoc checkout did not yet have today's SimplnxOoc change to that expected value, which matches the value the test got) and the DREAM3D-NX NXVtkLibImportedHistogramTests.

Related Issue

Closes #1887
Related to #1908 (fixes item L86, the NaN Epsilon)

@imikejackson imikejackson self-assigned this Nov 11, 2026
@joeykleingers
joeykleingers force-pushed the fix/dbscan-epsilon-minpoints-checks branch from 3eb8802 to 4299234 Compare November 13, 2026 15:14

@joeykleingers joeykleingers left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The review findings are fixed in de04381: the Minimum Points check in the algorithm and its direct-call test are removed, and execute now rejects a DBSCAN search grid too large to index (-54091, -54092) and an unmasked non-finite coordinate (-54093). Tested in the in-core and out-of-core Release builds.

@imikejackson
imikejackson force-pushed the fix/dbscan-epsilon-minpoints-checks branch from de04381 to ce3de68 Compare November 13, 2026 20:22
@imikejackson

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

imikejackson and others added 2 commits November 14, 2026 13:07
* DBSCANFilter preflight compared Epsilon with `<= 0.0f`. That comparison
  is false for NaN, so a NaN Epsilon got to the grid sizing and its
  float-to-integer conversion. Preflight now rejects each Epsilon that is
  not finite or not greater than 0 (-7584).
* The out-of-core path rejected only a negative Minimum Points value, and
  the in-core paths did not check it. DBSCAN now rejects a Minimum Points
  value of 0 or less before it selects the in-core or out-of-core path
  (-54063), so both paths agree with the filter.
* Add tests for the preflight errors and for the Minimum Points error on
  each algorithm path.

Closes BlueQuartzSoftware#1887

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
* Remove the Minimum Points check (-54063) from DBSCAN::operator() and
  its direct-call test. Preflight already rejects a Minimum Points value
  of 0 or less (-7585), and the knowledge-base rule "Run a filter, not
  its algorithm" (BlueQuartzSoftware#1959) keeps input checks in preflight only. -54063 is
  also a Compute K Means error code.
* A very small Epsilon or a very large coordinate range made the grid
  sizing overflow: the cast of an axis cell count to usize was undefined,
  and the dense-grid cell count could wrap, so binning wrote past the end
  of the grid. The new DBSCANCommon.hpp computes the grid dimensions with
  checks before the grid is allocated, on the in-core path and both
  out-of-core paths:
  - -54091: one axis spans too many grid cells, or its extent padded by
    one cell leaves the float32 range.
  - -54092: the dense-grid cell count, or its byte count at one usize
    per cell, does not fit in usize.
  Every grid that passes keeps its old dimensions.
* An unmasked NaN or infinite coordinate was skipped by the bounds scan
  and then converted to a grid index. Execute now stops at the first one
  with -54093, which names the array, tuple and axis. Masked tuples are
  not checked.
* Remove UnitTest::LoadPlugins() from the preflight test.
* Add tests through the filter on both algorithm paths, in 2D and 3D, and
  a hidden HDF5 out-of-core store test for the external path.
* Update the filter documentation and the DBSCAN V&V report.

Signed-off-by: Joey Kleingers <joey.kleingers@bluequartz.net>
@imikejackson
imikejackson force-pushed the fix/dbscan-epsilon-minpoints-checks branch from ce3de68 to 56e3e5f Compare November 14, 2026 18:07
@imikejackson

Copy link
Copy Markdown
Contributor Author

/azp run

@imikejackson
imikejackson enabled auto-merge (squash) November 14, 2026 18:07
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).

@imikejackson
imikejackson merged commit 6644c17 into BlueQuartzSoftware:develop Nov 14, 2026
5 checks passed
@imikejackson
imikejackson deleted the fix/dbscan-epsilon-minpoints-checks branch November 14, 2026 19:22
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.

BUG: DBSCAN algorithms use an Epsilon of 0, negative or NaN when called without the filter

2 participants