-
Notifications
You must be signed in to change notification settings - Fork 885
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
base: master
Are you sure you want to change the base?
[Breaking] Make dict representation of SymmetrizedStructure
MSONable
#4296
Conversation
…ture_as_dict_monsable
SymmetrizedStructure
MSONableSymmetrizedStructure
MSONable
dd6c999
to
49c3078
Compare
…ub.com/DanielYang59/pymatgen into symmetrized_structure_as_dict_monsable
@@ -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 |
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.
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
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! |
Hi @mkhorton thanks for reviewing!
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). |
Summary
SymmetrizedStructure
MSONable, to fix SymmetrizedStructure.to(json) raises TypeError #3018