本文整理汇总了Python中AnyQt.QtGui.QStandardItemModel.columnCount方法的典型用法代码示例。如果您正苦于以下问题:Python QStandardItemModel.columnCount方法的具体用法?Python QStandardItemModel.columnCount怎么用?Python QStandardItemModel.columnCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AnyQt.QtGui.QStandardItemModel
的用法示例。
在下文中一共展示了QStandardItemModel.columnCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __on_enrichment_finished
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import columnCount [as 别名]
#.........这里部分代码省略.........
ref_fmt = "%" + str(refspaces) + "s (%.2f%%)"
def fmt_count(fmt, count, total):
return fmt % (count, 100.0 * count / (total or 1))
fmt_query_count = partial(fmt_count, query_fmt)
fmt_ref_count = partial(fmt_count, ref_fmt)
linkFont = QFont(self.annotationsChartView.viewOptions().font)
linkFont.setUnderline(True)
def item(value=None, tooltip=None, user=None):
si = QStandardItem()
if value is not None:
si.setData(value, Qt.DisplayRole)
if tooltip is not None:
si.setData(tooltip, Qt.ToolTipRole)
if user is not None:
si.setData(user, Qt.UserRole)
else:
si.setData(value, Qt.UserRole)
return si
model = QStandardItemModel()
model.setSortRole(Qt.UserRole)
model.setHorizontalHeaderLabels(
["Category", "Term", "Count", "Reference count", "p-value",
"FDR", "Enrichment"])
for i, (gset, enrich) in enumerate(results):
if len(enrich.query_mapped) == 0:
continue
nquery_mapped = len(enrich.query_mapped)
nref_mapped = len(enrich.reference_mapped)
row = [
item(", ".join(gset.hierarchy)),
item(gsname(gset), tooltip=gset.link),
item(fmt_query_count(nquery_mapped, nquery),
tooltip=nquery_mapped, user=nquery_mapped),
item(fmt_ref_count(nref_mapped, nref),
tooltip=nref_mapped, user=nref_mapped),
item(fmtp(enrich.p_value), user=enrich.p_value),
item(), # column 5, FDR, is computed in filterAnnotationsChartView
item(enrich.enrichment_score,
tooltip="%.3f" % enrich.enrichment_score,
user=enrich.enrichment_score)
]
row[0].geneset = gset
row[0].enrichment = enrich
row[1].setData(gset.link, gui.LinkRole)
row[1].setFont(linkFont)
row[1].setForeground(QColor(Qt.blue))
model.appendRow(row)
self.annotationsChartView.setModel(model)
self.annotationsChartView.selectionModel().selectionChanged.connect(
self.commit
)
if not model.rowCount():
self.warning(0, "No enriched sets found.")
else:
self.warning(0)
allnames = set(gsname(geneset)
for geneset, (count, _, _, _) in results if count)
allnames |= reduce(operator.ior,
(set(word_split(name)) for name in allnames),
set())
self.filterCompleter.setModel(None)
self.completerModel = QStringListModel(sorted(allnames))
self.filterCompleter.setModel(self.completerModel)
if results:
max_score = max((e.enrichment_score for _, e in results
if np.isfinite(e.enrichment_score)),
default=1)
self.annotationsChartView.setItemDelegateForColumn(
6, BarItemDelegate(self, scale=(0.0, max_score))
)
self.annotationsChartView.setItemDelegateForColumn(
1, gui.LinkStyledItemDelegate(self.annotationsChartView)
)
header = self.annotationsChartView.header()
for i in range(model.columnCount()):
sh = self.annotationsChartView.sizeHintForColumn(i)
sh = max(sh, header.sectionSizeHint(i))
self.annotationsChartView.setColumnWidth(i, max(min(sh, 300), 30))
# self.annotationsChartView.resizeColumnToContents(i)
self.filterAnnotationsChartView()
self.progressBarFinished()
self.setStatusMessage("")
示例2: OWTestLearners
# 需要导入模块: from AnyQt.QtGui import QStandardItemModel [as 别名]
# 或者: from AnyQt.QtGui.QStandardItemModel import columnCount [as 别名]
#.........这里部分代码省略.........
for learner, result in zip(learners, results.split_by_model()):
stats = None
if class_var.is_discrete:
scorers = classification_stats.scores
elif class_var.is_continuous:
scorers = regression_stats.scores
else:
scorers = None
if scorers:
ex = result.failed[0]
if ex:
stats = [Try.Fail(ex)] * len(scorers)
result = Try.Fail(ex)
else:
stats = [Try(lambda: score(result)) for score in scorers]
result = Try.Success(result)
key = learner_key[learner]
self.learners[key] = \
self.learners[key]._replace(results=result, stats=stats)
self.setStatusMessage("")
def _update_header(self):
# Set the correct horizontal header labels on the results_model.
headers = ["Method"]
if self.data is not None:
if self.data.domain.has_discrete_class:
headers.extend(classification_stats.headers)
else:
headers.extend(regression_stats.headers)
# remove possible extra columns from the model.
for i in reversed(range(len(headers),
self.result_model.columnCount())):
self.result_model.takeColumn(i)
self.result_model.setHorizontalHeaderLabels(headers)
def _update_stats_model(self):
# Update the results_model with up to date scores.
# Note: The target class specific scores (if requested) are
# computed as needed in this method.
model = self.view.model()
# clear the table model, but preserving the header labels
for r in reversed(range(model.rowCount())):
model.takeRow(r)
target_index = None
if self.data is not None:
class_var = self.data.domain.class_var
if self.data.domain.has_discrete_class and \
self.class_selection != self.TARGET_AVERAGE:
target_index = class_var.values.index(self.class_selection)
else:
class_var = None
errors = []
has_missing_scores = False
for key, slot in self.learners.items():
name = learner_name(slot.learner)
head = QStandardItem(name)
head.setData(key, Qt.UserRole)
if isinstance(slot.results, Try.Fail):
head.setToolTip(str(slot.results.exception))
head.setText("{} (error)".format(name))