本文整理汇总了Python中dataset.DataSet.props['label']方法的典型用法代码示例。如果您正苦于以下问题:Python DataSet.props['label']方法的具体用法?Python DataSet.props['label']怎么用?Python DataSet.props['label']使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dataset.DataSet
的用法示例。
在下文中一共展示了DataSet.props['label']方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: collectXY
# 需要导入模块: from dataset import DataSet [as 别名]
# 或者: from dataset.DataSet import props['label'] [as 别名]
def collectXY(sets,x,y,foreach=[],ignoreProperties=False):
""" collects specified data from a list of DataSet objects
this function is used to collect data from a list of DataSet objects, to prepare plots or evaluation. The parameters are:
sets: the list of datasets
x: the name of the property or measurement to be used as x-value of the collected results
y: the name of the property or measurement to be used as y-value of the collected results
foreach: an optional list of properties used for grouping the results. A separate DataSet object is created for each unique set of values of the specified parameers.
ignoreProperties: setting ignoreProperties=True prevents collectXY() from collecting properties.
The function returns a list of DataSet objects.
"""
foreach_sets = {}
for iset in flatten(sets):
if iset.props['observable'] != y and not y in iset.props:
continue
fe_par_set = tuple((iset.props[m] for m in foreach))
if fe_par_set in foreach_sets:
foreach_sets[fe_par_set].append(iset)
else:
foreach_sets[fe_par_set] = [iset]
for k,v in foreach_sets.items():
common_props = dict_intersect([q.props for q in v])
res = DataSet()
res.props = common_props
for im in range(0,len(foreach)):
m = foreach[im]
res.props[m] = k[im]
res.props['xlabel'] = x
res.props['ylabel'] = y
for data in v:
if data.props['observable'] == y:
if len(data.y)>1:
res.props['line'] = '.'
xvalue = np.array([data.props[x] for i in range(len(data.y))])
if len(res.x) > 0 and len(res.y) > 0:
res.x = np.concatenate((res.x, xvalue ))
res.y = np.concatenate((res.y, data.y))
else:
res.x = xvalue
res.y = data.y
elif not ignoreProperties:
res.props['line'] = '.'
xvalue = np.array([ data.props[x] ])
if len(res.x) > 0 and len(res.y) > 0:
res.x = np.concatenate((res.x, xvalue ))
res.y = np.concatenate((res.y, np.array([ data.props[y] ])))
else:
res.x = xvalue
res.y = np.array([ data.props[y] ])
order = np.argsort(res.x, kind = 'mergesort')
res.x = res.x[order]
res.y = res.y[order]
res.props['label'] = ''
for im in range(0,len(foreach)):
res.props['label'] += '%s = %s ' % (foreach[im], k[im])
foreach_sets[k] = res
return foreach_sets.values()