我有一个PyQt4 GUI,我需要将一堆Numpy数组保存为*.tif图像.这似乎需要花费大量时间并导致我的GUI无法响应长达几分钟,具体取决于堆栈中的图像数量.
大部分处理发生在图像循环中:
for i in range(0, np.shape(dataStack)[2]):
print('Saving slice ' + str(i + 1))
#Save tumor stack
im1 = Image.fromarray(tumorStack[:,:,i]*255)
im1.save(saveLocationStr + 'Slice' + str(i+1) + '.tif')
#Set up correct number of subplots for review plot.
if T0 is not None:
plt.subplot(141)
else:
plt.subplot(131)
#Plot current brain slice in 1st position
plt.imshow(dataStack[:,:,i], cmap=mpl.cm.bone)
plt.axis('off')
plt.title(patient + '\n' + date + '\n' + 'Slice ' + str(i+1) + ' of ' + str(int(np.shape(dataStack)[2])))
#Select correct next subplot
if T0 is …Run Code Online (Sandbox Code Playgroud) 我正在使用带有嵌套 top_hits 聚合的 Elasticsearch 过滤器聚合来检索基于不同过滤器的最匹配文档,但我似乎无法通过 boosting 或嵌套的 function_score 查询更改每个存储桶中的结果分数。这是不可能的吗?我没有找到任何明确的文档说它不起作用,并且查询执行得很好,但是结果分数不受影响。
示例查询(注意第一次聚合中的巨大提升):
GET _search
{
"size":0,
"query":{
"bool":{
"should":[
{
"multi_match":{
"type":"phrase",
"query":"TV",
"fields":[
"categories^4"
]
}
}
]
}
},
"aggs":{
"1":{
"filter":{
"bool":{
"must":[
{
"multi_match":{
"type":"phrase",
"query":"Music",
"fields":[
"categories^10"
]
}
}
]
}
},
"aggs":{
"1_hits":{
"top_hits":{
"size":10,
"sort":[
{
"_score":{
"order":"desc"
}
}
]
}
}
}
},
"2":{
"filter":{
"bool":{
"must":[
{
"multi_match":{
"type":"phrase",
"query":"Music",
"fields":[
"categories"
]
}
}
]
}
},
"aggs":{
"2_hits":{
"top_hits":{ …Run Code Online (Sandbox Code Playgroud)