• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python json.MontyDecoder类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中monty.json.MontyDecoder的典型用法代码示例。如果您正苦于以下问题:Python MontyDecoder类的具体用法?Python MontyDecoder怎么用?Python MontyDecoder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了MontyDecoder类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: from_dict

 def from_dict(cls, d):
     d = d.copy()
     d.pop('@module', None)
     d.pop('@class', None)
     dec = MontyDecoder()
     d['kpts'] = dec.process_decoded(d['kpts'])
     return cls(**d)
开发者ID:Lightslayer,项目名称:pymatgen,代码行数:7,代码来源:abiobjects.py


示例2: from_dict

 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)
开发者ID:bocklund,项目名称:pymatgen,代码行数:7,代码来源:computed_entries.py


示例3: from_dict

 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"]),
     )
开发者ID:anhhv,项目名称:pymatgen,代码行数:7,代码来源:conversion_battery.py


示例4: apply_corrections

    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])
开发者ID:davidwaroquiers,项目名称:abiflows,代码行数:59,代码来源:utility_tasks.py


示例5: from_dict

    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'])
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:9,代码来源:strategies.py


示例6: from_dict

 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))
开发者ID:ExpHP,项目名称:pymatgen,代码行数:9,代码来源:computed_entries.py


示例7: from_dict

    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'])
开发者ID:ychaojia,项目名称:pymatgen,代码行数:11,代码来源:strategies.py


示例8: featurize

    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)]
开发者ID:ardunn,项目名称:MatMiner,代码行数:12,代码来源:conversions.py


示例9: from_dict

 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'])
开发者ID:gpetretto,项目名称:abiflows,代码行数:12,代码来源:mastermind_abc.py


示例10: from_dict

 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)
开发者ID:matk86,项目名称:pymatgen,代码行数:12,代码来源:conversion_battery.py


示例11: from_dict

    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)
开发者ID:ExpHP,项目名称:pymatgen,代码行数:15,代码来源:provenance.py


示例12: test_entry

    def test_entry(self):
        enc = MontyEncoder()
        dec = MontyDecoder()

        entry = ComputedEntry("Fe2O3", 2.3)
        jsonstr = enc.encode(entry)
        d = dec.decode(jsonstr)
        self.assertEqual(type(d), ComputedEntry)

        #Check list of entries
        entries = [entry, entry, entry]
        jsonstr = enc.encode(entries)
        d = dec.decode(jsonstr)
        for i in d:
            self.assertEqual(type(i), ComputedEntry)
        self.assertEqual(len(d), 3)
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:16,代码来源:test_json_coders.py


示例13: from_dict

 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)
开发者ID:WeiLiPenguin,项目名称:pymatgen,代码行数:18,代码来源:coordination_geometries.py


示例14: run_task

    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)
开发者ID:aykol,项目名称:MPWorks,代码行数:36,代码来源:surface_tasks.py


示例15: process_decoded

 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)
开发者ID:sonium0,项目名称:pymatgen,代码行数:16,代码来源:rest.py


示例16: from_dict

 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)
开发者ID:ATNDiaye,项目名称:pymatgen,代码行数:5,代码来源:reaction_calculator.py


示例17: from_dict

 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(*dec.process_decoded(d['args']), **dec.process_decoded(d['kwargs']))
开发者ID:akakcolin,项目名称:abipy,代码行数:3,代码来源:factories.py


示例18: from_dict

 def from_dict(cls, d):
     dec = MontyDecoder()
     kwargs = {k: dec.process_decoded(v) for k, v in d.items()
               if k in inspect.getargspec(cls.__init__).args}
     return cls(**kwargs)
开发者ID:gmrigna,项目名称:abipy,代码行数:5,代码来源:fw_tasks_old.py


示例19: from_dict

 def from_dict(cls, m_dict):
     m = MontyDecoder()
     return cls(handlers=m.process_decoded(m_dict['handlers']), validators=m.process_decoded(m_dict['validators'])
                , max_restarts=m_dict['max_restarts'])
开发者ID:davidwaroquiers,项目名称:abiflows,代码行数:4,代码来源:utility_tasks.py


示例20: from_dict

 def from_dict(cls, d):
     dec = MontyDecoder()
     return cls(inverse_power=d['inverse_power'], weights_setup=dec.process_decoded(d['weights_setup']))
开发者ID:davidwaroquiers,项目名称:abiflows,代码行数:3,代码来源:convergence.py



注:本文中的monty.json.MontyDecoder类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python os.cd函数代码示例发布时间:2022-05-27
下一篇:
Python io.zopen函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap