本文整理汇总了Python中monty.json.MontyDecoder.process_decoded方法的典型用法代码示例。如果您正苦于以下问题:Python MontyDecoder.process_decoded方法的具体用法?Python MontyDecoder.process_decoded怎么用?Python MontyDecoder.process_decoded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类monty.json.MontyDecoder
的用法示例。
在下文中一共展示了MontyDecoder.process_decoded方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
return cls(
dec.process_decoded(d["voltage_pairs"]),
dec.process_decoded(d["working_ion_entry"]),
Composition(d["initial_comp"]),
)
示例2: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
return cls(d["composition"], d["energy"], d["correction"],
dec.process_decoded(d.get("parameters", {})),
dec.process_decoded(d.get("data", {})),
entry_id=d.get("entry_id", None),
attribute=d["attribute"] if "attribute" in d else None)
示例3: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
return cls(dec.process_decoded(d["structure"]),
d["energy"], d["correction"],
parameters={k: dec.process_decoded(v)
for k, v in d.get("parameters", {}).items()},
data={k: dec.process_decoded(v)
for k, v in d.get("data", {}).items()},
entry_id=d.get("entry_id", None))
示例4: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
d = d.copy()
d.pop("@module", None)
d.pop("@class", None)
dec = MontyDecoder()
d["spin_mode"] = dec.process_decoded(d["spin_mode"])
d["smearing"] = dec.process_decoded(d["smearing"])
d["algorithm"] = dec.process_decoded(d["algorithm"]) if d["algorithm"] else None
return cls(**d)
示例5: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
scf_strategy = dec.process_decoded(d["scf_strategy"])
ksampling = dec.process_decoded(d["ksampling"])
nscf_nband = dec.process_decoded(d["nscf_nband"])
nscf_algorithm = dec.process_decoded(d["nscf_algorithm"])
return cls(scf_strategy=scf_strategy, ksampling=ksampling,
nscf_nband=nscf_nband, nscf_algorithm=nscf_algorithm, **d['extra_abivars'])
示例6: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
structure = dec.process_decoded(d["structure"])
pseudos = dec.process_decoded(d['pseudos'])
ksampling = dec.process_decoded(d["ksampling"])
electrons = dec.process_decoded(d["electrons"])
return cls(structure=structure, pseudos=pseudos, ksampling=ksampling, accuracy=d['accuracy'],
spin_mode=electrons.spin_mode, smearing=electrons.smearing, charge=d['charge'],
scf_algorithm=electrons.algorithm, use_symmetries=d['use_symmetries'],
**d['extra_abivars'])
示例7: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
if 'is_valid' in d:
return cls(controller=dec.process_decoded(d['controller']),
state=d['state'], problems=d['problems'],
actions=dec.process_decoded(d['actions']),
restart=d['restart'], is_valid=d['is_valid'])
else:
return cls(controller=dec.process_decoded(d['controller']),
state=d['state'], problems=d['problems'],
actions=dec.process_decoded(d['actions']),
restart=d['restart'])
示例8: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
working_ion_entry = dec.process_decoded(d["working_ion_entry"])
balanced_rxn = dec.process_decoded(d["balanced_rxn"])
entries_charge = dec.process_decoded(d["entries_charge"])
entries_discharge = dec.process_decoded(d["entries_discharge"])
return ConversionVoltagePair(balanced_rxn, d["voltage"], d["mAh"],
d["vol_charge"], d["vol_discharge"],
d["mass_charge"], d["mass_discharge"],
d["frac_charge"], d["frac_discharge"],
entries_charge, entries_discharge,
working_ion_entry)
示例9: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
a = d["about"]
dec = MontyDecoder()
created_at = dec.process_decoded(a.get("created_at"))
data = {k: v for k, v in d["about"].items()
if k.startswith("_")}
data = dec.process_decoded(data)
structure = Structure.from_dict(d) if "lattice" in d \
else Molecule.from_dict(d)
return cls(structure, a["authors"], projects=a.get("projects", None),
references=a.get("references", ""),
remarks=a.get("remarks", None), data=data,
history=a.get("history", None), created_at=created_at)
示例10: apply_corrections
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def apply_corrections(self, fw_to_correct, corrections):
# Apply the corrections
spec = fw_to_correct.spec
modder = Modder()
for correction in corrections:
actions = correction['actions']
for action in actions:
if action['action_type'] == 'modify_object':
if action['object']['source'] == 'fw_spec':
myobject = spec[action['object']['key']]
else:
raise NotImplementedError('Object source "{}" not implemented in '
'CheckTask'.format(action['object']['source']))
newobj = modder.modify_object(action['action'], myobject)
spec[action['object']['key']] = newobj
elif action['action_type'] == 'modify_dict':
if action['dict']['source'] == 'fw_spec':
mydict = spec[action['dict']['key']]
else:
raise NotImplementedError('Dict source "{}" not implemented in '
'CheckTask'.format(action['dict']['source']))
modder.modify(action['action'], mydict)
else:
raise NotImplementedError('Action type "{}" not implemented in '
'CheckTask'.format(action['action_type']))
# Keep track of the corrections that have been applied
spec['SRC_check_corrections'] = corrections
# Update the task index
fws_task_index = int(fw_to_correct.spec['wf_task_index'].split('_')[-1])
new_index = fws_task_index + 1
# Update the Fireworks _queueadapter key
#TODO: in the future, see whether the FW queueadapter might be replaced by the qtk_queueadapter ?
# ... to be discussed with Anubhav, when the qtk queueadapter is in a qtk toolkit and not anymore
# in pymatgen/io/abinit
spec['_queueadapter'] = spec['qtk_queueadapter'].get_subs_dict()
queue_adapter_update = get_queue_adapter_update(qtk_queueadapter=spec['qtk_queueadapter'],
corrections=corrections)
# Get and update the task_input if needed
# TODO: make this more general ... right now, it is based on AbinitInput and thus is strongly tight
# to abinit due to abiinput, deps, ...
mytask = fw_to_correct.tasks[0]
task_class = mytask.__class__
decoder = MontyDecoder()
task_input = decoder.process_decoded(fw_to_correct.spec['_tasks'][0]['abiinput'])
initialization_info = fw_to_correct.spec['initialization_info']
deps = mytask.deps
# Create the new Setup/Run/Check fireworks
SRC_fws = createSRCFireworksOld(task_class=task_class, task_input=task_input, SRC_spec=spec,
initialization_info=initialization_info,
wf_task_index_prefix=spec['wf_task_index_prefix'],
current_task_index=new_index,
handlers=self.handlers, validators=self.validators,
deps=deps,
task_type=mytask.task_type, queue_adapter_update=queue_adapter_update)
wf = Workflow(fireworks=SRC_fws['fws'], links_dict=SRC_fws['links_dict'])
return FWAction(detours=[wf])
示例11: featurize
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def featurize(self, dict_data):
"""Convert a string to a pymatgen Composition.
Args:
dict_data (dict): A MSONable dictionary. E.g. Produced from
`pymatgen.core.structure.Structure.as_dict()`.
Returns:
(object): An object with the type specified by `dict_data`.
"""
md = MontyDecoder()
return [md.process_decoded(dict_data)]
示例12: run_task
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def run_task(self, fw_spec):
"""
Required Parameters:
dir (str path): directory containing the vasp inputs
jobs (VaspJob): Contains the cmd needed to run vasp
Optional Parameters:
custodian_params (dict **kwargs): Contains the job and the
scratch directory for a custodian run
handlers (list of custodian handlers): Defaults to empty list
"""
dec = MontyDecoder()
dir = dec.process_decoded(self['dir'])
cwd = dec.process_decoded(self['cwd'])
# Change to the directory with the vasp inputs to run custodian
os.chdir(cwd+dir)
handlers = dec.process_decoded(self.get('handlers', []))
jobs = dec.process_decoded(self['jobs'])
max_errors = dec.process_decoded(self['max_errors'])
fw_env = fw_spec.get("_fw_env", {})
cust_params = self.get("custodian_params", {})
# Get the scratch directory
if fw_env.get('scratch_root'):
cust_params['scratch_dir'] = os.path.expandvars(
fw_env['scratch_root'])
c = Custodian(handlers=handlers, jobs=jobs, max_errors=max_errors, gzipped_output=True, **cust_params)
output = c.run()
return FWAction(stored_data=output)
示例13: process_decoded
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def process_decoded(self, d):
"""
Recursive method to support decoding dicts and lists containing
pymatgen objects.
"""
if isinstance(d, dict) and "module" in d and "class" in d:
modname = d["module"]
classname = d["class"]
mod = __import__(modname, globals(), locals(), [classname], 0)
if hasattr(mod, classname):
cls_ = getattr(mod, classname)
data = {k: v for k, v in d.items() if k not in ["module", "class"]}
if hasattr(cls_, "from_dict"):
return cls_.from_dict(data)
return {self.process_decoded(k): self.process_decoded(v) for k, v in d.items()}
return MontyDecoder.process_decoded(self, d)
示例14: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, dd):
dec = MontyDecoder()
return cls(mp_symbol=dd['mp_symbol'],
name=dd['name'],
alternative_names=dd['alternative_names'],
IUPAC_symbol=dd['IUPAC_symbol'],
IUCr_symbol=dd['IUCr_symbol'],
coordination=dd['coordination'],
central_site=dd['central_site'],
points=dd['points'],
solid_angles=(dd['solid_angles'] if 'solid_angles' in dd
else [4.0 * np.pi / dd['coordination']] * dd['coordination']),
deactivate=dd['deactivate'],
faces=dd['_faces'],
edges=dd['_edges'],
algorithms=[dec.process_decoded(algo_d)
for algo_d in dd['_algorithms']] if dd['_algorithms'] is not None else None,
equivalent_indices=dd['equivalent_indices'] if 'equivalent_indices' in dd else None)
示例15: from_dict
# 需要导入模块: from monty.json import MontyDecoder [as 别名]
# 或者: from monty.json.MontyDecoder import process_decoded [as 别名]
def from_dict(cls, d):
dec = MontyDecoder()
reactants = [dec.process_decoded(e) for e in d["reactants"]]
products = [dec.process_decoded(e) for e in d["products"]]
return cls(reactants, products)