Skip to content

Conversation

lan496
Copy link
Member

@lan496 lan496 commented Dec 30, 2023

Fixes: #381
When we compare two translation parts, we consider they are equal when the displacement is zero in module 1. For this comparison, mat_Dmod1 is not appropriate because, for example, mat_Dmod1(0 - eps) = 1 - eps for eps > 0.
This commit adds a new function mat_rem1, which is similar to numpy's fmod. For the example, abs(mat_rem1(0 - eps)) = abs(-eps) = eps gives the smallest displacement.

@lan496 lan496 requested review from atztogo and LecrisUT December 30, 2023 03:16
@lan496 lan496 added the bug label Dec 30, 2023
@lan496
Copy link
Member Author

lan496 commented Dec 30, 2023

@atztogo I am not sure how to name the function a - mat_Nint(a). For now, I use mat_rem1 because it is equivalent to Matlab's rem (and numpy.fmod). Do you have any other suggestions? In addition, what does "D" mean in mat_Dmod1?

@lan496 lan496 force-pushed the fix-381 branch 3 times, most recently from ef573f2 to 50852f1 Compare December 30, 2023 03:40
@codecov-commenter
Copy link

codecov-commenter commented Dec 30, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (3fa478e) 83.80% compared to head (89ec6d2) 83.84%.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #382      +/-   ##
===========================================
+ Coverage    83.80%   83.84%   +0.04%     
===========================================
  Files           24       24              
  Lines         8167     8172       +5     
===========================================
+ Hits          6844     6852       +8     
+ Misses        1323     1320       -3     
Flag Coverage Δ
c_api 77.57% <100.00%> (+0.38%) ⬆️
fortran_api 56.21% <87.50%> (+0.01%) ⬆️
python_api 80.48% <100.00%> (+0.01%) ⬆️
unit_tests 1.24% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@atztogo
Copy link
Collaborator

atztogo commented Dec 30, 2023

Thanks for your fix @lan496.

@atztogo I am not sure how to name the function a - mat_Nint(a). For now, I use mat_rem1 because it is equivalent to Matlab's rem (and numpy.fmod). Do you have any other suggestions?

No idea. mat_rem1 is good to me.

what does "D" mean in mat_Dmod1?

D means double. You can change if you want.

Copy link
Collaborator

@atztogo atztogo left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@lan496
Copy link
Member Author

lan496 commented Dec 30, 2023

D means double. You can change if you want.

@atztogo Thank you. I think no need to change the function name.

lan496 and others added 5 commits December 30, 2023 20:14
When we compare two translation parts, we consider they are equal when the displacements is zero module 1. For this comparison, `mat_Dmod1` is not appropriate because, for example, mat_Dmod1(0 - eps) = 1 - eps for eps > 0.
  This commit adds a new function `mat_rem1`, which is similar to numpy's fmod. For the example, abs(mat_rem1(0 - eps)) = abs(-eps) = eps gives the smallest displacement.
Co-authored-by: Cristian Le <github@lecris.me>
@lan496 lan496 enabled auto-merge December 30, 2023 11:16
@lan496 lan496 merged commit 04d097d into spglib:develop Dec 30, 2023
@LecrisUT LecrisUT added this to the 2.3 milestone Jan 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Failed to match with UNI number for MnBi2Te4
4 participants