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
| """ | ||
| 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.
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). |
SymmetrizedStructure MSONableSymmetrizedStructure MSONable
Summary
SymmetrizedStructureMSONable, to fix SymmetrizedStructure.to(json) raises TypeError #3018