MAINT: LindbladCoefficientBlock blocktype branching#701
MAINT: LindbladCoefficientBlock blocktype branching#701rileyjmurray merged 31 commits intodevelopfrom
Conversation
…indblad_term_objects
…ck.reate_lindblad_term_superoperators
…ary_errorgen_indices
…_deriv_wrt_params; apply input checking in caller function LindbladErrorgen.deriv_wrt_params.
…_hessian_wrt_params
…Code refactoring tool
coreyostrove
left a comment
There was a problem hiding this comment.
A couple non-blocking questions/requests. Generally this looks good and I appreciate the hard work and your patience waiting on my review. git diff really made a mess of this one...
A provocative question for you to seed future refactoring discussions. Should we (eventually) go even one step further and split the three block types off into separate classes, ditching the branching and dispatch structure entirely? There is a small shared core, but really the three blocks do quite different things with their internal parameters and it might be even cleaner longer term.
Not provocative at all! That's my evil plan 😈. This is just a stepping stone. |
|
Original response to Corey's comments referenced a wrong function name. I've fixed in the latest commit. Will see if tests pass. |
This PR has major changes to LindbladCoefficientBlock. I've taken care to produce code that is equivalent to the old code from an input-output perspective.
After this PR we'll be well-positioned to make a base class for LindbladCoefficientBlock (or just make LindbladCoefficientBlock a base class) from which new classes can inherit. I want to do this because I have an idea for a sparse Cholesky approach to reduced-order CPTP models.
The diff for this PR is kind of awful. Honestly, it's a little hopeless to track what happened. My ask is that we merge anyway once all tests pass. The approach I took to the refactor was to go function by function, preserving as much of the original implementation as possible. My first pass used an LLM for applying the refactoring pattern below. Once some tests failed after this, I did another pass that manually copy-pasted relevant codeblocks from the old
perform_operationfunctions into the new_perform_operation_<blocktype>helper functions.general approach
I took functions like
and refactored them to