-
Notifications
You must be signed in to change notification settings - Fork 116
Created SPGLIB_INFO messaging level #461
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
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.
I think we should use the IDE navigation and see how the functions are called. If they end up in a top-level err, if they are recovered, etc.
warning_print(" From DB matching: %d\n", msgtype.type); | ||
info_print("Inconsistent MSG type:\n"); | ||
info_print(" From FSG and XSG: %d\n", type); | ||
info_print(" From DB matching: %d\n", msgtype.type); | ||
goto err; |
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.
Is this an info or a warning? There are other goto err
including ones with malloc
issues.
This depends on how msg_identify_magnetic_space_group_type
is meant to be used and if any issue is recoverable, expected, etc.
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.
This is an unreachable situation without something floating-point error. So, I guess this will be info.
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.
If it's unreachable like an assert
it should be warning
. Assuming the floating point error is not a dynamic tolerance
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.
I will leave whether info or warning to you, but let me put more context.
If the parameters symprec
and mag_symprec
are sufficiently small, this is like the assert
. But if these are too large, this assertion may fail. In that case, I recommend to decrease these parameter values.
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.
Since these are tied to a user input, these would not be classified as assert
(assert is only for debug if you are sure that users would not encounter it, that is why it is gated by NDEBUG
), but as runtime try-except
-like functionality.
It seems it could be either info
or warning
, but these are quite hard to detangle, so I am not sure how to classify either, since some are in a for loop, some are not. Ultimately we are mostly limited by the C language that we cannot use libraries like spdlog
, which would make these issues obsolete (since we can dynamically enable/disable/redirect logging, including having python native logs)
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.
Let's go with info
.
warning_print("spglib: Attempt %d tolerance = %f failed.", attempt, | ||
tolerance); | ||
warning_print(" (line %d, %s).\n", __LINE__, __FILE__); | ||
info_print("spglib: Attempt %d tolerance = %f failed.", attempt, |
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.
For these tolerance, I will move them to debug and have only one info
when it exits
@@ -1121,8 +1121,8 @@ static void layer_check_and_sort_axes(int axes[3], int const aperiodic_axis) { | |||
} else { | |||
// Warning when rot_axes[axes[i]][aperiodic_axis] == -2, -3, 2, 3 | |||
// I am not sure if this would ever happen. |
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.
Comment above seems to indicate it is a proper warning that at least we should know about if it happens
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.
This code is introduced for layer group, but we will not want to expose the feature for users since we should reconsider the algorithm, and the implementation will be redesigned. This will be a work not only the code redesign but require some scientific discussion. The code lines for the layer group implementation were inserted in many places and the refactoring will need some effort and take time. So I just have been leaving it untouched.
@@ -908,9 +908,9 @@ static VecDBL *get_changed_pure_translations(double const tmat[3][3], | |||
|
|||
/* Sanity check */ | |||
if (count != size) { |
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.
This part is conflicting with the comment above
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.
This function transforms the basis but when the distortion of the input crystal structure is large and with naive choice of the tolerance, this fails. count == size
is a minimum check that should satisfy the condition. So the comment says Sanity check. Could you recommend a better word?
@@ -266,7 +266,7 @@ int mat_inverse_matrix_d3(double m[3][3], double const a[3][3], | |||
double c[3][3]; | |||
det = mat_get_determinant_d3(a); | |||
if (mat_Dabs(det) < precision) { | |||
warning_print("spglib: No inverse matrix (det=%f)\n", det); | |||
info_print("spglib: No inverse matrix (det=%f)\n", det); |
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.
Maybe this is a debug_print?
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.
So if I see this message, I will see that the crystal structure is distorted. But as you commented, it is not possible to see it from the local piece of the code.
Close this PR because #457 was merged |
Currently spglib has two levels of messaging:
debug_print
andwarning_print
. This PR introduces another levelinfo_print
.Most of
warning_print
were replaced byinfo_print
.debug_print
SPGDEBUG
SPGLIB_DEBUG
warning_print
SPGWARNING
SPGLIB_WARNING
info_print
SPGINFO
SPGLIB_INFO
Resolve #338