Narrow down returned cell types#607
Conversation
885178a to
ee012d3
Compare
There was a problem hiding this comment.
Pull Request Overview
This PR introduces type narrowing for Python cell types to provide more specific type annotations. The changes split the generic Cell type into two distinct types: BaseCell for non-magnetic cells (3-tuple) and MagneticCell for magnetic cells (4-tuple).
- Defines new type aliases
BaseCellandMagneticCellfor better type specificity - Updates function signatures to use the appropriate cell type (base or magnetic)
- Adds explicit type casting for backward compatibility in edge cases
Reviewed Changes
Copilot reviewed 3 out of 15 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/msg_database.c | Changes parameter qualifier order from const int to int const for consistency |
| python/spglib/spglib.py | Introduces BaseCell and MagneticCell type aliases and updates function signatures |
| .clang-format | Adds PointerAlignment: Right configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #607 +/- ##
===========================================
- Coverage 74.48% 73.29% -1.19%
===========================================
Files 26 25 -1
Lines 7888 7650 -238
Branches 1638 1613 -25
===========================================
- Hits 5875 5607 -268
- Misses 1534 1581 +47
+ Partials 479 462 -17
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
|
@atztogo Can I merge this PR now? |
Yes, please. |
7b9d59f to
38b2e2c
Compare
|
thanks for the quick update! |
Closes #605
This PR introduces two type annotations for the Python interface:
BaseCellandMagneticCell.The former represents a 3-tuple (lattice, positions, numbers), and the latter represents a 4-tuple (lattice, positions, numbers, magmoms).