Skip to content
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

[Breaking] Make dict representation of SymmetrizedStructure MSONable #4296

Open
wants to merge 11 commits into
base: master
Choose a base branch
from

Conversation

DanielYang59
Copy link
Contributor

@DanielYang59 DanielYang59 commented Feb 19, 2025

Summary

@DanielYang59 DanielYang59 changed the title Make dict representation of SymmetrizedStructure MSONable [Breaking] Make dict representation of SymmetrizedStructure MSONable Feb 27, 2025
@DanielYang59 DanielYang59 force-pushed the symmetrized_structure_as_dict_monsable branch from dd6c999 to 49c3078 Compare February 27, 2025 18:40
@@ -44,6 +47,7 @@ def __init__(
"""
self.spacegroup = spacegroup
uniq, inverse = np.unique(equivalent_positions, return_inverse=True)
inverse = np.atleast_1d(inverse) # Ensures `inverse` is 1D
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe this is needed, otherwise numpy would throw an exception when inverse is scalar:

        equivalent_indices: list[list[int]] = [[] for _ in range(len(uniq))]
        equivalent_sites: list[list[PeriodicSite]] = [[] for _ in range(len(uniq))]
        wyckoff_symbols: list[list[str]] = [[] for _ in range(len(uniq))]
>       for idx, inv_ in enumerate(inverse):
E       TypeError: iteration over a 0-d array

@DanielYang59 DanielYang59 marked this pull request as ready for review March 6, 2025 08:49
@mkhorton
Copy link
Member

mkhorton commented Mar 7, 2025

Thanks @DanielYang59, and thanks for flagging it as breaking. Could you clarify what is actually breaking here? As far as I can see it's just the extra keys in the dict representation?

If breaking, could you also make sure the PR includes an update to the compatibility page to make sure people are notified. Thanks!

@DanielYang59
Copy link
Contributor Author

Hi @mkhorton thanks for reviewing!

Could you clarify what is actually breaking here? As far as I can see it's just the extra keys in the dict representation?

Yes AFAIK the breaking change would be the change of dict representation (which could also be considered a fix, but I assume it's better safe than sorry).

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.

SymmetrizedStructure.to(json) raises TypeError
2 participants