Restore covariance#216
Conversation
Manual cherry pick of chunk logic fix to devel
…ke, a merge error
There was a problem hiding this comment.
Pull request overview
Restores coefficient covariance support in pyEXP by rebuilding the C++ inheritance path (moving covariance storage/API onto the Basis base) so covariance-related methods can be reached via polymorphism/dynamic dispatch in pybind11.
Changes:
- Move covariance state and the covariance API (
getCoefCovariance,writeCoefCovariance,enableCoefCovariance, etc.) fromBiorthBasisinto theBasisbase class. - Update pybind11 trampolines to override the covariance virtuals and adjust bindings to re-expose covariance operations.
- Re-point
setCovarH5Compressbinding to the new base-class location.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
| File | Description |
|---|---|
pyEXP/BasisWrappers.cc |
Updates pybind11 trampolines and (re)binds covariance-related methods after the inheritance changes. |
expui/BiorthBasis.H |
Removes covariance members/methods from BiorthBasis now that they live in Basis. |
expui/BasisFactory.H |
Adds covariance storage/methods to the Basis base class to restore polymorphic access. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Agent-Logs-Url: https://github.com/EXP-code/EXP/sessions/7396ab22-dac6-467e-9e74-f2fb2f26be91 Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 7 comments.
Comments suppressed due to low confidence (1)
pyEXP/BasisWrappers.cc:2230
- Covariance methods are now bound only on a subset of concrete classes (e.g.,
Cylindrical,SphericalSL,FlatDisk,Cube). Bases likeBessel(which inheritsSphericaland appears to share the same covariance-capable coefficient machinery) won’t exposegetCoefCovariance/writeCoefCovariance/enableCoefCovariancein Python anymore. To restore polymorphism via the pybind inheritance tree, bind these methods once on the common base (BiorthBasisorBasis) using the virtual API, or add the missing bindings forBessel(and any other covariance-capable derived bases).
py::arg("total")=true, py::arg("covar")=true);
py::class_<BasisClasses::Bessel, std::shared_ptr<BasisClasses::Bessel>, BasisClasses::Spherical>(m, "Bessel")
.def(py::init<const std::string&>(),
R"(
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Copy tensor contents into a new numpy-owned buffer. Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
copying tensor contents into a new numpy-owned buffer Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/EXP-code/EXP/sessions/cd11a5d9-ffd0-441c-bb19-d13d99a616d9 Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Agent-Logs-Url: https://github.com/EXP-code/EXP/sessions/cd11a5d9-ffd0-441c-bb19-d13d99a616d9 Co-authored-by: The9Cat <25960766+The9Cat@users.noreply.github.com>
|
Oooops. I believe this is actually a bug against |
|
I've added some test lines to make sure covariance is working; this isn't a regression test per se but it mirrors what we have been doing so far. |
|
It could be a bug against |
|
Bumped the version on |
michael-petersen
left a comment
There was a problem hiding this comment.
Version bump + compile + tests, seems good to me, will merge this to main and release.
Summary
Some recent merge seems to have removed some of the inheritance tree that supported covariance functionality in pyEXP. This PR restores that.
Details
No internal logic changes or API changes here. The header files were extended/rewritten to restore the inheritance chain that allowed allowed polymorphism and dynamic dispatch in pybind11. It is possible that a pybind11 update rather than a merge error caused this, but it was hard to reconstruct the history exactly.
Checks
Verified by building a covariance file from snapshots and reading and analyzing the resulting covariance db with an existing test notebook
Notes and comments
writeCovariance()after every coefficient build to write the covariance information to HDF5 covariance file.getCoefCovariance(time); that was a remnant from the first test API. User access to covariance data requires the HDF5 file to be read withbasis.CovarianceReader().make_coefs()call, optionally, for users who want to get the covariance data usinggetCoefCovariance(time)during the coefficient construction loop. For example, we could assign an instance of the helper classSubsampleCovariancetoBasisclass and populate that duringmake_coef()calls and optionally by reading the HDF5 covariance file. If this is desired, maybe we should open an issue on this, rather than implementing that as part of this bug fix since it would be a significant API change?