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

use jsanitize to serialize dicts/lists of msonables #354

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions smol/cofe/space/clusterspace.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from importlib import import_module

import numpy as np
from monty.json import MSONable
from monty.json import MSONable, jsanitize
from pymatgen.analysis.structure_matcher import (
OrderDisorderElementComparator,
StructureMatcher,
Expand Down Expand Up @@ -1516,11 +1516,11 @@ def as_dict(self):
"@class": self.__class__.__name__,
"structure": self.structure.as_dict(),
"expansion_structure": self.expansion_structure.as_dict(),
"symops": [so.as_dict() for so in self.symops],
"orbits": {s: [o.as_dict() for o in v] for s, v in self._orbits.items()},
"sc_matcher": self._sc_matcher.as_dict(),
"site_matcher": self._site_matcher.as_dict(),
"external_terms": [et.as_dict() for et in self.external_terms],
"symops": jsanitize(self.symops, strict=True),
"orbits": jsanitize(self._orbits, strict=True),
"external_terms": jsanitize(self.external_terms, strict=True),
"_supercell_orb_inds": _supercell_orb_inds,
}
return cs_dict
Expand Down
4 changes: 2 additions & 2 deletions smol/cofe/wrangling/wrangler.py
Original file line number Diff line number Diff line change
Expand Up @@ -878,8 +878,8 @@ def as_dict(self):
"@module": self.__class__.__module__,
"@class": self.__class__.__name__,
"_subspace": self._subspace.as_dict(),
"_entries": [entry.as_dict() for entry in self._entries],
"_ind_sets": jsanitize(self._ind_sets), # jic for int's
"_entries": jsanitize(self._entries, strict=True),
"_ind_sets": jsanitize(self._ind_sets, strict=True), # jic for int's
"metadata": self.metadata,
}
return wrangler_dict