-
Notifications
You must be signed in to change notification settings - Fork 588
Add compute_pca_statistics method to DataSetFilters #7694
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
base: main
Are you sure you want to change the base?
Conversation
This commit adds Principal Component Analysis (PCA) statistics computation capability to PyVista's DataSetFilters class. The implementation wraps VTK's vtkPCAStatistics filter to provide easy access to PCA analysis from PyVista. Key features: - Compute PCA statistics on point or cell data arrays - Support for analyzing all arrays or specific scalar arrays - Returns meaningful statistical measures including means and variances - Comprehensive test coverage with error handling - Follows PyVista's established patterns for filter implementation The method integrates seamlessly with PyVista's existing API and provides a Pythonic interface to VTK's statistical capabilities for data analysis and dimensionality reduction tasks. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #7694 +/- ##
==========================================
- Coverage 96.38% 96.26% -0.12%
==========================================
Files 150 150
Lines 32527 32578 +51
Branches 4114 4129 +15
==========================================
+ Hits 31351 31362 +11
- Misses 569 593 +24
- Partials 607 623 +16 |
Add type ignore comment for unreachable code warning when checking preference parameter that is already constrained by Literal type. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add missing return type annotation: -> pyvista.Table - Fix docstring example to use correct output keys ('means' instead of 'eigenvalues') - Update Returns section to accurately describe the actual output structure 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
When no meaningful data is extracted in compute_pca_statistics, return an empty Table as declared in the return type annotation instead of trying to return a wrapped multiblock output. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
- Add test for KeyError when scalar not found in point data - Add test for KeyError when scalar not found in cell data - Improve test coverage for uncovered lines 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
Add tests for specific scalar arrays, result field validation, and empty mesh handling to improve test coverage of the compute_pca_statistics functionality. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
vtkPCAStatistics looks really interesting and powerful. But compute_pca_statistics
seems to only implement very basic parts of that class to compute the mean and variance of arrays, which doesn't seem much more useful than using np.mean
and np.var
on the arrays directly.
If we could expand on this class and bit and show its use with an example like dimensionality reduction, I think it would make this more useful. There is vtk demo:
https://examples.vtk.org/site/PythonicAPI/Utilities/PCADemo/
Co-authored-by: user27182 <[email protected]>
Co-authored-by: user27182 <[email protected]>
for more information, see https://pre-commit.ci
Summary
This PR adds Principal Component Analysis (PCA) statistics computation capability to PyVista's DataSetFilters class by implementing a
compute_pca_statistics
method that wraps VTK'svtkPCAStatistics
filter.Changes
vtkPCAStatistics
import to_vtk_core.py
compute_pca_statistics
method inDataSetFilters
classFeatures
Test plan
🤖 Generated with Claude Code