-
Notifications
You must be signed in to change notification settings - Fork 116
Add get_magnetic_spacegroup_type_from_symmetry
and introduce dataclass output in python interface
#485
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
Add get_magnetic_spacegroup_type_from_symmetry
and introduce dataclass output in python interface
#485
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## develop #485 +/- ##
===========================================
+ Coverage 83.87% 83.90% +0.03%
===========================================
Files 25 25
Lines 8167 8184 +17
Branches 1702 1709 +7
===========================================
+ Hits 6850 6867 +17
Misses 1317 1317
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Can you also add spacegrouptype while you're at it? |
python/spglib/spglib.py
Outdated
msg_type_list = _spglib.magnetic_spacegroup_type_from_symmetry( | ||
rots, trans, timerev, latt, symprec | ||
) | ||
_set_error_message() |
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.
We have started to make functions raise error, maybe we should make this function raise errors as well. For compatibility it should be gated by a kwarg and we should start encouraging users to set it and use pythonic try catch logics
double(*lattice)[3]; | ||
int num_operations; | ||
|
||
SpglibMagneticSpacegroupType msg_type; |
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.
Can we start moving the type definitions next to where they are used? Can help with some optimizations and some readability by decluttering the variables and scoping the lifetimes
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.
Yes. Since we are free from some older compilers, my understanding is that we can start moving the location of type definitions
lattice = (double(*)[3])PyArray_DATA(py_lattice); | ||
num_operations = PyArray_DIMS(py_rotations)[0]; | ||
|
||
msg_type = spg_get_magnetic_spacegroup_type_from_symmetry( |
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.
There are a few interfaces that do not properly set error when they fail. Can you check them?
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.
To clarify on the C
side of the code in spglib.c
. At least anything that is public on spglib.h
should have some error setting.
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.
One more round of comments. Before the release we should migrate the other dict
as well.
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.
Also don't forget to rebase. CI is not running right now.
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
6c2e2e6
to
9c28457
Compare
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
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.
LGTM. The commit history is a bit noisy, so use squash commit if you don't plan on interactively rebasing.
@@ -97,6 +111,88 @@ class SpglibError: | |||
spglib_error = SpglibError() | |||
|
|||
|
|||
@dataclasses.dataclass(eq=True, frozen=True) | |||
class DictInterface(Mapping[str, "Any"]): |
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.
Did you find that@dataclass
was needed for this?
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.
Yes, mypy seems to need it.
get_magnetic_spacegroup_type_from_symmetry
in python interfaceget_magnetic_spacegroup_type_from_symmetry
and introduce dataclass output in python interface
Closes #482