本文整理匯總了Python中diffpy.srfit.util.ordereddict.OrderedDict.keys方法的典型用法代碼示例。如果您正苦於以下問題:Python OrderedDict.keys方法的具體用法?Python OrderedDict.keys怎麽用?Python OrderedDict.keys使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類diffpy.srfit.util.ordereddict.OrderedDict
的用法示例。
在下文中一共展示了OrderedDict.keys方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: test_iterators
# 需要導入模塊: from diffpy.srfit.util.ordereddict import OrderedDict [as 別名]
# 或者: from diffpy.srfit.util.ordereddict.OrderedDict import keys [as 別名]
def test_iterators(self):
pairs = [('c', 1), ('b', 2), ('a', 3), ('d', 4), ('e', 5), ('f', 6)]
shuffle(pairs)
od = OrderedDict(pairs)
self.assertEqual(list(od), [t[0] for t in pairs])
self.assertEqual(list(od.keys()), [t[0] for t in pairs])
self.assertEqual(list(od.values()), [t[1] for t in pairs])
self.assertEqual(list(od.items()), pairs)
self.assertEqual(list(reversed(od)),
[t[0] for t in reversed(pairs)])
示例2: FitResults
# 需要導入模塊: from diffpy.srfit.util.ordereddict import OrderedDict [as 別名]
# 或者: from diffpy.srfit.util.ordereddict.OrderedDict import keys [as 別名]
#.........這裏部分代碼省略.........
for con in self.conresults.values():
if (con.dy == 1).all():
certain = False
break
# User-defined header
if header:
lines.append(header)
if not certain:
l = "Some quantities invalid due to missing profile uncertainty"
if not l in self.messages:
self.messages.append(l)
lines.extend(self.messages)
## Overall results
l = "Overall"
if not certain:
l += " (Chi2 and Reduced Chi2 invalid)"
lines.append(l)
dashedline = 79 * '-'
lines.append(dashedline)
formatstr = "%-14s %.8f"
lines.append(formatstr%("Residual",self.residual))
lines.append(formatstr%("Contributions", self.residual - self.penalty))
lines.append(formatstr%("Restraints", self.penalty))
lines.append(formatstr%("Chi2",self.chi2))
lines.append(formatstr%("Reduced Chi2",self.rchi2))
lines.append(formatstr%("Rw",self.rw))
## Per-FitContribution results
if len(self.conresults) > 1:
keys = self.conresults.keys()
numericStringSort(keys)
lines.append("")
l = "Contributions"
if not certain:
l += " (Chi2 and Reduced Chi2 invalid)"
lines.append(l)
lines.append(dashedline)
formatstr = "%-10s %-42.8f"
for name in keys:
res = self.conresults[name]
lines.append("")
namestr = name + " (%f)"%res.weight
lines.append(namestr)
lines.append("-"*len(namestr))
lines.append(formatstr%("Residual",res.residual))
lines.append(formatstr%("Chi2",res.chi2))
lines.append(formatstr%("Rw",res.rw))
## The variables
if self.varnames:
lines.append("")
l = "Variables"
if not certain:
m = "Uncertainties invalid"
l += " (%s)"%m
lines.append(l)
lines.append(dashedline)
varnames = self.varnames
varvals = self.varvals
varunc = self.varunc