Skip to content

Narrow down returned cell types#607

Merged
lan496 merged 2 commits intospglib:developfrom
lan496:narrow-cell-types
Sep 17, 2025
Merged

Narrow down returned cell types#607
lan496 merged 2 commits intospglib:developfrom
lan496:narrow-cell-types

Conversation

@lan496
Copy link
Copy Markdown
Member

@lan496 lan496 commented Sep 15, 2025

Closes #605

This PR introduces two type annotations for the Python interface: BaseCell and MagneticCell.
The former represents a 3-tuple (lattice, positions, numbers), and the latter represents a 4-tuple (lattice, positions, numbers, magmoms).

@lan496 lan496 marked this pull request as ready for review September 15, 2025 07:00
@lan496 lan496 requested review from atztogo and Copilot September 15, 2025 07:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 BaseCell and MagneticCell for 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
Copy link
Copy Markdown

codecov bot commented Sep 15, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.29%. Comparing base (4add188) to head (38b2e2c).
⚠️ Report is 58 commits behind head on develop.

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     
Flag Coverage Δ
c_api 69.42% <ø> (ø)
fortran_api ?
python_api 67.34% <ø> (ø)
unit_tests ?

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.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lan496 lan496 enabled auto-merge September 17, 2025 13:24
@lan496
Copy link
Copy Markdown
Member Author

lan496 commented Sep 17, 2025

@atztogo Can I merge this PR now?

@lan496 lan496 disabled auto-merge September 17, 2025 13:24
@atztogo
Copy link
Copy Markdown
Collaborator

atztogo commented Sep 17, 2025

@atztogo Can I merge this PR now?

Yes, please.

@lan496 lan496 removed the request for review from atztogo September 17, 2025 13:51
@lan496 lan496 enabled auto-merge September 17, 2025 13:52
@lan496 lan496 merged commit b2d6545 into spglib:develop Sep 17, 2025
44 of 52 checks passed
@DanielYang59
Copy link
Copy Markdown
Contributor

DanielYang59 commented Sep 17, 2025

thanks for the quick update!

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.

Narrow Cell as TypeAlias for some interface?

5 participants