Skip to content

[bug] Correct spin check #1733

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

Merged
merged 3 commits into from
May 22, 2025
Merged

[bug] Correct spin check #1733

merged 3 commits into from
May 22, 2025

Conversation

samwaseda
Copy link
Member

Closes #1732

Copy link

codecov bot commented May 22, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 67.07%. Comparing base (acf0156) to head (871c755).
Report is 5 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1733   +/-   ##
=======================================
  Coverage   67.06%   67.07%           
=======================================
  Files          75       75           
  Lines       12095    12093    -2     
=======================================
- Hits         8112     8111    -1     
+ Misses       3983     3982    -1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@samwaseda samwaseda merged commit dfea944 into main May 22, 2025
27 checks passed
@samwaseda samwaseda deleted the magmoms branch May 22, 2025 11:53
@@ -3104,11 +3104,9 @@ def pyiron_to_ase(pyiron_obj):
positions = pyiron_obj.positions
pbc = pyiron_obj.get_pbc()
spins = pyiron_obj.get_initial_magnetic_moments()
if all(spins == np.array(None)) or sum(np.abs(spins)) == 0.0:
if np.linalg.norm(spins) == 0.0:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@samwaseda, if this is legitimately a float check and not just catching the case where spins is a list of integer 0's, you probably want to wrap this in an np.isclose call. Since the target is zero, the relative tolerance is meaningless and you can disable it (rtol=0?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought about it for a moment, but

  • Non magnetic usually means the magnetic moments are not defined in the first place. This case is covered by the unit tests
  • I cannot exclude the possibility that the user wants a very very small magnetic moment value, and I cannot confidently use isclose for such a case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

magmoms in vasp
2 participants