本文整理汇总了Python中gnome.environment.Waves.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python Waves.serialize方法的具体用法?Python Waves.serialize怎么用?Python Waves.serialize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnome.environment.Waves
的用法示例。
在下文中一共展示了Waves.serialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_serialize_deseriailize
# 需要导入模块: from gnome.environment import Waves [as 别名]
# 或者: from gnome.environment.Waves import serialize [as 别名]
def test_serialize_deseriailize():
'test serialize/deserialize for webapi'
wind = constant_wind(1., 0)
water = Water()
w = Waves(wind, water)
json_ = w.serialize()
# deserialize and ensure the dict's are correct
w2 = Waves.deserialize(json_)
assert w2.wind == Wind.deserialize(json_['wind'])
assert w2.water == Water.deserialize(json_['water'])
assert w == w2
示例2: test_serialize_deseriailize
# 需要导入模块: from gnome.environment import Waves [as 别名]
# 或者: from gnome.environment.Waves import serialize [as 别名]
def test_serialize_deseriailize():
"test serialize/deserialize for webapi"
wind = constant_wind(1.0, 0)
water = Water()
w = Waves(wind, water)
json_ = w.serialize()
json_["wind"] = wind.serialize()
json_["water"] = water.serialize()
# deserialize and ensure the dict's are correct
d_ = Waves.deserialize(json_)
print "d_"
print d_
assert d_["wind"] == Wind.deserialize(json_["wind"])
assert d_["water"] == Water.deserialize(json_["water"])
d_["wind"] = wind
d_["water"] = water
w.update_from_dict(d_)
assert w.wind is wind
assert w.water is water