Fix spglib >= 2.5 compatibility: convert SpglibDataset to plain dict#334
Open
abhinavships wants to merge 1 commit intousnistgov:masterfrom
Open
Fix spglib >= 2.5 compatibility: convert SpglibDataset to plain dict#334abhinavships wants to merge 1 commit intousnistgov:masterfrom
abhinavships wants to merge 1 commit intousnistgov:masterfrom
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
# Fix spglib >= 2.5 compatibility: SpglibDataset dataclass dict access
Closes #332 — "An update with spglib"
Problem
spglib >= 2.5.0changedget_symmetry_dataset()to return a typedSpglibDatasetdataclass object instead of a plain Pythondict.JARVIS-Tools accesses the result throughout
Spacegroup3Dusingsquare-bracket (dict-style) syntax, for example:
This raises
TypeError: 'SpglibDataset' object is not subscriptablefor anyone running a modern spglib installation, breaking spacegroup
determination, CFID descriptors, and any downstream workflow that calls
Spacegroup3D.Fix
Added a single small helper function
_dataset_to_dict()at modulelevel (≈ 25 lines):
Then called it in exactly two places inside
Spacegroup3D:__init__— normalise thedatasetargument before storing it.spacegroup_data()— normalise the return value ofspglib.get_symmetry_dataset()before constructing a newSpacegroup3D.No other code in the class was changed. The fix is fully backwards
compatible — a plain
dictpasses through_dataset_to_dict()unchanged, so users on older spglib versions are unaffected.
Testing
Verified locally with both spglib 1.16.5 and spglib 2.5.2:
All existing tests pass on both versions.
Files changed
jarvis/analysis/structure/spacegroup.py— added_dataset_to_dict();patched
__init__andspacegroup_data().