Support numpy >= 2.4 and relax the numpy requirement to <3#101
Open
pmrv wants to merge 1 commit into
Open
Conversation
Two changes are needed to work with numpy 2.4, both backward compatible down to numpy 1.x: 1. PyACECalculator/PyACEEnsembleCalculator filled the ASE results dict via np.float64(energy.reshape(-1,)). numpy 2.4 expired the 'conversion of ndim > 0 arrays to scalars' deprecation (present since numpy 1.25), so the scalar constructor now returns a shape-(1,) array instead of collapsing it to a scalar, and atoms.get_potential_energy() leaked a 1-element array of the total energy. Scalar results now go through float(), which behaves identically on every numpy version, and per-atom arrays through astype(np.float64), which also keeps energies_dev/forces_dev arrays for single-atom structures on older numpy. 2. pyace.radial used np.trapz, which numpy 2.0 kept only as a deprecated alias of np.trapezoid and numpy 2.4 removed. The module now picks whichever of the two exists. A regression assertion in tests/test_PyACECalculator.py guards the scalar energy output. Verified by building the package and running tests/test_PyACECalculator.py against numpy 1.26.4, 2.3.5 and 2.4.6. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_015Ui6Drmop9gZXo1fgn8yVg
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.
Two changes are needed to work with numpy 2.4, both backward compatible down to numpy 1.x:
PyACECalculator/PyACEEnsembleCalculator filled the ASE results dict via np.float64(energy.reshape(-1,)). numpy 2.4 expired the 'conversion of ndim > 0 arrays to scalars' deprecation (present since numpy 1.25), so the scalar constructor now returns a shape-(1,) array instead of collapsing it to a scalar, and atoms.get_potential_energy() leaked a 1-element array of the total energy. Scalar results now go through float(), which behaves identically on every numpy version, and per-atom arrays through astype(np.float64), which also keeps energies_dev/forces_dev arrays for single-atom structures on older numpy.
pyace.radial used np.trapz, which numpy 2.0 kept only as a deprecated alias of np.trapezoid and numpy 2.4 removed. The module now picks whichever of the two exists.
A regression assertion in tests/test_PyACECalculator.py guards the scalar energy output. Verified by building the package and running tests/test_PyACECalculator.py against numpy 1.26.4, 2.3.5 and 2.4.6.
Claude-Session: https://claude.ai/code/session_015Ui6Drmop9gZXo1fgn8yVg
Pull Request Template
Thank you for contributing to our project! Please review the checklist and fill out the details below.
Description of Changes
Checklist
License Agreement
By submitting this pull request, I agree that:
Thank you for your contribution!