本文整理汇总了Python中gnome.model.Model.deserialize方法的典型用法代码示例。如果您正苦于以下问题:Python Model.deserialize方法的具体用法?Python Model.deserialize怎么用?Python Model.deserialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.model.Model
的用法示例。
在下文中一共展示了Model.deserialize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_model_rt
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import deserialize [as 别名]
def test_model_rt(self, uncertain):
model = make_model(uncertain)
serial = model.serialize()
m2 = Model.deserialize(serial)
# update the dict so it gives a valid model to load
assert m2 == model
print m2
示例2: test_model_rt
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import deserialize [as 别名]
def test_model_rt(self, images_dir, uncertain):
model = make_model(images_dir, uncertain)
deserial = Model.deserialize(model.serialize('webapi'))
# update the dict so it gives a valid model to load
deserial['map'] = model.map
for coll in ['movers', 'weatherers', 'environment', 'outputters',
'spills']:
for ix, item in enumerate(deserial[coll]):
deserial[coll][ix] = getattr(model, coll)[item['id']]
m2 = Model.new_from_dict(deserial)
assert m2 == model
print m2
示例3: test_model_rt
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import deserialize [as 别名]
def test_model_rt(self, uncertain):
model = make_model(uncertain)
serial = model.serialize('webapi')
deserial = Model.deserialize(serial)
# update the dict so it gives a valid model to load
deserial['map'] = model.map
water = model.find_by_attr('_ref_as', 'water', model.environment)
deserial['water'] = water
for coll in ['movers', 'weatherers', 'environment', 'outputters',
'spills']:
for ix, item in enumerate(deserial[coll]):
deserial[coll][ix] = getattr(model, coll)[item['id']]
m2 = Model.new_from_dict(deserial)
assert m2 == model
print m2
示例4: get_json
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import deserialize [as 别名]
def get_json(mdl):
json_ = Model.deserialize(mdl.serialize('webapi'))
json_['map'] = mdl.map
return json_