-
Notifications
You must be signed in to change notification settings - Fork 153
fix(cp2k): extract scalar from numpy array for math.isclose() comparison #924
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Co-authored-by: njzjz <9496702+njzjz@users.noreply.github.com>
CodSpeed Performance ReportMerging this PR will improve performance by 17.32%Comparing
|
| Mode | Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|---|
| ⚡ | WallTime | test_import |
11.2 ms | 9.6 ms | +17.32% |
| ⚡ | WallTime | test_cli |
280.3 ms | 253 ms | +10.78% |
Footnotes
-
2 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## devel #924 +/- ##
=======================================
Coverage 86.06% 86.06%
=======================================
Files 83 83
Lines 7886 7886
=======================================
Hits 6787 6787
Misses 1099 1099 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes a TypeError that occurred when math.isclose() received 1D numpy arrays instead of scalar values during CP2K AIMD output parsing.
Changes:
- Extract scalar values from
energiesarrays using[0]indexing before passing tomath.isclose()in theCp2kSystems.__next__()method
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
math.isclose()requires scalar arguments but was receiving 1D numpy arrays, causingTypeError: only 0-dimensional arrays can be converted to Python scalarsin CP2K AIMD output parsing.Changes
energiesarrays using[0]indexing before comparison inCp2kSystems.__next__()Both
log_info_dict["energies"]andxyz_info_dict["energies"]are shape(1,)arrays created bynp.asarray([energy]), so[0]extracts the scalar energy value for comparison while preserving the original arrays in the assertion message for debugging.Original prompt
TypeError: only 0-dimensional arrays can be converted to Python scalars#922💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.