本文整理匯總了Python中diffpy.srfit.util.ordereddict.OrderedDict.copy方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedDict.copy方法的具體用法?Python OrderedDict.copy怎麽用?Python OrderedDict.copy使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類diffpy.srfit.util.ordereddict.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.copy方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_copying
# 需要導入模塊: from diffpy.srfit.util.ordereddict import OrderedDict [as 別名]
# 或者: from diffpy.srfit.util.ordereddict.OrderedDict import copy [as 別名]
def test_copying(self):
# Check that ordered dicts are copyable, deepcopyable, picklable,
# and have a repr/eval round-trip
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
od = OrderedDict(pairs)
update_test = OrderedDict()
update_test.update(od)
for i, dup in enumerate([
od.copy(),
copy.copy(od),
copy.deepcopy(od),
pickle.loads(pickle.dumps(od, 0)),
pickle.loads(pickle.dumps(od, 1)),
pickle.loads(pickle.dumps(od, 2)),
pickle.loads(pickle.dumps(od, -1)),
eval(repr(od)),
update_test,
OrderedDict(od),
]):
self.assert_(dup is not od)
self.assertEquals(dup, od)
self.assertEquals(list(dup.items()), list(od.items()))
self.assertEquals(len(dup), len(od))
self.assertEquals(type(dup), type(od))