Skip to content

Conversation

lan496
Copy link
Member

@lan496 lan496 commented May 6, 2024

Closes #482

@lan496 lan496 added this to the 2.5 milestone May 6, 2024
@lan496 lan496 mentioned this pull request May 6, 2024
4 tasks
Copy link

codecov bot commented May 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.90%. Comparing base (9c8ec60) to head (f7e8b2f).

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              
Flag Coverage Δ
c_api 74.78% <ø> (ø)
fortran_api 56.19% <ø> (ø)
python_api 80.35% <100.00%> (+0.35%) ⬆️
unit_tests 13.47% <ø> (ø)

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.

@lan496 lan496 marked this pull request as ready for review May 6, 2024 02:17
@lan496 lan496 requested a review from LecrisUT May 6, 2024 02:17
@LecrisUT
Copy link
Collaborator

LecrisUT commented May 6, 2024

Can you also add spacegrouptype while you're at it?

msg_type_list = _spglib.magnetic_spacegroup_type_from_symmetry(
rots, trans, timerev, latt, symprec
)
_set_error_message()
Copy link
Collaborator

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;
Copy link
Collaborator

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

Copy link
Member Author

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(
Copy link
Collaborator

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?

Copy link
Collaborator

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.

@lan496 lan496 requested a review from LecrisUT May 6, 2024 10:54
Copy link
Collaborator

@LecrisUT LecrisUT left a 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.

@lan496 lan496 requested a review from LecrisUT May 9, 2024 22:32
Copy link
Collaborator

@LecrisUT LecrisUT left a 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.

@lan496 lan496 force-pushed the get_magnetic_spacegroup_type_from_symmetry branch from 6c2e2e6 to 9c28457 Compare May 10, 2024 12:46
lan496 and others added 3 commits May 11, 2024 09:02
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
Co-authored-by: Cristian Le <github@lecris.me>
lan496 and others added 7 commits May 11, 2024 09:03
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>
@lan496 lan496 requested a review from LecrisUT May 11, 2024 01:05
Copy link
Collaborator

@LecrisUT LecrisUT left a 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"]):
Copy link
Collaborator

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?

Copy link
Member Author

@lan496 lan496 May 11, 2024

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.

@lan496 lan496 merged commit 0030689 into spglib:develop May 11, 2024
@lan496 lan496 deleted the get_magnetic_spacegroup_type_from_symmetry branch May 11, 2024 23:55
@lan496 lan496 changed the title Add get_magnetic_spacegroup_type_from_symmetry in python interface Add get_magnetic_spacegroup_type_from_symmetry and introduce dataclass output in python interface May 12, 2024
@LecrisUT LecrisUT linked an issue Jul 2, 2024 that may be closed by this pull request
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.

dataclass output for Python API Python get_magnetic_spacegroup_type_from_symmetry
2 participants