Test: interface submodule - #208
Merged
Merged
Conversation
This prevents a silent execution of new_ham has a wrong type.
This test needs to be updated once the stochastic optimizer is working properly.
checks if parameter saving is working check if we are able to use jac during optimization
rugwed-lokhande
approved these changes
Jun 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces several improvements and bug fixes to the
fanpy.interface.fanci.aliasand related PyCI interface code, with a strong focus on input validation, type safety, and enhanced test coverage. The most significant changes include stricter type and value checks in theAliasclass, improvements to interface consistency, and the addition of comprehensive unit tests for legacy, pyci and alias functionality.Input validation and error handling improvements:
Aliasclass constructor and__call__method to ensure probability vectors are numpy arrays, within the valid range, and 1D (with flattening and warning if not). The__call__method now checks thatnis an integer within valid bounds.fanpy_hamandpyci_hamproperty setters infanpy/interface/pyci.pyto raise clearTypeErrors when input types are invalid.Interface and documentation consistency:
maskparameter infanpy/interface/fanci/pyci.pyfrom alistto anp.ndarrayof bools, with updated docstrings to clarify its usage for freezing parameters.maskis correctly sized and of boolean type.Testing enhancements:
tests/test_interface_fanci_alias.pywith comprehensive unit tests for theAliasclass, covering input validation, warnings, and output correctness.tests/test_interface_fanci_legacy.pyandtests/test_interface_fanci_pyci.pytests/interface_utils.pymodule with reusable fake classes for testing, improving test isolation and maintainability.** Note on test coverage **
legacy.pydoes not cover the ProjectedSchrodingerLegacyFanci class individually. This is because this class is equivalent to thepyciFanCIclass.pyscf_tools.pyhas a lower test coverage because the localization function is not well documented, and may have a bug in it. Therefore, we are just testing the easiest case for localization.legacy.py&pyci.py: we are testing the most common inputs for the objective class. There are no additional masks,norm_detis set to the default, etc. These are features, we do not actively use, so testing them later should suffice. Especially since the test coverage now is significantly higher.