Skip to content

VTK algorithms: Statistics, Entropy and Integrate; the dataset cache's observers kept reachable - #301

Merged
berkgeveci merged 2 commits into
Kitware:mainfrom
berkgeveci:vis/vtk-algorithms-tables
Nov 5, 2026
Merged

berkgeveci merged 2 commits into
Kitware:mainfrom
berkgeveci:vis/vtk-algorithms-tables

Conversation

@berkgeveci

Copy link
Copy Markdown
Collaborator

Stacked on #295 (its commits show here until it merges; this merges after it). The fifth step of the VTK algorithms plan, and a crash fix in the dataset cache from #290.

Statistics, Entropy, Integrate. They reduce all their input -- every dataset of a partitioned dataset or a tree, on every MPI rank -- to one answer, as VTK's vtkDescriptiveStatistics and vtkIntegrateAttributes do; every rank gets it.

  • Statistics and Entropy: a vtkTable, a row per field and a vector field's components one by one; td.statistics' values under Tack's names (kurtosis is not the excess).
  • Integrate: vtkIntegrateAttributes' output, one vertex at the centroid, each field's integral on it, the measure as Length, Area or Volume. On VTK's wavelet: VTK's volume and centroid, the integral within 3e-9.
  • Fields by fields, SetInputArrayToProcess, or every field. A point pieces share counts once where GhostCells or GenerateGlobalIds marks its owner (the guide says so).

Fixed: a segfault in Python's collector (separate commit). The cache of Tack datasets per VTK dataset dropped an entry from a DeleteEvent observer that only the VTK object referred to. When the collector freed such a dataset in a reference cycle (a failing test's traceback; an exception in a script), it cleared the observer as garbage first, then the deletion called it: _PyEval_EvalFrameDefault from vtkPythonCommand::Execute from the collector. A VTK bug, VTK-only reproduction on 9.7.1 and master (the vault's VTK bugs 19). The observers are kept reachable until they fire and only note the deletion; the cache drops the entry at its next use. The regression test segfaulted before.

Tested: the summaries against td.statistics/td.entropy and vtkIntegrateAttributes, pieces and trees against the whole, a surface's area, and 3 MPI ranks against the whole. VTK tests 200 passed on the 9.7.1 wheel and 216 on a local VTK master; quick tier 3080 passed; lint, docs build and validate.py --vtk clean.

🤖 Generated with Claude Code

…ped at the next use

The cache of Tack datasets per VTK dataset drops an entry from a DeleteEvent
observer, a function only the VTK object referred to. When Python's collector
freed such a dataset in a reference cycle made after it was read (a failing
test's traceback holding its frames), it took the observer for garbage too and
cleared its globals and closure first; the deletion then called it, and Python
segfaulted (_PyEval_EvalFrameDefault from vtkPythonCommand::Execute, from
vtkObject::ObjectFinalize, from the collector). VTK 9.7.1 and master both; a
VTK-only reproduction is VTK bugs 19 in the vault.

The observers are now kept in a module-level dict until they fire, and do no
more than note the address; the cache drops the entry, and the observer, at its
next use, outside whatever freed the dataset. The regression test makes the
cycle after the dataset was read, as the crash needs; it segfaulted before.
… the input

The summaries reduce everything they are given -- every dataset of a partitioned
dataset or a tree, on every MPI rank (the run's world) -- to one answer, as VTK's
vtkDescriptiveStatistics and vtkIntegrateAttributes reduce composite data; every
rank gets it.

- Statistics: a vtkTable, a row per field and a vector field's components one by
  one (ExtractComponent), columns field, where, component, td.statistics' values
  under Tack's names, and the unit.
- Entropy: the same rows, with the entropy in bits over `bins` bins.
- Integrate: vtkIntegrateAttributes' output, one vertex at the measure-weighted
  centroid (the integral of position over the measure), each point field's
  integral as point data and each cell field's as cell data, the measure as
  Length, Area or Volume by the cells' dimension.
- Fields: `fields`, SetInputArrayToProcess, or every field.

Held to td.statistics and td.entropy called directly, Integrate to
vtkIntegrateAttributes (centroid, volume, a point and a vector cell field), pieces
and trees to the whole (each shared point counted once where GhostCells or
GenerateGlobalIds mark its owner), a surface's measure to its area, and 3 MPI
ranks to the whole.
@berkgeveci berkgeveci added this to the 0.7 milestone Nov 4, 2026
@berkgeveci berkgeveci closed this Nov 4, 2026
@berkgeveci berkgeveci reopened this Nov 4, 2026
@berkgeveci
berkgeveci merged commit 85a3057 into Kitware:main Nov 5, 2026
61 of 62 checks passed
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.

1 participant