本文整理汇总了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