本文整理汇总了Python中gnome.model.Model.new_from_dict方法的典型用法代码示例。如果您正苦于以下问题:Python Model.new_from_dict方法的具体用法?Python Model.new_from_dict怎么用?Python Model.new_from_dict使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.model.Model
的用法示例。
在下文中一共展示了Model.new_from_dict方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_model_rt
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import new_from_dict [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
示例2: test_model_rt
# 需要导入模块: from gnome.model import Model [as 别名]
# 或者: from gnome.model.Model import new_from_dict [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