{
    "file_diffs": [
        {
            "old_file_content": "import sys\nimport itertools\nimport warnings\nfrom typing import Callable\nfrom xml.sax.saxutils import escape\nfrom datetime import datetime, timezone\n\nimport numpy as np\nfrom AnyQt.QtCore import Qt, QRectF, QSize, QTimer, pyqtSignal as Signal, \\\n    QObject, QEvent\nfrom AnyQt.QtGui import QColor, QPen, QBrush, QPainterPath, QTransform, \\\n    QPainter, QPalette\nfrom AnyQt.QtWidgets import QApplication, QToolTip, QGraphicsTextItem, \\\n    QGraphicsRectItem, QGraphicsItemGroup\n\nimport pyqtgraph as pg\nfrom pyqtgraph.graphicsItems.ScatterPlotItem import Symbols\nfrom pyqtgraph.graphicsItems.LegendItem import LegendItem as PgLegendItem\nfrom pyqtgraph.graphicsItems.TextItem import TextItem\n\nfrom Orange.preprocess.discretize import _time_binnings\nfrom Orange.util import utc_from_timestamp\nfrom Orange.widgets import gui\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils import classdensity, colorpalettes\nfrom Orange.widgets.visualize.utils.customizableplot import Updater, \\\n    CommonParameterSetter\nfrom Orange.widgets.visualize.utils.plotutils import (\n    HelpEventDelegate as EventDelegate, InteractiveViewBox as ViewBox,\n    PaletteItemSample, SymbolItemSample, AxisItem, PlotWidget, DiscretizedScale\n)\n\nSELECTION_WIDTH = 5\nMAX_N_VALID_SIZE_ANIMATE = 1000\n\n# maximum number of colors (including Other)\nMAX_COLORS = 11\n\n\nclass LegendItem(PgLegendItem):\n    def __init__(\n            self, size=None, offset=None, pen=None, brush=None,\n    ):\n        super().__init__(size, offset)\n\n        self.layout.setContentsMargins(5, 5, 5, 5)\n        self.layout.setHorizontalSpacing(15)\n        self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)\n        if pen is not None:\n            pen = QPen(pen)\n        if brush is not None:\n            brush = QBrush(brush)\n        self.__pen = pen\n        self.__brush = brush\n\n    def restoreAnchor(self, anchors):\n        \"\"\"\n        Restore (parent) relative position from stored anchors.\n\n        The restored position is within the parent bounds.\n        \"\"\"\n        anchor, parentanchor = anchors\n        self.anchor(*bound_anchor_pos(anchor, parentanchor))\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, _option, _widget=None):\n        painter.setPen(self.pen())\n        painter.setBrush(self.brush())\n        rect = self.contentsRect()\n        painter.drawRoundedRect(rect, 2, 2)\n\n    def addItem(self, item, name):\n        super().addItem(item, name)\n        # Fix-up the label alignment, and color\n        color = self.palette().color(QPalette.Text)\n        _, label = self.items[-1]\n        label.setText(name, justify=\"left\", color=color)\n\n    def clear(self):\n        \"\"\"\n        Clear all legend items.\n        \"\"\"\n        items = list(self.items)\n        self.items = []\n        for sample, label in items:\n            self.layout.removeItem(sample)\n            self.layout.removeItem(label)\n            sample.hide()\n            label.hide()\n\n        self.updateSize()\n\n    def pen(self):\n        if self.__pen is not None:\n            return QPen(self.__pen)\n        else:\n            color = self.palette().color(QPalette.Disabled, QPalette.Text)\n            color.setAlpha(100)\n            pen = QPen(color, 1)\n            pen.setCosmetic(True)\n            return pen\n\n    def brush(self):\n        if self.__brush is not None:\n            return QBrush(self.__brush)\n        else:\n            color = self.palette().color(QPalette.Window)\n            color.setAlpha(150)\n            return QBrush(color)\n\n    def changeEvent(self, event: QEvent):\n        if event.type() == QEvent.PaletteChange:\n            color = self.palette().color(QPalette.Text)\n            for _, label in self.items:\n                label.setText(label.text, color=color)\n        super().changeEvent(event)\n\n\ndef bound_anchor_pos(corner, parentpos):\n    corner = np.clip(corner, 0, 1)\n    parentpos = np.clip(parentpos, 0, 1)\n\n    irx, iry = corner\n    prx, pry = parentpos\n\n    if irx > 0.9 and prx < 0.1:\n        irx = prx = 0.0\n    if iry > 0.9 and pry < 0.1:\n        iry = pry = 0.0\n    if irx < 0.1 and prx > 0.9:\n        irx = prx = 1.0\n    if iry < 0.1 and pry > 0.9:\n        iry = pry = 1.0\n    return (irx, iry), (prx, pry)\n\n\nclass ScatterPlotItem(pg.ScatterPlotItem):\n    \"\"\"\n    Modifies the behaviour of ScatterPlotItem as follows:\n\n    - Add z-index. ScatterPlotItem paints points in order of appearance in\n      self.data. Plotting by z-index is achieved by sorting before calling\n      super().paint() and re-sorting afterwards. Re-sorting (instead of\n      storing the original data) is needed because the inherited paint\n      may modify the data.\n\n    - Prevent multiple calls to updateSpots. ScatterPlotItem calls updateSpots\n      at any change of sizes/colors/symbols, which then rebuilds the stored\n      pixmaps for each symbol. Orange calls set* functions in succession,\n      so we postpone updateSpots() to paint().\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._update_spots_in_paint = False\n        self._z_mapping = None\n        self._inv_mapping = None\n\n    def setZ(self, z):\n        \"\"\"\n        Set z values for all points.\n\n        Points with higher values are plotted on top of those with lower.\n\n        Args:\n            z (np.ndarray or None): a vector of z values\n        \"\"\"\n        if z is None:\n            self._z_mapping = self._inv_mapping = None\n        else:\n            assert len(z) == len(self.data)\n            self._z_mapping = np.argsort(z)\n            self._inv_mapping = np.argsort(self._z_mapping)\n\n    def setCoordinates(self, x, y):\n        \"\"\"\n        Change the coordinates of points while keeping other properties.\n\n        Asserts that the number of points stays the same.\n\n        Note. Pyqtgraph does not offer a method for this: setting coordinates\n        invalidates other data. We therefore retrieve the data to set it\n        together with the coordinates. Pyqtgraph also does not offer a\n        (documented) method for retrieving the data, yet using\n        data[prop]` looks reasonably safe.\n\n        The alternative, updating the whole scatterplot from the Orange Table,\n        is too slow.\n        \"\"\"\n        assert len(self.data) == len(x) == len(y)\n        data = dict(x=x, y=y)\n        for prop in ('pen', 'brush', 'size', 'symbol', 'data'):\n            data[prop] = self.data[prop]\n        self.setData(**data)\n\n    def updateSpots(self, dataSet=None):  # pylint: disable=unused-argument\n        self._update_spots_in_paint = True\n        self.update()\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, option, widget=None):\n        try:\n            if self._z_mapping is not None:\n                assert len(self._z_mapping) == len(self.data)\n                self.data = self.data[self._z_mapping]\n            if self._update_spots_in_paint:\n                self._update_spots_in_paint = False\n                super().updateSpots()\n            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)\n            super().paint(painter, option, widget)\n        finally:\n            if self._inv_mapping is not None:\n                self.data = self.data[self._inv_mapping]\n\n\ndef _define_symbols():\n    \"\"\"\n    Add symbol ? to ScatterPlotItemSymbols,\n    reflect the triangle to point upwards\n    \"\"\"\n    path = QPainterPath()\n    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))\n    path.moveTo(-0.5, 0.5)\n    path.lineTo(0.5, -0.5)\n    path.moveTo(-0.5, -0.5)\n    path.lineTo(0.5, 0.5)\n    Symbols[\"?\"] = path\n\n    path = QPainterPath()\n    plusCoords = [\n        (-0.5, -0.1), (-0.5, 0.1), (-0.1, 0.1), (-0.1, 0.5),\n        (0.1, 0.5), (0.1, 0.1), (0.5, 0.1), (0.5, -0.1),\n        (0.1, -0.1), (0.1, -0.5), (-0.1, -0.5), (-0.1, -0.1)\n    ]\n    path.moveTo(*plusCoords[0])\n    for x, y in plusCoords[1:]:\n        path.lineTo(x, y)\n    path.closeSubpath()\n    Symbols[\"+\"] = path\n\n    tr = QTransform()\n    tr.rotate(180)\n    Symbols['t'] = tr.map(Symbols['t'])\n\n    tr = QTransform()\n    tr.rotate(45)\n    Symbols['x'] = tr.map(Symbols[\"+\"])\n\n\n_define_symbols()\n\n\ndef _make_pen(color, width):\n    p = QPen(color, width)\n    p.setCosmetic(True)\n    return p\n\n\nclass AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]\n\n\nclass ScatterBaseParameterSetter(CommonParameterSetter):\n    CAT_LEGEND_LABEL = \"Categorical legend\"\n    NUM_LEGEND_LABEL = \"Numerical legend\"\n    NUM_LEGEND_SETTING = {\n        Updater.SIZE_LABEL: (range(4, 50), 11),\n        Updater.IS_ITALIC_LABEL: (None, False),\n    }\n\n    def __init__(self, master):\n        super().__init__()\n        self.master = master\n        self.cat_legend_settings = {}\n        self.num_legend_settings = {}\n\n    def update_setters(self):\n        self.initial_settings = {\n            self.LABELS_BOX: {\n                self.FONT_FAMILY_LABEL: self.FONT_FAMILY_SETTING,\n                self.TITLE_LABEL: self.FONT_SETTING,\n                self.LABEL_LABEL: self.FONT_SETTING,\n                self.CAT_LEGEND_LABEL: self.FONT_SETTING,\n                self.NUM_LEGEND_LABEL: self.NUM_LEGEND_SETTING,\n            },\n            self.ANNOT_BOX: {\n                self.TITLE_LABEL: {self.TITLE_LABEL: (\"\", \"\")},\n            }\n        }\n\n        def update_cat_legend(**settings):\n            self.cat_legend_settings.update(**settings)\n            Updater.update_legend_font(self.cat_legend_items, **settings)\n\n        def update_num_legend(**settings):\n            self.num_legend_settings.update(**settings)\n            Updater.update_num_legend_font(self.num_legend, **settings)\n\n        labels = self.LABELS_BOX\n        self._setters[labels][self.CAT_LEGEND_LABEL] = update_cat_legend\n        self._setters[labels][self.NUM_LEGEND_LABEL] = update_num_legend\n\n    @property\n    def title_item(self):\n        return self.master.plot_widget.getPlotItem().titleLabel\n\n    @property\n    def cat_legend_items(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            items = []\n        return itertools.chain(self.master.shape_legend.items, items)\n\n    @property\n    def num_legend(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            return self.master.color_legend\n        return None\n\n    @property\n    def labels(self):\n        return self.master.labels\n\n\nclass OWScatterPlotBase(gui.OWComponent, QObject):\n    \"\"\"\n    Provide a graph component for widgets that show any kind of point plot\n\n    The component plots a set of points with given coordinates, shapes,\n    sizes and colors. Its function is similar to that of a *view*, whereas\n    the widget represents a *model* and a *controler*.\n\n    The model (widget) needs to provide methods:\n\n    - `get_coordinates_data`, `get_size_data`, `get_color_data`,\n      `get_shape_data`, `get_label_data`, which return a 1d array (or two\n      arrays, for `get_coordinates_data`) of `dtype` `float64`, except for\n      `get_label_data`, which returns formatted labels;\n    - `get_shape_labels` returns a list of strings for shape legend\n    - `get_color_labels` returns strings for color legend, or a function for\n       formatting numbers if the legend is continuous, or None for default\n       formatting\n    - `get_tooltip`, which gives a tooltip for a single data point\n    - (optional) `impute_sizes`, `impute_shapes` get final coordinates and\n      shapes, and replace nans;\n    - `get_subset_mask` returns a bool array indicating whether a\n      data point is in the subset or not (e.g. in the 'Data Subset' signal\n      in the Scatter plot and similar widgets);\n    - `get_palette` returns a palette appropriate for visualizing the\n      current color data;\n    - `is_continuous_color` decides the type of the color legend;\n\n    The widget (in a role of controller) must also provide methods\n    - `selection_changed`\n\n    If `get_coordinates_data` returns `(None, None)`, the plot is cleared. If\n    `get_size_data`, `get_color_data` or `get_shape_data` return `None`,\n    all points will have the same size, color or shape, respectively.\n    If `get_label_data` returns `None`, there are no labels.\n\n    The view (this compomnent) provides methods `update_coordinates`,\n    `update_sizes`, `update_colors`, `update_shapes` and `update_labels`\n    that the widget (in a role of a controler) should call when any of\n    these properties are changed. If the widget calls, for instance, the\n    plot's `update_colors`, the plot will react by calling the widget's\n    `get_color_data` as well as the widget's methods needed to construct the\n    legend.\n\n    The view also provides a method `reset_graph`, which should be called only\n    when\n    - the widget gets entirely new data\n    - the number of points may have changed, for instance when selecting\n    a different attribute for x or y in the scatter plot, where the points\n    with missing x or y coordinates are hidden.\n\n    Every `update_something` calls the plot's `get_something`, which\n    calls the model's `get_something_data`, then it transforms this data\n    into whatever is needed (colors, shapes, scaled sizes) and changes the\n    plot. For the simplest example, here is `update_shapes`:\n\n    ```\n        def update_shapes(self):\n            if self.scatterplot_item:\n                shape_data = self.get_shapes()\n                self.scatterplot_item.setSymbol(shape_data)\n            self.update_legends()\n\n        def get_shapes(self):\n            shape_data = self.master.get_shape_data()\n            shape_data = self.master.impute_shapes(\n                shape_data, len(self.CurveSymbols) - 1)\n            return self.CurveSymbols[shape_data]\n    ```\n\n    On the widget's side, `get_something_data` is essentially just:\n\n    ```\n        def get_size_data(self):\n            return self.get_column(self.attr_size)\n    ```\n\n    where `get_column` retrieves a column while also filtering out the\n    points with missing x and y and so forth. (Here we present the simplest\n    two cases, \"shapes\" for the view and \"sizes\" for the model. The colors\n    for the view are more complicated since they deal with discrete and\n    continuous palettes, and the shapes for the view merge infrequent shapes.)\n\n    The plot can also show just a random sample of the data. The sample size is\n    set by `set_sample_size`, and the rest is taken care by the plot: the\n    widget keeps providing the data for all points, selection indices refer\n    to the entire set etc. Internally, sampling happens as early as possible\n    (in methods `get_<something>`).\n    \"\"\"\n    too_many_labels = Signal(bool)\n    begin_resizing = Signal()\n    step_resizing = Signal()\n    end_resizing = Signal()\n\n    label_only_selected = Setting(False)\n    point_width = Setting(10)\n    alpha_value = Setting(128)\n    show_grid = Setting(False)\n    show_legend = Setting(True)\n    class_density = Setting(False)\n    jitter_size = Setting(0)\n\n    resolution = 256\n\n    CurveSymbols = np.array(\"o x t + d star ?\".split())\n    MinShapeSize = 6\n    DarkerValue = 120\n    UnknownColor = (168, 50, 168)\n\n    COLOR_DEFAULT = (128, 128, 128)\n\n    MAX_VISIBLE_LABELS = 500\n\n    def __init__(self, scatter_widget, parent=None, view_box=ViewBox):\n        QObject.__init__(self)\n        gui.OWComponent.__init__(self, scatter_widget)\n\n        self.subset_is_shown = False\n        self.jittering_suspended = False\n\n        self.view_box = view_box(self)\n        _axis = {\"left\": AxisItem(\"left\"), \"bottom\": AxisItem(\"bottom\")}\n        self.plot_widget = PlotWidget(\n            viewBox=self.view_box, parent=parent, background=None,\n            axisItems=_axis\n        )\n        self.plot_widget.hideAxis(\"left\")\n        self.plot_widget.hideAxis(\"bottom\")\n        self.plot_widget.getPlotItem().buttonsHidden = True\n        self.plot_widget.setAntialiasing(True)\n        self.plot_widget.sizeHint = lambda: QSize(500, 500)\n\n        self.density_img = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n\n        self.master = scatter_widget\n        tooltip = self._create_drag_tooltip()\n        self.view_box.setDragTooltip(tooltip)\n\n        self.selection = None  # np.ndarray\n\n        self.n_valid = 0\n        self.n_shown = 0\n        self.sample_size = None\n        self.sample_indices = None\n\n        self.palette = None\n\n        self.shape_legend = self._create_legend(((1, 0), (1, 0)))\n        self.color_legend = self._create_legend(((1, 1), (1, 1)))\n        self.update_legend_visibility()\n\n        self.scale = None  # DiscretizedScale\n        self._too_many_labels = False\n\n        # self.setMouseTracking(True)\n        # self.grabGesture(QPinchGesture)\n        # self.grabGesture(QPanGesture)\n\n        self.update_grid_visibility()\n\n        self._tooltip_delegate = EventDelegate(self.help_event)\n        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)\n        self.view_box.sigTransformChanged.connect(self.update_density)\n        self.view_box.sigRangeChangedManually.connect(self.update_labels)\n\n        self.timer = None\n\n        self.parameter_setter = ScatterBaseParameterSetter(self)\n\n    def _create_legend(self, anchor):\n        legend = LegendItem()\n        legend.setParentItem(self.plot_widget.getViewBox())\n        legend.restoreAnchor(anchor)\n        return legend\n\n    def _create_drag_tooltip(self):\n        tip_parts = [\n            (Qt.ControlModifier,\n             \"{}: Append to group\".\n             format(\"Cmd\" if sys.platform == \"darwin\" else \"Ctrl\")),\n            (Qt.ShiftModifier, \"Shift: Add group\"),\n            (Qt.AltModifier, \"Alt: Remove\")\n        ]\n        all_parts = \"<center>\" + \\\n                    \", \".join(part for _, part in tip_parts) + \\\n                    \"</center>\"\n        self.tiptexts = {\n            modifier: all_parts.replace(part, \"<b>{}</b>\".format(part))\n            for modifier, part in tip_parts\n        }\n        self.tiptexts[Qt.NoModifier] = all_parts\n\n        self.tip_textitem = text = QGraphicsTextItem()\n        # Set to the longest text\n        text.setHtml(self.tiptexts[Qt.ControlModifier])\n        text.setPos(4, 2)\n        r = text.boundingRect()\n        text.setTextWidth(r.width())\n        rect = QGraphicsRectItem(0, 0, r.width() + 8, r.height() + 4)\n        color = self.plot_widget.palette().color(QPalette.Disabled, QPalette.Window)\n        color.setAlpha(212)\n        rect.setBrush(color)\n        rect.setPen(QPen(Qt.NoPen))\n        self.update_tooltip()\n\n        tooltip_group = QGraphicsItemGroup()\n        tooltip_group.addToGroup(rect)\n        tooltip_group.addToGroup(text)\n        return tooltip_group\n\n    def update_tooltip(self, modifiers=Qt.NoModifier):\n        text = self.tiptexts[Qt.NoModifier]\n        for mod in [Qt.ControlModifier,\n                    Qt.ShiftModifier,\n                    Qt.AltModifier]:\n            if modifiers & mod:\n                text = self.tiptexts.get(mod)\n                break\n        self.tip_textitem.setHtml(text)\n\n    def suspend_jittering(self):\n        if self.jittering_suspended:\n            return\n        self.jittering_suspended = True\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def unsuspend_jittering(self):\n        if not self.jittering_suspended:\n            return\n        self.jittering_suspended = False\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def update_jittering(self):\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0 or self.scatterplot_item is None:\n            return\n        self.scatterplot_item.setCoordinates(x, y)\n        self.scatterplot_item_sel.setCoordinates(x, y)\n        self.update_labels()\n\n    # TODO: Rename to remove_plot_items\n    def clear(self):\n        \"\"\"\n        Remove all graphical elements from the plot\n\n        Calls the pyqtgraph's plot widget's clear, sets all handles to `None`,\n        removes labels and selections.\n\n        This method should generally not be called by the widget. If the data\n        is gone (*e.g.* upon receiving `None` as an input data signal), this\n        should be handler by calling `reset_graph`, which will in turn call\n        `clear`.\n\n        Derived classes should override this method if they add more graphical\n        elements. For instance, the regression line in the scatterplot adds\n        `self.reg_line_item = None` (the line in the plot is already removed\n        in this method).\n        \"\"\"\n        self.plot_widget.clear()\n\n        self.density_img = None\n        if self.timer is not None and self.timer.isActive():\n            self.timer.stop()\n            self.timer = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n        self._signal_too_many_labels(False)\n        self.view_box.init_history()\n        self.view_box.tag_history()\n\n    # TODO: I hate `keep_something` and `reset_something` arguments\n    # __keep_selection is used exclusively be set_sample size which would\n    # otherwise just repeat the code from reset_graph except for resetting\n    # the selection. I'm uncomfortable with this; we may prefer to have a\n    # method _reset_graph which does everything except resetting the selection,\n    # and reset_graph would call it.\n    def reset_graph(self, __keep_selection=False):\n        \"\"\"\n        Reset the graph to new data (or no data)\n\n        The method must be called when the plot receives new data, in\n        particular when the number of points change. If only their properties\n        - like coordinates or shapes - change, an update method\n        (`update_coordinates`, `update_shapes`...) should be called instead.\n\n        The method must also be called when the data is gone.\n\n        The method calls `clear`, followed by calls of all update methods.\n\n        NB. Argument `__keep_selection` is for internal use only\n        \"\"\"\n        self.clear()\n        if not __keep_selection:\n            self.selection = None\n        self.sample_indices = None\n        self.update_coordinates()\n        self.update_point_props()\n\n    def set_sample_size(self, sample_size):\n        \"\"\"\n        Set the sample size\n\n        Args:\n            sample_size (int or None): sample size or `None` to show all points\n        \"\"\"\n        if self.sample_size != sample_size:\n            self.sample_size = sample_size\n            self.reset_graph(True)\n\n    def update_point_props(self):\n        \"\"\"\n        Update the sizes, colors, shapes and labels\n\n        The method calls the appropriate update methods for individual\n        properties.\n        \"\"\"\n        self.update_sizes()\n        self.update_colors()\n        self.update_selection_colors()\n        self.update_shapes()\n        self.update_labels()\n\n    # Coordinates\n    # TODO: It could be nice if this method was run on entire data, not just\n    # a sample. For this, however, it would need to either be called from\n    # `get_coordinates` before sampling (very ugly) or call\n    # `self.master.get_coordinates_data` (beyond ugly) or the widget would\n    # have to store the ranges of unsampled data (ugly).\n    # Maybe we leave it as it is.\n    def _reset_view(self, x_data, y_data):\n        \"\"\"\n        Set the range of the view box\n\n        Args:\n            x_data (np.ndarray): x coordinates\n            y_data (np.ndarray) y coordinates\n        \"\"\"\n        min_x, max_x = np.min(x_data), np.max(x_data)\n        min_y, max_y = np.min(y_data), np.max(y_data)\n        self.view_box.setRange(\n            QRectF(min_x, min_y, max_x - min_x or 1, max_y - min_y or 1),\n            padding=0.025)\n\n    def _filter_visible(self, data):\n        \"\"\"Return the sample from the data using the stored sample_indices\"\"\"\n        if data is None or self.sample_indices is None:\n            return data\n        else:\n            return np.asarray(data[self.sample_indices])\n\n    def get_coordinates(self):\n        \"\"\"\n        Prepare coordinates of the points in the plot\n\n        The method is called by `update_coordinates`. It gets the coordinates\n        from the widget, jitters them and return them.\n\n        The methods also initializes the sample indices if neededd and stores\n        the original and sampled number of points.\n\n        Returns:\n            (tuple): a pair of numpy arrays containing (sampled) coordinates,\n                or `(None, None)`.\n        \"\"\"\n        x, y = self.master.get_coordinates_data()\n        if x is None:\n            self.n_valid = self.n_shown = 0\n            return None, None\n        self.n_valid = len(x)\n        self._create_sample()\n        x = self._filter_visible(x)\n        y = self._filter_visible(y)\n        # Jittering after sampling is OK if widgets do not change the sample\n        # semi-permanently, e.g. take a sample for the duration of some\n        # animation. If the sample size changes dynamically (like by adding\n        # a \"sample size\" slider), points would move around when the sample\n        # size changes. To prevent this, jittering should be done before\n        # sampling (i.e. two lines earlier). This would slow it down somewhat.\n        x, y = self.jitter_coordinates(x, y)\n        return x, y\n\n    def _create_sample(self):\n        \"\"\"\n        Create a random sample if the data is larger than the set sample size\n        \"\"\"\n        self.n_shown = min(self.n_valid, self.sample_size or self.n_valid)\n        if self.sample_size is not None \\\n                and self.sample_indices is None \\\n                and self.n_valid != self.n_shown:\n            random = np.random.RandomState(seed=0)\n            self.sample_indices = random.choice(\n                self.n_valid, self.n_shown, replace=False)\n            # TODO: Is this really needed?\n            np.sort(self.sample_indices)\n\n    def jitter_coordinates(self, x, y):\n        \"\"\"\n        Display coordinates to random positions within ellipses with\n        radiuses of `self.jittter_size` percents of spans\n        \"\"\"\n        if self.jitter_size == 0 or self.jittering_suspended:\n            return x, y\n        return self._jitter_data(x, y)\n\n    def _jitter_data(self, x, y, span_x=None, span_y=None):\n        if span_x is None:\n            span_x = np.max(x) - np.min(x)\n        if span_y is None:\n            span_y = np.max(y) - np.min(y)\n        random = np.random.RandomState(seed=0)\n        rs = random.uniform(0, 1, len(x))\n        phis = random.uniform(0, 2 * np.pi, len(x))\n        magnitude = self.jitter_size / 100\n        return (x + magnitude * span_x * rs * np.cos(phis),\n                y + magnitude * span_y * rs * np.sin(phis))\n\n    def update_coordinates(self):\n        \"\"\"\n        Trigger the update of coordinates while keeping other features intact.\n\n        The method gets the coordinates by calling `self.get_coordinates`,\n        which in turn calls the widget's `get_coordinate_data`. The number of\n        coordinate pairs returned by the latter must match the current number\n        of points. If this is not the case, the widget should trigger\n        the complete update by calling `reset_graph` instead of this method.\n        \"\"\"\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0:\n            return\n\n        self._reset_view(x, y)\n        if self.scatterplot_item is None:\n            if self.sample_indices is None:\n                indices = np.arange(self.n_valid)\n            else:\n                indices = self.sample_indices\n            kwargs = dict(x=x, y=y, data=indices)\n            self.scatterplot_item = ScatterPlotItem(**kwargs)\n            self.scatterplot_item.sigClicked.connect(self.select_by_click)\n            self.scatterplot_item_sel = ScatterPlotItem(**kwargs)\n            self.plot_widget.addItem(self.scatterplot_item_sel)\n            self.plot_widget.addItem(self.scatterplot_item)\n        else:\n            self.scatterplot_item.setCoordinates(x, y)\n            self.scatterplot_item_sel.setCoordinates(x, y)\n            self.update_labels()\n\n        self.update_density()  # Todo: doesn't work: try MDS with density on\n\n    # Sizes\n    def get_sizes(self):\n        \"\"\"\n        Prepare data for sizes of points in the plot\n\n        The method is called by `update_sizes`. It gets the sizes\n        from the widget and performs the necessary scaling and sizing.\n        The output is rounded to half a pixel for faster drawing.\n\n        Returns:\n            (np.ndarray): sizes\n        \"\"\"\n        size_column = self.master.get_size_data()\n        if size_column is None:\n            return np.full((self.n_shown,),\n                           self.MinShapeSize + (5 + self.point_width) * 0.5)\n        size_column = self._filter_visible(size_column)\n        size_column = size_column.copy()\n        with warnings.catch_warnings():\n            warnings.simplefilter(\"ignore\", category=RuntimeWarning)\n            size_column -= np.nanmin(size_column)\n            mx = np.nanmax(size_column)\n        if mx > 0:\n            size_column /= mx\n        else:\n            size_column[:] = 0.5\n\n        sizes = self.MinShapeSize + (5 + self.point_width) * size_column\n        # round sizes to half pixel for smaller pyqtgraph's symbol pixmap atlas\n        sizes = (sizes * 2).round() / 2\n        return sizes\n\n    def update_sizes(self):\n        \"\"\"\n        Trigger an update of point sizes\n\n        The method calls `self.get_sizes`, which in turn calls the widget's\n        `get_size_data`. The result are properly scaled and then passed\n        back to widget for imputing (`master.impute_sizes`).\n        \"\"\"\n        if self.scatterplot_item:\n            size_data = self.get_sizes()\n            size_imputer = getattr(\n                self.master, \"impute_sizes\", self.default_impute_sizes)\n            size_imputer(size_data)\n\n            if self.timer is not None and self.timer.isActive():\n                self.timer.stop()\n                self.timer = None\n\n            current_size_data = self.scatterplot_item.data[\"size\"].copy()\n            diff = size_data - current_size_data\n            widget = self\n\n            class Timeout:\n                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2\n                factors = [0.07, 0.16, 0.27, 0.41, 0.55,\n                           0.68, 0.81, 0.9, 0.97, 1]\n\n                def __init__(self):\n                    self._counter = 0\n\n                def __call__(self):\n                    factor = self.factors[self._counter]\n                    self._counter += 1\n                    size = current_size_data + diff * factor\n                    if len(self.factors) == self._counter:\n                        widget.timer.stop()\n                        widget.timer = None\n                        size = size_data\n                    widget.scatterplot_item.setSize(size)\n                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)\n                    if widget.timer is None:\n                        widget.end_resizing.emit()\n                    else:\n                        widget.step_resizing.emit()\n\n            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \\\n                    np.all(current_size_data > 0) and np.any(diff != 0):\n                # If encountered any strange behaviour when updating sizes,\n                # implement it with threads\n                self.begin_resizing.emit()\n                interval = int(500 / len(Timeout.factors))\n                self.timer = QTimer(self.scatterplot_item, interval=interval)\n                self.timer.timeout.connect(Timeout())\n                self.timer.start()\n            else:\n                self.begin_resizing.emit()\n                self.scatterplot_item.setSize(size_data)\n                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)\n                self.end_resizing.emit()\n\n    update_point_size = update_sizes  # backward compatibility (needed?!)\n    update_size = update_sizes\n\n    @classmethod\n    def default_impute_sizes(cls, size_data):\n        \"\"\"\n        Fallback imputation for sizes.\n\n        Set the size to two pixels smaller than the minimal size\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        nans = np.isnan(size_data)\n        if np.any(nans):\n            size_data[nans] = cls.MinShapeSize - 2\n            return True\n        else:\n            return False\n\n    # Colors\n    def get_colors(self):\n        \"\"\"\n        Prepare data for colors of the points in the plot\n\n        The method is called by `update_colors`. It gets the colors and the\n        indices of the data subset from the widget (`get_color_data`,\n        `get_subset_mask`), and constructs lists of pens and brushes for\n        each data point.\n\n        The method uses different palettes for discrete and continuous data,\n        as determined by calling the widget's method `is_continuous_color`.\n\n        If also marks the points that are in the subset as defined by, for\n        instance the 'Data Subset' signal in the Scatter plot and similar\n        widgets. (Do not confuse this with *selected points*, which are\n        marked by circles around the points, which are colored by groups\n        and thus independent of this method.)\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        c_data = self.master.get_color_data()\n        c_data = self._filter_visible(c_data)\n        subset = self.master.get_subset_mask()\n        subset = self._filter_visible(subset)\n        self.subset_is_shown = subset is not None\n        if c_data is None:  # same color\n            self.palette = None\n            return self._get_same_colors(subset)\n        elif self.master.is_continuous_color():\n            return self._get_continuous_colors(c_data, subset)\n        else:\n            return self._get_discrete_colors(c_data, subset)\n\n    def _get_same_colors(self, subset, color=COLOR_DEFAULT):\n        \"\"\"\n        Return the same pen for all points while the brush color depends\n        upon whether the point is in the subset or not\n\n        Args:\n            subset (np.ndarray): a bool array indicating whether a data point\n                is in the subset or not (e.g. in the 'Data Subset' signal\n                in the Scatter plot and similar widgets);\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        alpha_subset, alpha_unset = self._alpha_for_subsets()\n        if subset is not None:\n            qcolor = QColor(*color, alpha_subset)\n            brush = np.where(subset, QBrush(qcolor), QBrush(QColor(0, 0, 0, 0)))\n            pen = np.where(subset,\n                           _make_pen(qcolor, 1.5),\n                           _make_pen(QColor(*color, alpha_unset), 1.5))\n        else:\n            qcolor = QColor(*color, self.alpha_value)\n            brush = np.full(self.n_shown, QBrush(qcolor))\n            pen = [_make_pen(qcolor, 1.5)] * self.n_shown\n        return pen, brush\n\n    def _get_continuous_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a continuous palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        palette = self.master.get_palette()\n\n        if np.isnan(c_data).all():\n            self.palette = palette\n            return self._get_same_colors(subset, self.palette.nan_color)\n\n        self.scale = DiscretizedScale(np.nanmin(c_data), np.nanmax(c_data))\n        bins = self.scale.get_bins()\n        self.palette = \\\n            colorpalettes.BinnedContinuousPalette.from_palette(palette, bins)\n        colors = self.palette.values_to_colors(c_data)\n        alphas = np.full((len(c_data), 1), self.alpha_value, dtype=np.ubyte)\n        brush = np.hstack((colors, alphas))\n        pen = np.hstack(\n            ((colors.astype(dtype=float) * 100 / self.DarkerValue).astype(np.ubyte),\n             alphas))\n\n        # Reuse pens and brushes with the same colors because PyQtGraph then\n        # builds smaller pixmap atlas, which makes the drawing faster\n\n        def reuse(cache, fun, *args):\n            if args not in cache:\n                cache[args] = fun(args)\n            return cache[args]\n\n        def create_pen(col):\n            return _make_pen(QColor(*col), 1.5)\n\n        def create_brush(col):\n            return QBrush(QColor(*col))\n\n        if subset is not None:\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            brush[:, 3] = 0\n            brush[subset, 3] = alpha_subset\n            pen[:, 3] = alpha_unset\n            brush[subset, 3] = alpha_subset\n\n        cached_pens = {}\n        pen = [reuse(cached_pens, create_pen, *col) for col in pen.tolist()]\n        cached_brushes = {}\n        brush = np.array([reuse(cached_brushes, create_brush, *col)\n                          for col in brush.tolist()])\n\n        return pen, brush\n\n    def _get_discrete_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a discrete palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        self.palette = self.master.get_palette()\n        c_data = c_data.copy()\n        c_data[np.isnan(c_data)] = len(self.palette)\n        c_data = c_data.astype(int)\n        colors = self.palette.qcolors_w_nan\n        if subset is None:\n            for col in colors:\n                col.setAlpha(self.alpha_value)\n            pens = np.array(\n                [_make_pen(col.darker(self.DarkerValue), 1.5)\n                 for col in colors])\n            pen = pens[c_data]\n            brushes = np.array([QBrush(col) for col in colors])\n            brush = brushes[c_data]\n        else:\n            subset_colors = [QColor(col) for col in colors]\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            for col in subset_colors:\n                col.setAlpha(alpha_subset)\n            for col in colors:\n                col.setAlpha(alpha_unset)\n\n            pens, subset_pens = (\n                np.array(\n                    [_make_pen(col.darker(self.DarkerValue), 1.5)\n                     for col in cols])\n                for cols in (colors, subset_colors))\n            pen = np.where(subset, subset_pens[c_data], pens[c_data])\n\n            brushes = np.array([QBrush(col) for col in subset_colors])\n            brush = brushes[c_data]\n            black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))\n            brush = np.where(subset, brush, black)\n        return pen, brush\n\n    def _alpha_for_subsets(self):\n        a, b, c = 1.2, -3.2, 3\n        x = self.alpha_value / 255\n        alpha_subset = 31 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))\n        x = 1 - x\n        alpha_unset = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))\n        return alpha_subset, alpha_unset\n\n    def update_colors(self):\n        \"\"\"\n        Trigger an update of point colors\n\n        The method calls `self.get_colors`, which in turn calls the widget's\n        `get_color_data` to get the indices in the pallette. `get_colors`\n        returns a list of pens and brushes to which this method uses to\n        update the colors. Finally, the method triggers the update of the\n        legend and the density plot.\n        \"\"\"\n        if self.scatterplot_item is not None:\n            pen_data, brush_data = self.get_colors()\n            self.scatterplot_item.setPen(pen_data, update=False, mask=None)\n            self.scatterplot_item.setBrush(brush_data, mask=None)\n        self.update_z_values()\n        self.update_legends()\n        self.update_density()\n\n    update_alpha_value = update_colors\n\n    def update_density(self):\n        \"\"\"\n        Remove the existing density plot (if there is one) and replace it\n        with a new one (if enabled).\n\n        The method gets the colors from the pens of the currently plotted\n        points.\n        \"\"\"\n        if self.density_img:\n            self.plot_widget.removeItem(self.density_img)\n            self.density_img = None\n        if self.class_density and self.scatterplot_item is not None:\n            c_data = self.master.get_color_data()\n            if c_data is None:\n                return\n            visible_c_data = self._filter_visible(c_data)\n            mask = np.isfinite(visible_c_data)\n            if not self.master.is_continuous_color():\n                mask = np.bitwise_and(mask, visible_c_data < MAX_COLORS - 1)\n            pens = self.scatterplot_item.data['pen']\n            rgb_data = [\n                pen.color().getRgb()[:3] if pen is not None else (255, 255, 255)\n                for known, pen in zip(mask, pens)\n                if known]\n            if len(set(rgb_data)) <= 1:\n                return\n            [min_x, max_x], [min_y, max_y] = self.view_box.viewRange()\n            x_data, y_data = self.scatterplot_item.getData()\n            self.density_img = classdensity.class_density_image(\n                min_x, max_x, min_y, max_y, self.resolution,\n                x_data[mask], y_data[mask], rgb_data)\n            self.plot_widget.addItem(self.density_img, ignoreBounds=True)\n\n    def update_selection_colors(self):\n        \"\"\"\n        Trigger an update of selection markers\n\n        This update method is usually not called by the widget but by the\n        plot, since it is the plot that handles the selections.\n\n        Like other update methods, it calls the corresponding get method\n        (`get_colors_sel`) which returns a list of pens and brushes.\n        \"\"\"\n        if self.scatterplot_item_sel is None:\n            return\n        pen, brush = self.get_colors_sel()\n        self.scatterplot_item_sel.setPen(pen, update=False, mask=None)\n        self.scatterplot_item_sel.setBrush(brush, mask=None)\n        self.update_z_values()\n\n    def get_colors_sel(self):\n        \"\"\"\n        Return pens and brushes for selection markers.\n\n        A pen can is set to `Qt.NoPen` if a point is not selected.\n\n        All brushes are completely transparent whites.\n\n        Returns:\n            (tuple): a list of pens and a list of brushes\n        \"\"\"\n        nopen = QPen(Qt.NoPen)\n        if self.selection is None:\n            pen = [nopen] * self.n_shown\n        else:\n            sels = np.max(self.selection)\n            if sels == 1:\n                pen = np.where(\n                    self._filter_visible(self.selection),\n                    _make_pen(QColor(255, 190, 0, 255), SELECTION_WIDTH),\n                    nopen)\n            else:\n                palette = colorpalettes.LimitedDiscretePalette(\n                    number_of_colors=sels + 1)\n                pen = np.choose(\n                    self._filter_visible(self.selection),\n                    [nopen] + [_make_pen(palette[i], SELECTION_WIDTH)\n                               for i in range(sels)])\n        return pen, [QBrush(QColor(255, 255, 255, 0))] * self.n_shown\n\n    # Labels\n    def get_labels(self):\n        \"\"\"\n        Prepare data for labels for points\n\n        The method returns the results of the widget's `get_label_data`\n\n        Returns:\n            (labels): a sequence of labels\n        \"\"\"\n        return self._filter_visible(self.master.get_label_data())\n\n    def update_labels(self):\n        \"\"\"\n        Trigger an update of labels\n\n        The method calls `get_labels` which in turn calls the widget's\n        `get_label_data`. The obtained labels are shown if the corresponding\n        points are selected or if `label_only_selected` is `false`.\n        \"\"\"\n        for label in self.labels:\n            self.plot_widget.removeItem(label)\n        self.labels = []\n\n        mask = None\n        if self.scatterplot_item is not None:\n            x, y = self.scatterplot_item.getData()\n            mask = self._label_mask(x, y)\n\n        if mask is not None:\n            labels = self.get_labels()\n            if labels is None:\n                mask = None\n\n        self._signal_too_many_labels(\n            mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)\n        if self._too_many_labels or mask is None or not np.any(mask):\n            return\n\n        foreground = self.plot_widget.palette().color(QPalette.Text)\n        labels = labels[mask]\n        x = x[mask]\n        y = y[mask]\n        for label, xp, yp in zip(labels, x, y):\n            ti = TextItem(label, foreground)\n            ti.setPos(xp, yp)\n            self.plot_widget.addItem(ti)\n            self.labels.append(ti)\n            ti.setFont(self.parameter_setter.label_font)\n\n    def _signal_too_many_labels(self, too_many):\n        if self._too_many_labels != too_many:\n            self._too_many_labels = too_many\n            self.too_many_labels.emit(too_many)\n\n    def _label_mask(self, x, y):\n        (x0, x1), (y0, y1) = self.view_box.viewRange()\n        mask = np.logical_and(\n            np.logical_and(x >= x0, x <= x1),\n            np.logical_and(y >= y0, y <= y1))\n        if self.label_only_selected:\n            sub_mask = self._filter_visible(self.master.get_subset_mask())\n            if self.selection is None:\n                if sub_mask is None:\n                    return None\n                else:\n                    sel_mask = sub_mask\n            else:\n                sel_mask = self._filter_visible(self.selection) != 0\n                if sub_mask is not None:\n                    sel_mask = np.logical_or(sel_mask, sub_mask)\n            mask = np.logical_and(mask, sel_mask)\n        return mask\n\n    # Shapes\n    def get_shapes(self):\n        \"\"\"\n        Prepare data for shapes of points in the plot\n\n        The method is called by `update_shapes`. It gets the data from\n        the widget's `get_shape_data`, and then calls its `impute_shapes`\n        to impute the missing shape (usually with some default shape).\n\n        Returns:\n            (np.ndarray): an array of symbols (e.g. o, x, + ...)\n        \"\"\"\n        shape_data = self.master.get_shape_data()\n        shape_data = self._filter_visible(shape_data)\n        # Data has to be copied so the imputation can change it in-place\n        # TODO: Try avoiding this when we move imputation to the widget\n        if shape_data is not None:\n            shape_data = np.copy(shape_data)\n        shape_imputer = getattr(\n            self.master, \"impute_shapes\", self.default_impute_shapes)\n        shape_imputer(shape_data, len(self.CurveSymbols) - 1)\n        if isinstance(shape_data, np.ndarray):\n            shape_data = shape_data.astype(int)\n        else:\n            shape_data = np.zeros(self.n_shown, dtype=int)\n        return self.CurveSymbols[shape_data]\n\n    @staticmethod\n    def default_impute_shapes(shape_data, default_symbol):\n        \"\"\"\n        Fallback imputation for shapes.\n\n        Use the default symbol, usually the last symbol in the list.\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        if shape_data is None:\n            return False\n        nans = np.isnan(shape_data)\n        if np.any(nans):\n            shape_data[nans] = default_symbol\n            return True\n        else:\n            return False\n\n    def update_shapes(self):\n        \"\"\"\n        Trigger an update of point symbols\n\n        The method calls `get_shapes` to obtain an array with a symbol\n        for each point and uses it to update the symbols.\n\n        Finally, the method updates the legend.\n        \"\"\"\n        if self.scatterplot_item:\n            shape_data = self.get_shapes()\n            self.scatterplot_item.setSymbol(shape_data)\n        self.update_legends()\n\n    def update_z_values(self):\n        \"\"\"\n        Set z-values for point in the plot\n\n        The order is as follows:\n        - selected points that are also in the subset on top,\n        - followed by selected points,\n        - followed by points from the subset,\n        - followed by the rest.\n        Within each of these four groups, points are ordered by their colors.\n\n        Points with less frequent colors are above those with more frequent.\n        The points for which the value for the color is missing are at the\n        bottom of their respective group.\n        \"\"\"\n        if not self.scatterplot_item:\n            return\n\n        subset = self.master.get_subset_mask()\n        c_data = self.master.get_color_data()\n        if subset is None and self.selection is None and c_data is None:\n            self.scatterplot_item.setZ(None)\n            return\n\n        z = np.zeros(self.n_shown)\n\n        if subset is not None:\n            subset = self._filter_visible(subset)\n            z[subset] += 1000\n\n        if self.selection is not None:\n            z[self._filter_visible(self.selection) != 0] += 2000\n\n        if c_data is not None:\n            c_nan = np.isnan(c_data)\n            vis_data = self._filter_visible(c_data)\n            vis_nan = np.isnan(vis_data)\n            z[vis_nan] -= 999\n            if not self.master.is_continuous_color():\n                dist = np.bincount(c_data[~c_nan].astype(int))\n                vis_knowns = vis_data[~vis_nan].astype(int)\n                argdist = np.argsort(dist)\n                z[~vis_nan] -= argdist[vis_knowns]\n\n        self.scatterplot_item.setZ(z)\n\n    def update_grid_visibility(self):\n        \"\"\"Show or hide the grid\"\"\"\n        self.plot_widget.showGrid(x=self.show_grid, y=self.show_grid)\n\n    def update_legend_visibility(self):\n        \"\"\"\n        Show or hide legends based on whether they are enabled and non-empty\n        \"\"\"\n        self.shape_legend.setVisible(\n            self.show_legend and bool(self.shape_legend.items))\n        self.color_legend.setVisible(\n            self.show_legend and bool(self.color_legend.items))\n\n    def update_legends(self):\n        \"\"\"Update content of legends and their visibility\"\"\"\n        cont_color = self.master.is_continuous_color()\n        shape_labels = self.master.get_shape_labels()\n        color_labels = self.master.get_color_labels()\n        if not cont_color and shape_labels is not None \\\n                and shape_labels == color_labels:\n            colors = self.master.get_color_data()\n            shapes = self.master.get_shape_data()\n            mask = np.isfinite(colors) * np.isfinite(shapes)\n            combined = (colors == shapes)[mask].all()\n        else:\n            combined = False\n        if combined:\n            self._update_combined_legend(shape_labels)\n        else:\n            self._update_shape_legend(shape_labels)\n            if cont_color:\n                self._update_continuous_color_legend(color_labels)\n            else:\n                self._update_color_legend(color_labels)\n        self.update_legend_visibility()\n        Updater.update_legend_font(self.parameter_setter.cat_legend_items,\n                                   **self.parameter_setter.cat_legend_settings)\n        Updater.update_num_legend_font(self.parameter_setter.num_legend,\n                                       **self.parameter_setter.num_legend_settings)\n\n    def _update_shape_legend(self, labels):\n        self.shape_legend.clear()\n        if labels is None or self.scatterplot_item is None:\n            return\n        color = QColor(0, 0, 0)\n        color.setAlpha(self.alpha_value)\n        for label, symbol in zip(labels, self.CurveSymbols):\n            self.shape_legend.addItem(\n                SymbolItemSample(pen=color, brush=color, size=10, symbol=symbol),\n                escape(label))\n\n    def _update_continuous_color_legend(self, label_formatter: Callable[[float], str]):\n        self.color_legend.clear()\n        if self.scale is None or self.scatterplot_item is None:\n            return\n        label = PaletteItemSample(self.palette, self.scale, label_formatter)\n        self.color_legend.addItem(label, \"\")\n        self.color_legend.setGeometry(label.boundingRect())\n\n    def _update_color_legend(self, labels):\n        self.color_legend.clear()\n        if labels is None:\n            return\n        self._update_colored_legend(self.color_legend, labels, 'o')\n\n    def _update_combined_legend(self, labels):\n        # update_colored_legend will already clear the shape legend\n        # so we remove colors here\n        use_legend = \\\n            self.shape_legend if self.shape_legend.items else self.color_legend\n        self.color_legend.clear()\n        self.shape_legend.clear()\n        self._update_colored_legend(use_legend, labels, self.CurveSymbols)\n\n    def _update_colored_legend(self, legend, labels, symbols):\n        if self.scatterplot_item is None or not self.palette:\n            return\n        if isinstance(symbols, str):\n            symbols = itertools.repeat(symbols, times=len(labels))\n        colors = self.palette.values_to_colors(np.arange(len(labels)))\n        for color, label, symbol in zip(colors, labels, symbols):\n            color = QColor(*color)\n            pen = _make_pen(color.darker(self.DarkerValue), 1.5)\n            color.setAlpha(self.alpha_value)\n            brush = QBrush(color)\n            legend.addItem(\n                SymbolItemSample(pen=pen, brush=brush, size=10, symbol=symbol),\n                escape(label))\n\n    def zoom_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def pan_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().PanMode)\n\n    def select_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def reset_button_clicked(self):\n        self.plot_widget.getViewBox().autoRange()\n        self.update_labels()\n\n    def select_by_click(self, _, points):\n        if self.scatterplot_item is not None:\n            self.select(points)\n\n    def select_by_rectangle(self, rect):\n        if self.scatterplot_item is not None:\n            x0, x1 = sorted((rect.topLeft().x(), rect.bottomRight().x()))\n            y0, y1 = sorted((rect.topLeft().y(), rect.bottomRight().y()))\n            x, y = self.master.get_coordinates_data()\n            indices = np.flatnonzero(\n                (x0 <= x) & (x <= x1) & (y0 <= y) & (y <= y1))\n            self.select_by_indices(indices.astype(int))\n\n    def unselect_all(self):\n        if self.selection is not None:\n            self.selection = None\n            self.update_selection_colors()\n            if self.label_only_selected:\n                self.update_labels()\n            self.master.selection_changed()\n\n    def select(self, points):\n        # noinspection PyArgumentList\n        if self.scatterplot_item is None:\n            return\n        indices = [p.data() for p in points]\n        self.select_by_indices(indices)\n\n    def select_by_indices(self, indices):\n        if self.selection is None:\n            self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        keys = QApplication.keyboardModifiers()\n        if keys & Qt.ControlModifier:\n            self.selection_append(indices)\n        elif keys & Qt.ShiftModifier:\n            self.selection_new_group(indices)\n        elif keys & Qt.AltModifier:\n            self.selection_remove(indices)\n        else:\n            self.selection_select(indices)\n\n    def selection_select(self, indices):\n        self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        self.selection[indices] = 1\n        self._update_after_selection()\n\n    def selection_append(self, indices):\n        self.selection[indices] = max(np.max(self.selection), 1)\n        self._update_after_selection()\n\n    def selection_new_group(self, indices):\n        self.selection[indices] = np.max(self.selection) + 1\n        self._update_after_selection()\n\n    def selection_remove(self, indices):\n        self.selection[indices] = 0\n        self._update_after_selection()\n\n    def _update_after_selection(self):\n        self._compress_indices()\n        self.update_selection_colors()\n        if self.label_only_selected:\n            self.update_labels()\n        self.master.selection_changed()\n\n    def _compress_indices(self):\n        indices = sorted(set(self.selection) | {0})\n        if len(indices) == max(indices) + 1:\n            return\n        mapping = np.zeros((max(indices) + 1,), dtype=int)\n        for i, ind in enumerate(indices):\n            mapping[ind] = i\n        self.selection = mapping[self.selection]\n\n    def get_selection(self):\n        if self.selection is None:\n            return np.array([], dtype=np.uint8)\n        else:\n            return np.flatnonzero(self.selection)\n\n    def help_event(self, event):\n        \"\"\"\n        Create a `QToolTip` for the point hovered by the mouse\n        \"\"\"\n        if self.scatterplot_item is None:\n            return False\n        act_pos = self.scatterplot_item.mapFromScene(event.scenePos())\n        point_data = [p.data() for p in self.scatterplot_item.pointsAt(act_pos)]\n        text = self.master.get_tooltip(point_data)\n        if text:\n            QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)\n            return True\n        else:\n            return False\n",
            "new_file_content": "import sys\nimport itertools\nimport warnings\nfrom typing import Callable\nfrom xml.sax.saxutils import escape\nfrom datetime import datetime, timezone\n\nimport numpy as np\nfrom AnyQt.QtCore import Qt, QRectF, QSize, QTimer, pyqtSignal as Signal, \\\n    QObject, QEvent\nfrom AnyQt.QtGui import QColor, QPen, QBrush, QPainterPath, QTransform, \\\n    QPainter, QPalette\nfrom AnyQt.QtWidgets import QApplication, QToolTip, QGraphicsTextItem, \\\n    QGraphicsRectItem, QGraphicsItemGroup\n\nimport pyqtgraph as pg\nfrom pyqtgraph.graphicsItems.ScatterPlotItem import Symbols\nfrom pyqtgraph.graphicsItems.LegendItem import LegendItem as PgLegendItem\nfrom pyqtgraph.graphicsItems.TextItem import TextItem\n\nfrom Orange.preprocess.discretize import _time_binnings\nfrom Orange.util import utc_from_timestamp\nfrom Orange.widgets import gui\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils import classdensity, colorpalettes\nfrom Orange.widgets.visualize.utils.customizableplot import Updater, \\\n    CommonParameterSetter\nfrom Orange.widgets.visualize.utils.plotutils import (\n    HelpEventDelegate as EventDelegate, InteractiveViewBox as ViewBox,\n    PaletteItemSample, SymbolItemSample, AxisItem, PlotWidget, DiscretizedScale\n)\n\nSELECTION_WIDTH = 5\nMAX_N_VALID_SIZE_ANIMATE = 1000\n\n# maximum number of colors (including Other)\nMAX_COLORS = 11\n\n\nclass LegendItem(PgLegendItem):\n    def __init__(\n            self, size=None, offset=None, pen=None, brush=None,\n    ):\n        super().__init__(size, offset)\n\n        self.layout.setContentsMargins(5, 5, 5, 5)\n        self.layout.setHorizontalSpacing(15)\n        self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)\n        if pen is not None:\n            pen = QPen(pen)\n        if brush is not None:\n            brush = QBrush(brush)\n        self.__pen = pen\n        self.__brush = brush\n\n    def restoreAnchor(self, anchors):\n        \"\"\"\n        Restore (parent) relative position from stored anchors.\n\n        The restored position is within the parent bounds.\n        \"\"\"\n        anchor, parentanchor = anchors\n        self.anchor(*bound_anchor_pos(anchor, parentanchor))\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, _option, _widget=None):\n        painter.setPen(self.pen())\n        painter.setBrush(self.brush())\n        rect = self.contentsRect()\n        painter.drawRoundedRect(rect, 2, 2)\n\n    def addItem(self, item, name):\n        super().addItem(item, name)\n        # Fix-up the label alignment, and color\n        color = self.palette().color(QPalette.Text)\n        _, label = self.items[-1]\n        label.setText(name, justify=\"left\", color=color)\n\n    def clear(self):\n        \"\"\"\n        Clear all legend items.\n        \"\"\"\n        items = list(self.items)\n        self.items = []\n        for sample, label in items:\n            self.layout.removeItem(sample)\n            self.layout.removeItem(label)\n            sample.hide()\n            label.hide()\n\n        self.updateSize()\n\n    def pen(self):\n        if self.__pen is not None:\n            return QPen(self.__pen)\n        else:\n            color = self.palette().color(QPalette.Disabled, QPalette.Text)\n            color.setAlpha(100)\n            pen = QPen(color, 1)\n            pen.setCosmetic(True)\n            return pen\n\n    def brush(self):\n        if self.__brush is not None:\n            return QBrush(self.__brush)\n        else:\n            color = self.palette().color(QPalette.Window)\n            color.setAlpha(150)\n            return QBrush(color)\n\n    def changeEvent(self, event: QEvent):\n        if event.type() == QEvent.PaletteChange:\n            color = self.palette().color(QPalette.Text)\n            for _, label in self.items:\n                label.setText(label.text, color=color)\n        super().changeEvent(event)\n\n\ndef bound_anchor_pos(corner, parentpos):\n    corner = np.clip(corner, 0, 1)\n    parentpos = np.clip(parentpos, 0, 1)\n\n    irx, iry = corner\n    prx, pry = parentpos\n\n    if irx > 0.9 and prx < 0.1:\n        irx = prx = 0.0\n    if iry > 0.9 and pry < 0.1:\n        iry = pry = 0.0\n    if irx < 0.1 and prx > 0.9:\n        irx = prx = 1.0\n    if iry < 0.1 and pry > 0.9:\n        iry = pry = 1.0\n    return (irx, iry), (prx, pry)\n\n\nclass ScatterPlotItem(pg.ScatterPlotItem):\n    \"\"\"\n    Modifies the behaviour of ScatterPlotItem as follows:\n\n    - Add z-index. ScatterPlotItem paints points in order of appearance in\n      self.data. Plotting by z-index is achieved by sorting before calling\n      super().paint() and re-sorting afterwards. Re-sorting (instead of\n      storing the original data) is needed because the inherited paint\n      may modify the data.\n\n    - Prevent multiple calls to updateSpots. ScatterPlotItem calls updateSpots\n      at any change of sizes/colors/symbols, which then rebuilds the stored\n      pixmaps for each symbol. Orange calls set* functions in succession,\n      so we postpone updateSpots() to paint().\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._update_spots_in_paint = False\n        self._z_mapping = None\n        self._inv_mapping = None\n\n    def setZ(self, z):\n        \"\"\"\n        Set z values for all points.\n\n        Points with higher values are plotted on top of those with lower.\n\n        Args:\n            z (np.ndarray or None): a vector of z values\n        \"\"\"\n        if z is None:\n            self._z_mapping = self._inv_mapping = None\n        else:\n            assert len(z) == len(self.data)\n            self._z_mapping = np.argsort(z)\n            self._inv_mapping = np.argsort(self._z_mapping)\n\n    def setCoordinates(self, x, y):\n        \"\"\"\n        Change the coordinates of points while keeping other properties.\n\n        Asserts that the number of points stays the same.\n\n        Note. Pyqtgraph does not offer a method for this: setting coordinates\n        invalidates other data. We therefore retrieve the data to set it\n        together with the coordinates. Pyqtgraph also does not offer a\n        (documented) method for retrieving the data, yet using\n        data[prop]` looks reasonably safe.\n\n        The alternative, updating the whole scatterplot from the Orange Table,\n        is too slow.\n        \"\"\"\n        assert len(self.data) == len(x) == len(y)\n        data = dict(x=x, y=y)\n        for prop in ('pen', 'brush', 'size', 'symbol', 'data'):\n            data[prop] = self.data[prop]\n        self.setData(**data)\n\n    def updateSpots(self, dataSet=None):  # pylint: disable=unused-argument\n        self._update_spots_in_paint = True\n        self.update()\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, option, widget=None):\n        try:\n            if self._z_mapping is not None:\n                assert len(self._z_mapping) == len(self.data)\n                self.data = self.data[self._z_mapping]\n            if self._update_spots_in_paint:\n                self._update_spots_in_paint = False\n                super().updateSpots()\n            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)\n            super().paint(painter, option, widget)\n        finally:\n            if self._inv_mapping is not None:\n                self.data = self.data[self._inv_mapping]\n\n\ndef _define_symbols():\n    \"\"\"\n    Add symbol ? to ScatterPlotItemSymbols,\n    reflect the triangle to point upwards\n    \"\"\"\n    path = QPainterPath()\n    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))\n    path.moveTo(-0.5, 0.5)\n    path.lineTo(0.5, -0.5)\n    path.moveTo(-0.5, -0.5)\n    path.lineTo(0.5, 0.5)\n    Symbols[\"?\"] = path\n\n    path = QPainterPath()\n    plusCoords = [\n        (-0.5, -0.1), (-0.5, 0.1), (-0.1, 0.1), (-0.1, 0.5),\n        (0.1, 0.5), (0.1, 0.1), (0.5, 0.1), (0.5, -0.1),\n        (0.1, -0.1), (0.1, -0.5), (-0.1, -0.5), (-0.1, -0.1)\n    ]\n    path.moveTo(*plusCoords[0])\n    for x, y in plusCoords[1:]:\n        path.lineTo(x, y)\n    path.closeSubpath()\n    Symbols[\"+\"] = path\n\n    tr = QTransform()\n    tr.rotate(180)\n    Symbols['t'] = tr.map(Symbols['t'])\n\n    tr = QTransform()\n    tr.rotate(45)\n    Symbols['x'] = tr.map(Symbols[\"+\"])\n\n\n_define_symbols()\n\n\ndef _make_pen(color, width):\n    p = QPen(color, width)\n    p.setCosmetic(True)\n    return p\n\n\nclass AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        # In case of a single tick, `default` will inform tickStrings\n        # about the appropriate scale.\n        spacing = min((b - a for a, b in zip(ticks[:-1], ticks[1:])),\n                      default=maxVal - minVal)\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]\n\n\nclass ScatterBaseParameterSetter(CommonParameterSetter):\n    CAT_LEGEND_LABEL = \"Categorical legend\"\n    NUM_LEGEND_LABEL = \"Numerical legend\"\n    NUM_LEGEND_SETTING = {\n        Updater.SIZE_LABEL: (range(4, 50), 11),\n        Updater.IS_ITALIC_LABEL: (None, False),\n    }\n\n    def __init__(self, master):\n        super().__init__()\n        self.master = master\n        self.cat_legend_settings = {}\n        self.num_legend_settings = {}\n\n    def update_setters(self):\n        self.initial_settings = {\n            self.LABELS_BOX: {\n                self.FONT_FAMILY_LABEL: self.FONT_FAMILY_SETTING,\n                self.TITLE_LABEL: self.FONT_SETTING,\n                self.LABEL_LABEL: self.FONT_SETTING,\n                self.CAT_LEGEND_LABEL: self.FONT_SETTING,\n                self.NUM_LEGEND_LABEL: self.NUM_LEGEND_SETTING,\n            },\n            self.ANNOT_BOX: {\n                self.TITLE_LABEL: {self.TITLE_LABEL: (\"\", \"\")},\n            }\n        }\n\n        def update_cat_legend(**settings):\n            self.cat_legend_settings.update(**settings)\n            Updater.update_legend_font(self.cat_legend_items, **settings)\n\n        def update_num_legend(**settings):\n            self.num_legend_settings.update(**settings)\n            Updater.update_num_legend_font(self.num_legend, **settings)\n\n        labels = self.LABELS_BOX\n        self._setters[labels][self.CAT_LEGEND_LABEL] = update_cat_legend\n        self._setters[labels][self.NUM_LEGEND_LABEL] = update_num_legend\n\n    @property\n    def title_item(self):\n        return self.master.plot_widget.getPlotItem().titleLabel\n\n    @property\n    def cat_legend_items(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            items = []\n        return itertools.chain(self.master.shape_legend.items, items)\n\n    @property\n    def num_legend(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            return self.master.color_legend\n        return None\n\n    @property\n    def labels(self):\n        return self.master.labels\n\n\nclass OWScatterPlotBase(gui.OWComponent, QObject):\n    \"\"\"\n    Provide a graph component for widgets that show any kind of point plot\n\n    The component plots a set of points with given coordinates, shapes,\n    sizes and colors. Its function is similar to that of a *view*, whereas\n    the widget represents a *model* and a *controler*.\n\n    The model (widget) needs to provide methods:\n\n    - `get_coordinates_data`, `get_size_data`, `get_color_data`,\n      `get_shape_data`, `get_label_data`, which return a 1d array (or two\n      arrays, for `get_coordinates_data`) of `dtype` `float64`, except for\n      `get_label_data`, which returns formatted labels;\n    - `get_shape_labels` returns a list of strings for shape legend\n    - `get_color_labels` returns strings for color legend, or a function for\n       formatting numbers if the legend is continuous, or None for default\n       formatting\n    - `get_tooltip`, which gives a tooltip for a single data point\n    - (optional) `impute_sizes`, `impute_shapes` get final coordinates and\n      shapes, and replace nans;\n    - `get_subset_mask` returns a bool array indicating whether a\n      data point is in the subset or not (e.g. in the 'Data Subset' signal\n      in the Scatter plot and similar widgets);\n    - `get_palette` returns a palette appropriate for visualizing the\n      current color data;\n    - `is_continuous_color` decides the type of the color legend;\n\n    The widget (in a role of controller) must also provide methods\n    - `selection_changed`\n\n    If `get_coordinates_data` returns `(None, None)`, the plot is cleared. If\n    `get_size_data`, `get_color_data` or `get_shape_data` return `None`,\n    all points will have the same size, color or shape, respectively.\n    If `get_label_data` returns `None`, there are no labels.\n\n    The view (this compomnent) provides methods `update_coordinates`,\n    `update_sizes`, `update_colors`, `update_shapes` and `update_labels`\n    that the widget (in a role of a controler) should call when any of\n    these properties are changed. If the widget calls, for instance, the\n    plot's `update_colors`, the plot will react by calling the widget's\n    `get_color_data` as well as the widget's methods needed to construct the\n    legend.\n\n    The view also provides a method `reset_graph`, which should be called only\n    when\n    - the widget gets entirely new data\n    - the number of points may have changed, for instance when selecting\n    a different attribute for x or y in the scatter plot, where the points\n    with missing x or y coordinates are hidden.\n\n    Every `update_something` calls the plot's `get_something`, which\n    calls the model's `get_something_data`, then it transforms this data\n    into whatever is needed (colors, shapes, scaled sizes) and changes the\n    plot. For the simplest example, here is `update_shapes`:\n\n    ```\n        def update_shapes(self):\n            if self.scatterplot_item:\n                shape_data = self.get_shapes()\n                self.scatterplot_item.setSymbol(shape_data)\n            self.update_legends()\n\n        def get_shapes(self):\n            shape_data = self.master.get_shape_data()\n            shape_data = self.master.impute_shapes(\n                shape_data, len(self.CurveSymbols) - 1)\n            return self.CurveSymbols[shape_data]\n    ```\n\n    On the widget's side, `get_something_data` is essentially just:\n\n    ```\n        def get_size_data(self):\n            return self.get_column(self.attr_size)\n    ```\n\n    where `get_column` retrieves a column while also filtering out the\n    points with missing x and y and so forth. (Here we present the simplest\n    two cases, \"shapes\" for the view and \"sizes\" for the model. The colors\n    for the view are more complicated since they deal with discrete and\n    continuous palettes, and the shapes for the view merge infrequent shapes.)\n\n    The plot can also show just a random sample of the data. The sample size is\n    set by `set_sample_size`, and the rest is taken care by the plot: the\n    widget keeps providing the data for all points, selection indices refer\n    to the entire set etc. Internally, sampling happens as early as possible\n    (in methods `get_<something>`).\n    \"\"\"\n    too_many_labels = Signal(bool)\n    begin_resizing = Signal()\n    step_resizing = Signal()\n    end_resizing = Signal()\n\n    label_only_selected = Setting(False)\n    point_width = Setting(10)\n    alpha_value = Setting(128)\n    show_grid = Setting(False)\n    show_legend = Setting(True)\n    class_density = Setting(False)\n    jitter_size = Setting(0)\n\n    resolution = 256\n\n    CurveSymbols = np.array(\"o x t + d star ?\".split())\n    MinShapeSize = 6\n    DarkerValue = 120\n    UnknownColor = (168, 50, 168)\n\n    COLOR_DEFAULT = (128, 128, 128)\n\n    MAX_VISIBLE_LABELS = 500\n\n    def __init__(self, scatter_widget, parent=None, view_box=ViewBox):\n        QObject.__init__(self)\n        gui.OWComponent.__init__(self, scatter_widget)\n\n        self.subset_is_shown = False\n        self.jittering_suspended = False\n\n        self.view_box = view_box(self)\n        _axis = {\"left\": AxisItem(\"left\"), \"bottom\": AxisItem(\"bottom\")}\n        self.plot_widget = PlotWidget(\n            viewBox=self.view_box, parent=parent, background=None,\n            axisItems=_axis\n        )\n        self.plot_widget.hideAxis(\"left\")\n        self.plot_widget.hideAxis(\"bottom\")\n        self.plot_widget.getPlotItem().buttonsHidden = True\n        self.plot_widget.setAntialiasing(True)\n        self.plot_widget.sizeHint = lambda: QSize(500, 500)\n\n        self.density_img = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n\n        self.master = scatter_widget\n        tooltip = self._create_drag_tooltip()\n        self.view_box.setDragTooltip(tooltip)\n\n        self.selection = None  # np.ndarray\n\n        self.n_valid = 0\n        self.n_shown = 0\n        self.sample_size = None\n        self.sample_indices = None\n\n        self.palette = None\n\n        self.shape_legend = self._create_legend(((1, 0), (1, 0)))\n        self.color_legend = self._create_legend(((1, 1), (1, 1)))\n        self.update_legend_visibility()\n\n        self.scale = None  # DiscretizedScale\n        self._too_many_labels = False\n\n        # self.setMouseTracking(True)\n        # self.grabGesture(QPinchGesture)\n        # self.grabGesture(QPanGesture)\n\n        self.update_grid_visibility()\n\n        self._tooltip_delegate = EventDelegate(self.help_event)\n        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)\n        self.view_box.sigTransformChanged.connect(self.update_density)\n        self.view_box.sigRangeChangedManually.connect(self.update_labels)\n\n        self.timer = None\n\n        self.parameter_setter = ScatterBaseParameterSetter(self)\n\n    def _create_legend(self, anchor):\n        legend = LegendItem()\n        legend.setParentItem(self.plot_widget.getViewBox())\n        legend.restoreAnchor(anchor)\n        return legend\n\n    def _create_drag_tooltip(self):\n        tip_parts = [\n            (Qt.ControlModifier,\n             \"{}: Append to group\".\n             format(\"Cmd\" if sys.platform == \"darwin\" else \"Ctrl\")),\n            (Qt.ShiftModifier, \"Shift: Add group\"),\n            (Qt.AltModifier, \"Alt: Remove\")\n        ]\n        all_parts = \"<center>\" + \\\n                    \", \".join(part for _, part in tip_parts) + \\\n                    \"</center>\"\n        self.tiptexts = {\n            modifier: all_parts.replace(part, \"<b>{}</b>\".format(part))\n            for modifier, part in tip_parts\n        }\n        self.tiptexts[Qt.NoModifier] = all_parts\n\n        self.tip_textitem = text = QGraphicsTextItem()\n        # Set to the longest text\n        text.setHtml(self.tiptexts[Qt.ControlModifier])\n        text.setPos(4, 2)\n        r = text.boundingRect()\n        text.setTextWidth(r.width())\n        rect = QGraphicsRectItem(0, 0, r.width() + 8, r.height() + 4)\n        color = self.plot_widget.palette().color(QPalette.Disabled, QPalette.Window)\n        color.setAlpha(212)\n        rect.setBrush(color)\n        rect.setPen(QPen(Qt.NoPen))\n        self.update_tooltip()\n\n        tooltip_group = QGraphicsItemGroup()\n        tooltip_group.addToGroup(rect)\n        tooltip_group.addToGroup(text)\n        return tooltip_group\n\n    def update_tooltip(self, modifiers=Qt.NoModifier):\n        text = self.tiptexts[Qt.NoModifier]\n        for mod in [Qt.ControlModifier,\n                    Qt.ShiftModifier,\n                    Qt.AltModifier]:\n            if modifiers & mod:\n                text = self.tiptexts.get(mod)\n                break\n        self.tip_textitem.setHtml(text)\n\n    def suspend_jittering(self):\n        if self.jittering_suspended:\n            return\n        self.jittering_suspended = True\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def unsuspend_jittering(self):\n        if not self.jittering_suspended:\n            return\n        self.jittering_suspended = False\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def update_jittering(self):\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0 or self.scatterplot_item is None:\n            return\n        self.scatterplot_item.setCoordinates(x, y)\n        self.scatterplot_item_sel.setCoordinates(x, y)\n        self.update_labels()\n\n    # TODO: Rename to remove_plot_items\n    def clear(self):\n        \"\"\"\n        Remove all graphical elements from the plot\n\n        Calls the pyqtgraph's plot widget's clear, sets all handles to `None`,\n        removes labels and selections.\n\n        This method should generally not be called by the widget. If the data\n        is gone (*e.g.* upon receiving `None` as an input data signal), this\n        should be handler by calling `reset_graph`, which will in turn call\n        `clear`.\n\n        Derived classes should override this method if they add more graphical\n        elements. For instance, the regression line in the scatterplot adds\n        `self.reg_line_item = None` (the line in the plot is already removed\n        in this method).\n        \"\"\"\n        self.plot_widget.clear()\n\n        self.density_img = None\n        if self.timer is not None and self.timer.isActive():\n            self.timer.stop()\n            self.timer = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n        self._signal_too_many_labels(False)\n        self.view_box.init_history()\n        self.view_box.tag_history()\n\n    # TODO: I hate `keep_something` and `reset_something` arguments\n    # __keep_selection is used exclusively be set_sample size which would\n    # otherwise just repeat the code from reset_graph except for resetting\n    # the selection. I'm uncomfortable with this; we may prefer to have a\n    # method _reset_graph which does everything except resetting the selection,\n    # and reset_graph would call it.\n    def reset_graph(self, __keep_selection=False):\n        \"\"\"\n        Reset the graph to new data (or no data)\n\n        The method must be called when the plot receives new data, in\n        particular when the number of points change. If only their properties\n        - like coordinates or shapes - change, an update method\n        (`update_coordinates`, `update_shapes`...) should be called instead.\n\n        The method must also be called when the data is gone.\n\n        The method calls `clear`, followed by calls of all update methods.\n\n        NB. Argument `__keep_selection` is for internal use only\n        \"\"\"\n        self.clear()\n        if not __keep_selection:\n            self.selection = None\n        self.sample_indices = None\n        self.update_coordinates()\n        self.update_point_props()\n\n    def set_sample_size(self, sample_size):\n        \"\"\"\n        Set the sample size\n\n        Args:\n            sample_size (int or None): sample size or `None` to show all points\n        \"\"\"\n        if self.sample_size != sample_size:\n            self.sample_size = sample_size\n            self.reset_graph(True)\n\n    def update_point_props(self):\n        \"\"\"\n        Update the sizes, colors, shapes and labels\n\n        The method calls the appropriate update methods for individual\n        properties.\n        \"\"\"\n        self.update_sizes()\n        self.update_colors()\n        self.update_selection_colors()\n        self.update_shapes()\n        self.update_labels()\n\n    # Coordinates\n    # TODO: It could be nice if this method was run on entire data, not just\n    # a sample. For this, however, it would need to either be called from\n    # `get_coordinates` before sampling (very ugly) or call\n    # `self.master.get_coordinates_data` (beyond ugly) or the widget would\n    # have to store the ranges of unsampled data (ugly).\n    # Maybe we leave it as it is.\n    def _reset_view(self, x_data, y_data):\n        \"\"\"\n        Set the range of the view box\n\n        Args:\n            x_data (np.ndarray): x coordinates\n            y_data (np.ndarray) y coordinates\n        \"\"\"\n        min_x, max_x = np.min(x_data), np.max(x_data)\n        min_y, max_y = np.min(y_data), np.max(y_data)\n        self.view_box.setRange(\n            QRectF(min_x, min_y, max_x - min_x or 1, max_y - min_y or 1),\n            padding=0.025)\n\n    def _filter_visible(self, data):\n        \"\"\"Return the sample from the data using the stored sample_indices\"\"\"\n        if data is None or self.sample_indices is None:\n            return data\n        else:\n            return np.asarray(data[self.sample_indices])\n\n    def get_coordinates(self):\n        \"\"\"\n        Prepare coordinates of the points in the plot\n\n        The method is called by `update_coordinates`. It gets the coordinates\n        from the widget, jitters them and return them.\n\n        The methods also initializes the sample indices if neededd and stores\n        the original and sampled number of points.\n\n        Returns:\n            (tuple): a pair of numpy arrays containing (sampled) coordinates,\n                or `(None, None)`.\n        \"\"\"\n        x, y = self.master.get_coordinates_data()\n        if x is None:\n            self.n_valid = self.n_shown = 0\n            return None, None\n        self.n_valid = len(x)\n        self._create_sample()\n        x = self._filter_visible(x)\n        y = self._filter_visible(y)\n        # Jittering after sampling is OK if widgets do not change the sample\n        # semi-permanently, e.g. take a sample for the duration of some\n        # animation. If the sample size changes dynamically (like by adding\n        # a \"sample size\" slider), points would move around when the sample\n        # size changes. To prevent this, jittering should be done before\n        # sampling (i.e. two lines earlier). This would slow it down somewhat.\n        x, y = self.jitter_coordinates(x, y)\n        return x, y\n\n    def _create_sample(self):\n        \"\"\"\n        Create a random sample if the data is larger than the set sample size\n        \"\"\"\n        self.n_shown = min(self.n_valid, self.sample_size or self.n_valid)\n        if self.sample_size is not None \\\n                and self.sample_indices is None \\\n                and self.n_valid != self.n_shown:\n            random = np.random.RandomState(seed=0)\n            self.sample_indices = random.choice(\n                self.n_valid, self.n_shown, replace=False)\n            # TODO: Is this really needed?\n            np.sort(self.sample_indices)\n\n    def jitter_coordinates(self, x, y):\n        \"\"\"\n        Display coordinates to random positions within ellipses with\n        radiuses of `self.jittter_size` percents of spans\n        \"\"\"\n        if self.jitter_size == 0 or self.jittering_suspended:\n            return x, y\n        return self._jitter_data(x, y)\n\n    def _jitter_data(self, x, y, span_x=None, span_y=None):\n        if span_x is None:\n            span_x = np.max(x) - np.min(x)\n        if span_y is None:\n            span_y = np.max(y) - np.min(y)\n        random = np.random.RandomState(seed=0)\n        rs = random.uniform(0, 1, len(x))\n        phis = random.uniform(0, 2 * np.pi, len(x))\n        magnitude = self.jitter_size / 100\n        return (x + magnitude * span_x * rs * np.cos(phis),\n                y + magnitude * span_y * rs * np.sin(phis))\n\n    def update_coordinates(self):\n        \"\"\"\n        Trigger the update of coordinates while keeping other features intact.\n\n        The method gets the coordinates by calling `self.get_coordinates`,\n        which in turn calls the widget's `get_coordinate_data`. The number of\n        coordinate pairs returned by the latter must match the current number\n        of points. If this is not the case, the widget should trigger\n        the complete update by calling `reset_graph` instead of this method.\n        \"\"\"\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0:\n            return\n\n        self._reset_view(x, y)\n        if self.scatterplot_item is None:\n            if self.sample_indices is None:\n                indices = np.arange(self.n_valid)\n            else:\n                indices = self.sample_indices\n            kwargs = dict(x=x, y=y, data=indices)\n            self.scatterplot_item = ScatterPlotItem(**kwargs)\n            self.scatterplot_item.sigClicked.connect(self.select_by_click)\n            self.scatterplot_item_sel = ScatterPlotItem(**kwargs)\n            self.plot_widget.addItem(self.scatterplot_item_sel)\n            self.plot_widget.addItem(self.scatterplot_item)\n        else:\n            self.scatterplot_item.setCoordinates(x, y)\n            self.scatterplot_item_sel.setCoordinates(x, y)\n            self.update_labels()\n\n        self.update_density()  # Todo: doesn't work: try MDS with density on\n\n    # Sizes\n    def get_sizes(self):\n        \"\"\"\n        Prepare data for sizes of points in the plot\n\n        The method is called by `update_sizes`. It gets the sizes\n        from the widget and performs the necessary scaling and sizing.\n        The output is rounded to half a pixel for faster drawing.\n\n        Returns:\n            (np.ndarray): sizes\n        \"\"\"\n        size_column = self.master.get_size_data()\n        if size_column is None:\n            return np.full((self.n_shown,),\n                           self.MinShapeSize + (5 + self.point_width) * 0.5)\n        size_column = self._filter_visible(size_column)\n        size_column = size_column.copy()\n        with warnings.catch_warnings():\n            warnings.simplefilter(\"ignore\", category=RuntimeWarning)\n            size_column -= np.nanmin(size_column)\n            mx = np.nanmax(size_column)\n        if mx > 0:\n            size_column /= mx\n        else:\n            size_column[:] = 0.5\n\n        sizes = self.MinShapeSize + (5 + self.point_width) * size_column\n        # round sizes to half pixel for smaller pyqtgraph's symbol pixmap atlas\n        sizes = (sizes * 2).round() / 2\n        return sizes\n\n    def update_sizes(self):\n        \"\"\"\n        Trigger an update of point sizes\n\n        The method calls `self.get_sizes`, which in turn calls the widget's\n        `get_size_data`. The result are properly scaled and then passed\n        back to widget for imputing (`master.impute_sizes`).\n        \"\"\"\n        if self.scatterplot_item:\n            size_data = self.get_sizes()\n            size_imputer = getattr(\n                self.master, \"impute_sizes\", self.default_impute_sizes)\n            size_imputer(size_data)\n\n            if self.timer is not None and self.timer.isActive():\n                self.timer.stop()\n                self.timer = None\n\n            current_size_data = self.scatterplot_item.data[\"size\"].copy()\n            diff = size_data - current_size_data\n            widget = self\n\n            class Timeout:\n                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2\n                factors = [0.07, 0.16, 0.27, 0.41, 0.55,\n                           0.68, 0.81, 0.9, 0.97, 1]\n\n                def __init__(self):\n                    self._counter = 0\n\n                def __call__(self):\n                    factor = self.factors[self._counter]\n                    self._counter += 1\n                    size = current_size_data + diff * factor\n                    if len(self.factors) == self._counter:\n                        widget.timer.stop()\n                        widget.timer = None\n                        size = size_data\n                    widget.scatterplot_item.setSize(size)\n                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)\n                    if widget.timer is None:\n                        widget.end_resizing.emit()\n                    else:\n                        widget.step_resizing.emit()\n\n            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \\\n                    np.all(current_size_data > 0) and np.any(diff != 0):\n                # If encountered any strange behaviour when updating sizes,\n                # implement it with threads\n                self.begin_resizing.emit()\n                interval = int(500 / len(Timeout.factors))\n                self.timer = QTimer(self.scatterplot_item, interval=interval)\n                self.timer.timeout.connect(Timeout())\n                self.timer.start()\n            else:\n                self.begin_resizing.emit()\n                self.scatterplot_item.setSize(size_data)\n                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)\n                self.end_resizing.emit()\n\n    update_point_size = update_sizes  # backward compatibility (needed?!)\n    update_size = update_sizes\n\n    @classmethod\n    def default_impute_sizes(cls, size_data):\n        \"\"\"\n        Fallback imputation for sizes.\n\n        Set the size to two pixels smaller than the minimal size\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        nans = np.isnan(size_data)\n        if np.any(nans):\n            size_data[nans] = cls.MinShapeSize - 2\n            return True\n        else:\n            return False\n\n    # Colors\n    def get_colors(self):\n        \"\"\"\n        Prepare data for colors of the points in the plot\n\n        The method is called by `update_colors`. It gets the colors and the\n        indices of the data subset from the widget (`get_color_data`,\n        `get_subset_mask`), and constructs lists of pens and brushes for\n        each data point.\n\n        The method uses different palettes for discrete and continuous data,\n        as determined by calling the widget's method `is_continuous_color`.\n\n        If also marks the points that are in the subset as defined by, for\n        instance the 'Data Subset' signal in the Scatter plot and similar\n        widgets. (Do not confuse this with *selected points*, which are\n        marked by circles around the points, which are colored by groups\n        and thus independent of this method.)\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        c_data = self.master.get_color_data()\n        c_data = self._filter_visible(c_data)\n        subset = self.master.get_subset_mask()\n        subset = self._filter_visible(subset)\n        self.subset_is_shown = subset is not None\n        if c_data is None:  # same color\n            self.palette = None\n            return self._get_same_colors(subset)\n        elif self.master.is_continuous_color():\n            return self._get_continuous_colors(c_data, subset)\n        else:\n            return self._get_discrete_colors(c_data, subset)\n\n    def _get_same_colors(self, subset, color=COLOR_DEFAULT):\n        \"\"\"\n        Return the same pen for all points while the brush color depends\n        upon whether the point is in the subset or not\n\n        Args:\n            subset (np.ndarray): a bool array indicating whether a data point\n                is in the subset or not (e.g. in the 'Data Subset' signal\n                in the Scatter plot and similar widgets);\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        alpha_subset, alpha_unset = self._alpha_for_subsets()\n        if subset is not None:\n            qcolor = QColor(*color, alpha_subset)\n            brush = np.where(subset, QBrush(qcolor), QBrush(QColor(0, 0, 0, 0)))\n            pen = np.where(subset,\n                           _make_pen(qcolor, 1.5),\n                           _make_pen(QColor(*color, alpha_unset), 1.5))\n        else:\n            qcolor = QColor(*color, self.alpha_value)\n            brush = np.full(self.n_shown, QBrush(qcolor))\n            pen = [_make_pen(qcolor, 1.5)] * self.n_shown\n        return pen, brush\n\n    def _get_continuous_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a continuous palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        palette = self.master.get_palette()\n\n        if np.isnan(c_data).all():\n            self.palette = palette\n            return self._get_same_colors(subset, self.palette.nan_color)\n\n        self.scale = DiscretizedScale(np.nanmin(c_data), np.nanmax(c_data))\n        bins = self.scale.get_bins()\n        self.palette = \\\n            colorpalettes.BinnedContinuousPalette.from_palette(palette, bins)\n        colors = self.palette.values_to_colors(c_data)\n        alphas = np.full((len(c_data), 1), self.alpha_value, dtype=np.ubyte)\n        brush = np.hstack((colors, alphas))\n        pen = np.hstack(\n            ((colors.astype(dtype=float) * 100 / self.DarkerValue).astype(np.ubyte),\n             alphas))\n\n        # Reuse pens and brushes with the same colors because PyQtGraph then\n        # builds smaller pixmap atlas, which makes the drawing faster\n\n        def reuse(cache, fun, *args):\n            if args not in cache:\n                cache[args] = fun(args)\n            return cache[args]\n\n        def create_pen(col):\n            return _make_pen(QColor(*col), 1.5)\n\n        def create_brush(col):\n            return QBrush(QColor(*col))\n\n        if subset is not None:\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            brush[:, 3] = 0\n            brush[subset, 3] = alpha_subset\n            pen[:, 3] = alpha_unset\n            brush[subset, 3] = alpha_subset\n\n        cached_pens = {}\n        pen = [reuse(cached_pens, create_pen, *col) for col in pen.tolist()]\n        cached_brushes = {}\n        brush = np.array([reuse(cached_brushes, create_brush, *col)\n                          for col in brush.tolist()])\n\n        return pen, brush\n\n    def _get_discrete_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a discrete palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        self.palette = self.master.get_palette()\n        c_data = c_data.copy()\n        c_data[np.isnan(c_data)] = len(self.palette)\n        c_data = c_data.astype(int)\n        colors = self.palette.qcolors_w_nan\n        if subset is None:\n            for col in colors:\n                col.setAlpha(self.alpha_value)\n            pens = np.array(\n                [_make_pen(col.darker(self.DarkerValue), 1.5)\n                 for col in colors])\n            pen = pens[c_data]\n            brushes = np.array([QBrush(col) for col in colors])\n            brush = brushes[c_data]\n        else:\n            subset_colors = [QColor(col) for col in colors]\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            for col in subset_colors:\n                col.setAlpha(alpha_subset)\n            for col in colors:\n                col.setAlpha(alpha_unset)\n\n            pens, subset_pens = (\n                np.array(\n                    [_make_pen(col.darker(self.DarkerValue), 1.5)\n                     for col in cols])\n                for cols in (colors, subset_colors))\n            pen = np.where(subset, subset_pens[c_data], pens[c_data])\n\n            brushes = np.array([QBrush(col) for col in subset_colors])\n            brush = brushes[c_data]\n            black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))\n            brush = np.where(subset, brush, black)\n        return pen, brush\n\n    def _alpha_for_subsets(self):\n        a, b, c = 1.2, -3.2, 3\n        x = self.alpha_value / 255\n        alpha_subset = 31 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))\n        x = 1 - x\n        alpha_unset = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))\n        return alpha_subset, alpha_unset\n\n    def update_colors(self):\n        \"\"\"\n        Trigger an update of point colors\n\n        The method calls `self.get_colors`, which in turn calls the widget's\n        `get_color_data` to get the indices in the pallette. `get_colors`\n        returns a list of pens and brushes to which this method uses to\n        update the colors. Finally, the method triggers the update of the\n        legend and the density plot.\n        \"\"\"\n        if self.scatterplot_item is not None:\n            pen_data, brush_data = self.get_colors()\n            self.scatterplot_item.setPen(pen_data, update=False, mask=None)\n            self.scatterplot_item.setBrush(brush_data, mask=None)\n        self.update_z_values()\n        self.update_legends()\n        self.update_density()\n\n    update_alpha_value = update_colors\n\n    def update_density(self):\n        \"\"\"\n        Remove the existing density plot (if there is one) and replace it\n        with a new one (if enabled).\n\n        The method gets the colors from the pens of the currently plotted\n        points.\n        \"\"\"\n        if self.density_img:\n            self.plot_widget.removeItem(self.density_img)\n            self.density_img = None\n        if self.class_density and self.scatterplot_item is not None:\n            c_data = self.master.get_color_data()\n            if c_data is None:\n                return\n            visible_c_data = self._filter_visible(c_data)\n            mask = np.isfinite(visible_c_data)\n            if not self.master.is_continuous_color():\n                mask = np.bitwise_and(mask, visible_c_data < MAX_COLORS - 1)\n            pens = self.scatterplot_item.data['pen']\n            rgb_data = [\n                pen.color().getRgb()[:3] if pen is not None else (255, 255, 255)\n                for known, pen in zip(mask, pens)\n                if known]\n            if len(set(rgb_data)) <= 1:\n                return\n            [min_x, max_x], [min_y, max_y] = self.view_box.viewRange()\n            x_data, y_data = self.scatterplot_item.getData()\n            self.density_img = classdensity.class_density_image(\n                min_x, max_x, min_y, max_y, self.resolution,\n                x_data[mask], y_data[mask], rgb_data)\n            self.plot_widget.addItem(self.density_img, ignoreBounds=True)\n\n    def update_selection_colors(self):\n        \"\"\"\n        Trigger an update of selection markers\n\n        This update method is usually not called by the widget but by the\n        plot, since it is the plot that handles the selections.\n\n        Like other update methods, it calls the corresponding get method\n        (`get_colors_sel`) which returns a list of pens and brushes.\n        \"\"\"\n        if self.scatterplot_item_sel is None:\n            return\n        pen, brush = self.get_colors_sel()\n        self.scatterplot_item_sel.setPen(pen, update=False, mask=None)\n        self.scatterplot_item_sel.setBrush(brush, mask=None)\n        self.update_z_values()\n\n    def get_colors_sel(self):\n        \"\"\"\n        Return pens and brushes for selection markers.\n\n        A pen can is set to `Qt.NoPen` if a point is not selected.\n\n        All brushes are completely transparent whites.\n\n        Returns:\n            (tuple): a list of pens and a list of brushes\n        \"\"\"\n        nopen = QPen(Qt.NoPen)\n        if self.selection is None:\n            pen = [nopen] * self.n_shown\n        else:\n            sels = np.max(self.selection)\n            if sels == 1:\n                pen = np.where(\n                    self._filter_visible(self.selection),\n                    _make_pen(QColor(255, 190, 0, 255), SELECTION_WIDTH),\n                    nopen)\n            else:\n                palette = colorpalettes.LimitedDiscretePalette(\n                    number_of_colors=sels + 1)\n                pen = np.choose(\n                    self._filter_visible(self.selection),\n                    [nopen] + [_make_pen(palette[i], SELECTION_WIDTH)\n                               for i in range(sels)])\n        return pen, [QBrush(QColor(255, 255, 255, 0))] * self.n_shown\n\n    # Labels\n    def get_labels(self):\n        \"\"\"\n        Prepare data for labels for points\n\n        The method returns the results of the widget's `get_label_data`\n\n        Returns:\n            (labels): a sequence of labels\n        \"\"\"\n        return self._filter_visible(self.master.get_label_data())\n\n    def update_labels(self):\n        \"\"\"\n        Trigger an update of labels\n\n        The method calls `get_labels` which in turn calls the widget's\n        `get_label_data`. The obtained labels are shown if the corresponding\n        points are selected or if `label_only_selected` is `false`.\n        \"\"\"\n        for label in self.labels:\n            self.plot_widget.removeItem(label)\n        self.labels = []\n\n        mask = None\n        if self.scatterplot_item is not None:\n            x, y = self.scatterplot_item.getData()\n            mask = self._label_mask(x, y)\n\n        if mask is not None:\n            labels = self.get_labels()\n            if labels is None:\n                mask = None\n\n        self._signal_too_many_labels(\n            mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)\n        if self._too_many_labels or mask is None or not np.any(mask):\n            return\n\n        foreground = self.plot_widget.palette().color(QPalette.Text)\n        labels = labels[mask]\n        x = x[mask]\n        y = y[mask]\n        for label, xp, yp in zip(labels, x, y):\n            ti = TextItem(label, foreground)\n            ti.setPos(xp, yp)\n            self.plot_widget.addItem(ti)\n            self.labels.append(ti)\n            ti.setFont(self.parameter_setter.label_font)\n\n    def _signal_too_many_labels(self, too_many):\n        if self._too_many_labels != too_many:\n            self._too_many_labels = too_many\n            self.too_many_labels.emit(too_many)\n\n    def _label_mask(self, x, y):\n        (x0, x1), (y0, y1) = self.view_box.viewRange()\n        mask = np.logical_and(\n            np.logical_and(x >= x0, x <= x1),\n            np.logical_and(y >= y0, y <= y1))\n        if self.label_only_selected:\n            sub_mask = self._filter_visible(self.master.get_subset_mask())\n            if self.selection is None:\n                if sub_mask is None:\n                    return None\n                else:\n                    sel_mask = sub_mask\n            else:\n                sel_mask = self._filter_visible(self.selection) != 0\n                if sub_mask is not None:\n                    sel_mask = np.logical_or(sel_mask, sub_mask)\n            mask = np.logical_and(mask, sel_mask)\n        return mask\n\n    # Shapes\n    def get_shapes(self):\n        \"\"\"\n        Prepare data for shapes of points in the plot\n\n        The method is called by `update_shapes`. It gets the data from\n        the widget's `get_shape_data`, and then calls its `impute_shapes`\n        to impute the missing shape (usually with some default shape).\n\n        Returns:\n            (np.ndarray): an array of symbols (e.g. o, x, + ...)\n        \"\"\"\n        shape_data = self.master.get_shape_data()\n        shape_data = self._filter_visible(shape_data)\n        # Data has to be copied so the imputation can change it in-place\n        # TODO: Try avoiding this when we move imputation to the widget\n        if shape_data is not None:\n            shape_data = np.copy(shape_data)\n        shape_imputer = getattr(\n            self.master, \"impute_shapes\", self.default_impute_shapes)\n        shape_imputer(shape_data, len(self.CurveSymbols) - 1)\n        if isinstance(shape_data, np.ndarray):\n            shape_data = shape_data.astype(int)\n        else:\n            shape_data = np.zeros(self.n_shown, dtype=int)\n        return self.CurveSymbols[shape_data]\n\n    @staticmethod\n    def default_impute_shapes(shape_data, default_symbol):\n        \"\"\"\n        Fallback imputation for shapes.\n\n        Use the default symbol, usually the last symbol in the list.\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        if shape_data is None:\n            return False\n        nans = np.isnan(shape_data)\n        if np.any(nans):\n            shape_data[nans] = default_symbol\n            return True\n        else:\n            return False\n\n    def update_shapes(self):\n        \"\"\"\n        Trigger an update of point symbols\n\n        The method calls `get_shapes` to obtain an array with a symbol\n        for each point and uses it to update the symbols.\n\n        Finally, the method updates the legend.\n        \"\"\"\n        if self.scatterplot_item:\n            shape_data = self.get_shapes()\n            self.scatterplot_item.setSymbol(shape_data)\n        self.update_legends()\n\n    def update_z_values(self):\n        \"\"\"\n        Set z-values for point in the plot\n\n        The order is as follows:\n        - selected points that are also in the subset on top,\n        - followed by selected points,\n        - followed by points from the subset,\n        - followed by the rest.\n        Within each of these four groups, points are ordered by their colors.\n\n        Points with less frequent colors are above those with more frequent.\n        The points for which the value for the color is missing are at the\n        bottom of their respective group.\n        \"\"\"\n        if not self.scatterplot_item:\n            return\n\n        subset = self.master.get_subset_mask()\n        c_data = self.master.get_color_data()\n        if subset is None and self.selection is None and c_data is None:\n            self.scatterplot_item.setZ(None)\n            return\n\n        z = np.zeros(self.n_shown)\n\n        if subset is not None:\n            subset = self._filter_visible(subset)\n            z[subset] += 1000\n\n        if self.selection is not None:\n            z[self._filter_visible(self.selection) != 0] += 2000\n\n        if c_data is not None:\n            c_nan = np.isnan(c_data)\n            vis_data = self._filter_visible(c_data)\n            vis_nan = np.isnan(vis_data)\n            z[vis_nan] -= 999\n            if not self.master.is_continuous_color():\n                dist = np.bincount(c_data[~c_nan].astype(int))\n                vis_knowns = vis_data[~vis_nan].astype(int)\n                argdist = np.argsort(dist)\n                z[~vis_nan] -= argdist[vis_knowns]\n\n        self.scatterplot_item.setZ(z)\n\n    def update_grid_visibility(self):\n        \"\"\"Show or hide the grid\"\"\"\n        self.plot_widget.showGrid(x=self.show_grid, y=self.show_grid)\n\n    def update_legend_visibility(self):\n        \"\"\"\n        Show or hide legends based on whether they are enabled and non-empty\n        \"\"\"\n        self.shape_legend.setVisible(\n            self.show_legend and bool(self.shape_legend.items))\n        self.color_legend.setVisible(\n            self.show_legend and bool(self.color_legend.items))\n\n    def update_legends(self):\n        \"\"\"Update content of legends and their visibility\"\"\"\n        cont_color = self.master.is_continuous_color()\n        shape_labels = self.master.get_shape_labels()\n        color_labels = self.master.get_color_labels()\n        if not cont_color and shape_labels is not None \\\n                and shape_labels == color_labels:\n            colors = self.master.get_color_data()\n            shapes = self.master.get_shape_data()\n            mask = np.isfinite(colors) * np.isfinite(shapes)\n            combined = (colors == shapes)[mask].all()\n        else:\n            combined = False\n        if combined:\n            self._update_combined_legend(shape_labels)\n        else:\n            self._update_shape_legend(shape_labels)\n            if cont_color:\n                self._update_continuous_color_legend(color_labels)\n            else:\n                self._update_color_legend(color_labels)\n        self.update_legend_visibility()\n        Updater.update_legend_font(self.parameter_setter.cat_legend_items,\n                                   **self.parameter_setter.cat_legend_settings)\n        Updater.update_num_legend_font(self.parameter_setter.num_legend,\n                                       **self.parameter_setter.num_legend_settings)\n\n    def _update_shape_legend(self, labels):\n        self.shape_legend.clear()\n        if labels is None or self.scatterplot_item is None:\n            return\n        color = QColor(0, 0, 0)\n        color.setAlpha(self.alpha_value)\n        for label, symbol in zip(labels, self.CurveSymbols):\n            self.shape_legend.addItem(\n                SymbolItemSample(pen=color, brush=color, size=10, symbol=symbol),\n                escape(label))\n\n    def _update_continuous_color_legend(self, label_formatter: Callable[[float], str]):\n        self.color_legend.clear()\n        if self.scale is None or self.scatterplot_item is None:\n            return\n        label = PaletteItemSample(self.palette, self.scale, label_formatter)\n        self.color_legend.addItem(label, \"\")\n        self.color_legend.setGeometry(label.boundingRect())\n\n    def _update_color_legend(self, labels):\n        self.color_legend.clear()\n        if labels is None:\n            return\n        self._update_colored_legend(self.color_legend, labels, 'o')\n\n    def _update_combined_legend(self, labels):\n        # update_colored_legend will already clear the shape legend\n        # so we remove colors here\n        use_legend = \\\n            self.shape_legend if self.shape_legend.items else self.color_legend\n        self.color_legend.clear()\n        self.shape_legend.clear()\n        self._update_colored_legend(use_legend, labels, self.CurveSymbols)\n\n    def _update_colored_legend(self, legend, labels, symbols):\n        if self.scatterplot_item is None or not self.palette:\n            return\n        if isinstance(symbols, str):\n            symbols = itertools.repeat(symbols, times=len(labels))\n        colors = self.palette.values_to_colors(np.arange(len(labels)))\n        for color, label, symbol in zip(colors, labels, symbols):\n            color = QColor(*color)\n            pen = _make_pen(color.darker(self.DarkerValue), 1.5)\n            color.setAlpha(self.alpha_value)\n            brush = QBrush(color)\n            legend.addItem(\n                SymbolItemSample(pen=pen, brush=brush, size=10, symbol=symbol),\n                escape(label))\n\n    def zoom_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def pan_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().PanMode)\n\n    def select_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def reset_button_clicked(self):\n        self.plot_widget.getViewBox().autoRange()\n        self.update_labels()\n\n    def select_by_click(self, _, points):\n        if self.scatterplot_item is not None:\n            self.select(points)\n\n    def select_by_rectangle(self, rect):\n        if self.scatterplot_item is not None:\n            x0, x1 = sorted((rect.topLeft().x(), rect.bottomRight().x()))\n            y0, y1 = sorted((rect.topLeft().y(), rect.bottomRight().y()))\n            x, y = self.master.get_coordinates_data()\n            indices = np.flatnonzero(\n                (x0 <= x) & (x <= x1) & (y0 <= y) & (y <= y1))\n            self.select_by_indices(indices.astype(int))\n\n    def unselect_all(self):\n        if self.selection is not None:\n            self.selection = None\n            self.update_selection_colors()\n            if self.label_only_selected:\n                self.update_labels()\n            self.master.selection_changed()\n\n    def select(self, points):\n        # noinspection PyArgumentList\n        if self.scatterplot_item is None:\n            return\n        indices = [p.data() for p in points]\n        self.select_by_indices(indices)\n\n    def select_by_indices(self, indices):\n        if self.selection is None:\n            self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        keys = QApplication.keyboardModifiers()\n        if keys & Qt.ControlModifier:\n            self.selection_append(indices)\n        elif keys & Qt.ShiftModifier:\n            self.selection_new_group(indices)\n        elif keys & Qt.AltModifier:\n            self.selection_remove(indices)\n        else:\n            self.selection_select(indices)\n\n    def selection_select(self, indices):\n        self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        self.selection[indices] = 1\n        self._update_after_selection()\n\n    def selection_append(self, indices):\n        self.selection[indices] = max(np.max(self.selection), 1)\n        self._update_after_selection()\n\n    def selection_new_group(self, indices):\n        self.selection[indices] = np.max(self.selection) + 1\n        self._update_after_selection()\n\n    def selection_remove(self, indices):\n        self.selection[indices] = 0\n        self._update_after_selection()\n\n    def _update_after_selection(self):\n        self._compress_indices()\n        self.update_selection_colors()\n        if self.label_only_selected:\n            self.update_labels()\n        self.master.selection_changed()\n\n    def _compress_indices(self):\n        indices = sorted(set(self.selection) | {0})\n        if len(indices) == max(indices) + 1:\n            return\n        mapping = np.zeros((max(indices) + 1,), dtype=int)\n        for i, ind in enumerate(indices):\n            mapping[ind] = i\n        self.selection = mapping[self.selection]\n\n    def get_selection(self):\n        if self.selection is None:\n            return np.array([], dtype=np.uint8)\n        else:\n            return np.flatnonzero(self.selection)\n\n    def help_event(self, event):\n        \"\"\"\n        Create a `QToolTip` for the point hovered by the mouse\n        \"\"\"\n        if self.scatterplot_item is None:\n            return False\n        act_pos = self.scatterplot_item.mapFromScene(event.scenePos())\n        point_data = [p.data() for p in self.scatterplot_item.pointsAt(act_pos)]\n        text = self.master.get_tooltip(point_data)\n        if text:\n            QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)\n            return True\n        else:\n            return False\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/visualize/owscatterplotgraph.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "80bddde56",
                "new_commit_hash": "db81a89df",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/visualize/owscatterplotgraph.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/visualize/owscatterplotgraph.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 302,
                            "length": 7
                        },
                        "new_range": {
                            "start": 302,
                            "length": 10
                        },
                        "section": "class AxisItem(AxisItem):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "            step = int(np.ceil(float(len(ticks)) / max_steps))",
                                "type": "context"
                            },
                            {
                                "content": "            ticks = ticks[::step]",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))",
                                "type": "deleted"
                            },
                            {
                                "content": "        # In case of a single tick, `default` will inform tickStrings",
                                "type": "added"
                            },
                            {
                                "content": "        # about the appropriate scale.",
                                "type": "added"
                            },
                            {
                                "content": "        spacing = min((b - a for a, b in zip(ticks[:-1], ticks[1:])),",
                                "type": "added"
                            },
                            {
                                "content": "                      default=maxVal - minVal)",
                                "type": "added"
                            },
                            {
                                "content": "        return [(spacing, ticks)]",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def tickStrings(self, values, scale, spacing):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/owscatterplotgraph.py",
                            "type": "method",
                            "name": "AxisItem.tickValues",
                            "content": "class AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 274,
                            "end_lineno": 306,
                            "parent": {
                                "file_name": "Orange/widgets/visualize/owscatterplotgraph.py",
                                "type": "class",
                                "name": "AxisItem",
                                "content": "class AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 258,
                                "end_lineno": 337,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/visualize/owscatterplotgraph.py",
                            "type": "class",
                            "name": "AxisItem",
                            "content": "class AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 258,
                            "end_lineno": 337,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring,too-many-public-methods,protected-access\n# pylint: disable=too-many-lines\nfrom unittest.mock import MagicMock, patch, Mock\nimport numpy as np\n\nfrom AnyQt.QtCore import QRectF, Qt\nfrom AnyQt.QtWidgets import QToolTip\nfrom AnyQt.QtGui import QColor, QFont\n\nfrom Orange.data import (\n    Table, Domain, ContinuousVariable, DiscreteVariable, TimeVariable\n)\nfrom Orange.widgets.tests.base import (\n    WidgetTest, WidgetOutputsTestMixin, datasets, ProjectionWidgetTestMixin\n)\nfrom Orange.widgets.tests.utils import simulate, excepthook_catch\nfrom Orange.widgets.utils.colorpalettes import DefaultRGBColors\nfrom Orange.widgets.visualize.owscatterplot import (\n    OWScatterPlot, ScatterPlotVizRank, OWScatterPlotGraph)\nfrom Orange.widgets.visualize.utils.widget import MAX_COLORS\nfrom Orange.widgets.widget import AttributeList\n\n\nclass TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)\n\n\nif __name__ == \"__main__\":\n    import unittest\n    unittest.main()\n",
            "new_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring,too-many-public-methods,protected-access\n# pylint: disable=too-many-lines\nfrom unittest.mock import MagicMock, patch, Mock\nimport numpy as np\n\nfrom AnyQt.QtCore import QRectF, Qt\nfrom AnyQt.QtWidgets import QToolTip\nfrom AnyQt.QtGui import QColor, QFont\n\nfrom Orange.data import (\n    Table, Domain, ContinuousVariable, DiscreteVariable, TimeVariable\n)\nfrom Orange.widgets.tests.base import (\n    WidgetTest, WidgetOutputsTestMixin, datasets, ProjectionWidgetTestMixin\n)\nfrom Orange.widgets.tests.utils import simulate, excepthook_catch\nfrom Orange.widgets.utils.colorpalettes import DefaultRGBColors\nfrom Orange.widgets.visualize.owscatterplot import (\n    OWScatterPlot, ScatterPlotVizRank, OWScatterPlotGraph)\nfrom Orange.widgets.visualize.utils.widget import MAX_COLORS\nfrom Orange.widgets.widget import AttributeList\n\n\nclass TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n        self.assertEqual(spacing, 1582953776 - 1581953776)\n        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)\n\n\nif __name__ == \"__main__\":\n    import unittest\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/visualize/tests/test_owscatterplot.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "88802d632",
                "new_commit_hash": "51e2b39ad",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/visualize/tests/test_owscatterplot.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/visualize/tests/test_owscatterplot.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 1130,
                            "length": 6
                        },
                        "new_range": {
                            "start": 1130,
                            "length": 10
                        },
                        "section": "class TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        with self.assertRaises(ValueError):",
                                "type": "context"
                            },
                            {
                                "content": "            float(ticks[0])",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(spacing, 1582953776 - 1581953776)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "    def test_clear_plot(self):",
                                "type": "context"
                            },
                            {
                                "content": "        self.widget.cb_class_density.setChecked(True)",
                                "type": "context"
                            },
                            {
                                "content": "        self.send_signal(self.widget.Inputs.data, self.data)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_owscatterplot.py",
                            "type": "class",
                            "name": "TestOWScatterPlot",
                            "content": "class TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n        self.assertEqual(spacing, 1582953776 - 1581953776)\n        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 25,
                            "end_lineno": 1183,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/widgets/visualize/tests/test_owscatterplot.py",
                            "type": "method",
                            "name": "TestOWScatterPlot.test_time_axis",
                            "content": "class TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n        self.assertEqual(spacing, 1582953776 - 1581953776)\n        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 1108,
                            "end_lineno": 1135,
                            "parent": {
                                "file_name": "Orange/widgets/visualize/tests/test_owscatterplot.py",
                                "type": "class",
                                "name": "TestOWScatterPlot",
                                "content": "class TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n        self.assertEqual(spacing, 1582953776 - 1581953776)\n        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 25,
                                "end_lineno": 1183,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "ba814bd7c2ff10e3daf74b6f32cc596ce2255029^",
    "new_commit_hash": "ba814bd7c2ff10e3daf74b6f32cc596ce2255029",
    "commit_message": "Merge pull request #6144 from janezd/scatterplot-time-ticks\n\nScatterplot: Fix crash for a single time tick",
    "commit_date": "2022-09-30T09:38:34+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "ba814bd7c2ff10e3daf74b6f32cc596ce2255029",
    "test_file_codes": [
        "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring,too-many-public-methods,protected-access\n# pylint: disable=too-many-lines\nfrom unittest.mock import MagicMock, patch, Mock\nimport numpy as np\n\nfrom AnyQt.QtCore import QRectF, Qt\nfrom AnyQt.QtWidgets import QToolTip\nfrom AnyQt.QtGui import QColor, QFont\n\nfrom Orange.data import (\n    Table, Domain, ContinuousVariable, DiscreteVariable, TimeVariable\n)\nfrom Orange.widgets.tests.base import (\n    WidgetTest, WidgetOutputsTestMixin, datasets, ProjectionWidgetTestMixin\n)\nfrom Orange.widgets.tests.utils import simulate, excepthook_catch\nfrom Orange.widgets.utils.colorpalettes import DefaultRGBColors\nfrom Orange.widgets.visualize.owscatterplot import (\n    OWScatterPlot, ScatterPlotVizRank, OWScatterPlotGraph)\nfrom Orange.widgets.visualize.utils.widget import MAX_COLORS\nfrom Orange.widgets.widget import AttributeList\n\n\nclass TestOWScatterPlot(WidgetTest, ProjectionWidgetTestMixin,\n                        WidgetOutputsTestMixin):\n    @classmethod\n    def setUpClass(cls):\n        super().setUpClass()\n        WidgetOutputsTestMixin.init(cls)\n        cls.same_input_output_domain = False\n\n        cls.signal_name = \"Data\"\n        cls.signal_data = cls.data\n\n    def setUp(self):\n        self.widget = self.create_widget(OWScatterPlot)\n\n    def test_set_data(self):\n        # Connect iris to scatter plot\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        # First two attribute should be selected as x an y\n        self.assertEqual(self.widget.attr_x, self.data.domain[0])\n        self.assertEqual(self.widget.attr_y, self.data.domain[1])\n\n        # Class var should be selected as color\n        self.assertIs(self.widget.attr_color, self.data.domain.class_var)\n\n        # Change which attributes are displayed\n        self.widget.attr_x = self.data.domain[2]\n        self.widget.attr_y = self.data.domain[3]\n\n        # Disconnect the data\n        self.send_signal(self.widget.Inputs.data, None)\n\n        # removing data should have cleared attributes\n        self.assertIsNone(self.widget.attr_x)\n        self.assertIsNone(self.widget.attr_y)\n        self.assertIsNone(self.widget.attr_color)\n\n        # and remove the legend\n        self.assertEqual(len(self.widget.graph.color_legend.items), 0)\n\n        # Connect iris again\n        # same attributes that were used last time should be selected\n        self.send_signal(self.widget.Inputs.data, self.data)\n\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n\n    def test_score_heuristics(self):\n        domain = Domain([ContinuousVariable(c) for c in \"abcd\"],\n                        DiscreteVariable(\"e\", values=\"ab\"))\n        a = np.arange(10).reshape((10, 1))\n        data = Table(domain, np.hstack([a, a, a, a]), a >= 5)\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        self.assertEqual([x.name for x in vizrank.score_heuristic()],\n                         list(\"abcd\"))\n\n    def test_optional_combos(self):\n        domain = self.data.domain\n        d1 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[2]])\n        t1 = self.data.transform(d1)\n        self.send_signal(self.widget.Inputs.data, t1)\n        self.widget.graph.attr_size = domain.attributes[2]\n\n        d2 = Domain(domain.attributes[:2], domain.class_var,\n                    [domain.attributes[3]])\n        t2 = self.data.transform(d2)\n        self.send_signal(self.widget.Inputs.data, t2)\n\n    def test_error_message(self):\n        \"\"\"Check if error message appears and then disappears when\n        data is removed from input\"\"\"\n        data = self.data.copy()\n        with data.unlocked():\n            data.X[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertTrue(self.widget.Warning.missing_coords.is_shown())\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.Warning.missing_coords.is_shown())\n\n    def test_report_on_empty(self):\n        self.widget.report_plot = MagicMock()\n        self.widget.report_caption = MagicMock()\n        self.widget.report_items = MagicMock()\n        self.widget.send_report()  # Essentially, don't crash\n        self.widget.report_plot.assert_not_called()\n        self.widget.report_caption.assert_not_called()\n        self.widget.report_items.assert_not_called()\n\n    def test_data_column_nans(self):\n        \"\"\"\n        ValueError cannot convert float NaN to integer.\n        In case when all column values are NaN then it throws that error.\n        GH-2061\n        \"\"\"\n        table = datasets.data_one_column_nans()\n        self.send_signal(self.widget.Inputs.data, table)\n        cb_attr_color = self.widget.controls.attr_color\n        simulate.combobox_activate_item(cb_attr_color, \"b\")\n        simulate.combobox_activate_item(self.widget.cb_attr_x, \"a\")\n        simulate.combobox_activate_item(self.widget.cb_attr_y, \"a\")\n\n        #self.widget.update_graph()\n        self.widget.graph.reset_graph()\n\n    def test_data_column_infs(self):\n        \"\"\"\n        Scatter Plot should not crash on data with infinity values\n        GH-2707\n        GH-2684\n        \"\"\"\n        table = datasets.data_one_column_infs()\n        self.send_signal(self.widget.Inputs.data, table)\n        attr_x = self.widget.controls.attr_x\n        simulate.combobox_activate_item(attr_x, \"b\")\n\n    def test_regression_line(self):\n        \"\"\"It is possible to draw the line only for pair of continuous attrs\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n        self.widget.cb_reg_line.setChecked(True)\n        self.assertIsNotNone(self.widget.graph.reg_line_item)\n        self.widget.cb_attr_y.activated.emit(4)\n        self.widget.cb_attr_y.setCurrentIndex(4)\n        self.assertFalse(self.widget.cb_reg_line.isEnabled())\n        self.assertIsNone(self.widget.graph.reg_line_item)\n\n    def test_points_combo_boxes(self):\n        \"\"\"Check Point box combo models and values\"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        controls = self.widget.controls\n\n        # color and label should contain all variables\n        # size should contain only continuous variables\n        # shape should contain only discrete variables\n        for var in self.data.domain.variables + self.data.domain.metas:\n            self.assertIn(var, controls.attr_color.model())\n            self.assertIn(var, controls.attr_label.model())\n            if var.is_continuous:\n                self.assertIn(var, controls.attr_size.model())\n                self.assertNotIn(var, controls.attr_shape.model())\n            if var.is_discrete:\n                self.assertNotIn(var, controls.attr_size.model())\n                self.assertIn(var, controls.attr_shape.model())\n\n        widget = self.create_widget(OWScatterPlot)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=widget)\n        self.assertEqual(controls.attr_color.currentText(),\n                         self.data.domain.class_var.name)\n\n    def test_group_selections(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        graph = self.widget.graph\n        points = graph.scatterplot_item.points()\n        sel_column = np.zeros((len(self.data), 1))\n\n        x = self.data.X\n\n        def selectedx():\n            return self.get_output(self.widget.Outputs.selected_data).X\n\n        def selected_groups():\n            return self.get_output(self.widget.Outputs.selected_data).metas[:, 0]\n\n        def annotated():\n            return self.get_output(self.widget.Outputs.annotated_data).metas\n\n        def annotations():\n            return self.get_output(self.widget.Outputs.annotated_data).domain.metas[0].values\n\n        # Select 0:5\n        graph.select(points[:5])\n        np.testing.assert_equal(selectedx(), x[:5])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        sel_column[:5] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\", ))\n\n        # Shift-select 5:10; now we have groups 0:5 and 5:10\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[5:10])\n        np.testing.assert_equal(selectedx(), x[:10])\n        np.testing.assert_equal(selected_groups(), np.array([0] * 5 + [1] * 5))\n        sel_column[:5] = 0\n        sel_column[5:10] = 1\n        sel_column[10:] = 2\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n        # Select: 15:20; we have 15:20\n        graph.select(points[15:20])\n        sel_column = np.zeros((len(self.data), 1))\n        sel_column[15:20] = 1\n        np.testing.assert_equal(selectedx(), x[15:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(5))\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Alt-select (remove) 10:17; we have 17:20\n        with self.modifiers(Qt.AltModifier):\n            graph.select(points[10:17])\n        np.testing.assert_equal(selectedx(), x[17:20])\n        np.testing.assert_equal(selected_groups(), np.zeros(3))\n        sel_column[15:17] = 0\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Ctrl-Shift-select (add-to-last) 10:17; we have 17:25\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[20:25])\n        np.testing.assert_equal(selectedx(), x[17:25])\n        np.testing.assert_equal(selected_groups(), np.zeros(8))\n        sel_column[20:25] = 1\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(annotations(), (\"No\", \"Yes\"))\n\n        # Shift-select (add) 30:35; we have 17:25, 30:35\n        with self.modifiers(Qt.ShiftModifier):\n            graph.select(points[30:35])\n        # ... then Ctrl-Shift-select (add-to-last) 10:17; we have 17:25, 30:40\n        with self.modifiers(Qt.ShiftModifier | Qt.ControlModifier):\n            graph.select(points[35:40])\n        sel_column[:] = 2\n        sel_column[17:25] = 0\n        sel_column[30:40] = 1\n        np.testing.assert_equal(selected_groups(), np.array([0] * 8 + [1] * 10))\n        np.testing.assert_equal(annotated(), sel_column)\n        self.assertEqual(len(annotations()), 3)\n\n    def test_saving_selection(self):\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        self.widget.graph.select_by_rectangle(QRectF(4, 3, 3, 1))\n        selected_inds = np.flatnonzero(self.widget.graph.selection)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        np.testing.assert_equal(selected_inds,\n                                [i for i, g in settings[\"selection\"]])\n\n    def test_points_selection(self):\n        # Opening widget with saved selection should restore it\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        self.send_signal(self.widget.Inputs.data, self.data)  # iris\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertEqual(len(selected_data), 50)\n\n        # Changing the dataset should clear selection\n        titanic = Table(\"titanic\")\n        self.send_signal(self.widget.Inputs.data, titanic)\n        selected_data = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsNone(selected_data)\n\n    def test_migrate_selection(self):\n        settings = dict(selection=list(range(2)))\n        OWScatterPlot.migrate_settings(settings, 0)\n        self.assertEqual(settings[\"selection_group\"], [(0, 1), (1, 1)])\n\n    def test_invalid_points_selection(self):\n        # if selection contains rows that are not present in the current\n        # dataset, widget should select what can be selected.\n        self.widget = self.create_widget(\n            OWScatterPlot, stored_settings={\n                \"selection_group\": [(i, 1) for i in range(50)]}\n        )\n        data = self.data[:11].copy()\n        with data.unlocked():\n            data[0, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n\n    def test_set_strings_settings(self):\n        \"\"\"\n        Test if settings can be loaded as strings and successfully put\n        in new owplotgui combos.\n        \"\"\"\n        self.send_signal(self.widget.Inputs.data, self.data)\n        settings = self.widget.settingsHandler.pack_data(self.widget)\n        plot_settings = settings[\"context_settings\"][0].values\n        plot_settings[\"attr_label\"] = (\"sepal length\", -2)\n        plot_settings[\"attr_color\"] = (\"sepal width\", -2)\n        plot_settings[\"attr_shape\"] = (\"iris\", -2)\n        plot_settings[\"attr_size\"] = (\"petal width\", -2)\n        w = self.create_widget(OWScatterPlot, stored_settings=settings)\n        self.send_signal(self.widget.Inputs.data, self.data, widget=w)\n        self.assertEqual(w.attr_label.name, \"sepal length\")\n        self.assertEqual(w.attr_color.name, \"sepal width\")\n        self.assertEqual(w.attr_shape.name, \"iris\")\n        self.assertEqual(w.attr_size.name, \"petal width\")\n\n    def test_features_and_no_data(self):\n        \"\"\"\n        Prevent crashing when features are sent but no data.\n        \"\"\"\n        domain = Table(\"iris\").domain\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(domain.variables))\n        self.send_signal(self.widget.Inputs.features, None)\n\n    def test_features_and_data(self):\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.send_signal(self.widget.Inputs.data, self.data)\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 0])\n        np.testing.assert_array_equal(y, self.data.X[:, 1])\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain[2:]))\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n        x, y = self.widget.graph.scatterplot_item.getData()\n        np.testing.assert_array_equal(x, self.data.X[:, 2])\n        np.testing.assert_array_equal(y, self.data.X[:, 3])\n\n        self.send_signal(self.widget.Inputs.data, None)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertIs(self.widget.attr_x, self.data.domain[2])\n        self.assertIs(self.widget.attr_y, self.data.domain[3])\n        self.assertFalse(self.widget.attr_box.isEnabled())\n        self.assertFalse(self.widget.vizrank.isEnabled())\n\n        self.send_signal(self.widget.Inputs.features, None)\n        self.assertTrue(self.widget.attr_box.isEnabled())\n        self.assertTrue(self.widget.vizrank.isEnabled())\n\n    def test_output_features(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n\n        # This doesn't work because combo's callbacks are connected to signal\n        # `activated`, which is only triggered by user interaction, and not to\n        # `currentIndexChanged`\n        # combo_y = self.widget.controls.attr_y\n        # combo_y.setCurrentIndex(combo_y.model().indexOf(data.domain[3]))\n        # This is a workaround\n        self.widget.attr_y = data.domain[3]\n        self.widget.attr_changed()\n\n        features = self.get_output(self.widget.Outputs.features)\n        self.assertEqual(features, [data.domain[0], data.domain[3]])\n\n    def test_vizrank(self):\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        n_states = len(data.domain.attributes)\n        n_states = n_states * (n_states - 1) / 2\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertEqual(len(states), n_states)\n        self.assertEqual(len(set(states)), n_states)\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n        self.send_signal(self.widget.Inputs.data, data[:9])\n        self.assertIsNone(vizrank.compute_score(states[0]))\n\n        data = Table(\"housing\")[::10]\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = ScatterPlotVizRank(self.widget)\n        states = [state for state in vizrank.iterate_states(None)]\n        self.assertIsNotNone(vizrank.compute_score(states[0]))\n\n    def test_vizrank_class_nan(self):\n        \"\"\"\n        When class values are nan, vizrank should be disabled. It should behave like\n        the class column is missing.\n        GH-2757\n        \"\"\"\n        def assert_vizrank_enabled(data, is_enabled):\n            self.send_signal(self.widget.Inputs.data, data)\n            self.assertEqual(is_enabled, self.widget.vizrank_button.isEnabled())\n\n        data1 = Table(\"iris\")[::30]\n        data2 = Table(\"iris\")[::30].copy()\n        with data2.unlocked():\n            data2.Y[:] = np.nan\n        domain = Domain(\n            attributes=data2.domain.attributes[:4], class_vars=DiscreteVariable(\"iris\", values=()))\n        data2 = Table(domain, data2.X, Y=data2.Y)\n        data3 = Table(\"iris\")[::30].copy()\n        with data3.unlocked():\n            data3.Y[:] = np.nan\n\n        for data, is_enabled in zip([data1, data2, data1, data3, data1],\n                                    [True, False, True, False, True]):\n            assert_vizrank_enabled(data, is_enabled)\n\n    def test_vizrank_nonprimitives(self):\n        \"\"\"VizRank does not try to include non primitive attributes\"\"\"\n        data = Table(\"zoo\")\n        self.send_signal(self.widget.Inputs.data, data)\n        with patch(\"Orange.widgets.visualize.owscatterplot.ReliefF\",\n                   new=lambda *_1, **_2: lambda data: np.arange(len(data))):\n            self.widget.vizrank.score_heuristic()\n\n    def test_vizrank_enabled(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_no_data(self):\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"No data on input\")\n\n    def test_vizrank_enabled_sparse_data(self):\n        self.send_signal(self.widget.Inputs.data, self.data.to_sparse())\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"Data is sparse\")\n\n    def test_vizrank_enabled_constant_data(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        X = np.zeros((10, 4))\n        table = Table(domain, X, np.random.randint(2, size=10))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertEqual(self.widget.vizrank_button.toolTip(), \"\")\n        self.assertTrue(self.widget.vizrank_button.isEnabled())\n        self.assertTrue(self.widget.vizrank.button.isEnabled())\n        self.widget.vizrank.button.click()\n\n    def test_vizrank_enabled_two_features(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :2])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Not enough features for ranking\")\n\n    def test_vizrank_enabled_no_color_var(self):\n        self.send_signal(self.widget.Inputs.data, self.data[:, :3])\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable is not selected\")\n\n    def test_vizrank_enabled_color_var_nans(self):\n        domain = Domain([ContinuousVariable(\"c1\"),\n                         ContinuousVariable(\"c2\"),\n                         ContinuousVariable(\"c3\"),\n                         ContinuousVariable(\"c4\")],\n                        DiscreteVariable(\"cls\", values=(\"a\", \"b\")))\n        table = Table(domain, np.random.random((10, 4)), np.full(10, np.nan))\n        self.send_signal(self.widget.Inputs.data, table)\n        self.assertFalse(self.widget.vizrank_button.isEnabled())\n        self.assertEqual(self.widget.vizrank_button.toolTip(),\n                         \"Color variable has no values\")\n\n    def test_auto_send_selection(self):\n        \"\"\"\n        Scatter Plot automatically sends selection only when the checkbox Send automatically\n        is checked.\n        GH-2649\n        GH-2646\n        \"\"\"\n        data = Table(\"iris\")\n        self.send_signal(self.widget.Inputs.data, data)\n        self.widget.controls.auto_commit.setChecked(False)\n        self.assertFalse(self.widget.controls.auto_commit.isChecked())\n        self._select_data()\n        self.assertIsNone(self.get_output(self.widget.Outputs.selected_data))\n        self.widget.controls.auto_commit.setChecked(True)\n        output = self.get_output(self.widget.Outputs.selected_data)\n        self.assertIsInstance(output, Table)\n\n    def test_color_is_optional(self):\n        zoo = Table(\"zoo\")\n        backbone, breathes, airborne, type = \\\n            [zoo.domain[x] for x in [\"backbone\", \"breathes\", \"airborne\", \"type\"]]\n        default_x, default_y, default_color = \\\n            zoo.domain[0], zoo.domain[1], zoo.domain.class_var\n        attr_x = self.widget.controls.attr_x\n        attr_y = self.widget.controls.attr_y\n        attr_color = self.widget.controls.attr_color\n\n        # Send dataset, ensure defaults are what we expect them to be\n        self.send_signal(self.widget.Inputs.data, zoo)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n        # Select different values\n        simulate.combobox_activate_item(attr_x, backbone.name)\n        simulate.combobox_activate_item(attr_y, breathes.name)\n        simulate.combobox_activate_item(attr_color, airborne.name)\n\n        # Send compatible dataset, values should not change\n        zoo2 = zoo[:, (backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo2)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), airborne.name)\n\n        # Send dataset without color variable\n        # x and y should remain, color reset to default\n        zoo3 = zoo[:, (backbone, breathes, type)]\n        self.send_signal(self.widget.Inputs.data, zoo3)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset without x\n        # y and color should be the same as with zoo\n        zoo4 = zoo[:, (default_x, default_y, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo4)\n        self.assertEqual(attr_x.currentText(), default_x.name)\n        self.assertEqual(attr_y.currentText(), default_y.name)\n        self.assertEqual(attr_color.currentText(), default_color.name)\n\n        # Send dataset compatible with zoo2 and zoo3\n        # Color should reset to one in zoo3, as it was used more\n        # recently\n        zoo5 = zoo[:, (default_x, backbone, breathes, airborne, type)]\n        self.send_signal(self.widget.Inputs.data, zoo5)\n        self.assertEqual(attr_x.currentText(), backbone.name)\n        self.assertEqual(attr_y.currentText(), breathes.name)\n        self.assertEqual(attr_color.currentText(), type.name)\n\n    def test_handle_metas(self):\n        \"\"\"\n        Scatter Plot Graph can handle metas\n        GH-2699\n        \"\"\"\n        w = self.widget\n        data = Table(\"iris\")\n        domain = Domain(\n            attributes=data.domain.attributes[:2],\n            class_vars=data.domain.class_vars,\n            metas=data.domain.attributes[2:]\n        )\n        data = data.transform(domain).copy()\n        # Sometimes floats in metas are saved as objects\n        with data.unlocked():\n            data.metas = data.metas.astype(object)\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.cb_attr_x, data.domain.metas[1].name)\n        simulate.combobox_activate_item(w.controls.attr_color, data.domain.metas[0].name)\n        w.graph.reset_graph()\n\n    def test_subset_data(self):\n        \"\"\"\n        Scatter Plot subset data is sent to Scatter Plot Graph\n        GH-2773\n        \"\"\"\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertEqual(len(w.subset_indices), 5)\n\n    def test_opacity_warning(self):\n        data = Table(\"iris\")\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, data[::30])\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(200)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n        w.graph.controls.alpha_value.setSliderPosition(10)\n        self.assertTrue(w.Warning.transparent_subset.is_shown())\n        self.send_signal(w.Inputs.data_subset, None)\n        self.assertFalse(w.Warning.transparent_subset.is_shown())\n\n    def test_jittering(self):\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.graph.controls.jitter_continuous.setChecked(True)\n        self.widget.graph.controls.jitter_size.setValue(1)\n\n    def test_metas_zero_column(self):\n        \"\"\"\n        Prevent crash when metas column is zero.\n        GH-2775\n        \"\"\"\n        data = Table(\"iris\")\n        domain = data.domain\n        domain = Domain(domain.attributes[:3], domain.class_vars, domain.attributes[3:])\n        data = data.transform(domain).copy()\n        with data.unlocked():\n            data.metas[:, 0] = 0\n        w = self.widget\n        self.send_signal(w.Inputs.data, data)\n        simulate.combobox_activate_item(w.controls.attr_x, domain.metas[0].name)\n\n    def test_tooltip(self):\n        # The test tests presence of some data,\n        # but avoids checking the exact format\n        data = Table(\"heart_disease\")\n        self.send_signal(self.widget.Inputs.data, data)\n        widget = self.widget\n        graph = widget.graph\n        scatterplot_item = graph.scatterplot_item\n\n        widget.controls.attr_x = data.domain[\"chest pain\"]\n        widget.controls.attr_y = data.domain[\"cholesterol\"]\n        all_points = scatterplot_item.points()\n\n        event = MagicMock()\n        with patch.object(scatterplot_item, \"mapFromScene\"), \\\n                patch.object(QToolTip, \"showText\") as show_text:\n\n            # Single point hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42]]):\n                # Show just x and y attribute\n                widget.tooltip_shows_all = False\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertNotIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertNotIn(\"others\", text)\n\n                # Show all attributes\n                widget.tooltip_shows_all = True\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"max HR = {}\".format(data[42, \"max HR\"]), text)\n                self.assertIn(\"... and 4 others\", text)\n\n            # Two points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[all_points[42], all_points[100]]):\n                self.assertTrue(graph.help_event(event))\n                (_, text), _ = show_text.call_args\n                self.assertIn(\"age = {}\".format(data[42, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[42, \"gender\"]), text)\n                self.assertIn(\"age = {}\".format(data[100, \"age\"]), text)\n                self.assertIn(\"gender = {}\".format(data[100, \"gender\"]), text)\n\n            # No points hovered\n            with patch.object(scatterplot_item, \"pointsAt\",\n                              return_value=[]):\n                show_text.reset_mock()\n                self.assertFalse(graph.help_event(event))\n                self.assertEqual(show_text.call_count, 0)\n\n    def test_many_discrete_values(self):\n        \"\"\"\n        Do not show all discrete values if there are too many.\n        Also test for values with a nan.\n        GH-2804\n        \"\"\"\n        def prepare_data():\n            data = Table(\"iris\")\n            values = list(range(15))\n            class_var = DiscreteVariable(\"iris5\", values=[str(v) for v in values])\n            data = data.transform(\n                Domain(attributes=data.domain.attributes,\n                       class_vars=[class_var])).copy()\n            with data.unlocked():\n                data.Y = np.array(values * 10, dtype=float)\n            return data\n\n        def assert_equal(data, max):\n            self.send_signal(self.widget.Inputs.data, data)\n            pen_data, brush_data = self.widget.graph.get_colors()\n            self.assertEqual(max, len(np.unique([id(p) for p in pen_data])), )\n\n        assert_equal(prepare_data(), MAX_COLORS)\n        # data with nan value\n        data = prepare_data()\n        with data.unlocked():\n            data.Y[42] = np.nan\n        assert_equal(data, MAX_COLORS + 1)\n\n    def test_invalidated_same_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send the same features as already set\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.widget.setup_plot.assert_not_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and features at the same time (data first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (same as default ones)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[:2]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n    def test_invalidated_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features and data at the same time (features first)\n        features = self.data.domain.attributes[:2]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n        self.widget.setup_plot.reset_mock()\n        features = self.data.domain.attributes[2:]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n\n    def test_invalidated_diff_features(self):\n        self.widget.setup_plot = Mock()\n        # send data and set default features\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[:2]))\n\n        # send different features\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (data first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.data, self.data),\n                   (self.widget.Inputs.features, AttributeList(features))]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    def test_invalidated_diff_features_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send features (not the same as defaults)\n        self.send_signal(self.widget.Inputs.features,\n                         AttributeList(self.data.domain.attributes[2:4]))\n        self.assertListEqual(self.widget.effective_variables, [])\n        self.widget.setup_plot.assert_called_once()\n\n        # send data\n        self.widget.setup_plot.reset_mock()\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables,\n                             list(self.data.domain.attributes[2:4]))\n\n    def test_invalidated_diff_features_same_time_features_first(self):\n        self.widget.setup_plot = Mock()\n        # send data and different features at the same time (features first)\n        features = self.data.domain.attributes[2:4]\n        signals = [(self.widget.Inputs.features, AttributeList(features)),\n                   (self.widget.Inputs.data, self.data)]\n        self.send_signals(signals)\n        self.widget.setup_plot.assert_called_once()\n        self.assertListEqual(self.widget.effective_variables, list(features))\n\n    @patch('Orange.widgets.visualize.owscatterplot.ScatterPlotVizRank.'\n           'on_manual_change')\n    def test_vizrank_receives_manual_change(self, on_manual_change):\n        # Recreate the widget so the patch kicks in\n        self.widget = self.create_widget(OWScatterPlot)\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        model = self.widget.controls.attr_x.model()\n        self.widget.attr_x = model[0]\n        self.widget.attr_y = model[1]\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 2)\n        self.assertIs(self.widget.attr_x, model[2])\n        on_manual_change.assert_called_with(model[2], model[1])\n\n    def test_on_manual_change(self):\n        data = Table(\"iris.tab\")\n        self.send_signal(self.widget.Inputs.data, data)\n        vizrank = self.widget.vizrank\n        vizrank.toggle()\n        self.process_events(until=lambda: not vizrank.keep_running)\n\n        model = vizrank.rank_model\n        attrs = model.data(model.index(3, 0), vizrank._AttrRole)\n        vizrank.on_manual_change(*attrs)\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 1)\n        self.assertEqual(selection[0].row(), 3)\n\n        vizrank.on_manual_change(*attrs[::-1])\n        selection = vizrank.rank_table.selectedIndexes()\n        self.assertEqual(len(selection), 0)\n\n    def test_regression_lines_appear(self):\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 4)\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 1)\n        data = self.data.copy()\n        with data.unlocked():\n            data[:, 0] = np.nan\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertEqual(len(self.widget.graph.reg_line_items), 0)\n\n    def test_regression_line_coeffs(self):\n        widget = self.widget\n        graph = widget.graph\n        xy = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                       [0, 1], [1, 3], [2, 5]], dtype=float)\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: xy.T\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertEqual(line1.pos().y(), 0)\n        self.assertEqual(line1.angle, 45)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n        graph.orthonormal_regression = True\n        graph.update_regression_line()\n\n        line1 = graph.reg_line_items[1]\n        self.assertEqual(line1.pos().x(), 0)\n        self.assertAlmostEqual(line1.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line1.angle, 58.28252558853899)\n        self.assertEqual(line1.pen.color().hue(), graph.palette[0].hue())\n\n        line2 = graph.reg_line_items[2]\n        self.assertEqual(line2.pos().x(), 0)\n        self.assertEqual(line2.pos().y(), 1)\n        self.assertAlmostEqual(line2.angle, np.degrees(np.arctan2(2, 1)))\n        self.assertEqual(line2.pen.color().hue(), graph.palette[1].hue())\n\n    def test_orthonormal_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), -0.6180339887498949)\n        self.assertAlmostEqual(line.angle, 58.28252558853899)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertEqual(line.pos().x(), 42)\n        self.assertEqual(line.pos().y(), 10)\n        self.assertEqual(line.angle, 90)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n        # No line because the group is symmetric\n        line = OWScatterPlotGraph._orthonormal_line(\n            np.array([1, 1, 2, 2]), np.array([42, 5, 5, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_regression_line(self):\n        color = QColor(1, 2, 3)\n        width = 42\n        # Normal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([0, 1, 1, 2]), np.array([0, 0, 2, 2]), color, width)\n        self.assertEqual(line.pos().x(), 0)\n        self.assertAlmostEqual(line.pos().y(), 0)\n        self.assertEqual(line.angle, 45)\n        self.assertEqual(line.pen.color(), color)\n        self.assertEqual(line.pen.width(), width)\n\n        # Normal line, negative slope\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 2, 3]), np.array([3, 2, 1]), color, width)\n        self.assertEqual(line.pos().x(), 1)\n        self.assertEqual(line.pos().y(), 3)\n        self.assertEqual(line.angle % 360, 315)\n\n        # Horizontal line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([10, 11, 12]), np.array([42, 42, 42]), color, width)\n        self.assertEqual(line.pos().x(), 10)\n        self.assertEqual(line.pos().y(), 42)\n        self.assertEqual(line.angle, 0)\n\n        # Vertical line\n        line = OWScatterPlotGraph._regression_line(\n            np.array([42, 42, 42]), np.array([10, 11, 12]), color, width)\n        self.assertIsNone(line)\n\n        # No line because all points coincide\n        line = OWScatterPlotGraph._regression_line(\n            np.array([1, 1, 1]), np.array([42, 42, 42]), color, width)\n        self.assertIsNone(line)\n\n    def test_add_line_calls_proper_regressor(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = Mock(return_value=None)\n        graph._regression_line = Mock(return_value=None)\n        x, y, c = Mock(), Mock(), Mock()\n\n        graph.orthonormal_regression = True\n        graph._add_line(x, y, c)\n        graph._orthonormal_line.assert_called_once_with(x, y, c, 3, Qt.SolidLine)\n        graph._regression_line.assert_not_called()\n        graph._orthonormal_line.reset_mock()\n\n        graph.orthonormal_regression = False\n        graph._add_line(x, y, c)\n        graph._regression_line.assert_called_with(x, y, c, 3, Qt.SolidLine)\n        graph._orthonormal_line.assert_not_called()\n\n    def test_no_regression_line(self):\n        graph = self.widget.graph\n        graph._orthonormal_line = lambda *_: None\n        graph.orthonormal_regression = True\n\n        graph.plot_widget.addItem = Mock()\n\n        x, y, c = Mock(), Mock(), Mock()\n        graph._add_line(x, y, c)\n        graph.plot_widget.addItem.assert_not_called()\n        self.assertEqual(graph.reg_line_items, [])\n\n    def test_update_regression_line_calls_add_line(self):\n        widget = self.widget\n        graph = widget.graph\n        x, y = np.array([[0, 0], [1, 0], [1, 2], [2, 2],\n                         [0, 1], [1, 3], [2, 5]], dtype=float).T\n        colors = np.array([0, 0, 0, 0, 1, 1, 1], dtype=float)\n        widget.get_coordinates_data = lambda: (x, y)\n        widget.can_draw_regresssion_line = lambda: True\n        widget.get_color_data = lambda: colors\n        widget.is_continuous_color = lambda: False\n        graph.palette = DefaultRGBColors\n        graph.controls.show_reg_line.setChecked(True)\n\n        graph._add_line = Mock()\n\n        graph.update_regression_line()\n        (args1, _), (args2, _), (args3, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2], QColor(\"#505050\"))\n\n        np.testing.assert_equal(args2[0], x[:4])\n        np.testing.assert_equal(args2[1], y[:4])\n        self.assertEqual(args2[2].hue(), graph.palette[0].hue())\n\n        np.testing.assert_equal(args3[0], x[4:])\n        np.testing.assert_equal(args3[1], y[4:])\n        self.assertEqual(args3[2].hue(), graph.palette[1].hue())\n        graph._add_line.reset_mock()\n\n        # Continuous color - just a single line\n        widget.is_continuous_color = lambda: True\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        args1, _ = graph._add_line.call_args_list[0]\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n        graph._add_line.reset_mock()\n        widget.is_continuous_color = lambda: False\n\n        # No palette - just a single line\n        graph.palette = None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n        graph.palette = DefaultRGBColors\n\n        # Regression line is disabled\n        graph.show_reg_line = False\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n\n        # No colors - just one line\n        widget.get_color_data = lambda: None\n        graph.update_regression_line()\n        graph._add_line.assert_called_once()\n        graph._add_line.reset_mock()\n\n        # No data\n        widget.get_coordinates_data = lambda: (None, None)\n        graph.update_regression_line()\n        graph._add_line.assert_not_called()\n        graph.show_reg_line = True\n        widget.get_coordinates_data = lambda: (x, y)\n\n        # One color group contains just one point - skip that line\n        widget.get_color_data = lambda: np.array([0] + [1] * (len(x) - 1))\n\n        graph.update_regression_line()\n        (args1, _), (args2, _) = graph._add_line.call_args_list\n        np.testing.assert_equal(args1[0], x)\n        np.testing.assert_equal(args1[1], y)\n        self.assertEqual(args1[2].hue(), QColor(\"#505050\").hue())\n\n        np.testing.assert_equal(args2[0], x[1:])\n        np.testing.assert_equal(args2[1], y[1:])\n        self.assertEqual(args2[2].hue(), graph.palette[1].hue())\n\n    def test_update_regression_line_is_called(self):\n        widget = self.widget\n        graph = widget.graph\n        urline = graph.update_regression_line = Mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, None)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        self.send_signal(widget.Inputs.data, self.data)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 0)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_color, 2)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n        simulate.combobox_activate_index(self.widget.controls.attr_x, 3)\n        urline.assert_called_once()\n        urline.reset_mock()\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n\n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n\n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n\n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n\n        spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n        self.assertEqual(spacing, 1582953776 - 1581953776)\n        self.assertTrue(not ticks.size or 1581953776 <= ticks[0] <= 1582953776)\n\n    def test_clear_plot(self):\n        self.widget.cb_class_density.setChecked(True)\n        self.send_signal(self.widget.Inputs.data, self.data)\n        data = self.data.transform(Domain(self.data.domain.attributes))[:100]\n        self.send_signal(self.widget.Inputs.data, data)\n        with excepthook_catch():\n            self.send_signal(self.widget.Inputs.data, self.data)\n\n    def test_visual_settings(self):\n        super().test_visual_settings()\n\n        graph = self.widget.graph\n        font = QFont()\n        font.setItalic(True)\n        font.setFamily(\"Helvetica\")\n\n        key, value = ('Fonts', 'Axis title', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis title', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.label.font(), font)\n\n        key, value = ('Fonts', 'Axis ticks', 'Font size'), 15\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Axis ticks', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(15)\n        for item in graph.parameter_setter.axis_items:\n            self.assertFontEqual(item.style[\"tickFont\"], font)\n\n        self.widget.graph.controls.show_reg_line.setChecked(True)\n        self.assertGreater(len(graph.parameter_setter.reg_line_label_items), 0)\n\n        key, value = ('Fonts', 'Line label', 'Font size'), 16\n        self.widget.set_visual_settings(key, value)\n        key, value = ('Fonts', 'Line label', 'Italic'), True\n        self.widget.set_visual_settings(key, value)\n        font.setPointSize(16)\n        for label in graph.parameter_setter.reg_line_label_items:\n            self.assertFontEqual(label.textItem.font(), font)\n\n        key, value = ('Figure', 'Lines', 'Width'), 10\n        self.widget.set_visual_settings(key, value)\n        for item in graph.reg_line_items:\n            self.assertEqual(item.pen.width(), 10)\n\n\nif __name__ == \"__main__\":\n    import unittest\n    unittest.main()\n"
    ],
    "test_file_names": [
        "test_1.py"
    ],
    "setup_res_code": 0,
    "setup_res_stdout": "Starting Orange installation attempts...\nAttempting installation with Python 3.7...\nrunning build_ext\nCompiling Orange/classification/_tree_scorers.pyx because it changed.\nCompiling Orange/data/_contingency.pyx because it changed.\nCompiling Orange/data/_io.pyx because it changed.\nCompiling Orange/data/_valuecount.pyx because it changed.\nCompiling Orange/data/_variable.pyx because it changed.\nCompiling Orange/distance/_distance.pyx because it changed.\nCompiling Orange/preprocess/_discretize.pyx because it changed.\nCompiling Orange/preprocess/_relieff.pyx because it changed.\nCompiling Orange/projection/_som.pyx because it changed.\n[1/9] Cythonizing Orange/classification/_tree_scorers.pyx\n[2/9] Cythonizing Orange/data/_contingency.pyx\n[3/9] Cythonizing Orange/data/_io.pyx\n[4/9] Cythonizing Orange/data/_valuecount.pyx\n[5/9] Cythonizing Orange/data/_variable.pyx\n[6/9] Cythonizing Orange/distance/_distance.pyx\n[7/9] Cythonizing Orange/preprocess/_discretize.pyx\n[8/9] Cythonizing Orange/preprocess/_relieff.pyx\n[9/9] Cythonizing Orange/projection/_som.pyx\nbuilding 'Orange.classification._tree_scorers' extension\ncreating build\ncreating build/temp.linux-x86_64-3.7\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_tree_scorers.c -o build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o\ncreating build/lib.linux-x86_64-3.7\ncreating build/lib.linux-x86_64-3.7/Orange\ncreating build/lib.linux-x86_64-3.7/Orange/classification\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_tree_scorers.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_contingency.c -o build/temp.linux-x86_64-3.7/Orange/data/_contingency.o\ncreating build/lib.linux-x86_64-3.7/Orange/data\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_contingency.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_io.c -o build/temp.linux-x86_64-3.7/Orange/data/_io.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_io.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_valuecount.c -o build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_valuecount.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/data/_variable.c -o build/temp.linux-x86_64-3.7/Orange/data/_variable.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/data/_variable.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/distance/_distance.c -o build/temp.linux-x86_64-3.7/Orange/distance/_distance.o\ncreating build/lib.linux-x86_64-3.7/Orange/distance\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/distance/_distance.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_discretize.c -o build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o\ncreating build/lib.linux-x86_64-3.7/Orange/preprocess\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_discretize.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/preprocess/_relieff.cpp -o build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/preprocess/_relieff.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.projection._som' extension\ncreating build/temp.linux-x86_64-3.7/Orange/projection\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/projection/_som.c -o build/temp.linux-x86_64-3.7/Orange/projection/_som.o\ncreating build/lib.linux-x86_64-3.7/Orange/projection\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/projection/_som.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._simple_tree' extension\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/classification/_simple_tree.c -o build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o\ncc -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/classification/_simple_tree.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c Orange/widgets/utils/_grid_density.cpp -o build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o\ncreating build/lib.linux-x86_64-3.7/Orange/widgets\ncreating build/lib.linux-x86_64-3.7/Orange/widgets/utils\nc++ -pthread -shared -L/tools/deps/lib build/temp.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.o -L/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/lib -lm -lpython3.7m -o build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nrunning develop\nrunning egg_info\ncreating Orange3.egg-info\nwriting Orange3.egg-info/PKG-INFO\nwriting dependency_links to Orange3.egg-info/dependency_links.txt\nwriting entry points to Orange3.egg-info/entry_points.txt\nwriting requirements to Orange3.egg-info/requires.txt\nwriting top-level names to Orange3.egg-info/top_level.txt\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest file 'Orange3.egg-info/SOURCES.txt'\nreading manifest template 'MANIFEST.in'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_io.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so -> Orange/data\ncopying build/lib.linux-x86_64-3.7/Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so -> Orange/distance\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so -> Orange/preprocess\ncopying build/lib.linux-x86_64-3.7/Orange/projection/_som.cpython-37m-x86_64-linux-gnu.so -> Orange/projection\ncopying build/lib.linux-x86_64-3.7/Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so -> Orange/classification\ncopying build/lib.linux-x86_64-3.7/Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so -> Orange/widgets/utils\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.33.0.dev0+ba814bd to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029\nProcessing dependencies for Orange3==3.33.0.dev0+ba814bd\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for setuptools==59.8.0\nBest match: setuptools 59.8.0\nAdding setuptools 59.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for serverfiles==0.3.1\nBest match: serverfiles 0.3.1\nAdding serverfiles 0.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for scipy==1.7.3\nBest match: scipy 1.7.3\nAdding scipy 1.7.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for scikit-learn==1.0.2\nBest match: scikit-learn 1.0.2\nAdding scikit-learn 1.0.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for requests==2.31.0\nBest match: requests 2.31.0\nAdding requests 2.31.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for qtconsole==5.4.4\nBest match: qtconsole 5.4.4\nAdding qtconsole 5.4.4 to easy-install.pth file\nInstalling jupyter-qtconsole script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyYAML==6.0.1\nBest match: PyYAML 6.0.1\nAdding PyYAML 6.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for python-louvain==0.16\nBest match: python-louvain 0.16\nAdding python-louvain 0.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.12.3\nBest match: pyqtgraph 0.12.3\nAdding pyqtgraph 0.12.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pygments==2.17.2\nBest match: pygments 2.17.2\nAdding pygments 2.17.2 to easy-install.pth file\nInstalling pygmentize script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pip==24.0\nBest match: pip 24.0\nAdding pip 24.0 to easy-install.pth file\nInstalling pip script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pandas==1.3.5\nBest match: pandas 1.3.5\nAdding pandas 1.3.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for orange-widget-base==4.22.0\nBest match: orange-widget-base 4.22.0\nAdding orange-widget-base 4.22.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for orange-canvas-core==0.1.35\nBest match: orange-canvas-core 0.1.35\nAdding orange-canvas-core 0.1.35 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for openpyxl==3.1.3\nBest match: openpyxl 3.1.3\nAdding openpyxl 3.1.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for numpy==1.17.5\nBest match: numpy 1.17.5\nAdding numpy 1.17.5 to easy-install.pth file\nInstalling f2py script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for networkx==2.6.3\nBest match: networkx 2.6.3\nAdding networkx 2.6.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for matplotlib==3.5.3\nBest match: matplotlib 3.5.3\nAdding matplotlib 3.5.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for keyrings.alt==4.2.0\nBest match: keyrings.alt 4.2.0\nAdding keyrings.alt 4.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for keyring==24.1.1\nBest match: keyring 24.1.1\nAdding keyring 24.1.1 to easy-install.pth file\nInstalling keyring script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for joblib==1.3.2\nBest match: joblib 1.3.2\nAdding joblib 1.3.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for httpx==0.24.1\nBest match: httpx 0.24.1\nAdding httpx 0.24.1 to easy-install.pth file\nInstalling httpx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for chardet==5.2.0\nBest match: chardet 5.2.0\nAdding chardet 5.2.0 to easy-install.pth file\nInstalling chardetect script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for Bottleneck==1.4.0\nBest match: Bottleneck 1.4.0\nAdding Bottleneck 1.4.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for baycomp==1.0.3\nBest match: baycomp 1.0.3\nAdding baycomp 1.0.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine==5.15.6\nBest match: PyQtWebEngine 5.15.6\nAdding PyQtWebEngine 5.15.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyQt5==5.15.10\nBest match: PyQt5 5.15.10\nAdding PyQt5 5.15.10 to easy-install.pth file\nInstalling pylupdate5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pyrcc5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pyuic5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for AnyQt==0.2.0\nBest match: AnyQt 0.2.0\nAdding AnyQt 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for threadpoolctl==3.1.0\nBest match: threadpoolctl 3.1.0\nAdding threadpoolctl 3.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for urllib3==2.0.7\nBest match: urllib3 2.0.7\nAdding urllib3 2.0.7 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for charset-normalizer==3.4.1\nBest match: charset-normalizer 3.4.1\nAdding charset-normalizer 3.4.1 to easy-install.pth file\nInstalling normalizer script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for certifi==2024.12.14\nBest match: certifi 2024.12.14\nAdding certifi 2024.12.14 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for idna==3.10\nBest match: idna 3.10\nAdding idna 3.10 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for jupyter-core==4.12.0\nBest match: jupyter-core 4.12.0\nAdding jupyter-core 4.12.0 to easy-install.pth file\nInstalling jupyter script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling jupyter-migrate script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling jupyter-troubleshoot script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for jupyter-client==7.4.9\nBest match: jupyter-client 7.4.9\nAdding jupyter-client 7.4.9 to easy-install.pth file\nInstalling jupyter-kernel script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling jupyter-kernelspec script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling jupyter-run script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for ipython-genutils==0.2.0\nBest match: ipython-genutils 0.2.0\nAdding ipython-genutils 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for packaging==24.0\nBest match: packaging 24.0\nAdding packaging 24.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for traitlets==5.9.0\nBest match: traitlets 5.9.0\nAdding traitlets 5.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for ipykernel==6.16.2\nBest match: ipykernel 6.16.2\nAdding ipykernel 6.16.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pyzmq==26.2.0\nBest match: pyzmq 26.2.0\nAdding pyzmq 26.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for QtPy==2.4.2\nBest match: QtPy 2.4.2\nAdding QtPy 2.4.2 to easy-install.pth file\nInstalling qtpy script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pytz==2024.2\nBest match: pytz 2024.2\nAdding pytz 2024.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for python-dateutil==2.9.0.post0\nBest match: python-dateutil 2.9.0.post0\nAdding python-dateutil 2.9.0.post0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for typing-extensions==4.7.1\nBest match: typing-extensions 4.7.1\nAdding typing-extensions 4.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for dictdiffer==0.9.0\nBest match: dictdiffer 0.9.0\nAdding dictdiffer 0.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for qasync==0.25.0\nBest match: qasync 0.25.0\nAdding qasync 0.25.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for importlib-metadata==6.7.0\nBest match: importlib-metadata 6.7.0\nAdding importlib-metadata 6.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for docutils==0.20.1\nBest match: docutils 0.20.1\nAdding docutils 0.20.1 to easy-install.pth file\nInstalling docutils script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for commonmark==0.9.1\nBest match: commonmark 0.9.1\nAdding commonmark 0.9.1 to easy-install.pth file\nInstalling cmark script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for requests-cache==1.1.1\nBest match: requests-cache 1.1.1\nAdding requests-cache 1.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for et-xmlfile==1.1.0\nBest match: et-xmlfile 1.1.0\nAdding et-xmlfile 1.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for Pillow==9.5.0\nBest match: Pillow 9.5.0\nAdding Pillow 9.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for kiwisolver==1.4.5\nBest match: kiwisolver 1.4.5\nAdding kiwisolver 1.4.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for fonttools==4.38.0\nBest match: fonttools 4.38.0\nAdding fonttools 4.38.0 to easy-install.pth file\nInstalling fonttools script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for cycler==0.11.0\nBest match: cycler 0.11.0\nAdding cycler 0.11.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pyparsing==3.1.4\nBest match: pyparsing 3.1.4\nAdding pyparsing 3.1.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for jaraco.classes==3.2.3\nBest match: jaraco.classes 3.2.3\nAdding jaraco.classes 3.2.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for importlib-resources==5.12.0\nBest match: importlib-resources 5.12.0\nAdding importlib-resources 5.12.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for jeepney==0.8.0\nBest match: jeepney 0.8.0\nAdding jeepney 0.8.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for SecretStorage==3.3.3\nBest match: SecretStorage 3.3.3\nAdding SecretStorage 3.3.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for sniffio==1.3.1\nBest match: sniffio 1.3.1\nAdding sniffio 1.3.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for httpcore==0.17.3\nBest match: httpcore 0.17.3\nAdding httpcore 0.17.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyQtWebEngine-Qt5==5.15.16\nBest match: PyQtWebEngine-Qt5 5.15.16\nAdding PyQtWebEngine-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyQt5-sip==12.13.0\nBest match: PyQt5-sip 12.13.0\nAdding PyQt5-sip 12.13.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for PyQt5-Qt5==5.15.16\nBest match: PyQt5-Qt5 5.15.16\nAdding PyQt5-Qt5 5.15.16 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for entrypoints==0.4\nBest match: entrypoints 0.4\nAdding entrypoints 0.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for nest-asyncio==1.6.0\nBest match: nest-asyncio 1.6.0\nAdding nest-asyncio 1.6.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for tornado==6.2\nBest match: tornado 6.2\nAdding tornado 6.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for matplotlib-inline==0.1.6\nBest match: matplotlib-inline 0.1.6\nAdding matplotlib-inline 0.1.6 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for psutil==6.1.1\nBest match: psutil 6.1.1\nAdding psutil 6.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for ipython==7.34.0\nBest match: ipython 7.34.0\nAdding ipython 7.34.0 to easy-install.pth file\nInstalling iptest script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling iptest3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling ipython script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\nInstalling ipython3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for debugpy==1.7.0\nBest match: debugpy 1.7.0\nAdding debugpy 1.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for six==1.17.0\nBest match: six 1.17.0\nAdding six 1.17.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for zipp==3.15.0\nBest match: zipp 3.15.0\nAdding zipp 3.15.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for url-normalize==1.4.3\nBest match: url-normalize 1.4.3\nAdding url-normalize 1.4.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for platformdirs==4.0.0\nBest match: platformdirs 4.0.0\nAdding platformdirs 4.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for cattrs==23.1.2\nBest match: cattrs 23.1.2\nAdding cattrs 23.1.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for attrs==24.2.0\nBest match: attrs 24.2.0\nAdding attrs 24.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for more-itertools==9.1.0\nBest match: more-itertools 9.1.0\nAdding more-itertools 9.1.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for cryptography==44.0.0\nBest match: cryptography 44.0.0\nAdding cryptography 44.0.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for h11==0.14.0\nBest match: h11 0.14.0\nAdding h11 0.14.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for anyio==3.7.1\nBest match: anyio 3.7.1\nAdding anyio 3.7.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for jedi==0.19.2\nBest match: jedi 0.19.2\nAdding jedi 0.19.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pexpect==4.9.0\nBest match: pexpect 4.9.0\nAdding pexpect 4.9.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for backcall==0.2.0\nBest match: backcall 0.2.0\nAdding backcall 0.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pickleshare==0.7.5\nBest match: pickleshare 0.7.5\nAdding pickleshare 0.7.5 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for prompt-toolkit==3.0.48\nBest match: prompt-toolkit 3.0.48\nAdding prompt-toolkit 3.0.48 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for decorator==5.1.1\nBest match: decorator 5.1.1\nAdding decorator 5.1.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for exceptiongroup==1.2.2\nBest match: exceptiongroup 1.2.2\nAdding exceptiongroup 1.2.2 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for cffi==1.15.1\nBest match: cffi 1.15.1\nAdding cffi 1.15.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for parso==0.8.4\nBest match: parso 0.8.4\nAdding parso 0.8.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for ptyprocess==0.7.0\nBest match: ptyprocess 0.7.0\nAdding ptyprocess 0.7.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for wcwidth==0.2.13\nBest match: wcwidth 0.2.13\nAdding wcwidth 0.2.13 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nSearching for pycparser==2.21\nBest match: pycparser 2.21\nAdding pycparser 2.21 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.33.0.dev0+ba814bd\nVerifying Orange installation...\n✅ Orange installation successful!\nSuccessfully installed orange using Python 3.7\n",
    "setup_res_stderr": "Using CPython 3.7.9\nCreating virtual environment at: .venv\nActivate with: source .venv/bin/activate\nResolved 18 packages in 200ms\nPrepared 18 packages in 1ms\nInstalled 18 packages in 170ms\n + cython==0.29.37\n + exceptiongroup==1.2.2\n + importlib-metadata==6.7.0\n + iniconfig==2.0.0\n + numpy==1.17.5\n + packaging==24.0\n + pluggy==1.2.0\n + pyqt5==5.15.10\n + pyqt5-qt5==5.15.16\n + pyqt5-sip==12.13.0\n + pyqtwebengine==5.15.6\n + pyqtwebengine-qt5==5.15.16\n + pytest==7.4.4\n + setuptools==59.8.0\n + tomli==2.0.1\n + typing-extensions==4.7.1\n + wheel==0.42.0\n + zipp==3.15.0\nResolved 54 packages in 585ms\nInstalled 47 packages in 161ms\n + anyio==3.7.1\n + baycomp==1.0.3\n + bottleneck==1.4.0\n + certifi==2024.12.14\n + cffi==1.15.1\n + chardet==5.2.0\n + charset-normalizer==3.4.1\n + cryptography==44.0.0\n + cycler==0.11.0\n + et-xmlfile==1.1.0\n + fonttools==4.38.0\n + h11==0.14.0\n + httpcore==0.17.3\n + httpx==0.24.1\n + idna==3.10\n + importlib-resources==5.12.0\n + jaraco-classes==3.2.3\n + jeepney==0.8.0\n + joblib==1.3.2\n + keyring==24.1.1\n + keyrings-alt==4.2.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + more-itertools==9.1.0\n + networkx==2.6.3\n + openpyxl==3.1.3\n + opentsne==1.0.1\n + pandas==1.3.5\n + pillow==9.5.0\n + pip==24.0\n + pycparser==2.21\n + pyparsing==3.1.4\n + python-dateutil==2.9.0.post0\n + python-louvain==0.16\n + pytz==2024.2\n + pyyaml==6.0.1\n + requests==2.31.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + six==1.17.0\n + sniffio==1.3.1\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\n + xlsxwriter==3.2.0\nResolved 59 packages in 814ms\nInstalled 38 packages in 459ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + backcall==0.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + debugpy==1.7.0\n + decorator==5.1.1\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + entrypoints==0.4\n + ipykernel==6.16.2\n + ipython==7.34.0\n + ipython-genutils==0.2.0\n + jedi==0.19.2\n + jupyter-client==7.4.9\n + jupyter-core==4.12.0\n + matplotlib-inline==0.1.6\n + nest-asyncio==1.6.0\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.22.0\n + parso==0.8.4\n + pexpect==4.9.0\n + pickleshare==0.7.5\n + platformdirs==4.0.0\n + prompt-toolkit==3.0.48\n + psutil==6.1.1\n + ptyprocess==0.7.0\n + pygments==2.17.2\n + pyqtgraph==0.12.3\n + pyzmq==26.2.0\n + qasync==0.25.0\n + qtconsole==5.4.4\n + qtpy==2.4.2\n + requests-cache==1.1.1\n + tornado==6.2\n + traitlets==5.9.0\n + url-normalize==1.4.3\n + wcwidth==0.2.13\nResolved 2 packages in 3ms\nInstalled 2 packages in 28ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 19 packages in 120ms\nInstalled 5 packages in 1.16s\n + catboost==1.2.7\n + graphviz==0.20.1\n + plotly==5.18.0\n + tenacity==8.2.3\n + xgboost==1.6.2\nAudited 2 packages in 1ms\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_2find_threshold_entropy’:\nOrange/classification/_tree_scorers.c:3427:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3427 |   __pyx_t_7 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_6find_threshold_MSE’:\nOrange/classification/_tree_scorers.c:4883:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4883 |   __pyx_t_1 = ((__pyx_v_N <= __pyx_v_min_leaf) != 0);\n      |                           ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_8find_binarization_MSE’:\nOrange/classification/_tree_scorers.c:5629:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5629 |           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5750:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5750 |           __pyx_t_20 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5756:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5756 |           __pyx_t_20 = (((__pyx_v_N - __pyx_v_left) >= __pyx_v_min_leaf) != 0);\n      |                                                     ^~\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_14compute_predictions_csr’:\nOrange/classification/_tree_scorers.c:7217:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7217 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7874:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7874 |         for (__pyx_t_12 = 0; __pyx_t_12 < __pyx_t_11; __pyx_t_12+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7934:150: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7934 |               __pyx_t_16 = (((*((__pyx_t_5numpy_int32_t const  *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_15 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                                      ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/data/_io.c: In function ‘__pyx_pf_6Orange_4data_3_io_sparse_read_float.constprop’:\nOrange/data/_io.c:4120:43: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4120 |           __pyx_v_value = ((__pyx_v_value * __pyx_v_decs) + (__pyx_v_c & 0xf));\n      |                            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/data/_io.c:4318:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4318 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 223, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:683:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  683 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1590:7: note: ‘__pyx_v_attr_index’ was declared here\n 1590 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:3183:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3183 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:774:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:790:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/projection/_som.c:775:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/npy_1_7_deprecated_api.h:17:2: warning: #warning \"Using deprecated NumPy API, disable it with \" \"#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION\" [-Wcpp]\n   17 | #warning \"Using deprecated NumPy API, disable it with \" \\\n      |  ^~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_5update_hex’:\nOrange/projection/_som.c:3863:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3863 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3862:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3862 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_8update_sparse.constprop’:\nOrange/projection/_som.c:4934:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4934 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4933:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4933 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_7get_winners_sparse’:\nOrange/projection/_som.c:4732:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4732 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4307:7: note: ‘__pyx_v_win_y’ was declared here\n 4307 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:4721:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4721 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_27, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_26, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:4306:7: note: ‘__pyx_v_win_x’ was declared here\n 4306 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pf_6Orange_10projection_4_som_10update_sparse_hex.constprop’:\nOrange/projection/_som.c:5682:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5682 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:5681:7: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 5681 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_1get_winners’:\nOrange/projection/_som.c:3184:223: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3184 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_y;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2887:7: note: ‘__pyx_v_win_y’ was declared here\n 2887 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c:3173:223: warning: ‘__pyx_v_win_x’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3173 |           *__Pyx_BufPtrStrided2d(__pyx_t_5numpy_int16_t *, __pyx_pybuffernd_winners.rcbuffer->pybuffer.buf, __pyx_t_23, __pyx_pybuffernd_winners.diminfo[0].strides, __pyx_t_22, __pyx_pybuffernd_winners.diminfo[1].strides) = __pyx_v_win_x;\n      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~\nOrange/projection/_som.c:2886:7: note: ‘__pyx_v_win_x’ was declared here\n 2886 |   int __pyx_v_win_x;\n      |       ^~~~~~~~~~~~~\nOrange/projection/_som.c: In function ‘__pyx_pw_6Orange_10projection_4_som_3update’:\nOrange/projection/_som.c:3357:7: warning: ‘__pyx_v_win_y’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3357 |   int __pyx_v_win_y;\n      |       ^~~~~~~~~~~~~\nOrange/classification/_simple_tree.c: In function ‘gain_ratio_c’:\nOrange/classification/_simple_tree.c:63:9: warning: implicit declaration of function ‘qsort_r’; did you mean ‘qsort’? [-Wimplicit-function-declaration]\n   63 |         qsort_r(base, nel, size, compar, thunk)\n      |         ^~~~~~~\nOrange/classification/_simple_tree.c:147:9: note: in expansion of macro ‘QSORT_R_FUNC’\n  147 |         QSORT_R_FUNC(examples, size, sizeof(struct Example), (void*) &compar_attr, compar_examples);\n      |         ^~~~~~~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/setuptools/command/easy_install.py:159: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.\n  EasyInstallDeprecationWarning,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029/.venv/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.\n  setuptools.SetuptoolsDeprecationWarning,\nwarning: no files found matching 'README*' under directory 'Orange'\nwarning: no files found matching 'LICENSE' under directory 'Orange'\nwarning: no files found matching '*.basket' under directory 'Orange/datasets'\nwarning: no files found matching '*.svg' under directory 'Orange/canvas'\nwarning: no files found matching '*.js' under directory 'Orange/widgets'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching '*.html' under directory 'Orange/widgets'\nwarning: no files found matching '*.svg' under directory 'distribute'\nwarning: no files found matching 'COPYING'\n",
    "new_commit_res_code": 0,
    "new_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029\nplugins: anyio-3.7.1\ncollected 80 items\n\nr2e_tests/test_1.py sss................................................. [ 65%]\n............................                                             [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_add_line_calls_proper_regressor\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_attr_label_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_attr_models\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_auto_send_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_class_density\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_clear_plot\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_color_is_optional\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_data_column_infs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_data_column_nans\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_datasets\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_default_attrs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_dragging_tooltip\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_error_message\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_features_and_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_features_and_no_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_group_selections\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_handle_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_handle_primitive_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_hidden_effective_variables\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_image_export\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalid_points_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_same_time\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_same_time_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_embedding\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_time\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_time_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_jittering\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_many_discrete_values\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_metas_zero_column\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_migrate_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_no_regression_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_none_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_on_manual_change\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_opacity_warning\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_optional_combos\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_orthonormal_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_output_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_outputs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_plot_once\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_points_combo_boxes\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_points_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_line_coeffs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_lines_appear\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_report_on_empty\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_saved_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_saving_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_score_heuristics\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_send_report\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_set_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_set_strings_settings\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_setup_graph\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_sparse_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_subset_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_subset_data_color\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_time_axis\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_tooltip\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_update_regression_line_calls_add_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_update_regression_line_is_called\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_visual_settings\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_class_nan\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_color_var_nans\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_constant_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_no_color_var\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_no_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_sparse_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_two_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_nonprimitives\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_receives_manual_change\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\n======================== 77 passed, 3 skipped in 16.85s ========================\nWidgets left: 0    Max widgets: 23796 \n\n",
    "new_commit_res_stderr": "",
    "old_commit_res_code": 1,
    "old_commit_res_stdout": "============================= test session starts ==============================\nplatform linux -- Python 3.7.9, pytest-7.4.4, pluggy-1.2.0\nrootdir: /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_ba814bd7c2ff10e3daf74b6f32cc596ce2255029\nplugins: anyio-3.7.1\ncollected 80 items\n\nr2e_tests/test_1.py sss................................................. [ 65%]\n............F...............                                             [100%]\n\n=================================== FAILURES ===================================\n_______________________ TestOWScatterPlot.test_time_axis _______________________\n\nself = <r2e_tests.test_1.TestOWScatterPlot testMethod=test_time_axis>\n\n    def test_time_axis(self):\n        a = np.array([[1581953776, 1], [1581963776, 2], [1582953776, 3]])\n        d1 = Domain([ContinuousVariable(\"time\"), ContinuousVariable(\"value\")])\n        data = Table.from_numpy(d1, a)\n        d2 = Domain([TimeVariable(\"time\"), ContinuousVariable(\"value\")])\n        data_time = Table.from_numpy(d2, a)\n    \n        x_axis = self.widget.graph.plot_widget.plotItem.getAxis(\"bottom\")\n    \n        self.send_signal(self.widget.Inputs.data, data)\n        self.assertFalse(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        try:\n            float(ticks[0])\n        except ValueError:\n            self.fail(\"axis should display floats\")\n    \n        self.send_signal(self.widget.Inputs.data, data_time)\n        self.assertTrue(x_axis._use_time)\n        _ticks = x_axis.tickValues(1581953776, 1582953776, 1000)\n        ticks = x_axis.tickStrings(_ticks[0][1], 1, _ticks[0][0])\n        with self.assertRaises(ValueError):\n            float(ticks[0])\n    \n>       spacing, ticks = x_axis.tickValues(1581953776, 1582953776, 10)[0]\n\nr2e_tests/test_1.py:1133: \n_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n\nself = <Orange.widgets.visualize.owscatterplotgraph.AxisItem object at 0x728d0d076230>\nminVal = 1581953776, maxVal = 1582953776, size = 10\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n    \n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n    \n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n    \n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n    \n>       spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\nE       ValueError: min() arg is an empty sequence\n\nOrange/widgets/visualize/owscatterplotgraph.py:305: ValueError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_add_line_calls_proper_regressor\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_attr_label_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_attr_models\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_auto_send_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_class_density\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_clear_plot\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_color_is_optional\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_data_column_infs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_data_column_nans\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_datasets\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_default_attrs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_dragging_tooltip\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_error_message\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_features_and_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_features_and_no_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_group_selections\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_handle_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_handle_primitive_metas\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_hidden_effective_variables\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_image_export\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalid_points_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_same_time\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_diff_features_same_time_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_embedding\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_time\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_invalidated_same_time_features_first\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_jittering\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_many_discrete_values\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_metas_zero_column\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_migrate_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_no_regression_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_none_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_on_manual_change\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_opacity_warning\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_optional_combos\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_orthonormal_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_output_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_outputs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_plot_once\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_points_combo_boxes\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_points_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_line_coeffs\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_regression_lines_appear\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_report_on_empty\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_saved_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_saving_selection\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_score_heuristics\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_send_report\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_set_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_set_strings_settings\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_setup_graph\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_sparse_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_subset_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_subset_data_color\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_tooltip\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_update_regression_line_calls_add_line\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_update_regression_line_is_called\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_visual_settings\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_class_nan\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_color_var_nans\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_constant_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_no_color_var\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_no_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_sparse_data\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_enabled_two_features\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_nonprimitives\nPASSED r2e_tests/test_1.py::TestOWScatterPlot::test_vizrank_receives_manual_change\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:244: image exporting not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:238: minimum size not tested as .widget was not set\nSKIPPED [1] .venv/lib/python3.7/site-packages/orangewidget/tests/base.py:250: msg base class not tested as .widget was not set\nFAILED r2e_tests/test_1.py::TestOWScatterPlot::test_time_axis - ValueError: m...\n=================== 1 failed, 76 passed, 3 skipped in 14.15s ===================\nWidgets left: 0    Max widgets: 23796 \n\n",
    "old_commit_res_stderr": ""
}
Orange/widgets/visualize/owscatterplotgraph.py Orange/widgets/visualize/tests/test_owscatterplot.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** Scatterplot Crashes with ValueError When Using a Single Time Tick

**Description:**
When creating a scatterplot with only one time tick, the application crashes due to a `ValueError`. This occurs because the code attempts to calculate the minimum spacing between ticks, but with only one tick, the sequence is empty, leading to the error.

**Steps to Reproduce:**
```python
import numpy as np
from Orange.data import Domain, Table, TimeVariable, ContinuousVariable
from Orange.widgets.visualize.owscatterplot import OWScatterPlot

def test_single_time_tick_crash():
    # Create data with a single time tick
    data = Table.from_numpy(
        Domain([TimeVariable('time'), ContinuousVariable('value')]),
        np.array([[1582953776, 3]])
    )
    
    # Initialize the scatter plot widget and send the data
    widget = OWScatterPlot()
    widget.send_signal(widget.Inputs.data, data)
    
    # This will raise ValueError: min() arg is an empty sequence
```

**Expected Behavior:**
The scatterplot should handle a single time tick gracefully without crashing. It should display the tick appropriately, possibly by setting a default spacing based on the time range.

**Actual Behavior:**
A `ValueError` is raised with the message `min() arg is an empty sequence`, causing the scatterplot to crash when attempting to plot a single time tick.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/visualize/owscatterplotgraph.py
import sys
import itertools
import warnings
from typing import Callable
from xml.sax.saxutils import escape
from datetime import datetime, timezone

import numpy as np
from AnyQt.QtCore import Qt, QRectF, QSize, QTimer, pyqtSignal as Signal, \
    QObject, QEvent
from AnyQt.QtGui import QColor, QPen, QBrush, QPainterPath, QTransform, \
    QPainter, QPalette
from AnyQt.QtWidgets import QApplication, QToolTip, QGraphicsTextItem, \
    QGraphicsRectItem, QGraphicsItemGroup

import pyqtgraph as pg
from pyqtgraph.graphicsItems.ScatterPlotItem import Symbols
from pyqtgraph.graphicsItems.LegendItem import LegendItem as PgLegendItem
from pyqtgraph.graphicsItems.TextItem import TextItem

from Orange.preprocess.discretize import _time_binnings
from Orange.util import utc_from_timestamp
from Orange.widgets import gui
from Orange.widgets.settings import Setting
from Orange.widgets.utils import classdensity, colorpalettes
from Orange.widgets.visualize.utils.customizableplot import Updater, \
    CommonParameterSetter
from Orange.widgets.visualize.utils.plotutils import (
    HelpEventDelegate as EventDelegate, InteractiveViewBox as ViewBox,
    PaletteItemSample, SymbolItemSample, AxisItem, PlotWidget, DiscretizedScale
)

SELECTION_WIDTH = 5
MAX_N_VALID_SIZE_ANIMATE = 1000

# maximum number of colors (including Other)
MAX_COLORS = 11


class LegendItem(PgLegendItem):
    def __init__(
            self, size=None, offset=None, pen=None, brush=None,
    ):
        super().__init__(size, offset)

        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setHorizontalSpacing(15)
        self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)
        if pen is not None:
            pen = QPen(pen)
        if brush is not None:
            brush = QBrush(brush)
        self.__pen = pen
        self.__brush = brush

    def restoreAnchor(self, anchors):
        """
        Restore (parent) relative position from stored anchors.

        The restored position is within the parent bounds.
        """
        anchor, parentanchor = anchors
        self.anchor(*bound_anchor_pos(anchor, parentanchor))

    # pylint: disable=arguments-differ
    def paint(self, painter, _option, _widget=None):
        painter.setPen(self.pen())
        painter.setBrush(self.brush())
        rect = self.contentsRect()
        painter.drawRoundedRect(rect, 2, 2)

    def addItem(self, item, name):
        super().addItem(item, name)
        # Fix-up the label alignment, and color
        color = self.palette().color(QPalette.Text)
        _, label = self.items[-1]
        label.setText(name, justify="left", color=color)

    def clear(self):
        """
        Clear all legend items.
        """
        items = list(self.items)
        self.items = []
        for sample, label in items:
            self.layout.removeItem(sample)
            self.layout.removeItem(label)
            sample.hide()
            label.hide()

        self.updateSize()

    def pen(self):
        if self.__pen is not None:
            return QPen(self.__pen)
        else:
            color = self.palette().color(QPalette.Disabled, QPalette.Text)
            color.setAlpha(100)
            pen = QPen(color, 1)
            pen.setCosmetic(True)
            return pen

    def brush(self):
        if self.__brush is not None:
            return QBrush(self.__brush)
        else:
            color = self.palette().color(QPalette.Window)
            color.setAlpha(150)
            return QBrush(color)

    def changeEvent(self, event: QEvent):
        if event.type() == QEvent.PaletteChange:
            color = self.palette().color(QPalette.Text)
            for _, label in self.items:
                label.setText(label.text, color=color)
        super().changeEvent(event)


def bound_anchor_pos(corner, parentpos):
    corner = np.clip(corner, 0, 1)
    parentpos = np.clip(parentpos, 0, 1)

    irx, iry = corner
    prx, pry = parentpos

    if irx > 0.9 and prx < 0.1:
        irx = prx = 0.0
    if iry > 0.9 and pry < 0.1:
        iry = pry = 0.0
    if irx < 0.1 and prx > 0.9:
        irx = prx = 1.0
    if iry < 0.1 and pry > 0.9:
        iry = pry = 1.0
    return (irx, iry), (prx, pry)


class ScatterPlotItem(pg.ScatterPlotItem):
    """
    Modifies the behaviour of ScatterPlotItem as follows:

    - Add z-index. ScatterPlotItem paints points in order of appearance in
      self.data. Plotting by z-index is achieved by sorting before calling
      super().paint() and re-sorting afterwards. Re-sorting (instead of
      storing the original data) is needed because the inherited paint
      may modify the data.

    - Prevent multiple calls to updateSpots. ScatterPlotItem calls updateSpots
      at any change of sizes/colors/symbols, which then rebuilds the stored
      pixmaps for each symbol. Orange calls set* functions in succession,
      so we postpone updateSpots() to paint()."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._update_spots_in_paint = False
        self._z_mapping = None
        self._inv_mapping = None

    def setZ(self, z):
        """
        Set z values for all points.

        Points with higher values are plotted on top of those with lower.

        Args:
            z (np.ndarray or None): a vector of z values
        """
        if z is None:
            self._z_mapping = self._inv_mapping = None
        else:
            assert len(z) == len(self.data)
            self._z_mapping = np.argsort(z)
            self._inv_mapping = np.argsort(self._z_mapping)

    def setCoordinates(self, x, y):
        """
        Change the coordinates of points while keeping other properties.

        Asserts that the number of points stays the same.

        Note. Pyqtgraph does not offer a method for this: setting coordinates
        invalidates other data. We therefore retrieve the data to set it
        together with the coordinates. Pyqtgraph also does not offer a
        (documented) method for retrieving the data, yet using
        data[prop]` looks reasonably safe.

        The alternative, updating the whole scatterplot from the Orange Table,
        is too slow.
        """
        assert len(self.data) == len(x) == len(y)
        data = dict(x=x, y=y)
        for prop in ('pen', 'brush', 'size', 'symbol', 'data'):
            data[prop] = self.data[prop]
        self.setData(**data)

    def updateSpots(self, dataSet=None):  # pylint: disable=unused-argument
        self._update_spots_in_paint = True
        self.update()

    # pylint: disable=arguments-differ
    def paint(self, painter, option, widget=None):
        try:
            if self._z_mapping is not None:
                assert len(self._z_mapping) == len(self.data)
                self.data = self.data[self._z_mapping]
            if self._update_spots_in_paint:
                self._update_spots_in_paint = False
                super().updateSpots()
            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
            super().paint(painter, option, widget)
        finally:
            if self._inv_mapping is not None:
                self.data = self.data[self._inv_mapping]


def _define_symbols():
    """
    Add symbol ? to ScatterPlotItemSymbols,
    reflect the triangle to point upwards
    """
    path = QPainterPath()
    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))
    path.moveTo(-0.5, 0.5)
    path.lineTo(0.5, -0.5)
    path.moveTo(-0.5, -0.5)
    path.lineTo(0.5, 0.5)
    Symbols["?"] = path

    path = QPainterPath()
    plusCoords = [
        (-0.5, -0.1), (-0.5, 0.1), (-0.1, 0.1), (-0.1, 0.5),
        (0.1, 0.5), (0.1, 0.1), (0.5, 0.1), (0.5, -0.1),
        (0.1, -0.1), (0.1, -0.5), (-0.1, -0.5), (-0.1, -0.1)
    ]
    path.moveTo(*plusCoords[0])
    for x, y in plusCoords[1:]:
        path.lineTo(x, y)
    path.closeSubpath()
    Symbols["+"] = path

    tr = QTransform()
    tr.rotate(180)
    Symbols['t'] = tr.map(Symbols['t'])

    tr = QTransform()
    tr.rotate(45)
    Symbols['x'] = tr.map(Symbols["+"])


_define_symbols()


def _make_pen(color, width):
    p = QPen(color, width)
    p.setCosmetic(True)
    return p


class AxisItem(AxisItem):
    """
    Axis that if needed displays ticks appropriate for time data.
    """

    _label_width = 80

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._use_time = False

    def use_time(self, enable):
        """Enables axes to display ticks for time data."""
        self._use_time = enable
        self.enableAutoSIPrefix(not enable)

    def tickValues(self, minVal, maxVal, size):
        """Find appropriate tick locations."""
        if not self._use_time:
            return super().tickValues(minVal, maxVal, size)

        # if timezone is not set, then local is used which cause exceptions
        minVal = max(minVal,
                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)
        maxVal = min(maxVal,
                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)
        mn = utc_from_timestamp(minVal).timetuple()
        mx = utc_from_timestamp(maxVal).timetuple()
        try:
            bins = _time_binnings(mn, mx, 6, 30)[-1]
        except (IndexError, ValueError):
            # cannot handle very large and very small time intervals
            return super().tickValues(minVal, maxVal, size)

        ticks = bins.thresholds
        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs
        # because they are out of range. Removing them here is needed so that
        # they do not affect spaces and label format
        ticks = ticks[(ticks[0] < minVal)
                      :len(ticks) - (ticks[-1] > maxVal)]

        max_steps = max(int(size / self._label_width), 1)
        if len(ticks) > max_steps:
            # remove some of ticks so that they don't overlap
            step = int(np.ceil(float(len(ticks)) / max_steps))
            ticks = ticks[::step]

        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))
        return [(spacing, ticks)]

    def tickStrings(self, values, scale, spacing):
        """Format tick values according to space between them."""
        if not self._use_time:
            return super().tickStrings(values, scale, spacing)

        if spacing >= 3600 * 24 * 365:
            fmt = "%Y"
        elif spacing >= 3600 * 24 * 28:
            fmt = "%Y %b"
        elif spacing >= 3600 * 24:
            fmt = "%Y %b %d"
        elif spacing >= 3600:
            min_day = max_day = 1
            if len(values) > 0:
                min_day = datetime.fromtimestamp(
                    min(values), tz=timezone.utc).day
                max_day = datetime.fromtimestamp(
                    max(values), tz=timezone.utc).day
            if min_day == max_day:
                fmt = "%Hh"
            else:
                fmt = "%d %Hh"
        elif spacing >= 60:
            fmt = "%H:%M"
        elif spacing >= 1:
            fmt = "%H:%M:%S"
        else:
            fmt = '%S.%f'

        return [utc_from_timestamp(x).strftime(fmt) for x in values]


class ScatterBaseParameterSetter(CommonParameterSetter):
    CAT_LEGEND_LABEL = "Categorical legend"
    NUM_LEGEND_LABEL = "Numerical legend"
    NUM_LEGEND_SETTING = {
        Updater.SIZE_LABEL: (range(4, 50), 11),
        Updater.IS_ITALIC_LABEL: (None, False),
    }

    def __init__(self, master):
        super().__init__()
        self.master = master
        self.cat_legend_settings = {}
        self.num_legend_settings = {}

    def update_setters(self):
        self.initial_settings = {
            self.LABELS_BOX: {
                self.FONT_FAMILY_LABEL: self.FONT_FAMILY_SETTING,
                self.TITLE_LABEL: self.FONT_SETTING,
                self.LABEL_LABEL: self.FONT_SETTING,
                self.CAT_LEGEND_LABEL: self.FONT_SETTING,
                self.NUM_LEGEND_LABEL: self.NUM_LEGEND_SETTING,
            },
            self.ANNOT_BOX: {
                self.TITLE_LABEL: {self.TITLE_LABEL: ("", "")},
            }
        }

        def update_cat_legend(**settings):
            self.cat_legend_settings.update(**settings)
            Updater.update_legend_font(self.cat_legend_items, **settings)

        def update_num_legend(**settings):
            self.num_legend_settings.update(**settings)
            Updater.update_num_legend_font(self.num_legend, **settings)

        labels = self.LABELS_BOX
        self._setters[labels][self.CAT_LEGEND_LABEL] = update_cat_legend
        self._setters[labels][self.NUM_LEGEND_LABEL] = update_num_legend

    @property
    def title_item(self):
        return self.master.plot_widget.getPlotItem().titleLabel

    @property
    def cat_legend_items(self):
        items = self.master.color_legend.items
        if items and items[0] and isinstance(items[0][0], PaletteItemSample):
            items = []
        return itertools.chain(self.master.shape_legend.items, items)

    @property
    def num_legend(self):
        items = self.master.color_legend.items
        if items and items[0] and isinstance(items[0][0], PaletteItemSample):
            return self.master.color_legend
        return None

    @property
    def labels(self):
        return self.master.labels


class OWScatterPlotBase(gui.OWComponent, QObject):
    """
    Provide a graph component for widgets that show any kind of point plot

    The component plots a set of points with given coordinates, shapes,
    sizes and colors. Its function is similar to that of a *view*, whereas
    the widget represents a *model* and a *controler*.

    The model (widget) needs to provide methods:

    - `get_coordinates_data`, `get_size_data`, `get_color_data`,
      `get_shape_data`, `get_label_data`, which return a 1d array (or two
      arrays, for `get_coordinates_data`) of `dtype` `float64`, except for
      `get_label_data`, which returns formatted labels;
    - `get_shape_labels` returns a list of strings for shape legend
    - `get_color_labels` returns strings for color legend, or a function for
       formatting numbers if the legend is continuous, or None for default
       formatting
    - `get_tooltip`, which gives a tooltip for a single data point
    - (optional) `impute_sizes`, `impute_shapes` get final coordinates and
      shapes, and replace nans;
    - `get_subset_mask` returns a bool array indicating whether a
      data point is in the subset or not (e.g. in the 'Data Subset' signal
      in the Scatter plot and similar widgets);
    - `get_palette` returns a palette appropriate for visualizing the
      current color data;
    - `is_continuous_color` decides the type of the color legend;

    The widget (in a role of controller) must also provide methods
    - `selection_changed`

    If `get_coordinates_data` returns `(None, None)`, the plot is cleared. If
    `get_size_data`, `get_color_data` or `get_shape_data` return `None`,
    all points will have the same size, color or shape, respectively.
    If `get_label_data` returns `None`, there are no labels.

    The view (this compomnent) provides methods `update_coordinates`,
    `update_sizes`, `update_colors`, `update_shapes` and `update_labels`
    that the widget (in a role of a controler) should call when any of
    these properties are changed. If the widget calls, for instance, the
    plot's `update_colors`, the plot will react by calling the widget's
    `get_color_data` as well as the widget's methods needed to construct the
    legend.

    The view also provides a method `reset_graph`, which should be called only
    when
    - the widget gets entirely new data
    - the number of points may have changed, for instance when selecting
    a different attribute for x or y in the scatter plot, where the points
    with missing x or y coordinates are hidden.

    Every `update_something` calls the plot's `get_something`, which
    calls the model's `get_something_data`, then it transforms this data
    into whatever is needed (colors, shapes, scaled sizes) and changes the
    plot. For the simplest example, here is `update_shapes`:

    ```
        def update_shapes(self):
            if self.scatterplot_item:
                shape_data = self.get_shapes()
                self.scatterplot_item.setSymbol(shape_data)
            self.update_legends()

        def get_shapes(self):
            shape_data = self.master.get_shape_data()
            shape_data = self.master.impute_shapes(
                shape_data, len(self.CurveSymbols) - 1)
            return self.CurveSymbols[shape_data]
    ```

    On the widget's side, `get_something_data` is essentially just:

    ```
        def get_size_data(self):
            return self.get_column(self.attr_size)
    ```

    where `get_column` retrieves a column while also filtering out the
    points with missing x and y and so forth. (Here we present the simplest
    two cases, "shapes" for the view and "sizes" for the model. The colors
    for the view are more complicated since they deal with discrete and
    continuous palettes, and the shapes for the view merge infrequent shapes.)

    The plot can also show just a random sample of the data. The sample size is
    set by `set_sample_size`, and the rest is taken care by the plot: the
    widget keeps providing the data for all points, selection indices refer
    to the entire set etc. Internally, sampling happens as early as possible
    (in methods `get_<something>`).
    """
    too_many_labels = Signal(bool)
    begin_resizing = Signal()
    step_resizing = Signal()
    end_resizing = Signal()

    label_only_selected = Setting(False)
    point_width = Setting(10)
    alpha_value = Setting(128)
    show_grid = Setting(False)
    show_legend = Setting(True)
    class_density = Setting(False)
    jitter_size = Setting(0)

    resolution = 256

    CurveSymbols = np.array("o x t + d star ?".split())
    MinShapeSize = 6
    DarkerValue = 120
    UnknownColor = (168, 50, 168)

    COLOR_DEFAULT = (128, 128, 128)

    MAX_VISIBLE_LABELS = 500

    def __init__(self, scatter_widget, parent=None, view_box=ViewBox):
        QObject.__init__(self)
        gui.OWComponent.__init__(self, scatter_widget)

        self.subset_is_shown = False
        self.jittering_suspended = False

        self.view_box = view_box(self)
        _axis = {"left": AxisItem("left"), "bottom": AxisItem("bottom")}
        self.plot_widget = PlotWidget(
            viewBox=self.view_box, parent=parent, background=None,
            axisItems=_axis
        )
        self.plot_widget.hideAxis("left")
        self.plot_widget.hideAxis("bottom")
        self.plot_widget.getPlotItem().buttonsHidden = True
        self.plot_widget.setAntialiasing(True)
        self.plot_widget.sizeHint = lambda: QSize(500, 500)

        self.density_img = None
        self.scatterplot_item = None
        self.scatterplot_item_sel = None
        self.labels = []

        self.master = scatter_widget
        tooltip = self._create_drag_tooltip()
        self.view_box.setDragTooltip(tooltip)

        self.selection = None  # np.ndarray

        self.n_valid = 0
        self.n_shown = 0
        self.sample_size = None
        self.sample_indices = None

        self.palette = None

        self.shape_legend = self._create_legend(((1, 0), (1, 0)))
        self.color_legend = self._create_legend(((1, 1), (1, 1)))
        self.update_legend_visibility()

        self.scale = None  # DiscretizedScale
        self._too_many_labels = False

        # self.setMouseTracking(True)
        # self.grabGesture(QPinchGesture)
        # self.grabGesture(QPanGesture)

        self.update_grid_visibility()

        self._tooltip_delegate = EventDelegate(self.help_event)
        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)
        self.view_box.sigTransformChanged.connect(self.update_density)
        self.view_box.sigRangeChangedManually.connect(self.update_labels)

        self.timer = None

        self.parameter_setter = ScatterBaseParameterSetter(self)

    def _create_legend(self, anchor):
        legend = LegendItem()
        legend.setParentItem(self.plot_widget.getViewBox())
        legend.restoreAnchor(anchor)
        return legend

    def _create_drag_tooltip(self):
        tip_parts = [
            (Qt.ControlModifier,
             "{}: Append to group".
             format("Cmd" if sys.platform == "darwin" else "Ctrl")),
            (Qt.ShiftModifier, "Shift: Add group"),
            (Qt.AltModifier, "Alt: Remove")
        ]
        all_parts = "<center>" + \
                    ", ".join(part for _, part in tip_parts) + \
                    "</center>"
        self.tiptexts = {
            modifier: all_parts.replace(part, "<b>{}</b>".format(part))
            for modifier, part in tip_parts
        }
        self.tiptexts[Qt.NoModifier] = all_parts

        self.tip_textitem = text = QGraphicsTextItem()
        # Set to the longest text
        text.setHtml(self.tiptexts[Qt.ControlModifier])
        text.setPos(4, 2)
        r = text.boundingRect()
        text.setTextWidth(r.width())
        rect = QGraphicsRectItem(0, 0, r.width() + 8, r.height() + 4)
        color = self.plot_widget.palette().color(QPalette.Disabled, QPalette.Window)
        color.setAlpha(212)
        rect.setBrush(color)
        rect.setPen(QPen(Qt.NoPen))
        self.update_tooltip()

        tooltip_group = QGraphicsItemGroup()
        tooltip_group.addToGroup(rect)
        tooltip_group.addToGroup(text)
        return tooltip_group

    def update_tooltip(self, modifiers=Qt.NoModifier):
        text = self.tiptexts[Qt.NoModifier]
        for mod in [Qt.ControlModifier,
                    Qt.ShiftModifier,
                    Qt.AltModifier]:
            if modifiers & mod:
                text = self.tiptexts.get(mod)
                break
        self.tip_textitem.setHtml(text)

    def suspend_jittering(self):
        if self.jittering_suspended:
            return
        self.jittering_suspended = True
        if self.jitter_size != 0:
            self.update_jittering()

    def unsuspend_jittering(self):
        if not self.jittering_suspended:
            return
        self.jittering_suspended = False
        if self.jitter_size != 0:
            self.update_jittering()

    def update_jittering(self):
        x, y = self.get_coordinates()
        if x is None or len(x) == 0 or self.scatterplot_item is None:
            return
        self.scatterplot_item.setCoordinates(x, y)
        self.scatterplot_item_sel.setCoordinates(x, y)
        self.update_labels()

    # TODO: Rename to remove_plot_items
    def clear(self):
        """
        Remove all graphical elements from the plot

        Calls the pyqtgraph's plot widget's clear, sets all handles to `None`,
        removes labels and selections.

        This method should generally not be called by the widget. If the data
        is gone (*e.g.* upon receiving `None` as an input data signal), this
        should be handler by calling `reset_graph`, which will in turn call
        `clear`.

        Derived classes should override this method if they add more graphical
        elements. For instance, the regression line in the scatterplot adds
        `self.reg_line_item = None` (the line in the plot is already removed
        in this method).
        """
        self.plot_widget.clear()

        self.density_img = None
        if self.timer is not None and self.timer.isActive():
            self.timer.stop()
            self.timer = None
        self.scatterplot_item = None
        self.scatterplot_item_sel = None
        self.labels = []
        self._signal_too_many_labels(False)
        self.view_box.init_history()
        self.view_box.tag_history()

    # TODO: I hate `keep_something` and `reset_something` arguments
    # __keep_selection is used exclusively be set_sample size which would
    # otherwise just repeat the code from reset_graph except for resetting
    # the selection. I'm uncomfortable with this; we may prefer to have a
    # method _reset_graph which does everything except resetting the selection,
    # and reset_graph would call it.
    def reset_graph(self, __keep_selection=False):
        """
        Reset the graph to new data (or no data)

        The method must be called when the plot receives new data, in
        particular when the number of points change. If only their properties
        - like coordinates or shapes - change, an update method
        (`update_coordinates`, `update_shapes`...) should be called instead.

        The method must also be called when the data is gone.

        The method calls `clear`, followed by calls of all update methods.

        NB. Argument `__keep_selection` is for internal use only
        """
        self.clear()
        if not __keep_selection:
            self.selection = None
        self.sample_indices = None
        self.update_coordinates()
        self.update_point_props()

    def set_sample_size(self, sample_size):
        """
        Set the sample size

        Args:
            sample_size (int or None): sample size or `None` to show all points
        """
        if self.sample_size != sample_size:
            self.sample_size = sample_size
            self.reset_graph(True)

    def update_point_props(self):
        """
        Update the sizes, colors, shapes and labels

        The method calls the appropriate update methods for individual
        properties.
        """
        self.update_sizes()
        self.update_colors()
        self.update_selection_colors()
        self.update_shapes()
        self.update_labels()

    # Coordinates
    # TODO: It could be nice if this method was run on entire data, not just
    # a sample. For this, however, it would need to either be called from
    # `get_coordinates` before sampling (very ugly) or call
    # `self.master.get_coordinates_data` (beyond ugly) or the widget would
    # have to store the ranges of unsampled data (ugly).
    # Maybe we leave it as it is.
    def _reset_view(self, x_data, y_data):
        """
        Set the range of the view box

        Args:
            x_data (np.ndarray): x coordinates
            y_data (np.ndarray) y coordinates
        """
        min_x, max_x = np.min(x_data), np.max(x_data)
        min_y, max_y = np.min(y_data), np.max(y_data)
        self.view_box.setRange(
            QRectF(min_x, min_y, max_x - min_x or 1, max_y - min_y or 1),
            padding=0.025)

    def _filter_visible(self, data):
        """Return the sample from the data using the stored sample_indices"""
        if data is None or self.sample_indices is None:
            return data
        else:
            return np.asarray(data[self.sample_indices])

    def get_coordinates(self):
        """
        Prepare coordinates of the points in the plot

        The method is called by `update_coordinates`. It gets the coordinates
        from the widget, jitters them and return them.

        The methods also initializes the sample indices if neededd and stores
        the original and sampled number of points.

        Returns:
            (tuple): a pair of numpy arrays containing (sampled) coordinates,
                or `(None, None)`.
        """
        x, y = self.master.get_coordinates_data()
        if x is None:
            self.n_valid = self.n_shown = 0
            return None, None
        self.n_valid = len(x)
        self._create_sample()
        x = self._filter_visible(x)
        y = self._filter_visible(y)
        # Jittering after sampling is OK if widgets do not change the sample
        # semi-permanently, e.g. take a sample for the duration of some
        # animation. If the sample size changes dynamically (like by adding
        # a "sample size" slider), points would move around when the sample
        # size changes. To prevent this, jittering should be done before
        # sampling (i.e. two lines earlier). This would slow it down somewhat.
        x, y = self.jitter_coordinates(x, y)
        return x, y

    def _create_sample(self):
        """
        Create a random sample if the data is larger than the set sample size
        """
        self.n_shown = min(self.n_valid, self.sample_size or self.n_valid)
        if self.sample_size is not None \
                and self.sample_indices is None \
                and self.n_valid != self.n_shown:
            random = np.random.RandomState(seed=0)
            self.sample_indices = random.choice(
                self.n_valid, self.n_shown, replace=False)
            # TODO: Is this really needed?
            np.sort(self.sample_indices)

    def jitter_coordinates(self, x, y):
        """
        Display coordinates to random positions within ellipses with
        radiuses of `self.jittter_size` percents of spans
        """
        if self.jitter_size == 0 or self.jittering_suspended:
            return x, y
        return self._jitter_data(x, y)

    def _jitter_data(self, x, y, span_x=None, span_y=None):
        if span_x is None:
            span_x = np.max(x) - np.min(x)
        if span_y is None:
            span_y = np.max(y) - np.min(y)
        random = np.random.RandomState(seed=0)
        rs = random.uniform(0, 1, len(x))
        phis = random.uniform(0, 2 * np.pi, len(x))
        magnitude = self.jitter_size / 100
        return (x + magnitude * span_x * rs * np.cos(phis),
                y + magnitude * span_y * rs * np.sin(phis))

    def update_coordinates(self):
        """
        Trigger the update of coordinates while keeping other features intact.

        The method gets the coordinates by calling `self.get_coordinates`,
        which in turn calls the widget's `get_coordinate_data`. The number of
        coordinate pairs returned by the latter must match the current number
        of points. If this is not the case, the widget should trigger
        the complete update by calling `reset_graph` instead of this method.
        """
        x, y = self.get_coordinates()
        if x is None or len(x) == 0:
            return

        self._reset_view(x, y)
        if self.scatterplot_item is None:
            if self.sample_indices is None:
                indices = np.arange(self.n_valid)
            else:
                indices = self.sample_indices
            kwargs = dict(x=x, y=y, data=indices)
            self.scatterplot_item = ScatterPlotItem(**kwargs)
            self.scatterplot_item.sigClicked.connect(self.select_by_click)
            self.scatterplot_item_sel = ScatterPlotItem(**kwargs)
            self.plot_widget.addItem(self.scatterplot_item_sel)
            self.plot_widget.addItem(self.scatterplot_item)
        else:
            self.scatterplot_item.setCoordinates(x, y)
            self.scatterplot_item_sel.setCoordinates(x, y)
            self.update_labels()

        self.update_density()  # Todo: doesn't work: try MDS with density on

    # Sizes
    def get_sizes(self):
        """
        Prepare data for sizes of points in the plot

        The method is called by `update_sizes`. It gets the sizes
        from the widget and performs the necessary scaling and sizing.
        The output is rounded to half a pixel for faster drawing.

        Returns:
            (np.ndarray): sizes
        """
        size_column = self.master.get_size_data()
        if size_column is None:
            return np.full((self.n_shown,),
                           self.MinShapeSize + (5 + self.point_width) * 0.5)
        size_column = self._filter_visible(size_column)
        size_column = size_column.copy()
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", category=RuntimeWarning)
            size_column -= np.nanmin(size_column)
            mx = np.nanmax(size_column)
        if mx > 0:
            size_column /= mx
        else:
            size_column[:] = 0.5

        sizes = self.MinShapeSize + (5 + self.point_width) * size_column
        # round sizes to half pixel for smaller pyqtgraph's symbol pixmap atlas
        sizes = (sizes * 2).round() / 2
        return sizes

    def update_sizes(self):
        """
        Trigger an update of point sizes

        The method calls `self.get_sizes`, which in turn calls the widget's
        `get_size_data`. The result are properly scaled and then passed
        back to widget for imputing (`master.impute_sizes`).
        """
        if self.scatterplot_item:
            size_data = self.get_sizes()
            size_imputer = getattr(
                self.master, "impute_sizes", self.default_impute_sizes)
            size_imputer(size_data)

            if self.timer is not None and self.timer.isActive():
                self.timer.stop()
                self.timer = None

            current_size_data = self.scatterplot_item.data["size"].copy()
            diff = size_data - current_size_data
            widget = self

            class Timeout:
                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2
                factors = [0.07, 0.16, 0.27, 0.41, 0.55,
                           0.68, 0.81, 0.9, 0.97, 1]

                def __init__(self):
                    self._counter = 0

                def __call__(self):
                    factor = self.factors[self._counter]
                    self._counter += 1
                    size = current_size_data + diff * factor
                    if len(self.factors) == self._counter:
                        widget.timer.stop()
                        widget.timer = None
                        size = size_data
                    widget.scatterplot_item.setSize(size)
                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)
                    if widget.timer is None:
                        widget.end_resizing.emit()
                    else:
                        widget.step_resizing.emit()

            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \
                    np.all(current_size_data > 0) and np.any(diff != 0):
                # If encountered any strange behaviour when updating sizes,
                # implement it with threads
                self.begin_resizing.emit()
                interval = int(500 / len(Timeout.factors))
                self.timer = QTimer(self.scatterplot_item, interval=interval)
                self.timer.timeout.connect(Timeout())
                self.timer.start()
            else:
                self.begin_resizing.emit()
                self.scatterplot_item.setSize(size_data)
                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)
                self.end_resizing.emit()

    update_point_size = update_sizes  # backward compatibility (needed?!)
    update_size = update_sizes

    @classmethod
    def default_impute_sizes(cls, size_data):
        """
        Fallback imputation for sizes.

        Set the size to two pixels smaller than the minimal size

        Returns:
            (bool): True if there was any missing data
        """
        nans = np.isnan(size_data)
        if np.any(nans):
            size_data[nans] = cls.MinShapeSize - 2
            return True
        else:
            return False

    # Colors
    def get_colors(self):
        """
        Prepare data for colors of the points in the plot

        The method is called by `update_colors`. It gets the colors and the
        indices of the data subset from the widget (`get_color_data`,
        `get_subset_mask`), and constructs lists of pens and brushes for
        each data point.

        The method uses different palettes for discrete and continuous data,
        as determined by calling the widget's method `is_continuous_color`.

        If also marks the points that are in the subset as defined by, for
        instance the 'Data Subset' signal in the Scatter plot and similar
        widgets. (Do not confuse this with *selected points*, which are
        marked by circles around the points, which are colored by groups
        and thus independent of this method.)

        Returns:
            (tuple): a list of pens and list of brushes
        """
        c_data = self.master.get_color_data()
        c_data = self._filter_visible(c_data)
        subset = self.master.get_subset_mask()
        subset = self._filter_visible(subset)
        self.subset_is_shown = subset is not None
        if c_data is None:  # same color
            self.palette = None
            return self._get_same_colors(subset)
        elif self.master.is_continuous_color():
            return self._get_continuous_colors(c_data, subset)
        else:
            return self._get_discrete_colors(c_data, subset)

    def _get_same_colors(self, subset, color=COLOR_DEFAULT):
        """
        Return the same pen for all points while the brush color depends
        upon whether the point is in the subset or not

        Args:
            subset (np.ndarray): a bool array indicating whether a data point
                is in the subset or not (e.g. in the 'Data Subset' signal
                in the Scatter plot and similar widgets);

        Returns:
            (tuple): a list of pens and list of brushes
        """
        alpha_subset, alpha_unset = self._alpha_for_subsets()
        if subset is not None:
            qcolor = QColor(*color, alpha_subset)
            brush = np.where(subset, QBrush(qcolor), QBrush(QColor(0, 0, 0, 0)))
            pen = np.where(subset,
                           _make_pen(qcolor, 1.5),
                           _make_pen(QColor(*color, alpha_unset), 1.5))
        else:
            qcolor = QColor(*color, self.alpha_value)
            brush = np.full(self.n_shown, QBrush(qcolor))
            pen = [_make_pen(qcolor, 1.5)] * self.n_shown
        return pen, brush

    def _get_continuous_colors(self, c_data, subset):
        """
        Return the pens and colors whose color represent an index into
        a continuous palette. The same color is used for pen and brush,
        except the former is darker. If the data has a subset, the brush
        is transparent for points that are not in the subset.
        """
        palette = self.master.get_palette()

        if np.isnan(c_data).all():
            self.palette = palette
            return self._get_same_colors(subset, self.palette.nan_color)

        self.scale = DiscretizedScale(np.nanmin(c_data), np.nanmax(c_data))
        bins = self.scale.get_bins()
        self.palette = \
            colorpalettes.BinnedContinuousPalette.from_palette(palette, bins)
        colors = self.palette.values_to_colors(c_data)
        alphas = np.full((len(c_data), 1), self.alpha_value, dtype=np.ubyte)
        brush = np.hstack((colors, alphas))
        pen = np.hstack(
            ((colors.astype(dtype=float) * 100 / self.DarkerValue).astype(np.ubyte),
             alphas))

        # Reuse pens and brushes with the same colors because PyQtGraph then
        # builds smaller pixmap atlas, which makes the drawing faster

        def reuse(cache, fun, *args):
            if args not in cache:
                cache[args] = fun(args)
            return cache[args]

        def create_pen(col):
            return _make_pen(QColor(*col), 1.5)

        def create_brush(col):
            return QBrush(QColor(*col))

        if subset is not None:
            alpha_subset, alpha_unset = self._alpha_for_subsets()
            brush[:, 3] = 0
            brush[subset, 3] = alpha_subset
            pen[:, 3] = alpha_unset
            brush[subset, 3] = alpha_subset

        cached_pens = {}
        pen = [reuse(cached_pens, create_pen, *col) for col in pen.tolist()]
        cached_brushes = {}
        brush = np.array([reuse(cached_brushes, create_brush, *col)
                          for col in brush.tolist()])

        return pen, brush

    def _get_discrete_colors(self, c_data, subset):
        """
        Return the pens and colors whose color represent an index into
        a discrete palette. The same color is used for pen and brush,
        except the former is darker. If the data has a subset, the brush
        is transparent for points that are not in the subset.
        """
        self.palette = self.master.get_palette()
        c_data = c_data.copy()
        c_data[np.isnan(c_data)] = len(self.palette)
        c_data = c_data.astype(int)
        colors = self.palette.qcolors_w_nan
        if subset is None:
            for col in colors:
                col.setAlpha(self.alpha_value)
            pens = np.array(
                [_make_pen(col.darker(self.DarkerValue), 1.5)
                 for col in colors])
            pen = pens[c_data]
            brushes = np.array([QBrush(col) for col in colors])
            brush = brushes[c_data]
        else:
            subset_colors = [QColor(col) for col in colors]
            alpha_subset, alpha_unset = self._alpha_for_subsets()
            for col in subset_colors:
                col.setAlpha(alpha_subset)
            for col in colors:
                col.setAlpha(alpha_unset)

            pens, subset_pens = (
                np.array(
                    [_make_pen(col.darker(self.DarkerValue), 1.5)
                     for col in cols])
                for cols in (colors, subset_colors))
            pen = np.where(subset, subset_pens[c_data], pens[c_data])

            brushes = np.array([QBrush(col) for col in subset_colors])
            brush = brushes[c_data]
            black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))
            brush = np.where(subset, brush, black)
        return pen, brush

    def _alpha_for_subsets(self):
        a, b, c = 1.2, -3.2, 3
        x = self.alpha_value / 255
        alpha_subset = 31 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))
        x = 1 - x
        alpha_unset = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))
        return alpha_subset, alpha_unset

    def update_colors(self):
        """
        Trigger an update of point colors

        The method calls `self.get_colors`, which in turn calls the widget's
        `get_color_data` to get the indices in the pallette. `get_colors`
        returns a list of pens and brushes to which this method uses to
        update the colors. Finally, the method triggers the update of the
        legend and the density plot.
        """
        if self.scatterplot_item is not None:
            pen_data, brush_data = self.get_colors()
            self.scatterplot_item.setPen(pen_data, update=False, mask=None)
            self.scatterplot_item.setBrush(brush_data, mask=None)
        self.update_z_values()
        self.update_legends()
        self.update_density()

    update_alpha_value = update_colors

    def update_density(self):
        """
        Remove the existing density plot (if there is one) and replace it
        with a new one (if enabled).

        The method gets the colors from the pens of the currently plotted
        points.
        """
        if self.density_img:
            self.plot_widget.removeItem(self.density_img)
            self.density_img = None
        if self.class_density and self.scatterplot_item is not None:
            c_data = self.master.get_color_data()
            if c_data is None:
                return
            visible_c_data = self._filter_visible(c_data)
            mask = np.isfinite(visible_c_data)
            if not self.master.is_continuous_color():
                mask = np.bitwise_and(mask, visible_c_data < MAX_COLORS - 1)
            pens = self.scatterplot_item.data['pen']
            rgb_data = [
                pen.color().getRgb()[:3] if pen is not None else (255, 255, 255)
                for known, pen in zip(mask, pens)
                if known]
            if len(set(rgb_data)) <= 1:
                return
            [min_x, max_x], [min_y, max_y] = self.view_box.viewRange()
            x_data, y_data = self.scatterplot_item.getData()
            self.density_img = classdensity.class_density_image(
                min_x, max_x, min_y, max_y, self.resolution,
                x_data[mask], y_data[mask], rgb_data)
            self.plot_widget.addItem(self.density_img, ignoreBounds=True)

    def update_selection_colors(self):
        """
        Trigger an update of selection markers

        This update method is usually not called by the widget but by the
        plot, since it is the plot that handles the selections.

        Like other update methods, it calls the corresponding get method
        (`get_colors_sel`) which returns a list of pens and brushes.
        """
        if self.scatterplot_item_sel is None:
            return
        pen, brush = self.get_colors_sel()
        self.scatterplot_item_sel.setPen(pen, update=False, mask=None)
        self.scatterplot_item_sel.setBrush(brush, mask=None)
        self.update_z_values()

    def get_colors_sel(self):
        """
        Return pens and brushes for selection markers.

        A pen can is set to `Qt.NoPen` if a point is not selected.

        All brushes are completely transparent whites.

        Returns:
            (tuple): a list of pens and a list of brushes
        """
        nopen = QPen(Qt.NoPen)
        if self.selection is None:
            pen = [nopen] * self.n_shown
        else:
            sels = np.max(self.selection)
            if sels == 1:
                pen = np.where(
                    self._filter_visible(self.selection),
                    _make_pen(QColor(255, 190, 0, 255), SELECTION_WIDTH),
                    nopen)
            else:
                palette = colorpalettes.LimitedDiscretePalette(
                    number_of_colors=sels + 1)
                pen = np.choose(
                    self._filter_visible(self.selection),
                    [nopen] + [_make_pen(palette[i], SELECTION_WIDTH)
                               for i in range(sels)])
        return pen, [QBrush(QColor(255, 255, 255, 0))] * self.n_shown

    # Labels
    def get_labels(self):
        """
        Prepare data for labels for points

        The method returns the results of the widget's `get_label_data`

        Returns:
            (labels): a sequence of labels
        """
        return self._filter_visible(self.master.get_label_data())

    def update_labels(self):
        """
        Trigger an update of labels

        The method calls `get_labels` which in turn calls the widget's
        `get_label_data`. The obtained labels are shown if the corresponding
        points are selected or if `label_only_selected` is `false`.
        """
        for label in self.labels:
            self.plot_widget.removeItem(label)
        self.labels = []

        mask = None
        if self.scatterplot_item is not None:
            x, y = self.scatterplot_item.getData()
            mask = self._label_mask(x, y)

        if mask is not None:
            labels = self.get_labels()
            if labels is None:
                mask = None

        self._signal_too_many_labels(
            mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)
        if self._too_many_labels or mask is None or not np.any(mask):
            return

        foreground = self.plot_widget.palette().color(QPalette.Text)
        labels = labels[mask]
        x = x[mask]
        y = y[mask]
        for label, xp, yp in zip(labels, x, y):
            ti = TextItem(label, foreground)
            ti.setPos(xp, yp)
            self.plot_widget.addItem(ti)
            self.labels.append(ti)
            ti.setFont(self.parameter_setter.label_font)

    def _signal_too_many_labels(self, too_many):
        if self._too_many_labels != too_many:
            self._too_many_labels = too_many
            self.too_many_labels.emit(too_many)

    def _label_mask(self, x, y):
        (x0, x1), (y0, y1) = self.view_box.viewRange()
        mask = np.logical_and(
            np.logical_and(x >= x0, x <= x1),
            np.logical_and(y >= y0, y <= y1))
        if self.label_only_selected:
            sub_mask = self._filter_visible(self.master.get_subset_mask())
            if self.selection is None:
                if sub_mask is None:
                    return None
                else:
                    sel_mask = sub_mask
            else:
                sel_mask = self._filter_visible(self.selection) != 0
                if sub_mask is not None:
                    sel_mask = np.logical_or(sel_mask, sub_mask)
            mask = np.logical_and(mask, sel_mask)
        return mask

    # Shapes
    def get_shapes(self):
        """
        Prepare data for shapes of points in the plot

        The method is called by `update_shapes`. It gets the data from
        the widget's `get_shape_data`, and then calls its `impute_shapes`
        to impute the missing shape (usually with some default shape).

        Returns:
            (np.ndarray): an array of symbols (e.g. o, x, + ...)
        """
        shape_data = self.master.get_shape_data()
        shape_data = self._filter_visible(shape_data)
        # Data has to be copied so the imputation can change it in-place
        # TODO: Try avoiding this when we move imputation to the widget
        if shape_data is not None:
            shape_data = np.copy(shape_data)
        shape_imputer = getattr(
            self.master, "impute_shapes", self.default_impute_shapes)
        shape_imputer(shape_data, len(self.CurveSymbols) - 1)
        if isinstance(shape_data, np.ndarray):
            shape_data = shape_data.astype(int)
        else:
            shape_data = np.zeros(self.n_shown, dtype=int)
        return self.CurveSymbols[shape_data]

    @staticmethod
    def default_impute_shapes(shape_data, default_symbol):
        """
        Fallback imputation for shapes.

        Use the default symbol, usually the last symbol in the list.

        Returns:
            (bool): True if there was any missing data
        """
        if shape_data is None:
            return False
        nans = np.isnan(shape_data)
        if np.any(nans):
            shape_data[nans] = default_symbol
            return True
        else:
            return False

    def update_shapes(self):
        """
        Trigger an update of point symbols

        The method calls `get_shapes` to obtain an array with a symbol
        for each point and uses it to update the symbols.

        Finally, the method updates the legend.
        """
        if self.scatterplot_item:
            shape_data = self.get_shapes()
            self.scatterplot_item.setSymbol(shape_data)
        self.update_legends()

    def update_z_values(self):
        """
        Set z-values for point in the plot

        The order is as follows:
        - selected points that are also in the subset on top,
        - followed by selected points,
        - followed by points from the subset,
        - followed by the rest.
        Within each of these four groups, points are ordered by their colors.

        Points with less frequent colors are above those with more frequent.
        The points for which the value for the color is missing are at the
        bottom of their respective group.
        """
        if not self.scatterplot_item:
            return

        subset = self.master.get_subset_mask()
        c_data = self.master.get_color_data()
        if subset is None and self.selection is None and c_data is None:
            self.scatterplot_item.setZ(None)
            return

        z = np.zeros(self.n_shown)

        if subset is not None:
            subset = self._filter_visible(subset)
            z[subset] += 1000

        if self.selection is not None:
            z[self._filter_visible(self.selection) != 0] += 2000

        if c_data is not None:
            c_nan = np.isnan(c_data)
            vis_data = self._filter_visible(c_data)
            vis_nan = np.isnan(vis_data)
            z[vis_nan] -= 999
            if not self.master.is_continuous_color():
                dist = np.bincount(c_data[~c_nan].astype(int))
                vis_knowns = vis_data[~vis_nan].astype(int)
                argdist = np.argsort(dist)
                z[~vis_nan] -= argdist[vis_knowns]

        self.scatterplot_item.setZ(z)

    def update_grid_visibility(self):
        """Show or hide the grid"""
        self.plot_widget.showGrid(x=self.show_grid, y=self.show_grid)

    def update_legend_visibility(self):
        """
        Show or hide legends based on whether they are enabled and non-empty
        """
        self.shape_legend.setVisible(
            self.show_legend and bool(self.shape_legend.items))
        self.color_legend.setVisible(
            self.show_legend and bool(self.color_legend.items))

    def update_legends(self):
        """Update content of legends and their visibility"""
        cont_color = self.master.is_continuous_color()
        shape_labels = self.master.get_shape_labels()
        color_labels = self.master.get_color_labels()
        if not cont_color and shape_labels is not None \
                and shape_labels == color_labels:
            colors = self.master.get_color_data()
            shapes = self.master.get_shape_data()
            mask = np.isfinite(colors) * np.isfinite(shapes)
            combined = (colors == shapes)[mask].all()
        else:
            combined = False
        if combined:
            self._update_combined_legend(shape_labels)
        else:
            self._update_shape_legend(shape_labels)
            if cont_color:
                self._update_continuous_color_legend(color_labels)
            else:
                self._update_color_legend(color_labels)
        self.update_legend_visibility()
        Updater.update_legend_font(self.parameter_setter.cat_legend_items,
                                   **self.parameter_setter.cat_legend_settings)
        Updater.update_num_legend_font(self.parameter_setter.num_legend,
                                       **self.parameter_setter.num_legend_settings)

    def _update_shape_legend(self, labels):
        self.shape_legend.clear()
        if labels is None or self.scatterplot_item is None:
            return
        color = QColor(0, 0, 0)
        color.setAlpha(self.alpha_value)
        for label, symbol in zip(labels, self.CurveSymbols):
            self.shape_legend.addItem(
                SymbolItemSample(pen=color, brush=color, size=10, symbol=symbol),
                escape(label))

    def _update_continuous_color_legend(self, label_formatter: Callable[[float], str]):
        self.color_legend.clear()
        if self.scale is None or self.scatterplot_item is None:
            return
        label = PaletteItemSample(self.palette, self.scale, label_formatter)
        self.color_legend.addItem(label, "")
        self.color_legend.setGeometry(label.boundingRect())

    def _update_color_legend(self, labels):
        self.color_legend.clear()
        if labels is None:
            return
        self._update_colored_legend(self.color_legend, labels, 'o')

    def _update_combined_legend(self, labels):
        # update_colored_legend will already clear the shape legend
        # so we remove colors here
        use_legend = \
            self.shape_legend if self.shape_legend.items else self.color_legend
        self.color_legend.clear()
        self.shape_legend.clear()
        self._update_colored_legend(use_legend, labels, self.CurveSymbols)

    def _update_colored_legend(self, legend, labels, symbols):
        if self.scatterplot_item is None or not self.palette:
            return
        if isinstance(symbols, str):
            symbols = itertools.repeat(symbols, times=len(labels))
        colors = self.palette.values_to_colors(np.arange(len(labels)))
        for color, label, symbol in zip(colors, labels, symbols):
            color = QColor(*color)
            pen = _make_pen(color.darker(self.DarkerValue), 1.5)
            color.setAlpha(self.alpha_value)
            brush = QBrush(color)
            legend.addItem(
                SymbolItemSample(pen=pen, brush=brush, size=10, symbol=symbol),
                escape(label))

    def zoom_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().RectMode)

    def pan_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().PanMode)

    def select_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().RectMode)

    def reset_button_clicked(self):
        self.plot_widget.getViewBox().autoRange()
        self.update_labels()

    def select_by_click(self, _, points):
        if self.scatterplot_item is not None:
            self.select(points)

    def select_by_rectangle(self, rect):
        if self.scatterplot_item is not None:
            x0, x1 = sorted((rect.topLeft().x(), rect.bottomRight().x()))
            y0, y1 = sorted((rect.topLeft().y(), rect.bottomRight().y()))
            x, y = self.master.get_coordinates_data()
            indices = np.flatnonzero(
                (x0 <= x) & (x <= x1) & (y0 <= y) & (y <= y1))
            self.select_by_indices(indices.astype(int))

    def unselect_all(self):
        if self.selection is not None:
            self.selection = None
            self.update_selection_colors()
            if self.label_only_selected:
                self.update_labels()
            self.master.selection_changed()

    def select(self, points):
        # noinspection PyArgumentList
        if self.scatterplot_item is None:
            return
        indices = [p.data() for p in points]
        self.select_by_indices(indices)

    def select_by_indices(self, indices):
        if self.selection is None:
            self.selection = np.zeros(self.n_valid, dtype=np.uint8)
        keys = QApplication.keyboardModifiers()
        if keys & Qt.ControlModifier:
            self.selection_append(indices)
        elif keys & Qt.ShiftModifier:
            self.selection_new_group(indices)
        elif keys & Qt.AltModifier:
            self.selection_remove(indices)
        else:
            self.selection_select(indices)

    def selection_select(self, indices):
        self.selection = np.zeros(self.n_valid, dtype=np.uint8)
        self.selection[indices] = 1
        self._update_after_selection()

    def selection_append(self, indices):
        self.selection[indices] = max(np.max(self.selection), 1)
        self._update_after_selection()

    def selection_new_group(self, indices):
        self.selection[indices] = np.max(self.selection) + 1
        self._update_after_selection()

    def selection_remove(self, indices):
        self.selection[indices] = 0
        self._update_after_selection()

    def _update_after_selection(self):
        self._compress_indices()
        self.update_selection_colors()
        if self.label_only_selected:
            self.update_labels()
        self.master.selection_changed()

    def _compress_indices(self):
        indices = sorted(set(self.selection) | {0})
        if len(indices) == max(indices) + 1:
            return
        mapping = np.zeros((max(indices) + 1,), dtype=int)
        for i, ind in enumerate(indices):
            mapping[ind] = i
        self.selection = mapping[self.selection]

    def get_selection(self):
        if self.selection is None:
            return np.array([], dtype=np.uint8)
        else:
            return np.flatnonzero(self.selection)

    def help_event(self, event):
        """
        Create a `QToolTip` for the point hovered by the mouse
        """
        if self.scatterplot_item is None:
            return False
        act_pos = self.scatterplot_item.mapFromScene(event.scenePos())
        point_data = [p.data() for p in self.scatterplot_item.pointsAt(act_pos)]
        text = self.master.get_tooltip(point_data)
        if text:
            QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)
            return True
        else:
            return False

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
[ISSUE]

**Title:** Scatterplot Crashes with ValueError When Using a Single Time Tick

**Description:**
When creating a scatterplot with only one time tick, the application crashes due to a `ValueError`. This occurs because the code attempts to calculate the minimum spacing between ticks, but with only one tick, the sequence is empty, leading to the error.

**Steps to Reproduce:**
```python
import numpy as np
from Orange.data import Domain, Table, TimeVariable, ContinuousVariable
from Orange.widgets.visualize.owscatterplot import OWScatterPlot

def test_single_time_tick_crash():
    # Create data with a single time tick
    data = Table.from_numpy(
        Domain([TimeVariable('time'), ContinuousVariable('value')]),
        np.array([[1582953776, 3]])
    )
    
    # Initialize the scatter plot widget and send the data
    widget = OWScatterPlot()
    widget.send_signal(widget.Inputs.data, data)
    
    # This will raise ValueError: min() arg is an empty sequence
```

**Expected Behavior:**
The scatterplot should handle a single time tick gracefully without crashing. It should display the tick appropriately, possibly by setting a default spacing based on the time range.

**Actual Behavior:**
A `ValueError` is raised with the message `min() arg is an empty sequence`, causing the scatterplot to crash when attempting to plot a single time tick.

[/ISSUE]
{
    "TestOWScatterPlot.test_add_line_calls_proper_regressor": "PASSED",
    "TestOWScatterPlot.test_attr_label_metas": "PASSED",
    "TestOWScatterPlot.test_attr_models": "PASSED",
    "TestOWScatterPlot.test_auto_send_selection": "PASSED",
    "TestOWScatterPlot.test_class_density": "PASSED",
    "TestOWScatterPlot.test_clear_plot": "PASSED",
    "TestOWScatterPlot.test_color_is_optional": "PASSED",
    "TestOWScatterPlot.test_data_column_infs": "PASSED",
    "TestOWScatterPlot.test_data_column_nans": "PASSED",
    "TestOWScatterPlot.test_datasets": "PASSED",
    "TestOWScatterPlot.test_default_attrs": "PASSED",
    "TestOWScatterPlot.test_dragging_tooltip": "PASSED",
    "TestOWScatterPlot.test_error_message": "PASSED",
    "TestOWScatterPlot.test_features_and_data": "PASSED",
    "TestOWScatterPlot.test_features_and_no_data": "PASSED",
    "TestOWScatterPlot.test_group_selections": "PASSED",
    "TestOWScatterPlot.test_handle_metas": "PASSED",
    "TestOWScatterPlot.test_handle_primitive_metas": "PASSED",
    "TestOWScatterPlot.test_hidden_effective_variables": "PASSED",
    "TestOWScatterPlot.test_image_export": "PASSED",
    "TestOWScatterPlot.test_invalid_points_selection": "PASSED",
    "TestOWScatterPlot.test_invalidated_diff_features": "PASSED",
    "TestOWScatterPlot.test_invalidated_diff_features_features_first": "PASSED",
    "TestOWScatterPlot.test_invalidated_diff_features_same_time": "PASSED",
    "TestOWScatterPlot.test_invalidated_diff_features_same_time_features_first": "PASSED",
    "TestOWScatterPlot.test_invalidated_embedding": "PASSED",
    "TestOWScatterPlot.test_invalidated_features_first": "PASSED",
    "TestOWScatterPlot.test_invalidated_same_features": "PASSED",
    "TestOWScatterPlot.test_invalidated_same_time": "PASSED",
    "TestOWScatterPlot.test_invalidated_same_time_features_first": "PASSED",
    "TestOWScatterPlot.test_jittering": "PASSED",
    "TestOWScatterPlot.test_many_discrete_values": "PASSED",
    "TestOWScatterPlot.test_metas_zero_column": "PASSED",
    "TestOWScatterPlot.test_migrate_selection": "PASSED",
    "TestOWScatterPlot.test_minimum_size": "PASSED",
    "TestOWScatterPlot.test_msg_base_class": "PASSED",
    "TestOWScatterPlot.test_no_regression_line": "PASSED",
    "TestOWScatterPlot.test_none_data": "PASSED",
    "TestOWScatterPlot.test_on_manual_change": "PASSED",
    "TestOWScatterPlot.test_opacity_warning": "PASSED",
    "TestOWScatterPlot.test_optional_combos": "PASSED",
    "TestOWScatterPlot.test_orthonormal_line": "PASSED",
    "TestOWScatterPlot.test_output_features": "PASSED",
    "TestOWScatterPlot.test_outputs": "PASSED",
    "TestOWScatterPlot.test_plot_once": "PASSED",
    "TestOWScatterPlot.test_points_combo_boxes": "PASSED",
    "TestOWScatterPlot.test_points_selection": "PASSED",
    "TestOWScatterPlot.test_regression_line": "PASSED",
    "TestOWScatterPlot.test_regression_line_coeffs": "PASSED",
    "TestOWScatterPlot.test_regression_lines_appear": "PASSED",
    "TestOWScatterPlot.test_report_on_empty": "PASSED",
    "TestOWScatterPlot.test_saved_selection": "PASSED",
    "TestOWScatterPlot.test_saving_selection": "PASSED",
    "TestOWScatterPlot.test_score_heuristics": "PASSED",
    "TestOWScatterPlot.test_send_report": "PASSED",
    "TestOWScatterPlot.test_set_data": "PASSED",
    "TestOWScatterPlot.test_set_strings_settings": "PASSED",
    "TestOWScatterPlot.test_setup_graph": "PASSED",
    "TestOWScatterPlot.test_sparse_data": "PASSED",
    "TestOWScatterPlot.test_subset_data": "PASSED",
    "TestOWScatterPlot.test_subset_data_color": "PASSED",
    "TestOWScatterPlot.test_time_axis": "PASSED",
    "TestOWScatterPlot.test_tooltip": "PASSED",
    "TestOWScatterPlot.test_update_regression_line_calls_add_line": "PASSED",
    "TestOWScatterPlot.test_update_regression_line_is_called": "PASSED",
    "TestOWScatterPlot.test_visual_settings": "PASSED",
    "TestOWScatterPlot.test_vizrank": "PASSED",
    "TestOWScatterPlot.test_vizrank_class_nan": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_color_var_nans": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_constant_data": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_no_color_var": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_no_data": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_sparse_data": "PASSED",
    "TestOWScatterPlot.test_vizrank_enabled_two_features": "PASSED",
    "TestOWScatterPlot.test_vizrank_nonprimitives": "PASSED",
    "TestOWScatterPlot.test_vizrank_receives_manual_change": "PASSED"
}
diff --git a/Orange/widgets/visualize/owscatterplotgraph.py b/Orange/widgets/visualize/owscatterplotgraph.py
index 80bddde56..db81a89df 100644
--- a/Orange/widgets/visualize/owscatterplotgraph.py
+++ b/Orange/widgets/visualize/owscatterplotgraph.py
@@ -302,7 +302,10 @@ class AxisItem(AxisItem):
             step = int(np.ceil(float(len(ticks)) / max_steps))
             ticks = ticks[::step]
 
-        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))
+        # In case of a single tick, `default` will inform tickStrings
+        # about the appropriate scale.
+        spacing = min((b - a for a, b in zip(ticks[:-1], ticks[1:])),
+                      default=maxVal - minVal)
         return [(spacing, ticks)]
 
     def tickStrings(self, values, scale, spacing):

{"Orange/widgets/visualize/owscatterplotgraph.py": "import sys\nimport itertools\nimport warnings\nfrom typing import Callable\nfrom xml.sax.saxutils import escape\nfrom datetime import datetime, timezone\n\nimport numpy as np\nfrom AnyQt.QtCore import Qt, QRectF, QSize, QTimer, pyqtSignal as Signal, \\\n    QObject, QEvent\nfrom AnyQt.QtGui import QColor, QPen, QBrush, QPainterPath, QTransform, \\\n    QPainter, QPalette\nfrom AnyQt.QtWidgets import QApplication, QToolTip, QGraphicsTextItem, \\\n    QGraphicsRectItem, QGraphicsItemGroup\n\nimport pyqtgraph as pg\nfrom pyqtgraph.graphicsItems.ScatterPlotItem import Symbols\nfrom pyqtgraph.graphicsItems.LegendItem import LegendItem as PgLegendItem\nfrom pyqtgraph.graphicsItems.TextItem import TextItem\n\nfrom Orange.preprocess.discretize import _time_binnings\nfrom Orange.util import utc_from_timestamp\nfrom Orange.widgets import gui\nfrom Orange.widgets.settings import Setting\nfrom Orange.widgets.utils import classdensity, colorpalettes\nfrom Orange.widgets.visualize.utils.customizableplot import Updater, \\\n    CommonParameterSetter\nfrom Orange.widgets.visualize.utils.plotutils import (\n    HelpEventDelegate as EventDelegate, InteractiveViewBox as ViewBox,\n    PaletteItemSample, SymbolItemSample, AxisItem, PlotWidget, DiscretizedScale\n)\n\nSELECTION_WIDTH = 5\nMAX_N_VALID_SIZE_ANIMATE = 1000\n\n# maximum number of colors (including Other)\nMAX_COLORS = 11\n\n\nclass LegendItem(PgLegendItem):\n    def __init__(\n            self, size=None, offset=None, pen=None, brush=None,\n    ):\n        super().__init__(size, offset)\n\n        self.layout.setContentsMargins(5, 5, 5, 5)\n        self.layout.setHorizontalSpacing(15)\n        self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)\n        if pen is not None:\n            pen = QPen(pen)\n        if brush is not None:\n            brush = QBrush(brush)\n        self.__pen = pen\n        self.__brush = brush\n\n    def restoreAnchor(self, anchors):\n        \"\"\"\n        Restore (parent) relative position from stored anchors.\n\n        The restored position is within the parent bounds.\n        \"\"\"\n        anchor, parentanchor = anchors\n        self.anchor(*bound_anchor_pos(anchor, parentanchor))\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, _option, _widget=None):\n        painter.setPen(self.pen())\n        painter.setBrush(self.brush())\n        rect = self.contentsRect()\n        painter.drawRoundedRect(rect, 2, 2)\n\n    def addItem(self, item, name):\n        super().addItem(item, name)\n        # Fix-up the label alignment, and color\n        color = self.palette().color(QPalette.Text)\n        _, label = self.items[-1]\n        label.setText(name, justify=\"left\", color=color)\n\n    def clear(self):\n        \"\"\"\n        Clear all legend items.\n        \"\"\"\n        items = list(self.items)\n        self.items = []\n        for sample, label in items:\n            self.layout.removeItem(sample)\n            self.layout.removeItem(label)\n            sample.hide()\n            label.hide()\n\n        self.updateSize()\n\n    def pen(self):\n        if self.__pen is not None:\n            return QPen(self.__pen)\n        else:\n            color = self.palette().color(QPalette.Disabled, QPalette.Text)\n            color.setAlpha(100)\n            pen = QPen(color, 1)\n            pen.setCosmetic(True)\n            return pen\n\n    def brush(self):\n        if self.__brush is not None:\n            return QBrush(self.__brush)\n        else:\n            color = self.palette().color(QPalette.Window)\n            color.setAlpha(150)\n            return QBrush(color)\n\n    def changeEvent(self, event: QEvent):\n        if event.type() == QEvent.PaletteChange:\n            color = self.palette().color(QPalette.Text)\n            for _, label in self.items:\n                label.setText(label.text, color=color)\n        super().changeEvent(event)\n\n\ndef bound_anchor_pos(corner, parentpos):\n    corner = np.clip(corner, 0, 1)\n    parentpos = np.clip(parentpos, 0, 1)\n\n    irx, iry = corner\n    prx, pry = parentpos\n\n    if irx > 0.9 and prx < 0.1:\n        irx = prx = 0.0\n    if iry > 0.9 and pry < 0.1:\n        iry = pry = 0.0\n    if irx < 0.1 and prx > 0.9:\n        irx = prx = 1.0\n    if iry < 0.1 and pry > 0.9:\n        iry = pry = 1.0\n    return (irx, iry), (prx, pry)\n\n\nclass ScatterPlotItem(pg.ScatterPlotItem):\n    \"\"\"\n    Modifies the behaviour of ScatterPlotItem as follows:\n\n    - Add z-index. ScatterPlotItem paints points in order of appearance in\n      self.data. Plotting by z-index is achieved by sorting before calling\n      super().paint() and re-sorting afterwards. Re-sorting (instead of\n      storing the original data) is needed because the inherited paint\n      may modify the data.\n\n    - Prevent multiple calls to updateSpots. ScatterPlotItem calls updateSpots\n      at any change of sizes/colors/symbols, which then rebuilds the stored\n      pixmaps for each symbol. Orange calls set* functions in succession,\n      so we postpone updateSpots() to paint().\"\"\"\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._update_spots_in_paint = False\n        self._z_mapping = None\n        self._inv_mapping = None\n\n    def setZ(self, z):\n        \"\"\"\n        Set z values for all points.\n\n        Points with higher values are plotted on top of those with lower.\n\n        Args:\n            z (np.ndarray or None): a vector of z values\n        \"\"\"\n        if z is None:\n            self._z_mapping = self._inv_mapping = None\n        else:\n            assert len(z) == len(self.data)\n            self._z_mapping = np.argsort(z)\n            self._inv_mapping = np.argsort(self._z_mapping)\n\n    def setCoordinates(self, x, y):\n        \"\"\"\n        Change the coordinates of points while keeping other properties.\n\n        Asserts that the number of points stays the same.\n\n        Note. Pyqtgraph does not offer a method for this: setting coordinates\n        invalidates other data. We therefore retrieve the data to set it\n        together with the coordinates. Pyqtgraph also does not offer a\n        (documented) method for retrieving the data, yet using\n        data[prop]` looks reasonably safe.\n\n        The alternative, updating the whole scatterplot from the Orange Table,\n        is too slow.\n        \"\"\"\n        assert len(self.data) == len(x) == len(y)\n        data = dict(x=x, y=y)\n        for prop in ('pen', 'brush', 'size', 'symbol', 'data'):\n            data[prop] = self.data[prop]\n        self.setData(**data)\n\n    def updateSpots(self, dataSet=None):  # pylint: disable=unused-argument\n        self._update_spots_in_paint = True\n        self.update()\n\n    # pylint: disable=arguments-differ\n    def paint(self, painter, option, widget=None):\n        try:\n            if self._z_mapping is not None:\n                assert len(self._z_mapping) == len(self.data)\n                self.data = self.data[self._z_mapping]\n            if self._update_spots_in_paint:\n                self._update_spots_in_paint = False\n                super().updateSpots()\n            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)\n            super().paint(painter, option, widget)\n        finally:\n            if self._inv_mapping is not None:\n                self.data = self.data[self._inv_mapping]\n\n\ndef _define_symbols():\n    \"\"\"\n    Add symbol ? to ScatterPlotItemSymbols,\n    reflect the triangle to point upwards\n    \"\"\"\n    path = QPainterPath()\n    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))\n    path.moveTo(-0.5, 0.5)\n    path.lineTo(0.5, -0.5)\n    path.moveTo(-0.5, -0.5)\n    path.lineTo(0.5, 0.5)\n    Symbols[\"?\"] = path\n\n    path = QPainterPath()\n    plusCoords = [\n        (-0.5, -0.1), (-0.5, 0.1), (-0.1, 0.1), (-0.1, 0.5),\n        (0.1, 0.5), (0.1, 0.1), (0.5, 0.1), (0.5, -0.1),\n        (0.1, -0.1), (0.1, -0.5), (-0.1, -0.5), (-0.1, -0.1)\n    ]\n    path.moveTo(*plusCoords[0])\n    for x, y in plusCoords[1:]:\n        path.lineTo(x, y)\n    path.closeSubpath()\n    Symbols[\"+\"] = path\n\n    tr = QTransform()\n    tr.rotate(180)\n    Symbols['t'] = tr.map(Symbols['t'])\n\n    tr = QTransform()\n    tr.rotate(45)\n    Symbols['x'] = tr.map(Symbols[\"+\"])\n\n\n_define_symbols()\n\n\ndef _make_pen(color, width):\n    p = QPen(color, width)\n    p.setCosmetic(True)\n    return p\n\n\nclass AxisItem(AxisItem):\n    \"\"\"\n    Axis that if needed displays ticks appropriate for time data.\n    \"\"\"\n\n    _label_width = 80\n\n    def __init__(self, *args, **kwargs):\n        super().__init__(*args, **kwargs)\n        self._use_time = False\n\n    def use_time(self, enable):\n        \"\"\"Enables axes to display ticks for time data.\"\"\"\n        self._use_time = enable\n        self.enableAutoSIPrefix(not enable)\n\n    def tickValues(self, minVal, maxVal, size):\n        \"\"\"Find appropriate tick locations.\"\"\"\n        if not self._use_time:\n            return super().tickValues(minVal, maxVal, size)\n\n        # if timezone is not set, then local is used which cause exceptions\n        minVal = max(minVal,\n                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)\n        maxVal = min(maxVal,\n                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)\n        mn = utc_from_timestamp(minVal).timetuple()\n        mx = utc_from_timestamp(maxVal).timetuple()\n        try:\n            bins = _time_binnings(mn, mx, 6, 30)[-1]\n        except (IndexError, ValueError):\n            # cannot handle very large and very small time intervals\n            return super().tickValues(minVal, maxVal, size)\n\n        ticks = bins.thresholds\n        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs\n        # because they are out of range. Removing them here is needed so that\n        # they do not affect spaces and label format\n        ticks = ticks[(ticks[0] < minVal)\n                      :len(ticks) - (ticks[-1] > maxVal)]\n\n        max_steps = max(int(size / self._label_width), 1)\n        if len(ticks) > max_steps:\n            # remove some of ticks so that they don't overlap\n            step = int(np.ceil(float(len(ticks)) / max_steps))\n            ticks = ticks[::step]\n\n        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))\n        return [(spacing, ticks)]\n\n    def tickStrings(self, values, scale, spacing):\n        \"\"\"Format tick values according to space between them.\"\"\"\n        if not self._use_time:\n            return super().tickStrings(values, scale, spacing)\n\n        if spacing >= 3600 * 24 * 365:\n            fmt = \"%Y\"\n        elif spacing >= 3600 * 24 * 28:\n            fmt = \"%Y %b\"\n        elif spacing >= 3600 * 24:\n            fmt = \"%Y %b %d\"\n        elif spacing >= 3600:\n            min_day = max_day = 1\n            if len(values) > 0:\n                min_day = datetime.fromtimestamp(\n                    min(values), tz=timezone.utc).day\n                max_day = datetime.fromtimestamp(\n                    max(values), tz=timezone.utc).day\n            if min_day == max_day:\n                fmt = \"%Hh\"\n            else:\n                fmt = \"%d %Hh\"\n        elif spacing >= 60:\n            fmt = \"%H:%M\"\n        elif spacing >= 1:\n            fmt = \"%H:%M:%S\"\n        else:\n            fmt = '%S.%f'\n\n        return [utc_from_timestamp(x).strftime(fmt) for x in values]\n\n\nclass ScatterBaseParameterSetter(CommonParameterSetter):\n    CAT_LEGEND_LABEL = \"Categorical legend\"\n    NUM_LEGEND_LABEL = \"Numerical legend\"\n    NUM_LEGEND_SETTING = {\n        Updater.SIZE_LABEL: (range(4, 50), 11),\n        Updater.IS_ITALIC_LABEL: (None, False),\n    }\n\n    def __init__(self, master):\n        super().__init__()\n        self.master = master\n        self.cat_legend_settings = {}\n        self.num_legend_settings = {}\n\n    def update_setters(self):\n        self.initial_settings = {\n            self.LABELS_BOX: {\n                self.FONT_FAMILY_LABEL: self.FONT_FAMILY_SETTING,\n                self.TITLE_LABEL: self.FONT_SETTING,\n                self.LABEL_LABEL: self.FONT_SETTING,\n                self.CAT_LEGEND_LABEL: self.FONT_SETTING,\n                self.NUM_LEGEND_LABEL: self.NUM_LEGEND_SETTING,\n            },\n            self.ANNOT_BOX: {\n                self.TITLE_LABEL: {self.TITLE_LABEL: (\"\", \"\")},\n            }\n        }\n\n        def update_cat_legend(**settings):\n            self.cat_legend_settings.update(**settings)\n            Updater.update_legend_font(self.cat_legend_items, **settings)\n\n        def update_num_legend(**settings):\n            self.num_legend_settings.update(**settings)\n            Updater.update_num_legend_font(self.num_legend, **settings)\n\n        labels = self.LABELS_BOX\n        self._setters[labels][self.CAT_LEGEND_LABEL] = update_cat_legend\n        self._setters[labels][self.NUM_LEGEND_LABEL] = update_num_legend\n\n    @property\n    def title_item(self):\n        return self.master.plot_widget.getPlotItem().titleLabel\n\n    @property\n    def cat_legend_items(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            items = []\n        return itertools.chain(self.master.shape_legend.items, items)\n\n    @property\n    def num_legend(self):\n        items = self.master.color_legend.items\n        if items and items[0] and isinstance(items[0][0], PaletteItemSample):\n            return self.master.color_legend\n        return None\n\n    @property\n    def labels(self):\n        return self.master.labels\n\n\nclass OWScatterPlotBase(gui.OWComponent, QObject):\n    \"\"\"\n    Provide a graph component for widgets that show any kind of point plot\n\n    The component plots a set of points with given coordinates, shapes,\n    sizes and colors. Its function is similar to that of a *view*, whereas\n    the widget represents a *model* and a *controler*.\n\n    The model (widget) needs to provide methods:\n\n    - `get_coordinates_data`, `get_size_data`, `get_color_data`,\n      `get_shape_data`, `get_label_data`, which return a 1d array (or two\n      arrays, for `get_coordinates_data`) of `dtype` `float64`, except for\n      `get_label_data`, which returns formatted labels;\n    - `get_shape_labels` returns a list of strings for shape legend\n    - `get_color_labels` returns strings for color legend, or a function for\n       formatting numbers if the legend is continuous, or None for default\n       formatting\n    - `get_tooltip`, which gives a tooltip for a single data point\n    - (optional) `impute_sizes`, `impute_shapes` get final coordinates and\n      shapes, and replace nans;\n    - `get_subset_mask` returns a bool array indicating whether a\n      data point is in the subset or not (e.g. in the 'Data Subset' signal\n      in the Scatter plot and similar widgets);\n    - `get_palette` returns a palette appropriate for visualizing the\n      current color data;\n    - `is_continuous_color` decides the type of the color legend;\n\n    The widget (in a role of controller) must also provide methods\n    - `selection_changed`\n\n    If `get_coordinates_data` returns `(None, None)`, the plot is cleared. If\n    `get_size_data`, `get_color_data` or `get_shape_data` return `None`,\n    all points will have the same size, color or shape, respectively.\n    If `get_label_data` returns `None`, there are no labels.\n\n    The view (this compomnent) provides methods `update_coordinates`,\n    `update_sizes`, `update_colors`, `update_shapes` and `update_labels`\n    that the widget (in a role of a controler) should call when any of\n    these properties are changed. If the widget calls, for instance, the\n    plot's `update_colors`, the plot will react by calling the widget's\n    `get_color_data` as well as the widget's methods needed to construct the\n    legend.\n\n    The view also provides a method `reset_graph`, which should be called only\n    when\n    - the widget gets entirely new data\n    - the number of points may have changed, for instance when selecting\n    a different attribute for x or y in the scatter plot, where the points\n    with missing x or y coordinates are hidden.\n\n    Every `update_something` calls the plot's `get_something`, which\n    calls the model's `get_something_data`, then it transforms this data\n    into whatever is needed (colors, shapes, scaled sizes) and changes the\n    plot. For the simplest example, here is `update_shapes`:\n\n    ```\n        def update_shapes(self):\n            if self.scatterplot_item:\n                shape_data = self.get_shapes()\n                self.scatterplot_item.setSymbol(shape_data)\n            self.update_legends()\n\n        def get_shapes(self):\n            shape_data = self.master.get_shape_data()\n            shape_data = self.master.impute_shapes(\n                shape_data, len(self.CurveSymbols) - 1)\n            return self.CurveSymbols[shape_data]\n    ```\n\n    On the widget's side, `get_something_data` is essentially just:\n\n    ```\n        def get_size_data(self):\n            return self.get_column(self.attr_size)\n    ```\n\n    where `get_column` retrieves a column while also filtering out the\n    points with missing x and y and so forth. (Here we present the simplest\n    two cases, \"shapes\" for the view and \"sizes\" for the model. The colors\n    for the view are more complicated since they deal with discrete and\n    continuous palettes, and the shapes for the view merge infrequent shapes.)\n\n    The plot can also show just a random sample of the data. The sample size is\n    set by `set_sample_size`, and the rest is taken care by the plot: the\n    widget keeps providing the data for all points, selection indices refer\n    to the entire set etc. Internally, sampling happens as early as possible\n    (in methods `get_<something>`).\n    \"\"\"\n    too_many_labels = Signal(bool)\n    begin_resizing = Signal()\n    step_resizing = Signal()\n    end_resizing = Signal()\n\n    label_only_selected = Setting(False)\n    point_width = Setting(10)\n    alpha_value = Setting(128)\n    show_grid = Setting(False)\n    show_legend = Setting(True)\n    class_density = Setting(False)\n    jitter_size = Setting(0)\n\n    resolution = 256\n\n    CurveSymbols = np.array(\"o x t + d star ?\".split())\n    MinShapeSize = 6\n    DarkerValue = 120\n    UnknownColor = (168, 50, 168)\n\n    COLOR_DEFAULT = (128, 128, 128)\n\n    MAX_VISIBLE_LABELS = 500\n\n    def __init__(self, scatter_widget, parent=None, view_box=ViewBox):\n        QObject.__init__(self)\n        gui.OWComponent.__init__(self, scatter_widget)\n\n        self.subset_is_shown = False\n        self.jittering_suspended = False\n\n        self.view_box = view_box(self)\n        _axis = {\"left\": AxisItem(\"left\"), \"bottom\": AxisItem(\"bottom\")}\n        self.plot_widget = PlotWidget(\n            viewBox=self.view_box, parent=parent, background=None,\n            axisItems=_axis\n        )\n        self.plot_widget.hideAxis(\"left\")\n        self.plot_widget.hideAxis(\"bottom\")\n        self.plot_widget.getPlotItem().buttonsHidden = True\n        self.plot_widget.setAntialiasing(True)\n        self.plot_widget.sizeHint = lambda: QSize(500, 500)\n\n        self.density_img = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n\n        self.master = scatter_widget\n        tooltip = self._create_drag_tooltip()\n        self.view_box.setDragTooltip(tooltip)\n\n        self.selection = None  # np.ndarray\n\n        self.n_valid = 0\n        self.n_shown = 0\n        self.sample_size = None\n        self.sample_indices = None\n\n        self.palette = None\n\n        self.shape_legend = self._create_legend(((1, 0), (1, 0)))\n        self.color_legend = self._create_legend(((1, 1), (1, 1)))\n        self.update_legend_visibility()\n\n        self.scale = None  # DiscretizedScale\n        self._too_many_labels = False\n\n        # self.setMouseTracking(True)\n        # self.grabGesture(QPinchGesture)\n        # self.grabGesture(QPanGesture)\n\n        self.update_grid_visibility()\n\n        self._tooltip_delegate = EventDelegate(self.help_event)\n        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)\n        self.view_box.sigTransformChanged.connect(self.update_density)\n        self.view_box.sigRangeChangedManually.connect(self.update_labels)\n\n        self.timer = None\n\n        self.parameter_setter = ScatterBaseParameterSetter(self)\n\n    def _create_legend(self, anchor):\n        legend = LegendItem()\n        legend.setParentItem(self.plot_widget.getViewBox())\n        legend.restoreAnchor(anchor)\n        return legend\n\n    def _create_drag_tooltip(self):\n        tip_parts = [\n            (Qt.ControlModifier,\n             \"{}: Append to group\".\n             format(\"Cmd\" if sys.platform == \"darwin\" else \"Ctrl\")),\n            (Qt.ShiftModifier, \"Shift: Add group\"),\n            (Qt.AltModifier, \"Alt: Remove\")\n        ]\n        all_parts = \"<center>\" + \\\n                    \", \".join(part for _, part in tip_parts) + \\\n                    \"</center>\"\n        self.tiptexts = {\n            modifier: all_parts.replace(part, \"<b>{}</b>\".format(part))\n            for modifier, part in tip_parts\n        }\n        self.tiptexts[Qt.NoModifier] = all_parts\n\n        self.tip_textitem = text = QGraphicsTextItem()\n        # Set to the longest text\n        text.setHtml(self.tiptexts[Qt.ControlModifier])\n        text.setPos(4, 2)\n        r = text.boundingRect()\n        text.setTextWidth(r.width())\n        rect = QGraphicsRectItem(0, 0, r.width() + 8, r.height() + 4)\n        color = self.plot_widget.palette().color(QPalette.Disabled, QPalette.Window)\n        color.setAlpha(212)\n        rect.setBrush(color)\n        rect.setPen(QPen(Qt.NoPen))\n        self.update_tooltip()\n\n        tooltip_group = QGraphicsItemGroup()\n        tooltip_group.addToGroup(rect)\n        tooltip_group.addToGroup(text)\n        return tooltip_group\n\n    def update_tooltip(self, modifiers=Qt.NoModifier):\n        text = self.tiptexts[Qt.NoModifier]\n        for mod in [Qt.ControlModifier,\n                    Qt.ShiftModifier,\n                    Qt.AltModifier]:\n            if modifiers & mod:\n                text = self.tiptexts.get(mod)\n                break\n        self.tip_textitem.setHtml(text)\n\n    def suspend_jittering(self):\n        if self.jittering_suspended:\n            return\n        self.jittering_suspended = True\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def unsuspend_jittering(self):\n        if not self.jittering_suspended:\n            return\n        self.jittering_suspended = False\n        if self.jitter_size != 0:\n            self.update_jittering()\n\n    def update_jittering(self):\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0 or self.scatterplot_item is None:\n            return\n        self.scatterplot_item.setCoordinates(x, y)\n        self.scatterplot_item_sel.setCoordinates(x, y)\n        self.update_labels()\n\n    # TODO: Rename to remove_plot_items\n    def clear(self):\n        \"\"\"\n        Remove all graphical elements from the plot\n\n        Calls the pyqtgraph's plot widget's clear, sets all handles to `None`,\n        removes labels and selections.\n\n        This method should generally not be called by the widget. If the data\n        is gone (*e.g.* upon receiving `None` as an input data signal), this\n        should be handler by calling `reset_graph`, which will in turn call\n        `clear`.\n\n        Derived classes should override this method if they add more graphical\n        elements. For instance, the regression line in the scatterplot adds\n        `self.reg_line_item = None` (the line in the plot is already removed\n        in this method).\n        \"\"\"\n        self.plot_widget.clear()\n\n        self.density_img = None\n        if self.timer is not None and self.timer.isActive():\n            self.timer.stop()\n            self.timer = None\n        self.scatterplot_item = None\n        self.scatterplot_item_sel = None\n        self.labels = []\n        self._signal_too_many_labels(False)\n        self.view_box.init_history()\n        self.view_box.tag_history()\n\n    # TODO: I hate `keep_something` and `reset_something` arguments\n    # __keep_selection is used exclusively be set_sample size which would\n    # otherwise just repeat the code from reset_graph except for resetting\n    # the selection. I'm uncomfortable with this; we may prefer to have a\n    # method _reset_graph which does everything except resetting the selection,\n    # and reset_graph would call it.\n    def reset_graph(self, __keep_selection=False):\n        \"\"\"\n        Reset the graph to new data (or no data)\n\n        The method must be called when the plot receives new data, in\n        particular when the number of points change. If only their properties\n        - like coordinates or shapes - change, an update method\n        (`update_coordinates`, `update_shapes`...) should be called instead.\n\n        The method must also be called when the data is gone.\n\n        The method calls `clear`, followed by calls of all update methods.\n\n        NB. Argument `__keep_selection` is for internal use only\n        \"\"\"\n        self.clear()\n        if not __keep_selection:\n            self.selection = None\n        self.sample_indices = None\n        self.update_coordinates()\n        self.update_point_props()\n\n    def set_sample_size(self, sample_size):\n        \"\"\"\n        Set the sample size\n\n        Args:\n            sample_size (int or None): sample size or `None` to show all points\n        \"\"\"\n        if self.sample_size != sample_size:\n            self.sample_size = sample_size\n            self.reset_graph(True)\n\n    def update_point_props(self):\n        \"\"\"\n        Update the sizes, colors, shapes and labels\n\n        The method calls the appropriate update methods for individual\n        properties.\n        \"\"\"\n        self.update_sizes()\n        self.update_colors()\n        self.update_selection_colors()\n        self.update_shapes()\n        self.update_labels()\n\n    # Coordinates\n    # TODO: It could be nice if this method was run on entire data, not just\n    # a sample. For this, however, it would need to either be called from\n    # `get_coordinates` before sampling (very ugly) or call\n    # `self.master.get_coordinates_data` (beyond ugly) or the widget would\n    # have to store the ranges of unsampled data (ugly).\n    # Maybe we leave it as it is.\n    def _reset_view(self, x_data, y_data):\n        \"\"\"\n        Set the range of the view box\n\n        Args:\n            x_data (np.ndarray): x coordinates\n            y_data (np.ndarray) y coordinates\n        \"\"\"\n        min_x, max_x = np.min(x_data), np.max(x_data)\n        min_y, max_y = np.min(y_data), np.max(y_data)\n        self.view_box.setRange(\n            QRectF(min_x, min_y, max_x - min_x or 1, max_y - min_y or 1),\n            padding=0.025)\n\n    def _filter_visible(self, data):\n        \"\"\"Return the sample from the data using the stored sample_indices\"\"\"\n        if data is None or self.sample_indices is None:\n            return data\n        else:\n            return np.asarray(data[self.sample_indices])\n\n    def get_coordinates(self):\n        \"\"\"\n        Prepare coordinates of the points in the plot\n\n        The method is called by `update_coordinates`. It gets the coordinates\n        from the widget, jitters them and return them.\n\n        The methods also initializes the sample indices if neededd and stores\n        the original and sampled number of points.\n\n        Returns:\n            (tuple): a pair of numpy arrays containing (sampled) coordinates,\n                or `(None, None)`.\n        \"\"\"\n        x, y = self.master.get_coordinates_data()\n        if x is None:\n            self.n_valid = self.n_shown = 0\n            return None, None\n        self.n_valid = len(x)\n        self._create_sample()\n        x = self._filter_visible(x)\n        y = self._filter_visible(y)\n        # Jittering after sampling is OK if widgets do not change the sample\n        # semi-permanently, e.g. take a sample for the duration of some\n        # animation. If the sample size changes dynamically (like by adding\n        # a \"sample size\" slider), points would move around when the sample\n        # size changes. To prevent this, jittering should be done before\n        # sampling (i.e. two lines earlier). This would slow it down somewhat.\n        x, y = self.jitter_coordinates(x, y)\n        return x, y\n\n    def _create_sample(self):\n        \"\"\"\n        Create a random sample if the data is larger than the set sample size\n        \"\"\"\n        self.n_shown = min(self.n_valid, self.sample_size or self.n_valid)\n        if self.sample_size is not None \\\n                and self.sample_indices is None \\\n                and self.n_valid != self.n_shown:\n            random = np.random.RandomState(seed=0)\n            self.sample_indices = random.choice(\n                self.n_valid, self.n_shown, replace=False)\n            # TODO: Is this really needed?\n            np.sort(self.sample_indices)\n\n    def jitter_coordinates(self, x, y):\n        \"\"\"\n        Display coordinates to random positions within ellipses with\n        radiuses of `self.jittter_size` percents of spans\n        \"\"\"\n        if self.jitter_size == 0 or self.jittering_suspended:\n            return x, y\n        return self._jitter_data(x, y)\n\n    def _jitter_data(self, x, y, span_x=None, span_y=None):\n        if span_x is None:\n            span_x = np.max(x) - np.min(x)\n        if span_y is None:\n            span_y = np.max(y) - np.min(y)\n        random = np.random.RandomState(seed=0)\n        rs = random.uniform(0, 1, len(x))\n        phis = random.uniform(0, 2 * np.pi, len(x))\n        magnitude = self.jitter_size / 100\n        return (x + magnitude * span_x * rs * np.cos(phis),\n                y + magnitude * span_y * rs * np.sin(phis))\n\n    def update_coordinates(self):\n        \"\"\"\n        Trigger the update of coordinates while keeping other features intact.\n\n        The method gets the coordinates by calling `self.get_coordinates`,\n        which in turn calls the widget's `get_coordinate_data`. The number of\n        coordinate pairs returned by the latter must match the current number\n        of points. If this is not the case, the widget should trigger\n        the complete update by calling `reset_graph` instead of this method.\n        \"\"\"\n        x, y = self.get_coordinates()\n        if x is None or len(x) == 0:\n            return\n\n        self._reset_view(x, y)\n        if self.scatterplot_item is None:\n            if self.sample_indices is None:\n                indices = np.arange(self.n_valid)\n            else:\n                indices = self.sample_indices\n            kwargs = dict(x=x, y=y, data=indices)\n            self.scatterplot_item = ScatterPlotItem(**kwargs)\n            self.scatterplot_item.sigClicked.connect(self.select_by_click)\n            self.scatterplot_item_sel = ScatterPlotItem(**kwargs)\n            self.plot_widget.addItem(self.scatterplot_item_sel)\n            self.plot_widget.addItem(self.scatterplot_item)\n        else:\n            self.scatterplot_item.setCoordinates(x, y)\n            self.scatterplot_item_sel.setCoordinates(x, y)\n            self.update_labels()\n\n        self.update_density()  # Todo: doesn't work: try MDS with density on\n\n    # Sizes\n    def get_sizes(self):\n        \"\"\"\n        Prepare data for sizes of points in the plot\n\n        The method is called by `update_sizes`. It gets the sizes\n        from the widget and performs the necessary scaling and sizing.\n        The output is rounded to half a pixel for faster drawing.\n\n        Returns:\n            (np.ndarray): sizes\n        \"\"\"\n        size_column = self.master.get_size_data()\n        if size_column is None:\n            return np.full((self.n_shown,),\n                           self.MinShapeSize + (5 + self.point_width) * 0.5)\n        size_column = self._filter_visible(size_column)\n        size_column = size_column.copy()\n        with warnings.catch_warnings():\n            warnings.simplefilter(\"ignore\", category=RuntimeWarning)\n            size_column -= np.nanmin(size_column)\n            mx = np.nanmax(size_column)\n        if mx > 0:\n            size_column /= mx\n        else:\n            size_column[:] = 0.5\n\n        sizes = self.MinShapeSize + (5 + self.point_width) * size_column\n        # round sizes to half pixel for smaller pyqtgraph's symbol pixmap atlas\n        sizes = (sizes * 2).round() / 2\n        return sizes\n\n    def update_sizes(self):\n        \"\"\"\n        Trigger an update of point sizes\n\n        The method calls `self.get_sizes`, which in turn calls the widget's\n        `get_size_data`. The result are properly scaled and then passed\n        back to widget for imputing (`master.impute_sizes`).\n        \"\"\"\n        if self.scatterplot_item:\n            size_data = self.get_sizes()\n            size_imputer = getattr(\n                self.master, \"impute_sizes\", self.default_impute_sizes)\n            size_imputer(size_data)\n\n            if self.timer is not None and self.timer.isActive():\n                self.timer.stop()\n                self.timer = None\n\n            current_size_data = self.scatterplot_item.data[\"size\"].copy()\n            diff = size_data - current_size_data\n            widget = self\n\n            class Timeout:\n                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2\n                factors = [0.07, 0.16, 0.27, 0.41, 0.55,\n                           0.68, 0.81, 0.9, 0.97, 1]\n\n                def __init__(self):\n                    self._counter = 0\n\n                def __call__(self):\n                    factor = self.factors[self._counter]\n                    self._counter += 1\n                    size = current_size_data + diff * factor\n                    if len(self.factors) == self._counter:\n                        widget.timer.stop()\n                        widget.timer = None\n                        size = size_data\n                    widget.scatterplot_item.setSize(size)\n                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)\n                    if widget.timer is None:\n                        widget.end_resizing.emit()\n                    else:\n                        widget.step_resizing.emit()\n\n            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \\\n                    np.all(current_size_data > 0) and np.any(diff != 0):\n                # If encountered any strange behaviour when updating sizes,\n                # implement it with threads\n                self.begin_resizing.emit()\n                interval = int(500 / len(Timeout.factors))\n                self.timer = QTimer(self.scatterplot_item, interval=interval)\n                self.timer.timeout.connect(Timeout())\n                self.timer.start()\n            else:\n                self.begin_resizing.emit()\n                self.scatterplot_item.setSize(size_data)\n                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)\n                self.end_resizing.emit()\n\n    update_point_size = update_sizes  # backward compatibility (needed?!)\n    update_size = update_sizes\n\n    @classmethod\n    def default_impute_sizes(cls, size_data):\n        \"\"\"\n        Fallback imputation for sizes.\n\n        Set the size to two pixels smaller than the minimal size\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        nans = np.isnan(size_data)\n        if np.any(nans):\n            size_data[nans] = cls.MinShapeSize - 2\n            return True\n        else:\n            return False\n\n    # Colors\n    def get_colors(self):\n        \"\"\"\n        Prepare data for colors of the points in the plot\n\n        The method is called by `update_colors`. It gets the colors and the\n        indices of the data subset from the widget (`get_color_data`,\n        `get_subset_mask`), and constructs lists of pens and brushes for\n        each data point.\n\n        The method uses different palettes for discrete and continuous data,\n        as determined by calling the widget's method `is_continuous_color`.\n\n        If also marks the points that are in the subset as defined by, for\n        instance the 'Data Subset' signal in the Scatter plot and similar\n        widgets. (Do not confuse this with *selected points*, which are\n        marked by circles around the points, which are colored by groups\n        and thus independent of this method.)\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        c_data = self.master.get_color_data()\n        c_data = self._filter_visible(c_data)\n        subset = self.master.get_subset_mask()\n        subset = self._filter_visible(subset)\n        self.subset_is_shown = subset is not None\n        if c_data is None:  # same color\n            self.palette = None\n            return self._get_same_colors(subset)\n        elif self.master.is_continuous_color():\n            return self._get_continuous_colors(c_data, subset)\n        else:\n            return self._get_discrete_colors(c_data, subset)\n\n    def _get_same_colors(self, subset, color=COLOR_DEFAULT):\n        \"\"\"\n        Return the same pen for all points while the brush color depends\n        upon whether the point is in the subset or not\n\n        Args:\n            subset (np.ndarray): a bool array indicating whether a data point\n                is in the subset or not (e.g. in the 'Data Subset' signal\n                in the Scatter plot and similar widgets);\n\n        Returns:\n            (tuple): a list of pens and list of brushes\n        \"\"\"\n        alpha_subset, alpha_unset = self._alpha_for_subsets()\n        if subset is not None:\n            qcolor = QColor(*color, alpha_subset)\n            brush = np.where(subset, QBrush(qcolor), QBrush(QColor(0, 0, 0, 0)))\n            pen = np.where(subset,\n                           _make_pen(qcolor, 1.5),\n                           _make_pen(QColor(*color, alpha_unset), 1.5))\n        else:\n            qcolor = QColor(*color, self.alpha_value)\n            brush = np.full(self.n_shown, QBrush(qcolor))\n            pen = [_make_pen(qcolor, 1.5)] * self.n_shown\n        return pen, brush\n\n    def _get_continuous_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a continuous palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        palette = self.master.get_palette()\n\n        if np.isnan(c_data).all():\n            self.palette = palette\n            return self._get_same_colors(subset, self.palette.nan_color)\n\n        self.scale = DiscretizedScale(np.nanmin(c_data), np.nanmax(c_data))\n        bins = self.scale.get_bins()\n        self.palette = \\\n            colorpalettes.BinnedContinuousPalette.from_palette(palette, bins)\n        colors = self.palette.values_to_colors(c_data)\n        alphas = np.full((len(c_data), 1), self.alpha_value, dtype=np.ubyte)\n        brush = np.hstack((colors, alphas))\n        pen = np.hstack(\n            ((colors.astype(dtype=float) * 100 / self.DarkerValue).astype(np.ubyte),\n             alphas))\n\n        # Reuse pens and brushes with the same colors because PyQtGraph then\n        # builds smaller pixmap atlas, which makes the drawing faster\n\n        def reuse(cache, fun, *args):\n            if args not in cache:\n                cache[args] = fun(args)\n            return cache[args]\n\n        def create_pen(col):\n            return _make_pen(QColor(*col), 1.5)\n\n        def create_brush(col):\n            return QBrush(QColor(*col))\n\n        if subset is not None:\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            brush[:, 3] = 0\n            brush[subset, 3] = alpha_subset\n            pen[:, 3] = alpha_unset\n            brush[subset, 3] = alpha_subset\n\n        cached_pens = {}\n        pen = [reuse(cached_pens, create_pen, *col) for col in pen.tolist()]\n        cached_brushes = {}\n        brush = np.array([reuse(cached_brushes, create_brush, *col)\n                          for col in brush.tolist()])\n\n        return pen, brush\n\n    def _get_discrete_colors(self, c_data, subset):\n        \"\"\"\n        Return the pens and colors whose color represent an index into\n        a discrete palette. The same color is used for pen and brush,\n        except the former is darker. If the data has a subset, the brush\n        is transparent for points that are not in the subset.\n        \"\"\"\n        self.palette = self.master.get_palette()\n        c_data = c_data.copy()\n        c_data[np.isnan(c_data)] = len(self.palette)\n        c_data = c_data.astype(int)\n        colors = self.palette.qcolors_w_nan\n        if subset is None:\n            for col in colors:\n                col.setAlpha(self.alpha_value)\n            pens = np.array(\n                [_make_pen(col.darker(self.DarkerValue), 1.5)\n                 for col in colors])\n            pen = pens[c_data]\n            brushes = np.array([QBrush(col) for col in colors])\n            brush = brushes[c_data]\n        else:\n            subset_colors = [QColor(col) for col in colors]\n            alpha_subset, alpha_unset = self._alpha_for_subsets()\n            for col in subset_colors:\n                col.setAlpha(alpha_subset)\n            for col in colors:\n                col.setAlpha(alpha_unset)\n\n            pens, subset_pens = (\n                np.array(\n                    [_make_pen(col.darker(self.DarkerValue), 1.5)\n                     for col in cols])\n                for cols in (colors, subset_colors))\n            pen = np.where(subset, subset_pens[c_data], pens[c_data])\n\n            brushes = np.array([QBrush(col) for col in subset_colors])\n            brush = brushes[c_data]\n            black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))\n            brush = np.where(subset, brush, black)\n        return pen, brush\n\n    def _alpha_for_subsets(self):\n        a, b, c = 1.2, -3.2, 3\n        x = self.alpha_value / 255\n        alpha_subset = 31 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))\n        x = 1 - x\n        alpha_unset = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))\n        return alpha_subset, alpha_unset\n\n    def update_colors(self):\n        \"\"\"\n        Trigger an update of point colors\n\n        The method calls `self.get_colors`, which in turn calls the widget's\n        `get_color_data` to get the indices in the pallette. `get_colors`\n        returns a list of pens and brushes to which this method uses to\n        update the colors. Finally, the method triggers the update of the\n        legend and the density plot.\n        \"\"\"\n        if self.scatterplot_item is not None:\n            pen_data, brush_data = self.get_colors()\n            self.scatterplot_item.setPen(pen_data, update=False, mask=None)\n            self.scatterplot_item.setBrush(brush_data, mask=None)\n        self.update_z_values()\n        self.update_legends()\n        self.update_density()\n\n    update_alpha_value = update_colors\n\n    def update_density(self):\n        \"\"\"\n        Remove the existing density plot (if there is one) and replace it\n        with a new one (if enabled).\n\n        The method gets the colors from the pens of the currently plotted\n        points.\n        \"\"\"\n        if self.density_img:\n            self.plot_widget.removeItem(self.density_img)\n            self.density_img = None\n        if self.class_density and self.scatterplot_item is not None:\n            c_data = self.master.get_color_data()\n            if c_data is None:\n                return\n            visible_c_data = self._filter_visible(c_data)\n            mask = np.isfinite(visible_c_data)\n            if not self.master.is_continuous_color():\n                mask = np.bitwise_and(mask, visible_c_data < MAX_COLORS - 1)\n            pens = self.scatterplot_item.data['pen']\n            rgb_data = [\n                pen.color().getRgb()[:3] if pen is not None else (255, 255, 255)\n                for known, pen in zip(mask, pens)\n                if known]\n            if len(set(rgb_data)) <= 1:\n                return\n            [min_x, max_x], [min_y, max_y] = self.view_box.viewRange()\n            x_data, y_data = self.scatterplot_item.getData()\n            self.density_img = classdensity.class_density_image(\n                min_x, max_x, min_y, max_y, self.resolution,\n                x_data[mask], y_data[mask], rgb_data)\n            self.plot_widget.addItem(self.density_img, ignoreBounds=True)\n\n    def update_selection_colors(self):\n        \"\"\"\n        Trigger an update of selection markers\n\n        This update method is usually not called by the widget but by the\n        plot, since it is the plot that handles the selections.\n\n        Like other update methods, it calls the corresponding get method\n        (`get_colors_sel`) which returns a list of pens and brushes.\n        \"\"\"\n        if self.scatterplot_item_sel is None:\n            return\n        pen, brush = self.get_colors_sel()\n        self.scatterplot_item_sel.setPen(pen, update=False, mask=None)\n        self.scatterplot_item_sel.setBrush(brush, mask=None)\n        self.update_z_values()\n\n    def get_colors_sel(self):\n        \"\"\"\n        Return pens and brushes for selection markers.\n\n        A pen can is set to `Qt.NoPen` if a point is not selected.\n\n        All brushes are completely transparent whites.\n\n        Returns:\n            (tuple): a list of pens and a list of brushes\n        \"\"\"\n        nopen = QPen(Qt.NoPen)\n        if self.selection is None:\n            pen = [nopen] * self.n_shown\n        else:\n            sels = np.max(self.selection)\n            if sels == 1:\n                pen = np.where(\n                    self._filter_visible(self.selection),\n                    _make_pen(QColor(255, 190, 0, 255), SELECTION_WIDTH),\n                    nopen)\n            else:\n                palette = colorpalettes.LimitedDiscretePalette(\n                    number_of_colors=sels + 1)\n                pen = np.choose(\n                    self._filter_visible(self.selection),\n                    [nopen] + [_make_pen(palette[i], SELECTION_WIDTH)\n                               for i in range(sels)])\n        return pen, [QBrush(QColor(255, 255, 255, 0))] * self.n_shown\n\n    # Labels\n    def get_labels(self):\n        \"\"\"\n        Prepare data for labels for points\n\n        The method returns the results of the widget's `get_label_data`\n\n        Returns:\n            (labels): a sequence of labels\n        \"\"\"\n        return self._filter_visible(self.master.get_label_data())\n\n    def update_labels(self):\n        \"\"\"\n        Trigger an update of labels\n\n        The method calls `get_labels` which in turn calls the widget's\n        `get_label_data`. The obtained labels are shown if the corresponding\n        points are selected or if `label_only_selected` is `false`.\n        \"\"\"\n        for label in self.labels:\n            self.plot_widget.removeItem(label)\n        self.labels = []\n\n        mask = None\n        if self.scatterplot_item is not None:\n            x, y = self.scatterplot_item.getData()\n            mask = self._label_mask(x, y)\n\n        if mask is not None:\n            labels = self.get_labels()\n            if labels is None:\n                mask = None\n\n        self._signal_too_many_labels(\n            mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)\n        if self._too_many_labels or mask is None or not np.any(mask):\n            return\n\n        foreground = self.plot_widget.palette().color(QPalette.Text)\n        labels = labels[mask]\n        x = x[mask]\n        y = y[mask]\n        for label, xp, yp in zip(labels, x, y):\n            ti = TextItem(label, foreground)\n            ti.setPos(xp, yp)\n            self.plot_widget.addItem(ti)\n            self.labels.append(ti)\n            ti.setFont(self.parameter_setter.label_font)\n\n    def _signal_too_many_labels(self, too_many):\n        if self._too_many_labels != too_many:\n            self._too_many_labels = too_many\n            self.too_many_labels.emit(too_many)\n\n    def _label_mask(self, x, y):\n        (x0, x1), (y0, y1) = self.view_box.viewRange()\n        mask = np.logical_and(\n            np.logical_and(x >= x0, x <= x1),\n            np.logical_and(y >= y0, y <= y1))\n        if self.label_only_selected:\n            sub_mask = self._filter_visible(self.master.get_subset_mask())\n            if self.selection is None:\n                if sub_mask is None:\n                    return None\n                else:\n                    sel_mask = sub_mask\n            else:\n                sel_mask = self._filter_visible(self.selection) != 0\n                if sub_mask is not None:\n                    sel_mask = np.logical_or(sel_mask, sub_mask)\n            mask = np.logical_and(mask, sel_mask)\n        return mask\n\n    # Shapes\n    def get_shapes(self):\n        \"\"\"\n        Prepare data for shapes of points in the plot\n\n        The method is called by `update_shapes`. It gets the data from\n        the widget's `get_shape_data`, and then calls its `impute_shapes`\n        to impute the missing shape (usually with some default shape).\n\n        Returns:\n            (np.ndarray): an array of symbols (e.g. o, x, + ...)\n        \"\"\"\n        shape_data = self.master.get_shape_data()\n        shape_data = self._filter_visible(shape_data)\n        # Data has to be copied so the imputation can change it in-place\n        # TODO: Try avoiding this when we move imputation to the widget\n        if shape_data is not None:\n            shape_data = np.copy(shape_data)\n        shape_imputer = getattr(\n            self.master, \"impute_shapes\", self.default_impute_shapes)\n        shape_imputer(shape_data, len(self.CurveSymbols) - 1)\n        if isinstance(shape_data, np.ndarray):\n            shape_data = shape_data.astype(int)\n        else:\n            shape_data = np.zeros(self.n_shown, dtype=int)\n        return self.CurveSymbols[shape_data]\n\n    @staticmethod\n    def default_impute_shapes(shape_data, default_symbol):\n        \"\"\"\n        Fallback imputation for shapes.\n\n        Use the default symbol, usually the last symbol in the list.\n\n        Returns:\n            (bool): True if there was any missing data\n        \"\"\"\n        if shape_data is None:\n            return False\n        nans = np.isnan(shape_data)\n        if np.any(nans):\n            shape_data[nans] = default_symbol\n            return True\n        else:\n            return False\n\n    def update_shapes(self):\n        \"\"\"\n        Trigger an update of point symbols\n\n        The method calls `get_shapes` to obtain an array with a symbol\n        for each point and uses it to update the symbols.\n\n        Finally, the method updates the legend.\n        \"\"\"\n        if self.scatterplot_item:\n            shape_data = self.get_shapes()\n            self.scatterplot_item.setSymbol(shape_data)\n        self.update_legends()\n\n    def update_z_values(self):\n        \"\"\"\n        Set z-values for point in the plot\n\n        The order is as follows:\n        - selected points that are also in the subset on top,\n        - followed by selected points,\n        - followed by points from the subset,\n        - followed by the rest.\n        Within each of these four groups, points are ordered by their colors.\n\n        Points with less frequent colors are above those with more frequent.\n        The points for which the value for the color is missing are at the\n        bottom of their respective group.\n        \"\"\"\n        if not self.scatterplot_item:\n            return\n\n        subset = self.master.get_subset_mask()\n        c_data = self.master.get_color_data()\n        if subset is None and self.selection is None and c_data is None:\n            self.scatterplot_item.setZ(None)\n            return\n\n        z = np.zeros(self.n_shown)\n\n        if subset is not None:\n            subset = self._filter_visible(subset)\n            z[subset] += 1000\n\n        if self.selection is not None:\n            z[self._filter_visible(self.selection) != 0] += 2000\n\n        if c_data is not None:\n            c_nan = np.isnan(c_data)\n            vis_data = self._filter_visible(c_data)\n            vis_nan = np.isnan(vis_data)\n            z[vis_nan] -= 999\n            if not self.master.is_continuous_color():\n                dist = np.bincount(c_data[~c_nan].astype(int))\n                vis_knowns = vis_data[~vis_nan].astype(int)\n                argdist = np.argsort(dist)\n                z[~vis_nan] -= argdist[vis_knowns]\n\n        self.scatterplot_item.setZ(z)\n\n    def update_grid_visibility(self):\n        \"\"\"Show or hide the grid\"\"\"\n        self.plot_widget.showGrid(x=self.show_grid, y=self.show_grid)\n\n    def update_legend_visibility(self):\n        \"\"\"\n        Show or hide legends based on whether they are enabled and non-empty\n        \"\"\"\n        self.shape_legend.setVisible(\n            self.show_legend and bool(self.shape_legend.items))\n        self.color_legend.setVisible(\n            self.show_legend and bool(self.color_legend.items))\n\n    def update_legends(self):\n        \"\"\"Update content of legends and their visibility\"\"\"\n        cont_color = self.master.is_continuous_color()\n        shape_labels = self.master.get_shape_labels()\n        color_labels = self.master.get_color_labels()\n        if not cont_color and shape_labels is not None \\\n                and shape_labels == color_labels:\n            colors = self.master.get_color_data()\n            shapes = self.master.get_shape_data()\n            mask = np.isfinite(colors) * np.isfinite(shapes)\n            combined = (colors == shapes)[mask].all()\n        else:\n            combined = False\n        if combined:\n            self._update_combined_legend(shape_labels)\n        else:\n            self._update_shape_legend(shape_labels)\n            if cont_color:\n                self._update_continuous_color_legend(color_labels)\n            else:\n                self._update_color_legend(color_labels)\n        self.update_legend_visibility()\n        Updater.update_legend_font(self.parameter_setter.cat_legend_items,\n                                   **self.parameter_setter.cat_legend_settings)\n        Updater.update_num_legend_font(self.parameter_setter.num_legend,\n                                       **self.parameter_setter.num_legend_settings)\n\n    def _update_shape_legend(self, labels):\n        self.shape_legend.clear()\n        if labels is None or self.scatterplot_item is None:\n            return\n        color = QColor(0, 0, 0)\n        color.setAlpha(self.alpha_value)\n        for label, symbol in zip(labels, self.CurveSymbols):\n            self.shape_legend.addItem(\n                SymbolItemSample(pen=color, brush=color, size=10, symbol=symbol),\n                escape(label))\n\n    def _update_continuous_color_legend(self, label_formatter: Callable[[float], str]):\n        self.color_legend.clear()\n        if self.scale is None or self.scatterplot_item is None:\n            return\n        label = PaletteItemSample(self.palette, self.scale, label_formatter)\n        self.color_legend.addItem(label, \"\")\n        self.color_legend.setGeometry(label.boundingRect())\n\n    def _update_color_legend(self, labels):\n        self.color_legend.clear()\n        if labels is None:\n            return\n        self._update_colored_legend(self.color_legend, labels, 'o')\n\n    def _update_combined_legend(self, labels):\n        # update_colored_legend will already clear the shape legend\n        # so we remove colors here\n        use_legend = \\\n            self.shape_legend if self.shape_legend.items else self.color_legend\n        self.color_legend.clear()\n        self.shape_legend.clear()\n        self._update_colored_legend(use_legend, labels, self.CurveSymbols)\n\n    def _update_colored_legend(self, legend, labels, symbols):\n        if self.scatterplot_item is None or not self.palette:\n            return\n        if isinstance(symbols, str):\n            symbols = itertools.repeat(symbols, times=len(labels))\n        colors = self.palette.values_to_colors(np.arange(len(labels)))\n        for color, label, symbol in zip(colors, labels, symbols):\n            color = QColor(*color)\n            pen = _make_pen(color.darker(self.DarkerValue), 1.5)\n            color.setAlpha(self.alpha_value)\n            brush = QBrush(color)\n            legend.addItem(\n                SymbolItemSample(pen=pen, brush=brush, size=10, symbol=symbol),\n                escape(label))\n\n    def zoom_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def pan_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().PanMode)\n\n    def select_button_clicked(self):\n        self.plot_widget.getViewBox().setMouseMode(\n            self.plot_widget.getViewBox().RectMode)\n\n    def reset_button_clicked(self):\n        self.plot_widget.getViewBox().autoRange()\n        self.update_labels()\n\n    def select_by_click(self, _, points):\n        if self.scatterplot_item is not None:\n            self.select(points)\n\n    def select_by_rectangle(self, rect):\n        if self.scatterplot_item is not None:\n            x0, x1 = sorted((rect.topLeft().x(), rect.bottomRight().x()))\n            y0, y1 = sorted((rect.topLeft().y(), rect.bottomRight().y()))\n            x, y = self.master.get_coordinates_data()\n            indices = np.flatnonzero(\n                (x0 <= x) & (x <= x1) & (y0 <= y) & (y <= y1))\n            self.select_by_indices(indices.astype(int))\n\n    def unselect_all(self):\n        if self.selection is not None:\n            self.selection = None\n            self.update_selection_colors()\n            if self.label_only_selected:\n                self.update_labels()\n            self.master.selection_changed()\n\n    def select(self, points):\n        # noinspection PyArgumentList\n        if self.scatterplot_item is None:\n            return\n        indices = [p.data() for p in points]\n        self.select_by_indices(indices)\n\n    def select_by_indices(self, indices):\n        if self.selection is None:\n            self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        keys = QApplication.keyboardModifiers()\n        if keys & Qt.ControlModifier:\n            self.selection_append(indices)\n        elif keys & Qt.ShiftModifier:\n            self.selection_new_group(indices)\n        elif keys & Qt.AltModifier:\n            self.selection_remove(indices)\n        else:\n            self.selection_select(indices)\n\n    def selection_select(self, indices):\n        self.selection = np.zeros(self.n_valid, dtype=np.uint8)\n        self.selection[indices] = 1\n        self._update_after_selection()\n\n    def selection_append(self, indices):\n        self.selection[indices] = max(np.max(self.selection), 1)\n        self._update_after_selection()\n\n    def selection_new_group(self, indices):\n        self.selection[indices] = np.max(self.selection) + 1\n        self._update_after_selection()\n\n    def selection_remove(self, indices):\n        self.selection[indices] = 0\n        self._update_after_selection()\n\n    def _update_after_selection(self):\n        self._compress_indices()\n        self.update_selection_colors()\n        if self.label_only_selected:\n            self.update_labels()\n        self.master.selection_changed()\n\n    def _compress_indices(self):\n        indices = sorted(set(self.selection) | {0})\n        if len(indices) == max(indices) + 1:\n            return\n        mapping = np.zeros((max(indices) + 1,), dtype=int)\n        for i, ind in enumerate(indices):\n            mapping[ind] = i\n        self.selection = mapping[self.selection]\n\n    def get_selection(self):\n        if self.selection is None:\n            return np.array([], dtype=np.uint8)\n        else:\n            return np.flatnonzero(self.selection)\n\n    def help_event(self, event):\n        \"\"\"\n        Create a `QToolTip` for the point hovered by the mouse\n        \"\"\"\n        if self.scatterplot_item is None:\n            return False\n        act_pos = self.scatterplot_item.mapFromScene(event.scenePos())\n        point_data = [p.data() for p in self.scatterplot_item.pointsAt(act_pos)]\n        text = self.master.get_tooltip(point_data)\n        if text:\n            QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)\n            return True\n        else:\n            return False\n"}
A user will ask you to solve a task. You should first draft your thinking process (inner monologue). Then, generate the solution.

Your response format must follow the template below:
<think>
Your thoughts or/and draft, like working through an exercise on scratch paper. Be as casual and as long as you want until you are confident to generate a correct solution.
</think>
<solution>
Final solution presented to the user.
</solution>
system
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]

**Title:** Scatterplot Crashes with ValueError When Using a Single Time Tick

**Description:**
When creating a scatterplot with only one time tick, the application crashes due to a `ValueError`. This occurs because the code attempts to calculate the minimum spacing between ticks, but with only one tick, the sequence is empty, leading to the error.

**Steps to Reproduce:**
```python
import numpy as np
from Orange.data import Domain, Table, TimeVariable, ContinuousVariable
from Orange.widgets.visualize.owscatterplot import OWScatterPlot

def test_single_time_tick_crash():
    # Create data with a single time tick
    data = Table.from_numpy(
        Domain([TimeVariable('time'), ContinuousVariable('value')]),
        np.array([[1582953776, 3]])
    )
    
    # Initialize the scatter plot widget and send the data
    widget = OWScatterPlot()
    widget.send_signal(widget.Inputs.data, data)
    
    # This will raise ValueError: min() arg is an empty sequence
```

**Expected Behavior:**
The scatterplot should handle a single time tick gracefully without crashing. It should display the tick appropriately, possibly by setting a default spacing based on the time range.

**Actual Behavior:**
A `ValueError` is raised with the message `min() arg is an empty sequence`, causing the scatterplot to crash when attempting to plot a single time tick.

[/ISSUE]
--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.

--- BEGIN FILE ---
```
### Orange/widgets/visualize/owscatterplotgraph.py
import sys
import itertools
import warnings
from typing import Callable
from xml.sax.saxutils import escape
from datetime import datetime, timezone

import numpy as np
from AnyQt.QtCore import Qt, QRectF, QSize, QTimer, pyqtSignal as Signal, \
    QObject, QEvent
from AnyQt.QtGui import QColor, QPen, QBrush, QPainterPath, QTransform, \
    QPainter, QPalette
from AnyQt.QtWidgets import QApplication, QToolTip, QGraphicsTextItem, \
    QGraphicsRectItem, QGraphicsItemGroup

import pyqtgraph as pg
from pyqtgraph.graphicsItems.ScatterPlotItem import Symbols
from pyqtgraph.graphicsItems.LegendItem import LegendItem as PgLegendItem
from pyqtgraph.graphicsItems.TextItem import TextItem

from Orange.preprocess.discretize import _time_binnings
from Orange.util import utc_from_timestamp
from Orange.widgets import gui
from Orange.widgets.settings import Setting
from Orange.widgets.utils import classdensity, colorpalettes
from Orange.widgets.visualize.utils.customizableplot import Updater, \
    CommonParameterSetter
from Orange.widgets.visualize.utils.plotutils import (
    HelpEventDelegate as EventDelegate, InteractiveViewBox as ViewBox,
    PaletteItemSample, SymbolItemSample, AxisItem, PlotWidget, DiscretizedScale
)

SELECTION_WIDTH = 5
MAX_N_VALID_SIZE_ANIMATE = 1000

# maximum number of colors (including Other)
MAX_COLORS = 11


class LegendItem(PgLegendItem):
    def __init__(
            self, size=None, offset=None, pen=None, brush=None,
    ):
        super().__init__(size, offset)

        self.layout.setContentsMargins(5, 5, 5, 5)
        self.layout.setHorizontalSpacing(15)
        self.layout.setColumnAlignment(1, Qt.AlignLeft | Qt.AlignVCenter)
        if pen is not None:
            pen = QPen(pen)
        if brush is not None:
            brush = QBrush(brush)
        self.__pen = pen
        self.__brush = brush

    def restoreAnchor(self, anchors):
        """
        Restore (parent) relative position from stored anchors.

        The restored position is within the parent bounds.
        """
        anchor, parentanchor = anchors
        self.anchor(*bound_anchor_pos(anchor, parentanchor))

    # pylint: disable=arguments-differ
    def paint(self, painter, _option, _widget=None):
        painter.setPen(self.pen())
        painter.setBrush(self.brush())
        rect = self.contentsRect()
        painter.drawRoundedRect(rect, 2, 2)

    def addItem(self, item, name):
        super().addItem(item, name)
        # Fix-up the label alignment, and color
        color = self.palette().color(QPalette.Text)
        _, label = self.items[-1]
        label.setText(name, justify="left", color=color)

    def clear(self):
        """
        Clear all legend items.
        """
        items = list(self.items)
        self.items = []
        for sample, label in items:
            self.layout.removeItem(sample)
            self.layout.removeItem(label)
            sample.hide()
            label.hide()

        self.updateSize()

    def pen(self):
        if self.__pen is not None:
            return QPen(self.__pen)
        else:
            color = self.palette().color(QPalette.Disabled, QPalette.Text)
            color.setAlpha(100)
            pen = QPen(color, 1)
            pen.setCosmetic(True)
            return pen

    def brush(self):
        if self.__brush is not None:
            return QBrush(self.__brush)
        else:
            color = self.palette().color(QPalette.Window)
            color.setAlpha(150)
            return QBrush(color)

    def changeEvent(self, event: QEvent):
        if event.type() == QEvent.PaletteChange:
            color = self.palette().color(QPalette.Text)
            for _, label in self.items:
                label.setText(label.text, color=color)
        super().changeEvent(event)


def bound_anchor_pos(corner, parentpos):
    corner = np.clip(corner, 0, 1)
    parentpos = np.clip(parentpos, 0, 1)

    irx, iry = corner
    prx, pry = parentpos

    if irx > 0.9 and prx < 0.1:
        irx = prx = 0.0
    if iry > 0.9 and pry < 0.1:
        iry = pry = 0.0
    if irx < 0.1 and prx > 0.9:
        irx = prx = 1.0
    if iry < 0.1 and pry > 0.9:
        iry = pry = 1.0
    return (irx, iry), (prx, pry)


class ScatterPlotItem(pg.ScatterPlotItem):
    """
    Modifies the behaviour of ScatterPlotItem as follows:

    - Add z-index. ScatterPlotItem paints points in order of appearance in
      self.data. Plotting by z-index is achieved by sorting before calling
      super().paint() and re-sorting afterwards. Re-sorting (instead of
      storing the original data) is needed because the inherited paint
      may modify the data.

    - Prevent multiple calls to updateSpots. ScatterPlotItem calls updateSpots
      at any change of sizes/colors/symbols, which then rebuilds the stored
      pixmaps for each symbol. Orange calls set* functions in succession,
      so we postpone updateSpots() to paint()."""

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._update_spots_in_paint = False
        self._z_mapping = None
        self._inv_mapping = None

    def setZ(self, z):
        """
        Set z values for all points.

        Points with higher values are plotted on top of those with lower.

        Args:
            z (np.ndarray or None): a vector of z values
        """
        if z is None:
            self._z_mapping = self._inv_mapping = None
        else:
            assert len(z) == len(self.data)
            self._z_mapping = np.argsort(z)
            self._inv_mapping = np.argsort(self._z_mapping)

    def setCoordinates(self, x, y):
        """
        Change the coordinates of points while keeping other properties.

        Asserts that the number of points stays the same.

        Note. Pyqtgraph does not offer a method for this: setting coordinates
        invalidates other data. We therefore retrieve the data to set it
        together with the coordinates. Pyqtgraph also does not offer a
        (documented) method for retrieving the data, yet using
        data[prop]` looks reasonably safe.

        The alternative, updating the whole scatterplot from the Orange Table,
        is too slow.
        """
        assert len(self.data) == len(x) == len(y)
        data = dict(x=x, y=y)
        for prop in ('pen', 'brush', 'size', 'symbol', 'data'):
            data[prop] = self.data[prop]
        self.setData(**data)

    def updateSpots(self, dataSet=None):  # pylint: disable=unused-argument
        self._update_spots_in_paint = True
        self.update()

    # pylint: disable=arguments-differ
    def paint(self, painter, option, widget=None):
        try:
            if self._z_mapping is not None:
                assert len(self._z_mapping) == len(self.data)
                self.data = self.data[self._z_mapping]
            if self._update_spots_in_paint:
                self._update_spots_in_paint = False
                super().updateSpots()
            painter.setRenderHint(QPainter.SmoothPixmapTransform, True)
            super().paint(painter, option, widget)
        finally:
            if self._inv_mapping is not None:
                self.data = self.data[self._inv_mapping]


def _define_symbols():
    """
    Add symbol ? to ScatterPlotItemSymbols,
    reflect the triangle to point upwards
    """
    path = QPainterPath()
    path.addEllipse(QRectF(-0.35, -0.35, 0.7, 0.7))
    path.moveTo(-0.5, 0.5)
    path.lineTo(0.5, -0.5)
    path.moveTo(-0.5, -0.5)
    path.lineTo(0.5, 0.5)
    Symbols["?"] = path

    path = QPainterPath()
    plusCoords = [
        (-0.5, -0.1), (-0.5, 0.1), (-0.1, 0.1), (-0.1, 0.5),
        (0.1, 0.5), (0.1, 0.1), (0.5, 0.1), (0.5, -0.1),
        (0.1, -0.1), (0.1, -0.5), (-0.1, -0.5), (-0.1, -0.1)
    ]
    path.moveTo(*plusCoords[0])
    for x, y in plusCoords[1:]:
        path.lineTo(x, y)
    path.closeSubpath()
    Symbols["+"] = path

    tr = QTransform()
    tr.rotate(180)
    Symbols['t'] = tr.map(Symbols['t'])

    tr = QTransform()
    tr.rotate(45)
    Symbols['x'] = tr.map(Symbols["+"])


_define_symbols()


def _make_pen(color, width):
    p = QPen(color, width)
    p.setCosmetic(True)
    return p


class AxisItem(AxisItem):
    """
    Axis that if needed displays ticks appropriate for time data.
    """

    _label_width = 80

    def __init__(self, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self._use_time = False

    def use_time(self, enable):
        """Enables axes to display ticks for time data."""
        self._use_time = enable
        self.enableAutoSIPrefix(not enable)

    def tickValues(self, minVal, maxVal, size):
        """Find appropriate tick locations."""
        if not self._use_time:
            return super().tickValues(minVal, maxVal, size)

        # if timezone is not set, then local is used which cause exceptions
        minVal = max(minVal,
                     datetime.min.replace(tzinfo=timezone.utc).timestamp() + 1)
        maxVal = min(maxVal,
                     datetime.max.replace(tzinfo=timezone.utc).timestamp() - 1)
        mn = utc_from_timestamp(minVal).timetuple()
        mx = utc_from_timestamp(maxVal).timetuple()
        try:
            bins = _time_binnings(mn, mx, 6, 30)[-1]
        except (IndexError, ValueError):
            # cannot handle very large and very small time intervals
            return super().tickValues(minVal, maxVal, size)

        ticks = bins.thresholds
        # Remove ticks that will later be removed in AxisItem.generateDrawSpecs
        # because they are out of range. Removing them here is needed so that
        # they do not affect spaces and label format
        ticks = ticks[(ticks[0] < minVal)
                      :len(ticks) - (ticks[-1] > maxVal)]

        max_steps = max(int(size / self._label_width), 1)
        if len(ticks) > max_steps:
            # remove some of ticks so that they don't overlap
            step = int(np.ceil(float(len(ticks)) / max_steps))
            ticks = ticks[::step]

        spacing = min(b - a for a, b in zip(ticks[:-1], ticks[1:]))
        return [(spacing, ticks)]

    def tickStrings(self, values, scale, spacing):
        """Format tick values according to space between them."""
        if not self._use_time:
            return super().tickStrings(values, scale, spacing)

        if spacing >= 3600 * 24 * 365:
            fmt = "%Y"
        elif spacing >= 3600 * 24 * 28:
            fmt = "%Y %b"
        elif spacing >= 3600 * 24:
            fmt = "%Y %b %d"
        elif spacing >= 3600:
            min_day = max_day = 1
            if len(values) > 0:
                min_day = datetime.fromtimestamp(
                    min(values), tz=timezone.utc).day
                max_day = datetime.fromtimestamp(
                    max(values), tz=timezone.utc).day
            if min_day == max_day:
                fmt = "%Hh"
            else:
                fmt = "%d %Hh"
        elif spacing >= 60:
            fmt = "%H:%M"
        elif spacing >= 1:
            fmt = "%H:%M:%S"
        else:
            fmt = '%S.%f'

        return [utc_from_timestamp(x).strftime(fmt) for x in values]


class ScatterBaseParameterSetter(CommonParameterSetter):
    CAT_LEGEND_LABEL = "Categorical legend"
    NUM_LEGEND_LABEL = "Numerical legend"
    NUM_LEGEND_SETTING = {
        Updater.SIZE_LABEL: (range(4, 50), 11),
        Updater.IS_ITALIC_LABEL: (None, False),
    }

    def __init__(self, master):
        super().__init__()
        self.master = master
        self.cat_legend_settings = {}
        self.num_legend_settings = {}

    def update_setters(self):
        self.initial_settings = {
            self.LABELS_BOX: {
                self.FONT_FAMILY_LABEL: self.FONT_FAMILY_SETTING,
                self.TITLE_LABEL: self.FONT_SETTING,
                self.LABEL_LABEL: self.FONT_SETTING,
                self.CAT_LEGEND_LABEL: self.FONT_SETTING,
                self.NUM_LEGEND_LABEL: self.NUM_LEGEND_SETTING,
            },
            self.ANNOT_BOX: {
                self.TITLE_LABEL: {self.TITLE_LABEL: ("", "")},
            }
        }

        def update_cat_legend(**settings):
            self.cat_legend_settings.update(**settings)
            Updater.update_legend_font(self.cat_legend_items, **settings)

        def update_num_legend(**settings):
            self.num_legend_settings.update(**settings)
            Updater.update_num_legend_font(self.num_legend, **settings)

        labels = self.LABELS_BOX
        self._setters[labels][self.CAT_LEGEND_LABEL] = update_cat_legend
        self._setters[labels][self.NUM_LEGEND_LABEL] = update_num_legend

    @property
    def title_item(self):
        return self.master.plot_widget.getPlotItem().titleLabel

    @property
    def cat_legend_items(self):
        items = self.master.color_legend.items
        if items and items[0] and isinstance(items[0][0], PaletteItemSample):
            items = []
        return itertools.chain(self.master.shape_legend.items, items)

    @property
    def num_legend(self):
        items = self.master.color_legend.items
        if items and items[0] and isinstance(items[0][0], PaletteItemSample):
            return self.master.color_legend
        return None

    @property
    def labels(self):
        return self.master.labels


class OWScatterPlotBase(gui.OWComponent, QObject):
    """
    Provide a graph component for widgets that show any kind of point plot

    The component plots a set of points with given coordinates, shapes,
    sizes and colors. Its function is similar to that of a *view*, whereas
    the widget represents a *model* and a *controler*.

    The model (widget) needs to provide methods:

    - `get_coordinates_data`, `get_size_data`, `get_color_data`,
      `get_shape_data`, `get_label_data`, which return a 1d array (or two
      arrays, for `get_coordinates_data`) of `dtype` `float64`, except for
      `get_label_data`, which returns formatted labels;
    - `get_shape_labels` returns a list of strings for shape legend
    - `get_color_labels` returns strings for color legend, or a function for
       formatting numbers if the legend is continuous, or None for default
       formatting
    - `get_tooltip`, which gives a tooltip for a single data point
    - (optional) `impute_sizes`, `impute_shapes` get final coordinates and
      shapes, and replace nans;
    - `get_subset_mask` returns a bool array indicating whether a
      data point is in the subset or not (e.g. in the 'Data Subset' signal
      in the Scatter plot and similar widgets);
    - `get_palette` returns a palette appropriate for visualizing the
      current color data;
    - `is_continuous_color` decides the type of the color legend;

    The widget (in a role of controller) must also provide methods
    - `selection_changed`

    If `get_coordinates_data` returns `(None, None)`, the plot is cleared. If
    `get_size_data`, `get_color_data` or `get_shape_data` return `None`,
    all points will have the same size, color or shape, respectively.
    If `get_label_data` returns `None`, there are no labels.

    The view (this compomnent) provides methods `update_coordinates`,
    `update_sizes`, `update_colors`, `update_shapes` and `update_labels`
    that the widget (in a role of a controler) should call when any of
    these properties are changed. If the widget calls, for instance, the
    plot's `update_colors`, the plot will react by calling the widget's
    `get_color_data` as well as the widget's methods needed to construct the
    legend.

    The view also provides a method `reset_graph`, which should be called only
    when
    - the widget gets entirely new data
    - the number of points may have changed, for instance when selecting
    a different attribute for x or y in the scatter plot, where the points
    with missing x or y coordinates are hidden.

    Every `update_something` calls the plot's `get_something`, which
    calls the model's `get_something_data`, then it transforms this data
    into whatever is needed (colors, shapes, scaled sizes) and changes the
    plot. For the simplest example, here is `update_shapes`:

    ```
        def update_shapes(self):
            if self.scatterplot_item:
                shape_data = self.get_shapes()
                self.scatterplot_item.setSymbol(shape_data)
            self.update_legends()

        def get_shapes(self):
            shape_data = self.master.get_shape_data()
            shape_data = self.master.impute_shapes(
                shape_data, len(self.CurveSymbols) - 1)
            return self.CurveSymbols[shape_data]
    ```

    On the widget's side, `get_something_data` is essentially just:

    ```
        def get_size_data(self):
            return self.get_column(self.attr_size)
    ```

    where `get_column` retrieves a column while also filtering out the
    points with missing x and y and so forth. (Here we present the simplest
    two cases, "shapes" for the view and "sizes" for the model. The colors
    for the view are more complicated since they deal with discrete and
    continuous palettes, and the shapes for the view merge infrequent shapes.)

    The plot can also show just a random sample of the data. The sample size is
    set by `set_sample_size`, and the rest is taken care by the plot: the
    widget keeps providing the data for all points, selection indices refer
    to the entire set etc. Internally, sampling happens as early as possible
    (in methods `get_<something>`).
    """
    too_many_labels = Signal(bool)
    begin_resizing = Signal()
    step_resizing = Signal()
    end_resizing = Signal()

    label_only_selected = Setting(False)
    point_width = Setting(10)
    alpha_value = Setting(128)
    show_grid = Setting(False)
    show_legend = Setting(True)
    class_density = Setting(False)
    jitter_size = Setting(0)

    resolution = 256

    CurveSymbols = np.array("o x t + d star ?".split())
    MinShapeSize = 6
    DarkerValue = 120
    UnknownColor = (168, 50, 168)

    COLOR_DEFAULT = (128, 128, 128)

    MAX_VISIBLE_LABELS = 500

    def __init__(self, scatter_widget, parent=None, view_box=ViewBox):
        QObject.__init__(self)
        gui.OWComponent.__init__(self, scatter_widget)

        self.subset_is_shown = False
        self.jittering_suspended = False

        self.view_box = view_box(self)
        _axis = {"left": AxisItem("left"), "bottom": AxisItem("bottom")}
        self.plot_widget = PlotWidget(
            viewBox=self.view_box, parent=parent, background=None,
            axisItems=_axis
        )
        self.plot_widget.hideAxis("left")
        self.plot_widget.hideAxis("bottom")
        self.plot_widget.getPlotItem().buttonsHidden = True
        self.plot_widget.setAntialiasing(True)
        self.plot_widget.sizeHint = lambda: QSize(500, 500)

        self.density_img = None
        self.scatterplot_item = None
        self.scatterplot_item_sel = None
        self.labels = []

        self.master = scatter_widget
        tooltip = self._create_drag_tooltip()
        self.view_box.setDragTooltip(tooltip)

        self.selection = None  # np.ndarray

        self.n_valid = 0
        self.n_shown = 0
        self.sample_size = None
        self.sample_indices = None

        self.palette = None

        self.shape_legend = self._create_legend(((1, 0), (1, 0)))
        self.color_legend = self._create_legend(((1, 1), (1, 1)))
        self.update_legend_visibility()

        self.scale = None  # DiscretizedScale
        self._too_many_labels = False

        # self.setMouseTracking(True)
        # self.grabGesture(QPinchGesture)
        # self.grabGesture(QPanGesture)

        self.update_grid_visibility()

        self._tooltip_delegate = EventDelegate(self.help_event)
        self.plot_widget.scene().installEventFilter(self._tooltip_delegate)
        self.view_box.sigTransformChanged.connect(self.update_density)
        self.view_box.sigRangeChangedManually.connect(self.update_labels)

        self.timer = None

        self.parameter_setter = ScatterBaseParameterSetter(self)

    def _create_legend(self, anchor):
        legend = LegendItem()
        legend.setParentItem(self.plot_widget.getViewBox())
        legend.restoreAnchor(anchor)
        return legend

    def _create_drag_tooltip(self):
        tip_parts = [
            (Qt.ControlModifier,
             "{}: Append to group".
             format("Cmd" if sys.platform == "darwin" else "Ctrl")),
            (Qt.ShiftModifier, "Shift: Add group"),
            (Qt.AltModifier, "Alt: Remove")
        ]
        all_parts = "<center>" + \
                    ", ".join(part for _, part in tip_parts) + \
                    "</center>"
        self.tiptexts = {
            modifier: all_parts.replace(part, "<b>{}</b>".format(part))
            for modifier, part in tip_parts
        }
        self.tiptexts[Qt.NoModifier] = all_parts

        self.tip_textitem = text = QGraphicsTextItem()
        # Set to the longest text
        text.setHtml(self.tiptexts[Qt.ControlModifier])
        text.setPos(4, 2)
        r = text.boundingRect()
        text.setTextWidth(r.width())
        rect = QGraphicsRectItem(0, 0, r.width() + 8, r.height() + 4)
        color = self.plot_widget.palette().color(QPalette.Disabled, QPalette.Window)
        color.setAlpha(212)
        rect.setBrush(color)
        rect.setPen(QPen(Qt.NoPen))
        self.update_tooltip()

        tooltip_group = QGraphicsItemGroup()
        tooltip_group.addToGroup(rect)
        tooltip_group.addToGroup(text)
        return tooltip_group

    def update_tooltip(self, modifiers=Qt.NoModifier):
        text = self.tiptexts[Qt.NoModifier]
        for mod in [Qt.ControlModifier,
                    Qt.ShiftModifier,
                    Qt.AltModifier]:
            if modifiers & mod:
                text = self.tiptexts.get(mod)
                break
        self.tip_textitem.setHtml(text)

    def suspend_jittering(self):
        if self.jittering_suspended:
            return
        self.jittering_suspended = True
        if self.jitter_size != 0:
            self.update_jittering()

    def unsuspend_jittering(self):
        if not self.jittering_suspended:
            return
        self.jittering_suspended = False
        if self.jitter_size != 0:
            self.update_jittering()

    def update_jittering(self):
        x, y = self.get_coordinates()
        if x is None or len(x) == 0 or self.scatterplot_item is None:
            return
        self.scatterplot_item.setCoordinates(x, y)
        self.scatterplot_item_sel.setCoordinates(x, y)
        self.update_labels()

    # TODO: Rename to remove_plot_items
    def clear(self):
        """
        Remove all graphical elements from the plot

        Calls the pyqtgraph's plot widget's clear, sets all handles to `None`,
        removes labels and selections.

        This method should generally not be called by the widget. If the data
        is gone (*e.g.* upon receiving `None` as an input data signal), this
        should be handler by calling `reset_graph`, which will in turn call
        `clear`.

        Derived classes should override this method if they add more graphical
        elements. For instance, the regression line in the scatterplot adds
        `self.reg_line_item = None` (the line in the plot is already removed
        in this method).
        """
        self.plot_widget.clear()

        self.density_img = None
        if self.timer is not None and self.timer.isActive():
            self.timer.stop()
            self.timer = None
        self.scatterplot_item = None
        self.scatterplot_item_sel = None
        self.labels = []
        self._signal_too_many_labels(False)
        self.view_box.init_history()
        self.view_box.tag_history()

    # TODO: I hate `keep_something` and `reset_something` arguments
    # __keep_selection is used exclusively be set_sample size which would
    # otherwise just repeat the code from reset_graph except for resetting
    # the selection. I'm uncomfortable with this; we may prefer to have a
    # method _reset_graph which does everything except resetting the selection,
    # and reset_graph would call it.
    def reset_graph(self, __keep_selection=False):
        """
        Reset the graph to new data (or no data)

        The method must be called when the plot receives new data, in
        particular when the number of points change. If only their properties
        - like coordinates or shapes - change, an update method
        (`update_coordinates`, `update_shapes`...) should be called instead.

        The method must also be called when the data is gone.

        The method calls `clear`, followed by calls of all update methods.

        NB. Argument `__keep_selection` is for internal use only
        """
        self.clear()
        if not __keep_selection:
            self.selection = None
        self.sample_indices = None
        self.update_coordinates()
        self.update_point_props()

    def set_sample_size(self, sample_size):
        """
        Set the sample size

        Args:
            sample_size (int or None): sample size or `None` to show all points
        """
        if self.sample_size != sample_size:
            self.sample_size = sample_size
            self.reset_graph(True)

    def update_point_props(self):
        """
        Update the sizes, colors, shapes and labels

        The method calls the appropriate update methods for individual
        properties.
        """
        self.update_sizes()
        self.update_colors()
        self.update_selection_colors()
        self.update_shapes()
        self.update_labels()

    # Coordinates
    # TODO: It could be nice if this method was run on entire data, not just
    # a sample. For this, however, it would need to either be called from
    # `get_coordinates` before sampling (very ugly) or call
    # `self.master.get_coordinates_data` (beyond ugly) or the widget would
    # have to store the ranges of unsampled data (ugly).
    # Maybe we leave it as it is.
    def _reset_view(self, x_data, y_data):
        """
        Set the range of the view box

        Args:
            x_data (np.ndarray): x coordinates
            y_data (np.ndarray) y coordinates
        """
        min_x, max_x = np.min(x_data), np.max(x_data)
        min_y, max_y = np.min(y_data), np.max(y_data)
        self.view_box.setRange(
            QRectF(min_x, min_y, max_x - min_x or 1, max_y - min_y or 1),
            padding=0.025)

    def _filter_visible(self, data):
        """Return the sample from the data using the stored sample_indices"""
        if data is None or self.sample_indices is None:
            return data
        else:
            return np.asarray(data[self.sample_indices])

    def get_coordinates(self):
        """
        Prepare coordinates of the points in the plot

        The method is called by `update_coordinates`. It gets the coordinates
        from the widget, jitters them and return them.

        The methods also initializes the sample indices if neededd and stores
        the original and sampled number of points.

        Returns:
            (tuple): a pair of numpy arrays containing (sampled) coordinates,
                or `(None, None)`.
        """
        x, y = self.master.get_coordinates_data()
        if x is None:
            self.n_valid = self.n_shown = 0
            return None, None
        self.n_valid = len(x)
        self._create_sample()
        x = self._filter_visible(x)
        y = self._filter_visible(y)
        # Jittering after sampling is OK if widgets do not change the sample
        # semi-permanently, e.g. take a sample for the duration of some
        # animation. If the sample size changes dynamically (like by adding
        # a "sample size" slider), points would move around when the sample
        # size changes. To prevent this, jittering should be done before
        # sampling (i.e. two lines earlier). This would slow it down somewhat.
        x, y = self.jitter_coordinates(x, y)
        return x, y

    def _create_sample(self):
        """
        Create a random sample if the data is larger than the set sample size
        """
        self.n_shown = min(self.n_valid, self.sample_size or self.n_valid)
        if self.sample_size is not None \
                and self.sample_indices is None \
                and self.n_valid != self.n_shown:
            random = np.random.RandomState(seed=0)
            self.sample_indices = random.choice(
                self.n_valid, self.n_shown, replace=False)
            # TODO: Is this really needed?
            np.sort(self.sample_indices)

    def jitter_coordinates(self, x, y):
        """
        Display coordinates to random positions within ellipses with
        radiuses of `self.jittter_size` percents of spans
        """
        if self.jitter_size == 0 or self.jittering_suspended:
            return x, y
        return self._jitter_data(x, y)

    def _jitter_data(self, x, y, span_x=None, span_y=None):
        if span_x is None:
            span_x = np.max(x) - np.min(x)
        if span_y is None:
            span_y = np.max(y) - np.min(y)
        random = np.random.RandomState(seed=0)
        rs = random.uniform(0, 1, len(x))
        phis = random.uniform(0, 2 * np.pi, len(x))
        magnitude = self.jitter_size / 100
        return (x + magnitude * span_x * rs * np.cos(phis),
                y + magnitude * span_y * rs * np.sin(phis))

    def update_coordinates(self):
        """
        Trigger the update of coordinates while keeping other features intact.

        The method gets the coordinates by calling `self.get_coordinates`,
        which in turn calls the widget's `get_coordinate_data`. The number of
        coordinate pairs returned by the latter must match the current number
        of points. If this is not the case, the widget should trigger
        the complete update by calling `reset_graph` instead of this method.
        """
        x, y = self.get_coordinates()
        if x is None or len(x) == 0:
            return

        self._reset_view(x, y)
        if self.scatterplot_item is None:
            if self.sample_indices is None:
                indices = np.arange(self.n_valid)
            else:
                indices = self.sample_indices
            kwargs = dict(x=x, y=y, data=indices)
            self.scatterplot_item = ScatterPlotItem(**kwargs)
            self.scatterplot_item.sigClicked.connect(self.select_by_click)
            self.scatterplot_item_sel = ScatterPlotItem(**kwargs)
            self.plot_widget.addItem(self.scatterplot_item_sel)
            self.plot_widget.addItem(self.scatterplot_item)
        else:
            self.scatterplot_item.setCoordinates(x, y)
            self.scatterplot_item_sel.setCoordinates(x, y)
            self.update_labels()

        self.update_density()  # Todo: doesn't work: try MDS with density on

    # Sizes
    def get_sizes(self):
        """
        Prepare data for sizes of points in the plot

        The method is called by `update_sizes`. It gets the sizes
        from the widget and performs the necessary scaling and sizing.
        The output is rounded to half a pixel for faster drawing.

        Returns:
            (np.ndarray): sizes
        """
        size_column = self.master.get_size_data()
        if size_column is None:
            return np.full((self.n_shown,),
                           self.MinShapeSize + (5 + self.point_width) * 0.5)
        size_column = self._filter_visible(size_column)
        size_column = size_column.copy()
        with warnings.catch_warnings():
            warnings.simplefilter("ignore", category=RuntimeWarning)
            size_column -= np.nanmin(size_column)
            mx = np.nanmax(size_column)
        if mx > 0:
            size_column /= mx
        else:
            size_column[:] = 0.5

        sizes = self.MinShapeSize + (5 + self.point_width) * size_column
        # round sizes to half pixel for smaller pyqtgraph's symbol pixmap atlas
        sizes = (sizes * 2).round() / 2
        return sizes

    def update_sizes(self):
        """
        Trigger an update of point sizes

        The method calls `self.get_sizes`, which in turn calls the widget's
        `get_size_data`. The result are properly scaled and then passed
        back to widget for imputing (`master.impute_sizes`).
        """
        if self.scatterplot_item:
            size_data = self.get_sizes()
            size_imputer = getattr(
                self.master, "impute_sizes", self.default_impute_sizes)
            size_imputer(size_data)

            if self.timer is not None and self.timer.isActive():
                self.timer.stop()
                self.timer = None

            current_size_data = self.scatterplot_item.data["size"].copy()
            diff = size_data - current_size_data
            widget = self

            class Timeout:
                # 0.5 - np.cos(np.arange(0.17, 1, 0.09) * np.pi) / 2
                factors = [0.07, 0.16, 0.27, 0.41, 0.55,
                           0.68, 0.81, 0.9, 0.97, 1]

                def __init__(self):
                    self._counter = 0

                def __call__(self):
                    factor = self.factors[self._counter]
                    self._counter += 1
                    size = current_size_data + diff * factor
                    if len(self.factors) == self._counter:
                        widget.timer.stop()
                        widget.timer = None
                        size = size_data
                    widget.scatterplot_item.setSize(size)
                    widget.scatterplot_item_sel.setSize(size + SELECTION_WIDTH)
                    if widget.timer is None:
                        widget.end_resizing.emit()
                    else:
                        widget.step_resizing.emit()

            if self.n_valid <= MAX_N_VALID_SIZE_ANIMATE and \
                    np.all(current_size_data > 0) and np.any(diff != 0):
                # If encountered any strange behaviour when updating sizes,
                # implement it with threads
                self.begin_resizing.emit()
                interval = int(500 / len(Timeout.factors))
                self.timer = QTimer(self.scatterplot_item, interval=interval)
                self.timer.timeout.connect(Timeout())
                self.timer.start()
            else:
                self.begin_resizing.emit()
                self.scatterplot_item.setSize(size_data)
                self.scatterplot_item_sel.setSize(size_data + SELECTION_WIDTH)
                self.end_resizing.emit()

    update_point_size = update_sizes  # backward compatibility (needed?!)
    update_size = update_sizes

    @classmethod
    def default_impute_sizes(cls, size_data):
        """
        Fallback imputation for sizes.

        Set the size to two pixels smaller than the minimal size

        Returns:
            (bool): True if there was any missing data
        """
        nans = np.isnan(size_data)
        if np.any(nans):
            size_data[nans] = cls.MinShapeSize - 2
            return True
        else:
            return False

    # Colors
    def get_colors(self):
        """
        Prepare data for colors of the points in the plot

        The method is called by `update_colors`. It gets the colors and the
        indices of the data subset from the widget (`get_color_data`,
        `get_subset_mask`), and constructs lists of pens and brushes for
        each data point.

        The method uses different palettes for discrete and continuous data,
        as determined by calling the widget's method `is_continuous_color`.

        If also marks the points that are in the subset as defined by, for
        instance the 'Data Subset' signal in the Scatter plot and similar
        widgets. (Do not confuse this with *selected points*, which are
        marked by circles around the points, which are colored by groups
        and thus independent of this method.)

        Returns:
            (tuple): a list of pens and list of brushes
        """
        c_data = self.master.get_color_data()
        c_data = self._filter_visible(c_data)
        subset = self.master.get_subset_mask()
        subset = self._filter_visible(subset)
        self.subset_is_shown = subset is not None
        if c_data is None:  # same color
            self.palette = None
            return self._get_same_colors(subset)
        elif self.master.is_continuous_color():
            return self._get_continuous_colors(c_data, subset)
        else:
            return self._get_discrete_colors(c_data, subset)

    def _get_same_colors(self, subset, color=COLOR_DEFAULT):
        """
        Return the same pen for all points while the brush color depends
        upon whether the point is in the subset or not

        Args:
            subset (np.ndarray): a bool array indicating whether a data point
                is in the subset or not (e.g. in the 'Data Subset' signal
                in the Scatter plot and similar widgets);

        Returns:
            (tuple): a list of pens and list of brushes
        """
        alpha_subset, alpha_unset = self._alpha_for_subsets()
        if subset is not None:
            qcolor = QColor(*color, alpha_subset)
            brush = np.where(subset, QBrush(qcolor), QBrush(QColor(0, 0, 0, 0)))
            pen = np.where(subset,
                           _make_pen(qcolor, 1.5),
                           _make_pen(QColor(*color, alpha_unset), 1.5))
        else:
            qcolor = QColor(*color, self.alpha_value)
            brush = np.full(self.n_shown, QBrush(qcolor))
            pen = [_make_pen(qcolor, 1.5)] * self.n_shown
        return pen, brush

    def _get_continuous_colors(self, c_data, subset):
        """
        Return the pens and colors whose color represent an index into
        a continuous palette. The same color is used for pen and brush,
        except the former is darker. If the data has a subset, the brush
        is transparent for points that are not in the subset.
        """
        palette = self.master.get_palette()

        if np.isnan(c_data).all():
            self.palette = palette
            return self._get_same_colors(subset, self.palette.nan_color)

        self.scale = DiscretizedScale(np.nanmin(c_data), np.nanmax(c_data))
        bins = self.scale.get_bins()
        self.palette = \
            colorpalettes.BinnedContinuousPalette.from_palette(palette, bins)
        colors = self.palette.values_to_colors(c_data)
        alphas = np.full((len(c_data), 1), self.alpha_value, dtype=np.ubyte)
        brush = np.hstack((colors, alphas))
        pen = np.hstack(
            ((colors.astype(dtype=float) * 100 / self.DarkerValue).astype(np.ubyte),
             alphas))

        # Reuse pens and brushes with the same colors because PyQtGraph then
        # builds smaller pixmap atlas, which makes the drawing faster

        def reuse(cache, fun, *args):
            if args not in cache:
                cache[args] = fun(args)
            return cache[args]

        def create_pen(col):
            return _make_pen(QColor(*col), 1.5)

        def create_brush(col):
            return QBrush(QColor(*col))

        if subset is not None:
            alpha_subset, alpha_unset = self._alpha_for_subsets()
            brush[:, 3] = 0
            brush[subset, 3] = alpha_subset
            pen[:, 3] = alpha_unset
            brush[subset, 3] = alpha_subset

        cached_pens = {}
        pen = [reuse(cached_pens, create_pen, *col) for col in pen.tolist()]
        cached_brushes = {}
        brush = np.array([reuse(cached_brushes, create_brush, *col)
                          for col in brush.tolist()])

        return pen, brush

    def _get_discrete_colors(self, c_data, subset):
        """
        Return the pens and colors whose color represent an index into
        a discrete palette. The same color is used for pen and brush,
        except the former is darker. If the data has a subset, the brush
        is transparent for points that are not in the subset.
        """
        self.palette = self.master.get_palette()
        c_data = c_data.copy()
        c_data[np.isnan(c_data)] = len(self.palette)
        c_data = c_data.astype(int)
        colors = self.palette.qcolors_w_nan
        if subset is None:
            for col in colors:
                col.setAlpha(self.alpha_value)
            pens = np.array(
                [_make_pen(col.darker(self.DarkerValue), 1.5)
                 for col in colors])
            pen = pens[c_data]
            brushes = np.array([QBrush(col) for col in colors])
            brush = brushes[c_data]
        else:
            subset_colors = [QColor(col) for col in colors]
            alpha_subset, alpha_unset = self._alpha_for_subsets()
            for col in subset_colors:
                col.setAlpha(alpha_subset)
            for col in colors:
                col.setAlpha(alpha_unset)

            pens, subset_pens = (
                np.array(
                    [_make_pen(col.darker(self.DarkerValue), 1.5)
                     for col in cols])
                for cols in (colors, subset_colors))
            pen = np.where(subset, subset_pens[c_data], pens[c_data])

            brushes = np.array([QBrush(col) for col in subset_colors])
            brush = brushes[c_data]
            black = np.full(len(brush), QBrush(QColor(0, 0, 0, 0)))
            brush = np.where(subset, brush, black)
        return pen, brush

    def _alpha_for_subsets(self):
        a, b, c = 1.2, -3.2, 3
        x = self.alpha_value / 255
        alpha_subset = 31 + int(224 * (a * x ** 3 + b * x ** 2 + c * x))
        x = 1 - x
        alpha_unset = int(255 - 224 * (a * x ** 3 + b * x ** 2 + c * x))
        return alpha_subset, alpha_unset

    def update_colors(self):
        """
        Trigger an update of point colors

        The method calls `self.get_colors`, which in turn calls the widget's
        `get_color_data` to get the indices in the pallette. `get_colors`
        returns a list of pens and brushes to which this method uses to
        update the colors. Finally, the method triggers the update of the
        legend and the density plot.
        """
        if self.scatterplot_item is not None:
            pen_data, brush_data = self.get_colors()
            self.scatterplot_item.setPen(pen_data, update=False, mask=None)
            self.scatterplot_item.setBrush(brush_data, mask=None)
        self.update_z_values()
        self.update_legends()
        self.update_density()

    update_alpha_value = update_colors

    def update_density(self):
        """
        Remove the existing density plot (if there is one) and replace it
        with a new one (if enabled).

        The method gets the colors from the pens of the currently plotted
        points.
        """
        if self.density_img:
            self.plot_widget.removeItem(self.density_img)
            self.density_img = None
        if self.class_density and self.scatterplot_item is not None:
            c_data = self.master.get_color_data()
            if c_data is None:
                return
            visible_c_data = self._filter_visible(c_data)
            mask = np.isfinite(visible_c_data)
            if not self.master.is_continuous_color():
                mask = np.bitwise_and(mask, visible_c_data < MAX_COLORS - 1)
            pens = self.scatterplot_item.data['pen']
            rgb_data = [
                pen.color().getRgb()[:3] if pen is not None else (255, 255, 255)
                for known, pen in zip(mask, pens)
                if known]
            if len(set(rgb_data)) <= 1:
                return
            [min_x, max_x], [min_y, max_y] = self.view_box.viewRange()
            x_data, y_data = self.scatterplot_item.getData()
            self.density_img = classdensity.class_density_image(
                min_x, max_x, min_y, max_y, self.resolution,
                x_data[mask], y_data[mask], rgb_data)
            self.plot_widget.addItem(self.density_img, ignoreBounds=True)

    def update_selection_colors(self):
        """
        Trigger an update of selection markers

        This update method is usually not called by the widget but by the
        plot, since it is the plot that handles the selections.

        Like other update methods, it calls the corresponding get method
        (`get_colors_sel`) which returns a list of pens and brushes.
        """
        if self.scatterplot_item_sel is None:
            return
        pen, brush = self.get_colors_sel()
        self.scatterplot_item_sel.setPen(pen, update=False, mask=None)
        self.scatterplot_item_sel.setBrush(brush, mask=None)
        self.update_z_values()

    def get_colors_sel(self):
        """
        Return pens and brushes for selection markers.

        A pen can is set to `Qt.NoPen` if a point is not selected.

        All brushes are completely transparent whites.

        Returns:
            (tuple): a list of pens and a list of brushes
        """
        nopen = QPen(Qt.NoPen)
        if self.selection is None:
            pen = [nopen] * self.n_shown
        else:
            sels = np.max(self.selection)
            if sels == 1:
                pen = np.where(
                    self._filter_visible(self.selection),
                    _make_pen(QColor(255, 190, 0, 255), SELECTION_WIDTH),
                    nopen)
            else:
                palette = colorpalettes.LimitedDiscretePalette(
                    number_of_colors=sels + 1)
                pen = np.choose(
                    self._filter_visible(self.selection),
                    [nopen] + [_make_pen(palette[i], SELECTION_WIDTH)
                               for i in range(sels)])
        return pen, [QBrush(QColor(255, 255, 255, 0))] * self.n_shown

    # Labels
    def get_labels(self):
        """
        Prepare data for labels for points

        The method returns the results of the widget's `get_label_data`

        Returns:
            (labels): a sequence of labels
        """
        return self._filter_visible(self.master.get_label_data())

    def update_labels(self):
        """
        Trigger an update of labels

        The method calls `get_labels` which in turn calls the widget's
        `get_label_data`. The obtained labels are shown if the corresponding
        points are selected or if `label_only_selected` is `false`.
        """
        for label in self.labels:
            self.plot_widget.removeItem(label)
        self.labels = []

        mask = None
        if self.scatterplot_item is not None:
            x, y = self.scatterplot_item.getData()
            mask = self._label_mask(x, y)

        if mask is not None:
            labels = self.get_labels()
            if labels is None:
                mask = None

        self._signal_too_many_labels(
            mask is not None and mask.sum() > self.MAX_VISIBLE_LABELS)
        if self._too_many_labels or mask is None or not np.any(mask):
            return

        foreground = self.plot_widget.palette().color(QPalette.Text)
        labels = labels[mask]
        x = x[mask]
        y = y[mask]
        for label, xp, yp in zip(labels, x, y):
            ti = TextItem(label, foreground)
            ti.setPos(xp, yp)
            self.plot_widget.addItem(ti)
            self.labels.append(ti)
            ti.setFont(self.parameter_setter.label_font)

    def _signal_too_many_labels(self, too_many):
        if self._too_many_labels != too_many:
            self._too_many_labels = too_many
            self.too_many_labels.emit(too_many)

    def _label_mask(self, x, y):
        (x0, x1), (y0, y1) = self.view_box.viewRange()
        mask = np.logical_and(
            np.logical_and(x >= x0, x <= x1),
            np.logical_and(y >= y0, y <= y1))
        if self.label_only_selected:
            sub_mask = self._filter_visible(self.master.get_subset_mask())
            if self.selection is None:
                if sub_mask is None:
                    return None
                else:
                    sel_mask = sub_mask
            else:
                sel_mask = self._filter_visible(self.selection) != 0
                if sub_mask is not None:
                    sel_mask = np.logical_or(sel_mask, sub_mask)
            mask = np.logical_and(mask, sel_mask)
        return mask

    # Shapes
    def get_shapes(self):
        """
        Prepare data for shapes of points in the plot

        The method is called by `update_shapes`. It gets the data from
        the widget's `get_shape_data`, and then calls its `impute_shapes`
        to impute the missing shape (usually with some default shape).

        Returns:
            (np.ndarray): an array of symbols (e.g. o, x, + ...)
        """
        shape_data = self.master.get_shape_data()
        shape_data = self._filter_visible(shape_data)
        # Data has to be copied so the imputation can change it in-place
        # TODO: Try avoiding this when we move imputation to the widget
        if shape_data is not None:
            shape_data = np.copy(shape_data)
        shape_imputer = getattr(
            self.master, "impute_shapes", self.default_impute_shapes)
        shape_imputer(shape_data, len(self.CurveSymbols) - 1)
        if isinstance(shape_data, np.ndarray):
            shape_data = shape_data.astype(int)
        else:
            shape_data = np.zeros(self.n_shown, dtype=int)
        return self.CurveSymbols[shape_data]

    @staticmethod
    def default_impute_shapes(shape_data, default_symbol):
        """
        Fallback imputation for shapes.

        Use the default symbol, usually the last symbol in the list.

        Returns:
            (bool): True if there was any missing data
        """
        if shape_data is None:
            return False
        nans = np.isnan(shape_data)
        if np.any(nans):
            shape_data[nans] = default_symbol
            return True
        else:
            return False

    def update_shapes(self):
        """
        Trigger an update of point symbols

        The method calls `get_shapes` to obtain an array with a symbol
        for each point and uses it to update the symbols.

        Finally, the method updates the legend.
        """
        if self.scatterplot_item:
            shape_data = self.get_shapes()
            self.scatterplot_item.setSymbol(shape_data)
        self.update_legends()

    def update_z_values(self):
        """
        Set z-values for point in the plot

        The order is as follows:
        - selected points that are also in the subset on top,
        - followed by selected points,
        - followed by points from the subset,
        - followed by the rest.
        Within each of these four groups, points are ordered by their colors.

        Points with less frequent colors are above those with more frequent.
        The points for which the value for the color is missing are at the
        bottom of their respective group.
        """
        if not self.scatterplot_item:
            return

        subset = self.master.get_subset_mask()
        c_data = self.master.get_color_data()
        if subset is None and self.selection is None and c_data is None:
            self.scatterplot_item.setZ(None)
            return

        z = np.zeros(self.n_shown)

        if subset is not None:
            subset = self._filter_visible(subset)
            z[subset] += 1000

        if self.selection is not None:
            z[self._filter_visible(self.selection) != 0] += 2000

        if c_data is not None:
            c_nan = np.isnan(c_data)
            vis_data = self._filter_visible(c_data)
            vis_nan = np.isnan(vis_data)
            z[vis_nan] -= 999
            if not self.master.is_continuous_color():
                dist = np.bincount(c_data[~c_nan].astype(int))
                vis_knowns = vis_data[~vis_nan].astype(int)
                argdist = np.argsort(dist)
                z[~vis_nan] -= argdist[vis_knowns]

        self.scatterplot_item.setZ(z)

    def update_grid_visibility(self):
        """Show or hide the grid"""
        self.plot_widget.showGrid(x=self.show_grid, y=self.show_grid)

    def update_legend_visibility(self):
        """
        Show or hide legends based on whether they are enabled and non-empty
        """
        self.shape_legend.setVisible(
            self.show_legend and bool(self.shape_legend.items))
        self.color_legend.setVisible(
            self.show_legend and bool(self.color_legend.items))

    def update_legends(self):
        """Update content of legends and their visibility"""
        cont_color = self.master.is_continuous_color()
        shape_labels = self.master.get_shape_labels()
        color_labels = self.master.get_color_labels()
        if not cont_color and shape_labels is not None \
                and shape_labels == color_labels:
            colors = self.master.get_color_data()
            shapes = self.master.get_shape_data()
            mask = np.isfinite(colors) * np.isfinite(shapes)
            combined = (colors == shapes)[mask].all()
        else:
            combined = False
        if combined:
            self._update_combined_legend(shape_labels)
        else:
            self._update_shape_legend(shape_labels)
            if cont_color:
                self._update_continuous_color_legend(color_labels)
            else:
                self._update_color_legend(color_labels)
        self.update_legend_visibility()
        Updater.update_legend_font(self.parameter_setter.cat_legend_items,
                                   **self.parameter_setter.cat_legend_settings)
        Updater.update_num_legend_font(self.parameter_setter.num_legend,
                                       **self.parameter_setter.num_legend_settings)

    def _update_shape_legend(self, labels):
        self.shape_legend.clear()
        if labels is None or self.scatterplot_item is None:
            return
        color = QColor(0, 0, 0)
        color.setAlpha(self.alpha_value)
        for label, symbol in zip(labels, self.CurveSymbols):
            self.shape_legend.addItem(
                SymbolItemSample(pen=color, brush=color, size=10, symbol=symbol),
                escape(label))

    def _update_continuous_color_legend(self, label_formatter: Callable[[float], str]):
        self.color_legend.clear()
        if self.scale is None or self.scatterplot_item is None:
            return
        label = PaletteItemSample(self.palette, self.scale, label_formatter)
        self.color_legend.addItem(label, "")
        self.color_legend.setGeometry(label.boundingRect())

    def _update_color_legend(self, labels):
        self.color_legend.clear()
        if labels is None:
            return
        self._update_colored_legend(self.color_legend, labels, 'o')

    def _update_combined_legend(self, labels):
        # update_colored_legend will already clear the shape legend
        # so we remove colors here
        use_legend = \
            self.shape_legend if self.shape_legend.items else self.color_legend
        self.color_legend.clear()
        self.shape_legend.clear()
        self._update_colored_legend(use_legend, labels, self.CurveSymbols)

    def _update_colored_legend(self, legend, labels, symbols):
        if self.scatterplot_item is None or not self.palette:
            return
        if isinstance(symbols, str):
            symbols = itertools.repeat(symbols, times=len(labels))
        colors = self.palette.values_to_colors(np.arange(len(labels)))
        for color, label, symbol in zip(colors, labels, symbols):
            color = QColor(*color)
            pen = _make_pen(color.darker(self.DarkerValue), 1.5)
            color.setAlpha(self.alpha_value)
            brush = QBrush(color)
            legend.addItem(
                SymbolItemSample(pen=pen, brush=brush, size=10, symbol=symbol),
                escape(label))

    def zoom_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().RectMode)

    def pan_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().PanMode)

    def select_button_clicked(self):
        self.plot_widget.getViewBox().setMouseMode(
            self.plot_widget.getViewBox().RectMode)

    def reset_button_clicked(self):
        self.plot_widget.getViewBox().autoRange()
        self.update_labels()

    def select_by_click(self, _, points):
        if self.scatterplot_item is not None:
            self.select(points)

    def select_by_rectangle(self, rect):
        if self.scatterplot_item is not None:
            x0, x1 = sorted((rect.topLeft().x(), rect.bottomRight().x()))
            y0, y1 = sorted((rect.topLeft().y(), rect.bottomRight().y()))
            x, y = self.master.get_coordinates_data()
            indices = np.flatnonzero(
                (x0 <= x) & (x <= x1) & (y0 <= y) & (y <= y1))
            self.select_by_indices(indices.astype(int))

    def unselect_all(self):
        if self.selection is not None:
            self.selection = None
            self.update_selection_colors()
            if self.label_only_selected:
                self.update_labels()
            self.master.selection_changed()

    def select(self, points):
        # noinspection PyArgumentList
        if self.scatterplot_item is None:
            return
        indices = [p.data() for p in points]
        self.select_by_indices(indices)

    def select_by_indices(self, indices):
        if self.selection is None:
            self.selection = np.zeros(self.n_valid, dtype=np.uint8)
        keys = QApplication.keyboardModifiers()
        if keys & Qt.ControlModifier:
            self.selection_append(indices)
        elif keys & Qt.ShiftModifier:
            self.selection_new_group(indices)
        elif keys & Qt.AltModifier:
            self.selection_remove(indices)
        else:
            self.selection_select(indices)

    def selection_select(self, indices):
        self.selection = np.zeros(self.n_valid, dtype=np.uint8)
        self.selection[indices] = 1
        self._update_after_selection()

    def selection_append(self, indices):
        self.selection[indices] = max(np.max(self.selection), 1)
        self._update_after_selection()

    def selection_new_group(self, indices):
        self.selection[indices] = np.max(self.selection) + 1
        self._update_after_selection()

    def selection_remove(self, indices):
        self.selection[indices] = 0
        self._update_after_selection()

    def _update_after_selection(self):
        self._compress_indices()
        self.update_selection_colors()
        if self.label_only_selected:
            self.update_labels()
        self.master.selection_changed()

    def _compress_indices(self):
        indices = sorted(set(self.selection) | {0})
        if len(indices) == max(indices) + 1:
            return
        mapping = np.zeros((max(indices) + 1,), dtype=int)
        for i, ind in enumerate(indices):
            mapping[ind] = i
        self.selection = mapping[self.selection]

    def get_selection(self):
        if self.selection is None:
            return np.array([], dtype=np.uint8)
        else:
            return np.flatnonzero(self.selection)

    def help_event(self, event):
        """
        Create a `QToolTip` for the point hovered by the mouse
        """
        if self.scatterplot_item is None:
            return False
        act_pos = self.scatterplot_item.mapFromScene(event.scenePos())
        point_data = [p.data() for p in self.scatterplot_item.pointsAt(act_pos)]
        text = self.master.get_tooltip(point_data)
        if text:
            QToolTip.showText(event.screenPos(), text, widget=self.plot_widget)
            return True
        else:
            return False

```
--- END FILE ---

Please first localize the bug based on the issue statement, and then generate *SEARCH/REPLACE* edits to fix the issue.

Every *SEARCH/REPLACE* edit must use this format:
1. The file path
2. The start of search block: <<<<<<< SEARCH
3. A contiguous chunk of lines to search for in the existing source code
4. The dividing line: =======
5. The lines to replace into the source code
6. The end of the replace block: >>>>>>> REPLACE

Here is an example:

```python
### mathweb/flask/app.py
<<<<<<< SEARCH
from flask import Flask
=======
import math
from flask import Flask
>>>>>>> REPLACE
```
</solution>

Please note that the *SEARCH/REPLACE* edit REQUIRES PROPER INDENTATION. If you would like to add the line '        print(x)', you must fully write that out, with all those spaces before the code!
Wrap each *SEARCH/REPLACE* edit in a code block as shown in the example above. If you have multiple *SEARCH/REPLACE* edits, use a separate code block for each one.
user