Skip to content

Chore: extract calculations from interface and clean up#198

Open
kzsigmond wants to merge 30 commits into
mainfrom
194-test-extract-and-test-code-that-performs-calculations
Open

Chore: extract calculations from interface and clean up#198
kzsigmond wants to merge 30 commits into
mainfrom
194-test-extract-and-test-code-that-performs-calculations

Conversation

@kzsigmond
Copy link
Copy Markdown
Contributor

This pull request refactors both the legacy.py and pyci.py FanCI interface modules to streamline the conversion of occupation arrays to Slater determinants. It removes the energy (aka variational-like) objective code, since the classes are for the projected Schrodinger equation. The PR removes unused imports and redundant code.

Refactoring and code simplification:

  • Replaced repeated logic for converting occupation arrays to Slater determinants with a single utility function, convert_pyci_occs_to_fanpy_sds, in all relevant methods (compute_overlap, compute_overlap_deriv, and compute_overlap_double_deriv) in both legacy.py and pyci.py. [1] [2] [3] [4] [5] [6]
  • Removed the import and usage of the slater module in both files, as its functionality is now encapsulated in the utility function. [1] [2]
  • Removed unused imports, specifically cma, minimize, and related optimization methods. Note that these methods do not work with the Projected Schrodinger objective. They will be added to the variational interface class. The supported optimization modes are 'root' and 'lstsq' for the ProjectedSchrodingerFanCI class. [1] [2] [3]

API and logic changes:

  • Simplified the compute_objective and compute_jacobian methods in legacy.py by removing the code paths for the 'energy' objective type, focusing exclusively on the 'projected' objective. [1] [2] [3]
  • Fixed argument handling in compute_overlap_double_deriv to clarify the logic for string and array inputs. [1] [2]

Documentation and comments:

  • Updated class docstrings to clarify the role of pyci.py as the Projected Schrodinger objective class for PyCI.
  • Added or updated TODO comments for future improvements and clarifications. [1] [2] [3] [4] [5] [6]

kzsigmond added 30 commits May 4, 2026 11:23
Note: this is in preparation of extracting methods that perform computations
Note: these follow the same structure as compute overlap
Note: this should already be the case for the ProjectedSchrodingerPyCI class
Note: this will be a comment until we have an interface for the variational energy
Only root and least squares supported for projected objective
@kzsigmond kzsigmond added this to the v2.0.0 milestone May 14, 2026
@kzsigmond kzsigmond requested a review from rugwed-lokhande May 14, 2026 13:51
@kzsigmond kzsigmond self-assigned this May 14, 2026
@kzsigmond kzsigmond linked an issue May 14, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Test: Extract and test code that performs calculations

1 participant