本文整理汇总了Python中Orange.widgets.utils.itemmodels.DomainModel类的典型用法代码示例。如果您正苦于以下问题:Python DomainModel类的具体用法?Python DomainModel怎么用?Python DomainModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DomainModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_read_only
def test_read_only(self):
model = DomainModel()
domain = Domain([ContinuousVariable(x) for x in "abc"])
model.set_domain(domain)
index = model.index(0, 0)
self.assertRaises(TypeError, model.append, 42)
self.assertRaises(TypeError, model.extend, [42])
self.assertRaises(TypeError, model.insert, 0, 42)
self.assertRaises(TypeError, model.remove, 0)
self.assertRaises(TypeError, model.pop)
self.assertRaises(TypeError, model.clear)
self.assertRaises(TypeError, model.reverse)
self.assertRaises(TypeError, model.sort)
with self.assertRaises(TypeError):
model[0] = 1
with self.assertRaises(TypeError):
del model[0]
self.assertFalse(model.setData(index, domain[0], Qt.EditRole))
self.assertTrue(model.setData(index, "foo", Qt.ToolTipRole))
self.assertFalse(model.setItemData(index, {Qt.EditRole: domain[0],
Qt.ToolTipRole: "foo"}))
self.assertTrue(model.setItemData(index, {Qt.ToolTipRole: "foo"}))
self.assertFalse(model.insertRows(0, 1))
self.assertSequenceEqual(model, domain)
self.assertFalse(model.removeRows(0, 1))
self.assertSequenceEqual(model, domain)
示例2: __init__
def __init__(self):
super().__init__()
self.data = None
self.discrete_data = None
self.subset_data = None
self.subset_indices = None
self.color_data = None
self.areas = []
self.canvas = QGraphicsScene()
self.canvas_view = ViewWithPress(
self.canvas, handler=self.clear_selection)
self.mainArea.layout().addWidget(self.canvas_view)
self.canvas_view.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.canvas_view.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.canvas_view.setRenderHint(QPainter.Antialiasing)
box = gui.vBox(self.controlArea, box=True)
self.model_1 = DomainModel(
order=DomainModel.MIXED, valid_types=DomainModel.PRIMITIVE)
self.model_234 = DomainModel(
order=DomainModel.MIXED, valid_types=DomainModel.PRIMITIVE,
placeholder="(None)")
self.attr_combos = [
gui.comboBox(
box, self, value="variable{}".format(i),
orientation=Qt.Horizontal, contentsLength=12,
callback=self.attr_changed,
model=self.model_1 if i == 1 else self.model_234)
for i in range(1, 5)]
self.vizrank, self.vizrank_button = MosaicVizRank.add_vizrank(
box, self, "Find Informative Mosaics", self.set_attr)
box2 = gui.vBox(self.controlArea, box="Interior Coloring")
self.color_model = DomainModel(
order=DomainModel.MIXED, valid_types=DomainModel.PRIMITIVE,
placeholder="(Pearson residuals)")
self.cb_attr_color = gui.comboBox(
box2, self, value="variable_color",
orientation=Qt.Horizontal, contentsLength=12, labelWidth=50,
callback=self.set_color_data, model=self.color_model)
self.bar_button = gui.checkBox(
box2, self, 'use_boxes', label='Compare with total',
callback=self.update_graph)
gui.rubber(self.controlArea)
示例3: __init__
def __init__(self):
super().__init__()
self.data = None
self.feature_model = DomainModel(valid_types=DiscreteVariable)
self.table = None
box = gui.vBox(self.controlArea, "Rows")
gui.comboBox(box, self, 'rows', sendSelectedValue=True,
model=self.feature_model, callback=self._attribute_changed)
box = gui.vBox(self.controlArea, "Columns")
gui.comboBox(box, self, 'columns', sendSelectedValue=True,
model=self.feature_model, callback=self._attribute_changed)
gui.rubber(self.controlArea)
box = gui.vBox(self.controlArea, "Scores")
self.scores = gui.widgetLabel(box, "\n\n")
self.apply_button = gui.auto_commit(
self.controlArea, self, "auto_apply", "&Apply", box=False)
self.tableview = ContingencyTable(self)
self.mainArea.layout().addWidget(self.tableview)
示例4: __init__
def __init__(self):
super().__init__()
self.data = None
self.cont_data = None
# GUI
box = gui.vBox(self.mainArea)
self.correlation_combo = gui.comboBox(
box, self, "correlation_type", items=CorrelationType.items(),
orientation=Qt.Horizontal, callback=self._correlation_combo_changed
)
self.feature_model = DomainModel(
order=DomainModel.ATTRIBUTES, separators=False,
placeholder="(All combinations)", valid_types=ContinuousVariable)
gui.comboBox(
box, self, "feature", callback=self._feature_combo_changed,
model=self.feature_model
)
self.vizrank, _ = CorrelationRank.add_vizrank(
None, self, None, self._vizrank_selection_changed)
self.vizrank.progressBar = self.progressBar
self.vizrank.button.setEnabled(False)
self.vizrank.threadStopped.connect(self._vizrank_stopped)
gui.separator(box)
box.layout().addWidget(self.vizrank.filter)
box.layout().addWidget(self.vizrank.rank_table)
button_box = gui.hBox(self.mainArea)
button_box.layout().addWidget(self.vizrank.button)
示例5: __init__
def __init__(self):
super().__init__()
self.data = None
box = gui.radioButtons(
self.controlArea, self, "feature_type", box="Feature names",
callback=lambda: self.apply())
button = gui.appendRadioButton(box, "Generic")
edit = gui.lineEdit(
gui.indentedBox(box, gui.checkButtonOffsetHint(button)), self,
"feature_name",
placeholderText="Type a prefix ...", toolTip="Custom feature name")
edit.editingFinished.connect(self._apply_editing)
self.meta_button = gui.appendRadioButton(box, "From meta attribute:")
self.feature_model = DomainModel(
order=DomainModel.METAS, valid_types=StringVariable,
alphabetical=True)
self.feature_combo = gui.comboBox(
gui.indentedBox(box, gui.checkButtonOffsetHint(button)), self,
"feature_names_column", callback=self._feature_combo_changed,
model=self.feature_model)
self.apply_button = gui.auto_commit(
self.controlArea, self, "auto_apply", "&Apply",
box=False, commit=self.apply)
self.apply_button.button.setAutoDefault(False)
self.set_controls()
示例6: __init__
def __init__(self):
# pylint: disable=missing-docstring
super().__init__()
self.data = self.discrete_data = None
self.attrs = []
self.input_features = None
self.areas = []
self.selection = set()
self.attr_box = gui.hBox(self.mainArea)
self.domain_model = DomainModel(valid_types=DomainModel.PRIMITIVE)
combo_args = dict(
widget=self.attr_box, master=self, contentsLength=12,
callback=self.update_attr, sendSelectedValue=True, valueType=str,
model=self.domain_model)
fixed_size = (QSizePolicy.Fixed, QSizePolicy.Fixed)
gui.comboBox(value="attr_x", **combo_args)
gui.widgetLabel(self.attr_box, "\u2715", sizePolicy=fixed_size)
gui.comboBox(value="attr_y", **combo_args)
self.vizrank, self.vizrank_button = SieveRank.add_vizrank(
self.attr_box, self, "Score Combinations", self.set_attr)
self.vizrank_button.setSizePolicy(*fixed_size)
self.canvas = QGraphicsScene()
self.canvasView = ViewWithPress(
self.canvas, self.mainArea, handler=self.reset_selection)
self.mainArea.layout().addWidget(self.canvasView)
self.canvasView.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
self.canvasView.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
示例7: __init__
def __init__(self):
super().__init__()
dbox = gui.widgetBox(self.controlArea, "Image values")
rbox = gui.radioButtons(
dbox, self, "value_type", callback=self._change_integration)
gui.appendRadioButton(rbox, "From spectra")
self.box_values_spectra = gui.indentedBox(rbox)
gui.comboBox(
self.box_values_spectra, self, "integration_method", valueType=int,
items=(a.name for a in self.integration_methods),
callback=self._change_integral_type)
gui.rubber(self.controlArea)
gui.appendRadioButton(rbox, "Use feature")
self.box_values_feature = gui.indentedBox(rbox)
self.feature_value_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES,
valid_types=DomainModel.PRIMITIVE)
self.feature_value = gui.comboBox(
self.box_values_feature, self, "attr_value",
callback=self.update_feature_value, model=self.feature_value_model,
sendSelectedValue=True, valueType=str)
splitter = QSplitter(self)
splitter.setOrientation(Qt.Vertical)
self.imageplot = ImagePlot(self)
self.imageplot.selection_changed.connect(self.output_image_selection)
self.curveplot = CurvePlotHyper(self, select=SELECTONE)
self.curveplot.selection_changed.connect(self.redraw_data)
self.curveplot.plot.vb.x_padding = 0.005 # pad view so that lines are not hidden
splitter.addWidget(self.imageplot)
splitter.addWidget(self.curveplot)
self.mainArea.layout().addWidget(splitter)
self.line1 = MovableVline(position=self.lowlim, label="", report=self.curveplot)
self.line1.sigMoved.connect(lambda v: setattr(self, "lowlim", v))
self.line2 = MovableVline(position=self.highlim, label="", report=self.curveplot)
self.line2.sigMoved.connect(lambda v: setattr(self, "highlim", v))
self.line3 = MovableVline(position=self.choose, label="", report=self.curveplot)
self.line3.sigMoved.connect(lambda v: setattr(self, "choose", v))
for line in [self.line1, self.line2, self.line3]:
line.sigMoveFinished.connect(self.changed_integral_range)
self.curveplot.add_marking(line)
line.hide()
self.data = None
self.disable_integral_range = False
self.resize(900, 700)
self._update_integration_type()
# prepare interface according to the new context
self.contextAboutToBeOpened.connect(lambda x: self.init_interface_data(x[0]))
示例8: _add_controls
def _add_controls(self):
infobox = gui.widgetBox(self.controlArea, "Info")
self.infoLabel = gui.widgetLabel(infobox, "No data on input.")
displaybox = gui.widgetBox(self.controlArea, "Display")
gui.checkBox(displaybox, self, "show_profiles", "Lines",
callback=self.__show_profiles_changed,
tooltip="Plot lines")
gui.checkBox(displaybox, self, "show_range", "Range",
callback=self.__show_range_changed,
tooltip="Plot range between 10th and 90th percentile")
gui.checkBox(displaybox, self, "show_mean", "Mean",
callback=self.__show_mean_changed,
tooltip="Plot mean curve")
gui.checkBox(displaybox, self, "show_error", "Error bars",
callback=self.__show_error_changed,
tooltip="Show standard deviation")
self.group_vars = DomainModel(
placeholder="None", separators=False, valid_types=DiscreteVariable)
self.group_view = gui.listView(
self.controlArea, self, "group_var", box="Group by",
model=self.group_vars, callback=self.__group_var_changed)
self.group_view.setEnabled(False)
self.group_view.setMinimumSize(QSize(30, 100))
self.group_view.setSizePolicy(QSizePolicy.Expanding,
QSizePolicy.Ignored)
plot_gui = OWPlotGUI(self)
plot_gui.box_zoom_select(self.controlArea)
gui.rubber(self.controlArea)
gui.auto_commit(self.controlArea, self, "auto_commit",
"Send Selection", "Send Automatically")
示例9: __init__
def __init__(self):
super().__init__()
self.dataset = None
self.attrs = DomainModel(
valid_types=Orange.data.DiscreteVariable, separators=False)
cb = gui.comboBox(
self.controlArea, self, "attribute", box=True,
model=self.attrs, callback=self.update_scene, contentsLength=12)
grid = QGridLayout()
self.legend = gui.widgetBox(gui.indentedBox(cb.box), orientation=grid)
grid.setColumnStretch(1, 1)
grid.setHorizontalSpacing(6)
self.legend_items = []
self.split_vars = DomainModel(
valid_types=Orange.data.DiscreteVariable, separators=False,
placeholder="None", )
gui.comboBox(
self.controlArea, self, "split_var", box="Split by",
model=self.split_vars, callback=self.update_scene)
gui.checkBox(
self.controlArea, self, "explode", "Explode pies", box=True,
callback=self.update_scene)
gui.rubber(self.controlArea)
gui.widgetLabel(
gui.hBox(self.controlArea, box=True),
"The aim of this widget is to\n"
"demonstrate that pie charts are\n"
"a terrible visualization. Please\n"
"don't use it for any other purpose.")
self.scene = QGraphicsScene()
self.view = QGraphicsView(self.scene)
self.view.setRenderHints(
QPainter.Antialiasing | QPainter.TextAntialiasing |
QPainter.SmoothPixmapTransform)
self.mainArea.layout().addWidget(self.view)
self.mainArea.setMinimumWidth(600)
示例10: __init__
def __init__(self):
super().__init__()
self.data = None
self.set_data(self.data) # show warning
self.group_vars = DomainModel(
placeholder="None", separators=False,
valid_types=Orange.data.DiscreteVariable)
self.group_view = gui.listView(
self.controlArea, self, "group_var", box="Group by",
model=self.group_vars, callback=self.grouping_changed)
gui.auto_commit(self.controlArea, self, "autocommit", "Apply")
示例11: __init__
def __init__(self):
super().__init__()
self.data = None # type: Optional[Table]
# Information panel
info_box = gui.vBox(self.controlArea, 'Info')
info_box.setMinimumWidth(200)
self.info_summary = gui.widgetLabel(info_box, wordWrap=True)
self.info_attr = gui.widgetLabel(info_box, wordWrap=True)
self.info_class = gui.widgetLabel(info_box, wordWrap=True)
self.info_meta = gui.widgetLabel(info_box, wordWrap=True)
self.set_info()
# TODO: Implement filtering on the model
# filter_box = gui.vBox(self.controlArea, 'Filter')
# self.filter_text = gui.lineEdit(
# filter_box, self, value='filter_string',
# placeholderText='Filter variables by name',
# callback=self._filter_table_variables, callbackOnType=True,
# )
# shortcut = QShortcut(QKeySequence('Ctrl+f'), self, self.filter_text.setFocus)
# shortcut.setWhatsThis('Filter variables by name')
self.color_var_model = DomainModel(
valid_types=(ContinuousVariable, DiscreteVariable),
placeholder='None',
)
box = gui.vBox(self.controlArea, 'Histogram')
self.cb_color_var = gui.comboBox(
box, master=self, value='color_var', model=self.color_var_model,
label='Color:', orientation=Qt.Horizontal,
)
self.cb_color_var.activated.connect(self.__color_var_changed)
gui.rubber(self.controlArea)
gui.auto_commit(
self.buttonsArea, self, 'auto_commit', 'Send Selected Rows',
'Send Automatically',
)
# Main area
self.model = FeatureStatisticsTableModel(parent=self)
self.table_view = FeatureStatisticsTableView(self.model, parent=self)
self.table_view.selectionModel().selectionChanged.connect(self.on_select)
self.table_view.horizontalHeader().sectionClicked.connect(self.on_header_click)
self.mainArea.layout().addWidget(self.table_view)
示例12: _add_controls_axis
def _add_controls_axis(self):
common_options = dict(
labelWidth=50, orientation=Qt.Horizontal, sendSelectedValue=True,
valueType=str, contentsLength=14
)
box = gui.vBox(self.controlArea, True)
dmod = DomainModel
self.xy_model = DomainModel(dmod.MIXED, valid_types=ContinuousVariable)
self.cb_attr_x = gui.comboBox(
box, self, "attr_x", label="Axis x:",
callback=self.set_attr_from_combo,
model=self.xy_model, **common_options)
self.cb_attr_y = gui.comboBox(
box, self, "attr_y", label="Axis y:",
callback=self.set_attr_from_combo,
model=self.xy_model, **common_options)
vizrank_box = gui.hBox(box)
self.vizrank, self.vizrank_button = ScatterPlotVizRank.add_vizrank(
vizrank_box, self, "Find Informative Projections", self.set_attr)
示例13: __init__
def __init__(self):
super().__init__()
# TODO: add input box for selecting which should be the reference frame
box = gui.widgetBox(self.controlArea, "Axes")
common_options = dict(
labelWidth=50, orientation=Qt.Horizontal, sendSelectedValue=True,
valueType=str)
self.xy_model = DomainModel(DomainModel.METAS | DomainModel.CLASSES,
valid_types=ContinuousVariable)
self.cb_attr_x = gui.comboBox(
box, self, "attr_x", label="Axis x:", callback=self._update_attr,
model=self.xy_model, **common_options)
self.cb_attr_y = gui.comboBox(
box, self, "attr_y", label="Axis y:", callback=self._update_attr,
model=self.xy_model, **common_options)
self.contextAboutToBeOpened.connect(self._init_interface_data)
box = gui.widgetBox(self.controlArea, "Parameters")
gui.checkBox(box, self, "sobel_filter",
label="Use sobel filter",
callback=self._sobel_changed)
gui.separator(box)
hbox = gui.hBox(box)
self.le1 = lineEditIntRange(box, self, "ref_frame_num", bottom=1, default=1,
callback=self._ref_frame_changed)
hbox.layout().addWidget(QLabel("Reference frame:", self))
hbox.layout().addWidget(self.le1)
gui.rubber(self.controlArea)
plot_box = gui.widgetBox(self.mainArea, "Shift curves")
self.plotview = pg.PlotWidget(background="w")
plot_box.layout().addWidget(self.plotview)
# TODO: resize widget to make it a bit smaller
self.data = None
gui.auto_commit(self.controlArea, self, "autocommit", "Send Data")
示例14: __init__
def __init__(self):
super().__init__()
self.data = None
# GUI
box = gui.vBox(self.controlArea, "Feature names")
self.feature_radio = gui.radioButtonsInBox(
box, self, "feature_type", callback=lambda: self.apply(), btnLabels=["Generic", "From meta attribute:"]
)
self.feature_model = DomainModel(order=DomainModel.METAS, valid_types=StringVariable, alphabetical=True)
self.feature_combo = gui.comboBox(
gui.indentedBox(box, gui.checkButtonOffsetHint(self.feature_radio.buttons[0])),
self,
"feature_names_column",
callback=self._feature_combo_changed,
model=self.feature_model,
)
self.apply_button = gui.auto_commit(
self.controlArea, self, "auto_apply", "&Apply", box=False, commit=self.apply
)
示例15: test_no_separators
def test_no_separators(self):
"""
GH-2697
"""
attrs = [ContinuousVariable(n) for n in "abg"]
classes = [ContinuousVariable(n) for n in "deh"]
metas = [ContinuousVariable(n) for n in "ijf"]
model = DomainModel(order=DomainModel.SEPARATED, separators=False)
model.set_domain(Domain(attrs, classes, metas))
self.assertEqual(list(model), classes + metas + attrs)
model = DomainModel(order=DomainModel.SEPARATED, separators=True)
model.set_domain(Domain(attrs, classes, metas))
self.assertEqual(
list(model),
classes + [PyListModel.Separator] + metas + [PyListModel.Separator] + attrs)