{
    "file_diffs": [
        {
            "old_file_content": "\"\"\"Widget for creating classes from non-numeric attribute by substrings\"\"\"\nimport re\nfrom itertools import count\n\nimport numpy as np\n\nfrom AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget\nfrom AnyQt.QtCore import QSize, Qt\n\nfrom Orange.data import StringVariable, DiscreteVariable, Domain\nfrom Orange.data.table import Table\nfrom Orange.statistics.util import bincount\nfrom Orange.preprocess.transformation import Transformation, Lookup\nfrom Orange.widgets import gui, widget\nfrom Orange.widgets.settings import DomainContextHandler, ContextSetting\nfrom Orange.widgets.utils.itemmodels import DomainModel\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef map_by_substring(a, patterns, case_sensitive, match_beginning,\n                     map_values=None):\n    \"\"\"\n    Map values in a using a list of patterns. The patterns are considered in\n    order of appearance.\n\n    Args:\n        a (np.array): input array of `dtype` `str`\n        patterns (list of str): list of strings\n        case_sensitive (bool): case sensitive match\n        match_beginning (bool): match only at the beginning of the string\n        map_values (list of int): list of len(pattens);\n                                  contains return values for each pattern\n\n    Returns:\n        np.array of floats representing indices of matched patterns\n    \"\"\"\n    if map_values is None:\n        map_values = np.arange(len(patterns))\n    else:\n        map_values = np.array(map_values, dtype=int)\n    res = np.full(len(a), np.nan)\n    if not case_sensitive:\n        a = np.char.lower(a)\n        patterns = (pattern.lower() for pattern in patterns)\n    for val_idx, pattern in reversed(list(enumerate(patterns))):\n        indices = np.char.find(a, pattern)\n        matches = indices == 0 if match_beginning else indices != -1\n        res[matches] = map_values[val_idx]\n    return res\n\n\nclass ValueFromStringSubstring(Transformation):\n    \"\"\"\n    Transformation that computes a discrete variable from a string variable by\n    pattern matching.\n\n    Given patterns `[\"abc\", \"a\", \"bc\", \"\"]`, string data\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]` is transformed to values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.StringVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False, map_values=None):\n        super().__init__(variable)\n        self.patterns = patterns\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n\n    def transform(self, c):\n        \"\"\"\n        Transform the given data.\n\n        Args:\n            c (np.array): an array of type that can be cast to dtype `str`\n\n        Returns:\n            np.array of floats representing indices of matched patterns\n        \"\"\"\n        nans = np.equal(c, None)\n        c = c.astype(str)\n        c[nans] = \"\"\n        res = map_by_substring(\n            c, self.patterns, self.case_sensitive, self.match_beginning,\n            self.map_values)\n        res[nans] = np.nan\n        return res\n\n    def __eq__(self, other):\n        return super().__eq__(other) \\\n               and self.patterns == other.patterns \\\n               and self.case_sensitive == other.case_sensitive \\\n               and self.match_beginning == other.match_beginning \\\n               and self.map_values == other.map_values\n\n    def __hash__(self):\n        return hash((type(self), self.variable,\n                     tuple(self.patterns),\n                     self.case_sensitive, self.match_beginning,\n                     self.map_values))\n\n\nclass ValueFromDiscreteSubstring(Lookup):\n    \"\"\"\n    Transformation that computes a discrete variable from discrete variable by\n    pattern matching.\n\n    Say that the original attribute has values\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]`. Given patterns\n    `[\"abc\", \"a\", \"bc\", \"\"]`, the values are mapped to the values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.DiscreteVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False,\n                 map_values=None):\n        super().__init__(variable, [])\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n        self.patterns = patterns  # Finally triggers computation of the lookup\n\n    def __setattr__(self, key, value):\n        \"\"\"__setattr__ is overloaded to recompute the lookup table when the\n        patterns, the original attribute or the flags change.\"\"\"\n        super().__setattr__(key, value)\n        if hasattr(self, \"patterns\") and \\\n                key in (\"case_sensitive\", \"match_beginning\", \"patterns\",\n                        \"variable\", \"map_values\"):\n            self.lookup_table = map_by_substring(\n                self.variable.values, self.patterns,\n                self.case_sensitive, self.match_beginning, self.map_values)\n\n\ndef unique_in_order_mapping(a):\n    \"\"\" Return\n    - unique elements of the input list (in the order of appearance)\n    - indices of the input list onto the returned uniques\n    \"\"\"\n    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)\n    unique_in_order = u[np.argsort(idx)]\n    mapping = np.argsort(idx)[inv]\n    return unique_in_order, mapping\n\n\nclass OWCreateClass(widget.OWWidget):\n    name = \"Create Class\"\n    description = \"Create class attribute from a string attribute\"\n    icon = \"icons/CreateClass.svg\"\n    category = \"Data\"\n    keywords = []\n\n    class Inputs:\n        data = Input(\"Data\", Table)\n\n    class Outputs:\n        data = Output(\"Data\", Table)\n\n    want_main_area = False\n    buttons_area_orientation = Qt.Vertical\n\n    settingsHandler = DomainContextHandler()\n    attribute = ContextSetting(None)\n    class_name = ContextSetting(\"class\")\n    rules = ContextSetting({})\n    match_beginning = ContextSetting(False)\n    case_sensitive = ContextSetting(False)\n\n    TRANSFORMERS = {StringVariable: ValueFromStringSubstring,\n                    DiscreteVariable: ValueFromDiscreteSubstring}\n\n    # Cached variables are used so that two instances of the widget with the\n    # same settings will create the same variable. The usual `make` wouldn't\n    # work here because variables with `compute_value` are not reused.\n    cached_variables = {}\n\n    class Warning(widget.OWWidget.Warning):\n        no_nonnumeric_vars = Msg(\"Data contains only numeric variables.\")\n\n    class Error(widget.OWWidget.Error):\n        class_name_duplicated = Msg(\"Class name duplicated.\")\n        class_name_empty = Msg(\"Class name should not be empty.\")\n\n    def __init__(self):\n        super().__init__()\n        self.data = None\n\n        # The following lists are of the same length as self.active_rules\n\n        #: list of pairs with counts of matches for each patter when the\n        #     patterns are applied in order and when applied on the entire set,\n        #     disregarding the preceding patterns\n        self.match_counts = []\n\n        #: list of list of QLineEdit: line edit pairs for each pattern\n        self.line_edits = []\n        #: list of QPushButton: list of remove buttons\n        self.remove_buttons = []\n        #: list of list of QLabel: pairs of labels with counts\n        self.counts = []\n\n        gui.lineEdit(\n            self.controlArea, self, \"class_name\",\n            orientation=Qt.Horizontal, box=\"New Class Name\")\n\n        variable_select_box = gui.vBox(self.controlArea, \"Match by Substring\")\n\n        combo = gui.comboBox(\n            variable_select_box, self, \"attribute\", label=\"From column:\",\n            orientation=Qt.Horizontal, searchable=True,\n            callback=self.update_rules,\n            model=DomainModel(valid_types=(StringVariable, DiscreteVariable)))\n        # Don't use setSizePolicy keyword argument here: it applies to box,\n        # not the combo\n        combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)\n\n        patternbox = gui.vBox(variable_select_box)\n        #: QWidget: the box that contains the remove buttons, line edits and\n        #    count labels. The lines are added and removed dynamically.\n        self.rules_box = rules_box = QGridLayout()\n        rules_box.setSpacing(4)\n        rules_box.setContentsMargins(4, 4, 4, 4)\n        self.rules_box.setColumnMinimumWidth(1, 70)\n        self.rules_box.setColumnMinimumWidth(0, 10)\n        self.rules_box.setColumnStretch(0, 1)\n        self.rules_box.setColumnStretch(1, 1)\n        self.rules_box.setColumnStretch(2, 100)\n        rules_box.addWidget(QLabel(\"Name\"), 0, 1)\n        rules_box.addWidget(QLabel(\"Substring\"), 0, 2)\n        rules_box.addWidget(QLabel(\"Count\"), 0, 3, 1, 2)\n        self.update_rules()\n\n        widget = QWidget(patternbox)\n        widget.setLayout(rules_box)\n        patternbox.layout().addWidget(widget)\n\n        box = gui.hBox(patternbox)\n        gui.rubber(box)\n        gui.button(box, self, \"+\", callback=self.add_row,\n                   autoDefault=False, width=34,\n                   sizePolicy=(QSizePolicy.Maximum,\n                               QSizePolicy.Maximum))\n\n        optionsbox = gui.vBox(self.controlArea, \"Options\")\n        gui.checkBox(\n            optionsbox, self, \"match_beginning\", \"Match only at the beginning\",\n            callback=self.options_changed)\n        gui.checkBox(\n            optionsbox, self, \"case_sensitive\", \"Case sensitive\",\n            callback=self.options_changed)\n\n        gui.rubber(self.controlArea)\n\n        gui.button(self.buttonsArea, self, \"Apply\", callback=self.apply)\n\n        # TODO: Resizing upon changing the number of rules does not work\n        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)\n\n    @property\n    def active_rules(self):\n        \"\"\"\n        Returns the class names and patterns corresponding to the currently\n            selected attribute. If the attribute is not yet in the dictionary,\n            set the default.\n        \"\"\"\n        return self.rules.setdefault(self.attribute and self.attribute.name,\n                                     [[\"\", \"\"], [\"\", \"\"]])\n\n    def rules_to_edits(self):\n        \"\"\"Fill the line edites with the rules from the current settings.\"\"\"\n        for editr, textr in zip(self.line_edits, self.active_rules):\n            for edit, text in zip(editr, textr):\n                edit.setText(text)\n\n    @Inputs.data\n    def set_data(self, data):\n        \"\"\"Input data signal handler.\"\"\"\n        self.closeContext()\n        self.rules = {}\n        self.data = data\n        model = self.controls.attribute.model()\n        model.set_domain(data.domain if data is not None else None)\n        self.Warning.no_nonnumeric_vars(shown=data is not None and not model)\n        if not model:\n            self.attribute = None\n            self.Outputs.data.send(None)\n            return\n        self.attribute = model[0]\n        self.openContext(data)\n        self.update_rules()\n        self.apply()\n\n    def update_rules(self):\n        \"\"\"Called when the rules are changed: adjust the number of lines in\n        the form and fill them, update the counts. The widget does not have\n        auto-apply.\"\"\"\n        self.adjust_n_rule_rows()\n        self.rules_to_edits()\n        self.update_counts()\n        # TODO: Indicator that changes need to be applied\n\n    def options_changed(self):\n        self.update_counts()\n\n    def adjust_n_rule_rows(self):\n        \"\"\"Add or remove lines if needed and fix the tab order.\"\"\"\n        def _add_line():\n            self.line_edits.append([])\n            n_lines = len(self.line_edits)\n            for coli in range(1, 3):\n                edit = QLineEdit()\n                self.line_edits[-1].append(edit)\n                self.rules_box.addWidget(edit, n_lines, coli)\n                edit.textChanged.connect(self.sync_edit)\n            button = gui.button(\n                None, self, label='×', width=33,\n                autoDefault=False, callback=self.remove_row,\n                sizePolicy=(QSizePolicy.Maximum,\n                            QSizePolicy.Maximum)\n            )\n            self.remove_buttons.append(button)\n            self.rules_box.addWidget(button, n_lines, 0)\n            self.counts.append([])\n            for coli, kwargs in enumerate(\n                    (dict(),\n                     dict(styleSheet=\"color: gray\"))):\n                label = QLabel(alignment=Qt.AlignCenter, **kwargs)\n                self.counts[-1].append(label)\n                self.rules_box.addWidget(label, n_lines, 3 + coli)\n\n        def _remove_line():\n            for edit in self.line_edits.pop():\n                edit.deleteLater()\n            self.remove_buttons.pop().deleteLater()\n            for label in self.counts.pop():\n                label.deleteLater()\n\n        def _fix_tab_order():\n            prev = None\n            for row, rule in zip(self.line_edits, self.active_rules):\n                for col_idx, edit in enumerate(row):\n                    edit.row, edit.col_idx = rule, col_idx\n                    if prev is not None:\n                        self.setTabOrder(prev, edit)\n                    prev = edit\n\n        n = len(self.active_rules)\n        while n > len(self.line_edits):\n            _add_line()\n        while len(self.line_edits) > n:\n            _remove_line()\n        _fix_tab_order()\n\n    def add_row(self):\n        \"\"\"Append a new row at the end.\"\"\"\n        self.active_rules.append([\"\", \"\"])\n        self.adjust_n_rule_rows()\n        self.update_counts()\n\n    def remove_row(self):\n        \"\"\"Remove a row.\"\"\"\n        remove_idx = self.remove_buttons.index(self.sender())\n        del self.active_rules[remove_idx]\n        self.update_rules()\n        self.update_counts()\n\n    def sync_edit(self, text):\n        \"\"\"Handle changes in line edits: update the active rules and counts\"\"\"\n        edit = self.sender()\n        edit.row[edit.col_idx] = text\n        self.update_counts()\n\n    def class_labels(self):\n        \"\"\"Construct a list of class labels. Empty labels are replaced with\n        C1, C2, C3. If C<n> already appears in the list of values given by\n        the user, the labels start at C<n+1> instead.\n        \"\"\"\n        largest_c = max((int(label[1:]) for label, _ in self.active_rules\n                         if re.match(\"^C\\\\d+\", label)),\n                        default=0)\n        class_count = count(largest_c + 1)\n        return [label_edit.text() or \"C{}\".format(next(class_count))\n                for label_edit, _ in self.line_edits]\n\n    def update_counts(self):\n        \"\"\"Recompute and update the counts of matches.\"\"\"\n        def _matcher(strings, pattern):\n            \"\"\"Return indices of strings into patterns; consider case\n            sensitivity and matching at the beginning. The given strings are\n            assumed to be in lower case if match is case insensitive. Patterns\n            are fixed on the fly.\"\"\"\n            if not self.case_sensitive:\n                pattern = pattern.lower()\n            indices = np.char.find(strings, pattern.strip())\n            return indices == 0 if self.match_beginning else indices != -1\n\n        def _lower_if_needed(strings):\n            return strings if self.case_sensitive else np.char.lower(strings)\n\n        def _string_counts():\n            \"\"\"\n            Generate pairs of arrays for each rule until running out of data\n            instances. np.sum over the two arrays in each pair gives the\n            number of matches of the remaining instances (considering the\n            order of patterns) and of the original data.\n\n            For _string_counts, the arrays contain bool masks referring to the\n            original data\n            \"\"\"\n            nonlocal data\n            data = data.astype(str)\n            data = data[~np.char.equal(data, \"\")]\n            data = _lower_if_needed(data)\n            remaining = np.array(data)\n            for _, pattern in self.active_rules:\n                matching = _matcher(remaining, pattern)\n                total_matching = _matcher(data, pattern)\n                yield matching, total_matching\n                remaining = remaining[~matching]\n                if not remaining.size:\n                    break\n\n        def _discrete_counts():\n            \"\"\"\n            Generate pairs similar to _string_counts, except that the arrays\n            contain bin counts for the attribute's values matching the pattern.\n            \"\"\"\n            attr_vals = np.array(attr.values)\n            attr_vals = _lower_if_needed(attr_vals)\n            bins = bincount(data, max_val=len(attr.values) - 1)[0]\n            remaining = np.array(bins)\n            for _, pattern in self.active_rules:\n                matching = _matcher(attr_vals, pattern)\n                yield remaining[matching], bins[matching]\n                remaining[matching] = 0\n                if not np.any(remaining):\n                    break\n\n        def _clear_labels():\n            \"\"\"Clear all labels\"\"\"\n            for lab_matched, lab_total in self.counts:\n                lab_matched.setText(\"\")\n                lab_total.setText(\"\")\n\n        def _set_labels():\n            \"\"\"Set the labels to show the counts\"\"\"\n            for (n_matched, n_total), (lab_matched, lab_total), (lab, patt) in \\\n                    zip(self.match_counts, self.counts, self.active_rules):\n                n_before = n_total - n_matched\n                lab_matched.setText(\"{}\".format(n_matched))\n                if n_before and (lab or patt):\n                    lab_total.setText(\"+ {}\".format(n_before))\n                    if n_matched:\n                        tip = \"{} of the {} matching instances are already \" \\\n                              \"covered above\".format(n_before, n_total)\n                    else:\n                        tip = \"All matching instances are already covered above\"\n                    lab_total.setToolTip(tip)\n                    lab_matched.setToolTip(tip)\n\n        def _set_placeholders():\n            \"\"\"Set placeholders for empty edit lines\"\"\"\n            matches = [n for n, _ in self.match_counts] + \\\n                      [0] * len(self.line_edits)\n            for n_matched, (_, patt) in zip(matches, self.line_edits):\n                if not patt.text():\n                    patt.setPlaceholderText(\n                        \"(remaining instances)\" if n_matched else \"(unused)\")\n\n            labels = self.class_labels()\n            for label, (lab_edit, _) in zip(labels, self.line_edits):\n                if not lab_edit.text():\n                    lab_edit.setPlaceholderText(label)\n\n        _clear_labels()\n        attr = self.attribute\n        if attr is None:\n            return\n        counters = {StringVariable: _string_counts,\n                    DiscreteVariable: _discrete_counts}\n        data = self.data.get_column_view(attr)[0]\n        self.match_counts = [[int(np.sum(x)) for x in matches]\n                             for matches in counters[type(attr)]()]\n        _set_labels()\n        _set_placeholders()\n\n    def apply(self):\n        \"\"\"Output the transformed data.\"\"\"\n        self.Error.clear()\n        self.class_name = self.class_name.strip()\n        if not self.attribute:\n            self.Outputs.data.send(None)\n            return\n        domain = self.data.domain\n        if not self.class_name:\n            self.Error.class_name_empty()\n        if self.class_name in domain:\n            self.Error.class_name_duplicated()\n        if not self.class_name or self.class_name in domain:\n            self.Outputs.data.send(None)\n            return\n        new_class = self._create_variable()\n        new_domain = Domain(\n            domain.attributes, new_class, domain.metas + domain.class_vars)\n        new_data = self.data.transform(new_domain)\n        self.Outputs.data.send(new_data)\n\n    def _create_variable(self):\n        rules = self.active_rules\n        # Transposition + stripping\n        valid_rules = [label or pattern or n_matches\n                       for (label, pattern), n_matches in\n                       zip(rules, self.match_counts)]\n        patterns = tuple(\n            pattern for (_, pattern), valid in zip(rules, valid_rules) if valid)\n        names = tuple(\n            name for name, valid in zip(self.class_labels(), valid_rules)\n            if valid)\n        transformer = self.TRANSFORMERS[type(self.attribute)]\n\n        # join patters with the same names\n        names, map_values = unique_in_order_mapping(names)\n        names = tuple(str(a) for a in names)\n        map_values = tuple(map_values)\n\n        var_key = (self.attribute, self.class_name, names,\n                   patterns, self.case_sensitive, self.match_beginning, map_values)\n        if var_key in self.cached_variables:\n            return self.cached_variables[var_key]\n\n        compute_value = transformer(\n            self.attribute, patterns, self.case_sensitive, self.match_beginning,\n            map_values)\n        new_var = DiscreteVariable(\n            self.class_name, names, compute_value=compute_value)\n        self.cached_variables[var_key] = new_var\n        return new_var\n\n    def send_report(self):\n        # Pylint gives false positives: these functions are always called from\n        # within the loop\n        # pylint: disable=undefined-loop-variable\n        def _cond_part():\n            rule = \"<b>{}</b> \".format(class_name)\n            if patt:\n                rule += \"if <b>{}</b> contains <b>{}</b>\".format(\n                    self.attribute.name, patt)\n            else:\n                rule += \"otherwise\"\n            return rule\n\n        def _count_part():\n            if not n_matched:\n                return \"all {} matching instances are already covered \" \\\n                       \"above\".format(n_total)\n            elif n_matched < n_total and patt:\n                return \"{} matching instances (+ {} that are already \" \\\n                       \"covered above\".format(n_matched, n_total - n_matched)\n            else:\n                return \"{} matching instances\".format(n_matched)\n\n        if not self.attribute:\n            return\n        self.report_items(\"Input\", [(\"Source attribute\", self.attribute.name)])\n        output = \"\"\n        names = self.class_labels()\n        for (n_matched, n_total), class_name, (lab, patt) in \\\n                zip(self.match_counts, names, self.active_rules):\n            if lab or patt or n_total:\n                output += \"<li>{}; {}</li>\".format(_cond_part(), _count_part())\n        if output:\n            self.report_items(\"Output\", [(\"Class name\", self.class_name)])\n            self.report_raw(\"<ol>{}</ol>\".format(output))\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWCreateClass).run(Table(\"zoo\"))\n",
            "new_file_content": "\"\"\"Widget for creating classes from non-numeric attribute by substrings\"\"\"\nimport re\nfrom itertools import count\n\nimport numpy as np\n\nfrom AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget\nfrom AnyQt.QtCore import QSize, Qt\n\nfrom Orange.data import StringVariable, DiscreteVariable, Domain\nfrom Orange.data.table import Table\nfrom Orange.statistics.util import bincount\nfrom Orange.preprocess.transformation import Transformation, Lookup\nfrom Orange.widgets import gui, widget\nfrom Orange.widgets.settings import DomainContextHandler, ContextSetting\nfrom Orange.widgets.utils.itemmodels import DomainModel\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef map_by_substring(a, patterns, case_sensitive, match_beginning,\n                     map_values=None):\n    \"\"\"\n    Map values in a using a list of patterns. The patterns are considered in\n    order of appearance.\n\n    Args:\n        a (np.array): input array of `dtype` `str`\n        patterns (list of str): list of strings\n        case_sensitive (bool): case sensitive match\n        match_beginning (bool): match only at the beginning of the string\n        map_values (list of int): list of len(pattens);\n                                  contains return values for each pattern\n\n    Returns:\n        np.array of floats representing indices of matched patterns\n    \"\"\"\n    if map_values is None:\n        map_values = np.arange(len(patterns))\n    else:\n        map_values = np.array(map_values, dtype=int)\n    res = np.full(len(a), np.nan)\n    if not case_sensitive:\n        a = np.char.lower(a)\n        patterns = (pattern.lower() for pattern in patterns)\n    for val_idx, pattern in reversed(list(enumerate(patterns))):\n        indices = np.char.find(a, pattern)\n        matches = indices == 0 if match_beginning else indices != -1\n        res[matches] = map_values[val_idx]\n    return res\n\n\nclass ValueFromStringSubstring(Transformation):\n    \"\"\"\n    Transformation that computes a discrete variable from a string variable by\n    pattern matching.\n\n    Given patterns `[\"abc\", \"a\", \"bc\", \"\"]`, string data\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]` is transformed to values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.StringVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False, map_values=None):\n        super().__init__(variable)\n        self.patterns = patterns\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n\n    def transform(self, c):\n        \"\"\"\n        Transform the given data.\n\n        Args:\n            c (np.array): an array of type that can be cast to dtype `str`\n\n        Returns:\n            np.array of floats representing indices of matched patterns\n        \"\"\"\n        nans = np.equal(c, None)\n        c = c.astype(str)\n        c[nans] = \"\"\n        res = map_by_substring(\n            c, self.patterns, self.case_sensitive, self.match_beginning,\n            self.map_values)\n        res[nans] = np.nan\n        return res\n\n    def __eq__(self, other):\n        return super().__eq__(other) \\\n               and self.patterns == other.patterns \\\n               and self.case_sensitive == other.case_sensitive \\\n               and self.match_beginning == other.match_beginning \\\n               and self.map_values == other.map_values\n\n    def __hash__(self):\n        return hash((type(self), self.variable,\n                     tuple(self.patterns),\n                     self.case_sensitive, self.match_beginning,\n                     self.map_values))\n\n\nclass ValueFromDiscreteSubstring(Lookup):\n    \"\"\"\n    Transformation that computes a discrete variable from discrete variable by\n    pattern matching.\n\n    Say that the original attribute has values\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]`. Given patterns\n    `[\"abc\", \"a\", \"bc\", \"\"]`, the values are mapped to the values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.DiscreteVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False,\n                 map_values=None):\n        super().__init__(variable, [])\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n        self.patterns = patterns  # Finally triggers computation of the lookup\n\n    def __setattr__(self, key, value):\n        \"\"\"__setattr__ is overloaded to recompute the lookup table when the\n        patterns, the original attribute or the flags change.\"\"\"\n        super().__setattr__(key, value)\n        if hasattr(self, \"patterns\") and \\\n                key in (\"case_sensitive\", \"match_beginning\", \"patterns\",\n                        \"variable\", \"map_values\"):\n            self.lookup_table = map_by_substring(\n                self.variable.values, self.patterns,\n                self.case_sensitive, self.match_beginning, self.map_values)\n\n\ndef unique_in_order_mapping(a):\n    \"\"\" Return\n    - unique elements of the input list (in the order of appearance)\n    - indices of the input list onto the returned uniques\n    \"\"\"\n    first_position = {}\n    unique_in_order = []\n    mapping = []\n    for e in a:\n        if e not in first_position:\n            first_position[e] = len(unique_in_order)\n            unique_in_order.append(e)\n        mapping.append(first_position[e])\n    return unique_in_order, mapping\n\n\nclass OWCreateClass(widget.OWWidget):\n    name = \"Create Class\"\n    description = \"Create class attribute from a string attribute\"\n    icon = \"icons/CreateClass.svg\"\n    category = \"Data\"\n    keywords = []\n\n    class Inputs:\n        data = Input(\"Data\", Table)\n\n    class Outputs:\n        data = Output(\"Data\", Table)\n\n    want_main_area = False\n    buttons_area_orientation = Qt.Vertical\n\n    settingsHandler = DomainContextHandler()\n    attribute = ContextSetting(None)\n    class_name = ContextSetting(\"class\")\n    rules = ContextSetting({})\n    match_beginning = ContextSetting(False)\n    case_sensitive = ContextSetting(False)\n\n    TRANSFORMERS = {StringVariable: ValueFromStringSubstring,\n                    DiscreteVariable: ValueFromDiscreteSubstring}\n\n    # Cached variables are used so that two instances of the widget with the\n    # same settings will create the same variable. The usual `make` wouldn't\n    # work here because variables with `compute_value` are not reused.\n    cached_variables = {}\n\n    class Warning(widget.OWWidget.Warning):\n        no_nonnumeric_vars = Msg(\"Data contains only numeric variables.\")\n\n    class Error(widget.OWWidget.Error):\n        class_name_duplicated = Msg(\"Class name duplicated.\")\n        class_name_empty = Msg(\"Class name should not be empty.\")\n\n    def __init__(self):\n        super().__init__()\n        self.data = None\n\n        # The following lists are of the same length as self.active_rules\n\n        #: list of pairs with counts of matches for each patter when the\n        #     patterns are applied in order and when applied on the entire set,\n        #     disregarding the preceding patterns\n        self.match_counts = []\n\n        #: list of list of QLineEdit: line edit pairs for each pattern\n        self.line_edits = []\n        #: list of QPushButton: list of remove buttons\n        self.remove_buttons = []\n        #: list of list of QLabel: pairs of labels with counts\n        self.counts = []\n\n        gui.lineEdit(\n            self.controlArea, self, \"class_name\",\n            orientation=Qt.Horizontal, box=\"New Class Name\")\n\n        variable_select_box = gui.vBox(self.controlArea, \"Match by Substring\")\n\n        combo = gui.comboBox(\n            variable_select_box, self, \"attribute\", label=\"From column:\",\n            orientation=Qt.Horizontal, searchable=True,\n            callback=self.update_rules,\n            model=DomainModel(valid_types=(StringVariable, DiscreteVariable)))\n        # Don't use setSizePolicy keyword argument here: it applies to box,\n        # not the combo\n        combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)\n\n        patternbox = gui.vBox(variable_select_box)\n        #: QWidget: the box that contains the remove buttons, line edits and\n        #    count labels. The lines are added and removed dynamically.\n        self.rules_box = rules_box = QGridLayout()\n        rules_box.setSpacing(4)\n        rules_box.setContentsMargins(4, 4, 4, 4)\n        self.rules_box.setColumnMinimumWidth(1, 70)\n        self.rules_box.setColumnMinimumWidth(0, 10)\n        self.rules_box.setColumnStretch(0, 1)\n        self.rules_box.setColumnStretch(1, 1)\n        self.rules_box.setColumnStretch(2, 100)\n        rules_box.addWidget(QLabel(\"Name\"), 0, 1)\n        rules_box.addWidget(QLabel(\"Substring\"), 0, 2)\n        rules_box.addWidget(QLabel(\"Count\"), 0, 3, 1, 2)\n        self.update_rules()\n\n        widget = QWidget(patternbox)\n        widget.setLayout(rules_box)\n        patternbox.layout().addWidget(widget)\n\n        box = gui.hBox(patternbox)\n        gui.rubber(box)\n        gui.button(box, self, \"+\", callback=self.add_row,\n                   autoDefault=False, width=34,\n                   sizePolicy=(QSizePolicy.Maximum,\n                               QSizePolicy.Maximum))\n\n        optionsbox = gui.vBox(self.controlArea, \"Options\")\n        gui.checkBox(\n            optionsbox, self, \"match_beginning\", \"Match only at the beginning\",\n            callback=self.options_changed)\n        gui.checkBox(\n            optionsbox, self, \"case_sensitive\", \"Case sensitive\",\n            callback=self.options_changed)\n\n        gui.rubber(self.controlArea)\n\n        gui.button(self.buttonsArea, self, \"Apply\", callback=self.apply)\n\n        # TODO: Resizing upon changing the number of rules does not work\n        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)\n\n    @property\n    def active_rules(self):\n        \"\"\"\n        Returns the class names and patterns corresponding to the currently\n            selected attribute. If the attribute is not yet in the dictionary,\n            set the default.\n        \"\"\"\n        return self.rules.setdefault(self.attribute and self.attribute.name,\n                                     [[\"\", \"\"], [\"\", \"\"]])\n\n    def rules_to_edits(self):\n        \"\"\"Fill the line edites with the rules from the current settings.\"\"\"\n        for editr, textr in zip(self.line_edits, self.active_rules):\n            for edit, text in zip(editr, textr):\n                edit.setText(text)\n\n    @Inputs.data\n    def set_data(self, data):\n        \"\"\"Input data signal handler.\"\"\"\n        self.closeContext()\n        self.rules = {}\n        self.data = data\n        model = self.controls.attribute.model()\n        model.set_domain(data.domain if data is not None else None)\n        self.Warning.no_nonnumeric_vars(shown=data is not None and not model)\n        if not model:\n            self.attribute = None\n            self.Outputs.data.send(None)\n            return\n        self.attribute = model[0]\n        self.openContext(data)\n        self.update_rules()\n        self.apply()\n\n    def update_rules(self):\n        \"\"\"Called when the rules are changed: adjust the number of lines in\n        the form and fill them, update the counts. The widget does not have\n        auto-apply.\"\"\"\n        self.adjust_n_rule_rows()\n        self.rules_to_edits()\n        self.update_counts()\n        # TODO: Indicator that changes need to be applied\n\n    def options_changed(self):\n        self.update_counts()\n\n    def adjust_n_rule_rows(self):\n        \"\"\"Add or remove lines if needed and fix the tab order.\"\"\"\n        def _add_line():\n            self.line_edits.append([])\n            n_lines = len(self.line_edits)\n            for coli in range(1, 3):\n                edit = QLineEdit()\n                self.line_edits[-1].append(edit)\n                self.rules_box.addWidget(edit, n_lines, coli)\n                edit.textChanged.connect(self.sync_edit)\n            button = gui.button(\n                None, self, label='×', width=33,\n                autoDefault=False, callback=self.remove_row,\n                sizePolicy=(QSizePolicy.Maximum,\n                            QSizePolicy.Maximum)\n            )\n            self.remove_buttons.append(button)\n            self.rules_box.addWidget(button, n_lines, 0)\n            self.counts.append([])\n            for coli, kwargs in enumerate(\n                    (dict(),\n                     dict(styleSheet=\"color: gray\"))):\n                label = QLabel(alignment=Qt.AlignCenter, **kwargs)\n                self.counts[-1].append(label)\n                self.rules_box.addWidget(label, n_lines, 3 + coli)\n\n        def _remove_line():\n            for edit in self.line_edits.pop():\n                edit.deleteLater()\n            self.remove_buttons.pop().deleteLater()\n            for label in self.counts.pop():\n                label.deleteLater()\n\n        def _fix_tab_order():\n            prev = None\n            for row, rule in zip(self.line_edits, self.active_rules):\n                for col_idx, edit in enumerate(row):\n                    edit.row, edit.col_idx = rule, col_idx\n                    if prev is not None:\n                        self.setTabOrder(prev, edit)\n                    prev = edit\n\n        n = len(self.active_rules)\n        while n > len(self.line_edits):\n            _add_line()\n        while len(self.line_edits) > n:\n            _remove_line()\n        _fix_tab_order()\n\n    def add_row(self):\n        \"\"\"Append a new row at the end.\"\"\"\n        self.active_rules.append([\"\", \"\"])\n        self.adjust_n_rule_rows()\n        self.update_counts()\n\n    def remove_row(self):\n        \"\"\"Remove a row.\"\"\"\n        remove_idx = self.remove_buttons.index(self.sender())\n        del self.active_rules[remove_idx]\n        self.update_rules()\n        self.update_counts()\n\n    def sync_edit(self, text):\n        \"\"\"Handle changes in line edits: update the active rules and counts\"\"\"\n        edit = self.sender()\n        edit.row[edit.col_idx] = text\n        self.update_counts()\n\n    def class_labels(self):\n        \"\"\"Construct a list of class labels. Empty labels are replaced with\n        C1, C2, C3. If C<n> already appears in the list of values given by\n        the user, the labels start at C<n+1> instead.\n        \"\"\"\n        largest_c = max((int(label[1:]) for label, _ in self.active_rules\n                         if re.match(\"^C\\\\d+\", label)),\n                        default=0)\n        class_count = count(largest_c + 1)\n        return [label_edit.text() or \"C{}\".format(next(class_count))\n                for label_edit, _ in self.line_edits]\n\n    def update_counts(self):\n        \"\"\"Recompute and update the counts of matches.\"\"\"\n        def _matcher(strings, pattern):\n            \"\"\"Return indices of strings into patterns; consider case\n            sensitivity and matching at the beginning. The given strings are\n            assumed to be in lower case if match is case insensitive. Patterns\n            are fixed on the fly.\"\"\"\n            if not self.case_sensitive:\n                pattern = pattern.lower()\n            indices = np.char.find(strings, pattern.strip())\n            return indices == 0 if self.match_beginning else indices != -1\n\n        def _lower_if_needed(strings):\n            return strings if self.case_sensitive else np.char.lower(strings)\n\n        def _string_counts():\n            \"\"\"\n            Generate pairs of arrays for each rule until running out of data\n            instances. np.sum over the two arrays in each pair gives the\n            number of matches of the remaining instances (considering the\n            order of patterns) and of the original data.\n\n            For _string_counts, the arrays contain bool masks referring to the\n            original data\n            \"\"\"\n            nonlocal data\n            data = data.astype(str)\n            data = data[~np.char.equal(data, \"\")]\n            data = _lower_if_needed(data)\n            remaining = np.array(data)\n            for _, pattern in self.active_rules:\n                matching = _matcher(remaining, pattern)\n                total_matching = _matcher(data, pattern)\n                yield matching, total_matching\n                remaining = remaining[~matching]\n                if not remaining.size:\n                    break\n\n        def _discrete_counts():\n            \"\"\"\n            Generate pairs similar to _string_counts, except that the arrays\n            contain bin counts for the attribute's values matching the pattern.\n            \"\"\"\n            attr_vals = np.array(attr.values)\n            attr_vals = _lower_if_needed(attr_vals)\n            bins = bincount(data, max_val=len(attr.values) - 1)[0]\n            remaining = np.array(bins)\n            for _, pattern in self.active_rules:\n                matching = _matcher(attr_vals, pattern)\n                yield remaining[matching], bins[matching]\n                remaining[matching] = 0\n                if not np.any(remaining):\n                    break\n\n        def _clear_labels():\n            \"\"\"Clear all labels\"\"\"\n            for lab_matched, lab_total in self.counts:\n                lab_matched.setText(\"\")\n                lab_total.setText(\"\")\n\n        def _set_labels():\n            \"\"\"Set the labels to show the counts\"\"\"\n            for (n_matched, n_total), (lab_matched, lab_total), (lab, patt) in \\\n                    zip(self.match_counts, self.counts, self.active_rules):\n                n_before = n_total - n_matched\n                lab_matched.setText(\"{}\".format(n_matched))\n                if n_before and (lab or patt):\n                    lab_total.setText(\"+ {}\".format(n_before))\n                    if n_matched:\n                        tip = \"{} of the {} matching instances are already \" \\\n                              \"covered above\".format(n_before, n_total)\n                    else:\n                        tip = \"All matching instances are already covered above\"\n                    lab_total.setToolTip(tip)\n                    lab_matched.setToolTip(tip)\n\n        def _set_placeholders():\n            \"\"\"Set placeholders for empty edit lines\"\"\"\n            matches = [n for n, _ in self.match_counts] + \\\n                      [0] * len(self.line_edits)\n            for n_matched, (_, patt) in zip(matches, self.line_edits):\n                if not patt.text():\n                    patt.setPlaceholderText(\n                        \"(remaining instances)\" if n_matched else \"(unused)\")\n\n            labels = self.class_labels()\n            for label, (lab_edit, _) in zip(labels, self.line_edits):\n                if not lab_edit.text():\n                    lab_edit.setPlaceholderText(label)\n\n        _clear_labels()\n        attr = self.attribute\n        if attr is None:\n            return\n        counters = {StringVariable: _string_counts,\n                    DiscreteVariable: _discrete_counts}\n        data = self.data.get_column_view(attr)[0]\n        self.match_counts = [[int(np.sum(x)) for x in matches]\n                             for matches in counters[type(attr)]()]\n        _set_labels()\n        _set_placeholders()\n\n    def apply(self):\n        \"\"\"Output the transformed data.\"\"\"\n        self.Error.clear()\n        self.class_name = self.class_name.strip()\n        if not self.attribute:\n            self.Outputs.data.send(None)\n            return\n        domain = self.data.domain\n        if not self.class_name:\n            self.Error.class_name_empty()\n        if self.class_name in domain:\n            self.Error.class_name_duplicated()\n        if not self.class_name or self.class_name in domain:\n            self.Outputs.data.send(None)\n            return\n        new_class = self._create_variable()\n        new_domain = Domain(\n            domain.attributes, new_class, domain.metas + domain.class_vars)\n        new_data = self.data.transform(new_domain)\n        self.Outputs.data.send(new_data)\n\n    def _create_variable(self):\n        rules = self.active_rules\n        # Transposition + stripping\n        valid_rules = [label or pattern or n_matches\n                       for (label, pattern), n_matches in\n                       zip(rules, self.match_counts)]\n        patterns = tuple(\n            pattern for (_, pattern), valid in zip(rules, valid_rules) if valid)\n        names = tuple(\n            name for name, valid in zip(self.class_labels(), valid_rules)\n            if valid)\n        transformer = self.TRANSFORMERS[type(self.attribute)]\n\n        # join patters with the same names\n        names, map_values = unique_in_order_mapping(names)\n        names = tuple(str(a) for a in names)\n        map_values = tuple(map_values)\n\n        var_key = (self.attribute, self.class_name, names,\n                   patterns, self.case_sensitive, self.match_beginning, map_values)\n        if var_key in self.cached_variables:\n            return self.cached_variables[var_key]\n\n        compute_value = transformer(\n            self.attribute, patterns, self.case_sensitive, self.match_beginning,\n            map_values)\n        new_var = DiscreteVariable(\n            self.class_name, names, compute_value=compute_value)\n        self.cached_variables[var_key] = new_var\n        return new_var\n\n    def send_report(self):\n        # Pylint gives false positives: these functions are always called from\n        # within the loop\n        # pylint: disable=undefined-loop-variable\n        def _cond_part():\n            rule = \"<b>{}</b> \".format(class_name)\n            if patt:\n                rule += \"if <b>{}</b> contains <b>{}</b>\".format(\n                    self.attribute.name, patt)\n            else:\n                rule += \"otherwise\"\n            return rule\n\n        def _count_part():\n            if not n_matched:\n                return \"all {} matching instances are already covered \" \\\n                       \"above\".format(n_total)\n            elif n_matched < n_total and patt:\n                return \"{} matching instances (+ {} that are already \" \\\n                       \"covered above\".format(n_matched, n_total - n_matched)\n            else:\n                return \"{} matching instances\".format(n_matched)\n\n        if not self.attribute:\n            return\n        self.report_items(\"Input\", [(\"Source attribute\", self.attribute.name)])\n        output = \"\"\n        names = self.class_labels()\n        for (n_matched, n_total), class_name, (lab, patt) in \\\n                zip(self.match_counts, names, self.active_rules):\n            if lab or patt or n_total:\n                output += \"<li>{}; {}</li>\".format(_cond_part(), _count_part())\n        if output:\n            self.report_items(\"Output\", [(\"Class name\", self.class_name)])\n            self.report_raw(\"<ol>{}</ol>\".format(output))\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWCreateClass).run(Table(\"zoo\"))\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/data/owcreateclass.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "bbf200967",
                "new_commit_hash": "d05579c16",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/data/owcreateclass.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/data/owcreateclass.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 152,
                            "length": 9
                        },
                        "new_range": {
                            "start": 152,
                            "length": 14
                        },
                        "section": "def unique_in_order_mapping(a):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    - unique elements of the input list (in the order of appearance)",
                                "type": "context"
                            },
                            {
                                "content": "    - indices of the input list onto the returned uniques",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"",
                                "type": "context"
                            },
                            {
                                "content": "    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)",
                                "type": "deleted"
                            },
                            {
                                "content": "    unique_in_order = u[np.argsort(idx)]",
                                "type": "deleted"
                            },
                            {
                                "content": "    mapping = np.argsort(idx)[inv]",
                                "type": "deleted"
                            },
                            {
                                "content": "    first_position = {}",
                                "type": "added"
                            },
                            {
                                "content": "    unique_in_order = []",
                                "type": "added"
                            },
                            {
                                "content": "    mapping = []",
                                "type": "added"
                            },
                            {
                                "content": "    for e in a:",
                                "type": "added"
                            },
                            {
                                "content": "        if e not in first_position:",
                                "type": "added"
                            },
                            {
                                "content": "            first_position[e] = len(unique_in_order)",
                                "type": "added"
                            },
                            {
                                "content": "            unique_in_order.append(e)",
                                "type": "added"
                            },
                            {
                                "content": "        mapping.append(first_position[e])",
                                "type": "added"
                            },
                            {
                                "content": "    return unique_in_order, mapping",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/owcreateclass.py",
                            "type": "function",
                            "name": "unique_in_order_mapping",
                            "content": "def unique_in_order_mapping(a):\n    \"\"\" Return\n    - unique elements of the input list (in the order of appearance)\n    - indices of the input list onto the returned uniques\n    \"\"\"\n    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)\n    unique_in_order = u[np.argsort(idx)]\n    mapping = np.argsort(idx)[inv]\n    return unique_in_order, mapping",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 150,
                            "end_lineno": 158,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring, protected-access\nimport unittest\nfrom unittest.mock import patch\n\nimport numpy as np\n\nfrom Orange.data import Table, StringVariable, DiscreteVariable, Domain\nfrom Orange.widgets.data.owcreateclass import (\n    OWCreateClass,\n    map_by_substring, ValueFromStringSubstring, ValueFromDiscreteSubstring,\n    unique_in_order_mapping)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\nclass TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\nclass TestOWCreateClass(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWCreateClass)\n        self.heart = Table(\"heart_disease\")\n        self.zoo = Table(\"zoo\")\n        self.no_attributes = Table(\"iris\")[:, :4]\n\n    def _test_default_rules(self):\n        self.assertEqual(self.widget.active_rules, [[\"\", \"\"], [\"\", \"\"]])\n        for i, (label, pattern) in enumerate(self.widget.line_edits, start=1):\n            self.assertEqual(label.placeholderText(), f\"C{i}\")\n            self.assertEqual(pattern.text(), \"\")\n\n    def _set_attr(self, attr, widget=None):\n        if widget is None:\n            widget = self.widget\n        attr_combo = widget.controls.attribute\n        idx = attr_combo.model().indexOf(attr)\n        attr_combo.setCurrentIndex(idx)\n        attr_combo.activated.emit(idx)\n\n    def _check_counts(self, expected):\n        for countrow, expectedrow in zip(self.widget.counts, expected):\n            for count, exp in zip(countrow, expectedrow):\n                self.assertEqual(count.text(), exp)\n\n    def test_no_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, None)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        # That's all. I don't care if line edits retain the content\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n    def test_no_useful_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.heart[:0])\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes[:0])\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n    def test_string_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        widget.line_edits[0][1].setText(\"a\")\n\n        self._check_counts([[\"54\", \"\"], [\"47\", \"\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"name\")[0].astype(str)\n        has_a = np.char.find(attr, \"a\") != -1\n        np.testing.assert_equal(classes[has_a], 0)\n        np.testing.assert_equal(classes[~has_a], 1)\n\n    def _set_repeated(self):\n        widget = self.widget\n        widget.line_edits[0][0].setText(\"repeated\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.line_edits[1][0].setText(\"not repeated\")\n        widget.line_edits[1][1].setText(\"b\")\n        widget.add_row()\n        widget.line_edits[2][0].setText(\"repeated\")\n        widget.line_edits[2][1].setText(\"c\")\n\n    def _check_repeated(self, source, source_var, output_var):\n        self.assertEqual(output_var.values,\n                         (\"repeated\", \"not repeated\"))\n\n        def vals(var):\n            return [var.str_val(v) for v in\n                    source.transform(Domain([], metas=[var])).metas.flatten()]\n\n        def new_class(v):\n            if \"a\" in v:\n                return \"repeated\"\n            elif \"b\" in v:\n                return \"not repeated\"\n            elif \"c\" in v:\n                return \"repeated\"\n            else:\n                return \"?\"\n\n        source_vals = vals(source_var)\n        out_vals = vals(output_var)\n        self.assertEqual([new_class(v) for v in source_vals], out_vals)\n\n    def test_repeated_class_values_string(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.metas[0],\n                             outdata.domain.class_var)\n\n    def test_repeated_class_values_discrete(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.class_var)\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.class_var,\n                             outdata.domain.class_var)\n\n    def _set_thal(self):\n        widget = self.widget\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n\n        widget.line_edits[0][0].setText(\"Cls1\")\n        widget.line_edits[1][0].setText(\"Cls2\")\n        widget.line_edits[0][1].setText(\"eversa\")\n        widget.line_edits[1][1].setText(\"efect\")\n\n    def _check_thal(self):\n        widget = self.widget\n        self.assertEqual(widget.attribute.name, \"thal\")\n        # This line indeed tests an implementational detail, but the one I\n        # got wrong. Until implementation changes, it makes me feel safe.\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"Cls1\", \"Cls2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"thal\")[0]\n        thal = self.heart.domain[\"thal\"]\n        reversable = np.equal(attr, thal.values.index(\"reversable defect\"))\n        fixed = np.equal(attr, thal.values.index(\"fixed defect\"))\n        np.testing.assert_equal(classes[reversable], 0)\n        np.testing.assert_equal(classes[fixed], 1)\n        self.assertTrue(np.all(np.isnan(classes[~(reversable | fixed)])))\n\n    def test_flow_and_context_handling(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._test_default_rules()\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", ))\n        classes = outdata.get_column_view(\"class\")[0]\n        np.testing.assert_equal(classes, 0)\n\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n        self._test_default_rules()\n\n        self._set_thal()\n        self._check_thal()\n\n        gender = self.heart.domain[\"gender\"]\n        self._set_attr(gender)\n        self.assertIs(widget.rules[\"gender\"], widget.active_rules)\n        self._test_default_rules()\n\n        widget.line_edits[0][1].setText(\"ema\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"\"]])\n        widget.line_edits[1][1].setText(\"ma\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"+ 97\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", \"C2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"gender\")[0]\n        female = np.equal(attr, gender.values.index(\"female\"))\n        np.testing.assert_equal(classes[female], 0)\n        # pylint: disable=invalid-unary-operand-type\n        np.testing.assert_equal(classes[~female], 1)\n\n        self._set_attr(thal)\n        self._check_thal()\n\n        prev_rules = widget.rules\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        # Check that sending None as data does not ruin the context, and that\n        # the empty context does not match the true one later\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n    def test_add_remove_lines(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._set_thal()\n        widget.add_row()\n        self.assertEqual(len(widget.line_edits), 3)\n        widget.line_edits[2][0].setText(\"Cls3\")\n        widget.line_edits[2][1].setText(\"a\")\n        # Observing counts suffices to deduct that rules are set correctly\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"]])\n\n        widget.add_row()\n        widget.add_row()\n        widget.line_edits[3][1].setText(\"c\")\n        widget.line_edits[4][1].setText(\"b\")\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        # Ignore classes without labels\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual(outdata.domain.class_var.values,\n                         (\"Cls1\", \"Cls2\", \"Cls3\"))\n\n        widget.remove_buttons[1].click()\n        self._check_counts([[\"117\", \"\"], [\"166\", \"+ 117\"], [\"18\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual([lab.text() for _, lab in widget.line_edits],\n                         [\"eversa\", \"a\", \"c\", \"b\"])\n\n        # Removal preserves integrity of connections\n        widget.line_edits[1][1].setText(\"efect\")\n        widget.line_edits[2][1].setText(\"a\")\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"]])\n\n        while widget.remove_buttons:\n            widget.remove_buttons[0].click()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        np.testing.assert_equal(self.heart.X, outdata.X)\n        self.assertTrue(np.all(np.isnan(outdata.Y)))\n\n    def test_options(self):\n        def _transformer_flags():\n            widget.apply()\n            outdata = self.get_output(self.widget.Outputs.data)\n            transformer = outdata.domain.class_var.compute_value\n            return transformer.case_sensitive, transformer.match_beginning\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertEqual(_transformer_flags(), (False, False))\n        widget.controls.case_sensitive.click()\n        self.assertEqual(_transformer_flags(), (True, False))\n        widget.controls.case_sensitive.click()\n        widget.controls.match_beginning.click()\n        self.assertEqual(_transformer_flags(), (False, True))\n\n    def test_report(self):\n        \"\"\"Report does not crash\"\"\"\n        widget = self.widget\n        widget.send_report()\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        widget.line_edits[0][0].setText(\"Cls3\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"b\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"c\")\n        widget.send_report()\n\n    def test_bad_class_name(self):\n        \"\"\"\n        Error shown if class name is duplicated or empty and no data on output.\n        GH-2440\n        \"\"\"\n        def assertError(class_name, class_name_empty, class_name_duplicated, is_out):\n            widget.class_name = class_name\n            widget.apply()\n            output = self.get_output(\"Data\")\n            self.assertEqual(widget.Error.class_name_empty.is_shown(), class_name_empty)\n            self.assertEqual(widget.Error.class_name_duplicated.is_shown(), class_name_duplicated)\n            self.assertEqual(output is not None, is_out)\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n\n        assertError(\"\", True, False, False)\n        assertError(\"class\", False, False, True)\n        assertError(\"gender\", False, True, False)\n\n        widget.class_name = \"  class \"\n        widget.apply()\n        self.assertEqual(widget.class_name, \"class\")\n\n    def test_same_class(self):\n        widget1 = self.create_widget(OWCreateClass)\n        self.send_signal(widget1.Inputs.data, self.zoo, widget=widget1)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget1)\n        widget1.line_edits[0][1].setText(\"a\")\n        widget1.apply()\n\n        widget2 = self.create_widget(OWCreateClass)\n        self.send_signal(widget2.Inputs.data, self.zoo, widget=widget2)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget2)\n        widget2.line_edits[0][1].setText(\"a\")\n        widget2.apply()\n\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1).domain.class_var,\n            self.get_output(widget2.Outputs.data, widget=widget2).domain.class_var\n        )\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "new_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring, protected-access\nimport unittest\nfrom unittest.mock import patch\n\nimport numpy as np\n\nfrom Orange.data import Table, StringVariable, DiscreteVariable, Domain\nfrom Orange.widgets.data.owcreateclass import (\n    OWCreateClass,\n    map_by_substring, ValueFromStringSubstring, ValueFromDiscreteSubstring,\n    unique_in_order_mapping)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\nclass TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 2])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 0])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\nclass TestOWCreateClass(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWCreateClass)\n        self.heart = Table(\"heart_disease\")\n        self.zoo = Table(\"zoo\")\n        self.no_attributes = Table(\"iris\")[:, :4]\n\n    def _test_default_rules(self):\n        self.assertEqual(self.widget.active_rules, [[\"\", \"\"], [\"\", \"\"]])\n        for i, (label, pattern) in enumerate(self.widget.line_edits, start=1):\n            self.assertEqual(label.placeholderText(), f\"C{i}\")\n            self.assertEqual(pattern.text(), \"\")\n\n    def _set_attr(self, attr, widget=None):\n        if widget is None:\n            widget = self.widget\n        attr_combo = widget.controls.attribute\n        idx = attr_combo.model().indexOf(attr)\n        attr_combo.setCurrentIndex(idx)\n        attr_combo.activated.emit(idx)\n\n    def _check_counts(self, expected):\n        for countrow, expectedrow in zip(self.widget.counts, expected):\n            for count, exp in zip(countrow, expectedrow):\n                self.assertEqual(count.text(), exp)\n\n    def test_no_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, None)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        # That's all. I don't care if line edits retain the content\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n    def test_no_useful_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.heart[:0])\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes[:0])\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n    def test_string_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        widget.line_edits[0][1].setText(\"a\")\n\n        self._check_counts([[\"54\", \"\"], [\"47\", \"\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"name\")[0].astype(str)\n        has_a = np.char.find(attr, \"a\") != -1\n        np.testing.assert_equal(classes[has_a], 0)\n        np.testing.assert_equal(classes[~has_a], 1)\n\n    def _set_repeated(self):\n        widget = self.widget\n        widget.line_edits[0][0].setText(\"repeated\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.line_edits[1][0].setText(\"not repeated\")\n        widget.line_edits[1][1].setText(\"b\")\n        widget.add_row()\n        widget.line_edits[2][0].setText(\"repeated\")\n        widget.line_edits[2][1].setText(\"c\")\n\n    def _check_repeated(self, source, source_var, output_var):\n        self.assertEqual(output_var.values,\n                         (\"repeated\", \"not repeated\"))\n\n        def vals(var):\n            return [var.str_val(v) for v in\n                    source.transform(Domain([], metas=[var])).metas.flatten()]\n\n        def new_class(v):\n            if \"a\" in v:\n                return \"repeated\"\n            elif \"b\" in v:\n                return \"not repeated\"\n            elif \"c\" in v:\n                return \"repeated\"\n            else:\n                return \"?\"\n\n        source_vals = vals(source_var)\n        out_vals = vals(output_var)\n        self.assertEqual([new_class(v) for v in source_vals], out_vals)\n\n    def test_repeated_class_values_string(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.metas[0],\n                             outdata.domain.class_var)\n\n    def test_repeated_class_values_discrete(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.class_var)\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.class_var,\n                             outdata.domain.class_var)\n\n    def _set_thal(self):\n        widget = self.widget\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n\n        widget.line_edits[0][0].setText(\"Cls1\")\n        widget.line_edits[1][0].setText(\"Cls2\")\n        widget.line_edits[0][1].setText(\"eversa\")\n        widget.line_edits[1][1].setText(\"efect\")\n\n    def _check_thal(self):\n        widget = self.widget\n        self.assertEqual(widget.attribute.name, \"thal\")\n        # This line indeed tests an implementational detail, but the one I\n        # got wrong. Until implementation changes, it makes me feel safe.\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"Cls1\", \"Cls2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"thal\")[0]\n        thal = self.heart.domain[\"thal\"]\n        reversable = np.equal(attr, thal.values.index(\"reversable defect\"))\n        fixed = np.equal(attr, thal.values.index(\"fixed defect\"))\n        np.testing.assert_equal(classes[reversable], 0)\n        np.testing.assert_equal(classes[fixed], 1)\n        self.assertTrue(np.all(np.isnan(classes[~(reversable | fixed)])))\n\n    def test_flow_and_context_handling(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._test_default_rules()\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", ))\n        classes = outdata.get_column_view(\"class\")[0]\n        np.testing.assert_equal(classes, 0)\n\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n        self._test_default_rules()\n\n        self._set_thal()\n        self._check_thal()\n\n        gender = self.heart.domain[\"gender\"]\n        self._set_attr(gender)\n        self.assertIs(widget.rules[\"gender\"], widget.active_rules)\n        self._test_default_rules()\n\n        widget.line_edits[0][1].setText(\"ema\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"\"]])\n        widget.line_edits[1][1].setText(\"ma\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"+ 97\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", \"C2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"gender\")[0]\n        female = np.equal(attr, gender.values.index(\"female\"))\n        np.testing.assert_equal(classes[female], 0)\n        # pylint: disable=invalid-unary-operand-type\n        np.testing.assert_equal(classes[~female], 1)\n\n        self._set_attr(thal)\n        self._check_thal()\n\n        prev_rules = widget.rules\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        # Check that sending None as data does not ruin the context, and that\n        # the empty context does not match the true one later\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n    def test_add_remove_lines(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._set_thal()\n        widget.add_row()\n        self.assertEqual(len(widget.line_edits), 3)\n        widget.line_edits[2][0].setText(\"Cls3\")\n        widget.line_edits[2][1].setText(\"a\")\n        # Observing counts suffices to deduct that rules are set correctly\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"]])\n\n        widget.add_row()\n        widget.add_row()\n        widget.line_edits[3][1].setText(\"c\")\n        widget.line_edits[4][1].setText(\"b\")\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        # Ignore classes without labels\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual(outdata.domain.class_var.values,\n                         (\"Cls1\", \"Cls2\", \"Cls3\"))\n\n        widget.remove_buttons[1].click()\n        self._check_counts([[\"117\", \"\"], [\"166\", \"+ 117\"], [\"18\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual([lab.text() for _, lab in widget.line_edits],\n                         [\"eversa\", \"a\", \"c\", \"b\"])\n\n        # Removal preserves integrity of connections\n        widget.line_edits[1][1].setText(\"efect\")\n        widget.line_edits[2][1].setText(\"a\")\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"]])\n\n        while widget.remove_buttons:\n            widget.remove_buttons[0].click()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        np.testing.assert_equal(self.heart.X, outdata.X)\n        self.assertTrue(np.all(np.isnan(outdata.Y)))\n\n    def test_options(self):\n        def _transformer_flags():\n            widget.apply()\n            outdata = self.get_output(self.widget.Outputs.data)\n            transformer = outdata.domain.class_var.compute_value\n            return transformer.case_sensitive, transformer.match_beginning\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertEqual(_transformer_flags(), (False, False))\n        widget.controls.case_sensitive.click()\n        self.assertEqual(_transformer_flags(), (True, False))\n        widget.controls.case_sensitive.click()\n        widget.controls.match_beginning.click()\n        self.assertEqual(_transformer_flags(), (False, True))\n\n    def test_report(self):\n        \"\"\"Report does not crash\"\"\"\n        widget = self.widget\n        widget.send_report()\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        widget.line_edits[0][0].setText(\"Cls3\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"b\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"c\")\n        widget.send_report()\n\n    def test_bad_class_name(self):\n        \"\"\"\n        Error shown if class name is duplicated or empty and no data on output.\n        GH-2440\n        \"\"\"\n        def assertError(class_name, class_name_empty, class_name_duplicated, is_out):\n            widget.class_name = class_name\n            widget.apply()\n            output = self.get_output(\"Data\")\n            self.assertEqual(widget.Error.class_name_empty.is_shown(), class_name_empty)\n            self.assertEqual(widget.Error.class_name_duplicated.is_shown(), class_name_duplicated)\n            self.assertEqual(output is not None, is_out)\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n\n        assertError(\"\", True, False, False)\n        assertError(\"class\", False, False, True)\n        assertError(\"gender\", False, True, False)\n\n        widget.class_name = \"  class \"\n        widget.apply()\n        self.assertEqual(widget.class_name, \"class\")\n\n    def test_same_class(self):\n        widget1 = self.create_widget(OWCreateClass)\n        self.send_signal(widget1.Inputs.data, self.zoo, widget=widget1)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget1)\n        widget1.line_edits[0][1].setText(\"a\")\n        widget1.apply()\n\n        widget2 = self.create_widget(OWCreateClass)\n        self.send_signal(widget2.Inputs.data, self.zoo, widget=widget2)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget2)\n        widget2.line_edits[0][1].setText(\"a\")\n        widget2.apply()\n\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1).domain.class_var,\n            self.get_output(widget2.Outputs.data, widget=widget2).domain.class_var\n        )\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/widgets/data/tests/test_owcreateclass.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "640addd72",
                "new_commit_hash": "7419bbae4",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/widgets/data/tests/test_owcreateclass.py"
            },
            "plus_file": {
                "path": "b/Orange/widgets/data/tests/test_owcreateclass.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 89,
                            "length": 6
                        },
                        "new_range": {
                            "start": 89,
                            "length": 15
                        },
                        "section": "class TestHelpers(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        u, m = unique_in_order_mapping([2, 1, 2, 3])",
                                "type": "context"
                            },
                            {
                                "content": "        np.testing.assert_equal(u, [2, 1, 3])",
                                "type": "context"
                            },
                            {
                                "content": "        np.testing.assert_equal(m, [0, 1, 0, 2])",
                                "type": "context"
                            },
                            {
                                "content": "        u, m = unique_in_order_mapping([2, 3, 1])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(u, [2, 3, 1])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(m, [0, 1, 2])",
                                "type": "added"
                            },
                            {
                                "content": "        u, m = unique_in_order_mapping([2, 3, 1, 1])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(u, [2, 3, 1])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(m, [0, 1, 2, 2])",
                                "type": "added"
                            },
                            {
                                "content": "        u, m = unique_in_order_mapping([2, 3, 1, 2])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(u, [2, 3, 1])",
                                "type": "added"
                            },
                            {
                                "content": "        np.testing.assert_equal(m, [0, 1, 2, 0])",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_value_from_string_substring(self):",
                                "type": "context"
                            },
                            {
                                "content": "        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/widgets/data/tests/test_owcreateclass.py",
                            "type": "method",
                            "name": "TestHelpers.test_unique_in_order_mapping",
                            "content": "class TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 2])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 0])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 76,
                            "end_lineno": 100,
                            "parent": {
                                "file_name": "Orange/widgets/data/tests/test_owcreateclass.py",
                                "type": "class",
                                "name": "TestHelpers",
                                "content": "class TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 2])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 0])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 16,
                                "end_lineno": 234,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/widgets/data/tests/test_owcreateclass.py",
                            "type": "class",
                            "name": "TestHelpers",
                            "content": "class TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 2])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 0])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 16,
                            "end_lineno": 234,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "92715a01b44eb476ed78b04a3c763b592052c4c6^",
    "new_commit_hash": "92715a01b44eb476ed78b04a3c763b592052c4c6",
    "commit_message": "Merge pull request #5478 from markotoplak/fix-create-class\n\n[FIX] Create Class: fix incorrect value assignment",
    "commit_date": "2021-06-09T14:46:52+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "92715a01b44eb476ed78b04a3c763b592052c4c6",
    "test_file_codes": [
        "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring, protected-access\nimport unittest\nfrom unittest.mock import patch\n\nimport numpy as np\n\nfrom Orange.data import Table, StringVariable, DiscreteVariable, Domain\nfrom Orange.widgets.data.owcreateclass import (\n    OWCreateClass,\n    map_by_substring, ValueFromStringSubstring, ValueFromDiscreteSubstring,\n    unique_in_order_mapping)\nfrom Orange.widgets.tests.base import WidgetTest\n\n\nclass TestHelpers(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.patterns = [\"abc\", \"a\", \"bc\", \"\"]\n        cls.arr = np.array([\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"])\n\n    def test_map_by_substring(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=True, match_beginning=False),\n            [0, 1, 3, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"Bc\", \"\"],\n                             case_sensitive=False, match_beginning=False),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=False, match_beginning=True),\n            [0, 1, 2, 3, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr, [\"\", \"\"], False, False),\n            0)\n        self.assertTrue(np.all(np.isnan(\n            map_by_substring(self.arr, [], False, False))))\n\n    def test_map_by_substring_with_map_values(self):\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=None),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[0, 1, 2, 3]),\n            [0, 1, 2, 0, 3])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 0, 3, 2]),\n            [1, 0, 3, 1, 2])\n        np.testing.assert_equal(\n            map_by_substring(self.arr,\n                             [\"abc\", \"a\", \"bc\", \"\"],\n                             case_sensitive=True, match_beginning=False,\n                             map_values=[1, 1, 0, 0]),\n            [1, 1, 0, 1, 0])\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 2])\n        u, m = unique_in_order_mapping([2, 3, 1, 2])\n        np.testing.assert_equal(u, [2, 3, 1])\n        np.testing.assert_equal(m, [0, 1, 2, 0])\n\n    def test_value_from_string_substring(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        arr2 = np.hstack((self.arr.astype(object), [None]))\n\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.transform(self.arr)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.transform(arr2)\n            a, patterns, *_ = mbs.call_args[0]\n            np.testing.assert_equal(a,\n                                    np.hstack((self.arr.astype(str), \"\")))\n\n        np.testing.assert_equal(trans.transform(arr2),\n                                [0, 1, 2, 0, 3, np.nan])\n\n    def test_value_string_substring_flags(self):\n        trans = ValueFromStringSubstring(StringVariable(\"x\"), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            trans.transform(self.arr)\n            case_sensitive, match_beginning = mbs.call_args[0][-3:-1]\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n\n    def test_value_from_discrete_substring(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        np.testing.assert_equal(trans.lookup_table, [0, 1, 2, 0, 3])\n\n    def test_value_from_discrete_substring_flags(self):\n        trans = ValueFromDiscreteSubstring(\n            DiscreteVariable(\"x\", values=self.arr), self.patterns)\n        with patch('Orange.widgets.data.owcreateclass.map_by_substring') as mbs:\n            trans.case_sensitive = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertTrue(case_sensitive)\n            self.assertFalse(match_beginning)\n            self.assertIsNone(map_values)\n\n            trans.case_sensitive = False\n            trans.match_beginning = True\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, self.arr)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            arr2 = self.arr[::-1]\n            trans.variable = DiscreteVariable(\"x\", values=arr2)\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, self.patterns)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n            patt2 = self.patterns[::-1]\n            trans.patterns = patt2\n            a, patterns, case_sensitive, match_beginning, map_values = mbs.call_args[0]\n            np.testing.assert_equal(a, arr2)\n            self.assertEqual(patterns, patt2)\n            self.assertFalse(case_sensitive)\n            self.assertTrue(match_beginning)\n            self.assertIsNone(map_values)\n\n    def test_valuefromstringsubstring_equality(self):\n        str1 = StringVariable(\"d1\")\n        str1a = StringVariable(\"d1\")\n        str2 = StringVariable(\"d2\")\n        assert str1 == str1a\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromStringSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n        t1 = ValueFromStringSubstring(str1, [\"abc\", \"def\"], True, True)\n        t1a = ValueFromStringSubstring(str1a, [\"abc\", \"def\"], True, False)\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\n    def test_valuefromsdiscretesubstring_equality(self):\n        str1 = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str1a = DiscreteVariable(\"d1\", values=(\"abc\", \"ghi\"))\n        str2 = DiscreteVariable(\"d2\", values=(\"abc\", \"ghi\"))\n        assert str1 == str1a\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"def\"])\n        t2 = ValueFromDiscreteSubstring(str2, [\"abc\", \"def\"])\n        self.assertEqual(t1, t1)\n        self.assertEqual(t1, t1a)\n        self.assertNotEqual(t1, t2)\n\n        self.assertEqual(hash(t1), hash(t1a))\n        self.assertNotEqual(hash(t1), hash(t2))\n\n        t1 = ValueFromDiscreteSubstring(str1, [\"abc\", \"def\"])\n        t1a = ValueFromDiscreteSubstring(str1a, [\"abc\", \"ghi\"])\n        self.assertNotEqual(t1, t1a)\n        self.assertNotEqual(hash(t1), hash(t1a))\n\n\nclass TestOWCreateClass(WidgetTest):\n    def setUp(self):\n        self.widget = self.create_widget(OWCreateClass)\n        self.heart = Table(\"heart_disease\")\n        self.zoo = Table(\"zoo\")\n        self.no_attributes = Table(\"iris\")[:, :4]\n\n    def _test_default_rules(self):\n        self.assertEqual(self.widget.active_rules, [[\"\", \"\"], [\"\", \"\"]])\n        for i, (label, pattern) in enumerate(self.widget.line_edits, start=1):\n            self.assertEqual(label.placeholderText(), f\"C{i}\")\n            self.assertEqual(pattern.text(), \"\")\n\n    def _set_attr(self, attr, widget=None):\n        if widget is None:\n            widget = self.widget\n        attr_combo = widget.controls.attribute\n        idx = attr_combo.model().indexOf(attr)\n        attr_combo.setCurrentIndex(idx)\n        attr_combo.activated.emit(idx)\n\n    def _check_counts(self, expected):\n        for countrow, expectedrow in zip(self.widget.counts, expected):\n            for count, exp in zip(countrow, expectedrow):\n                self.assertEqual(count.text(), exp)\n\n    def test_no_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, None)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        # That's all. I don't care if line edits retain the content\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n    def test_no_useful_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        attr_combo = widget.controls.attribute\n\n        self.assertFalse(attr_combo.model())\n        self.assertIsNone(widget.attribute)\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        widget.apply()\n        self.assertIsNone(self.get_output(self.widget.Outputs.data))\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.heart[:0])\n        self.assertFalse(widget.Warning.no_nonnumeric_vars.is_shown())\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes[:0])\n        self.assertTrue(widget.Warning.no_nonnumeric_vars.is_shown())\n\n    def test_string_data(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        widget.line_edits[0][1].setText(\"a\")\n\n        self._check_counts([[\"54\", \"\"], [\"47\", \"\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"name\")[0].astype(str)\n        has_a = np.char.find(attr, \"a\") != -1\n        np.testing.assert_equal(classes[has_a], 0)\n        np.testing.assert_equal(classes[~has_a], 1)\n\n    def _set_repeated(self):\n        widget = self.widget\n        widget.line_edits[0][0].setText(\"repeated\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.line_edits[1][0].setText(\"not repeated\")\n        widget.line_edits[1][1].setText(\"b\")\n        widget.add_row()\n        widget.line_edits[2][0].setText(\"repeated\")\n        widget.line_edits[2][1].setText(\"c\")\n\n    def _check_repeated(self, source, source_var, output_var):\n        self.assertEqual(output_var.values,\n                         (\"repeated\", \"not repeated\"))\n\n        def vals(var):\n            return [var.str_val(v) for v in\n                    source.transform(Domain([], metas=[var])).metas.flatten()]\n\n        def new_class(v):\n            if \"a\" in v:\n                return \"repeated\"\n            elif \"b\" in v:\n                return \"not repeated\"\n            elif \"c\" in v:\n                return \"repeated\"\n            else:\n                return \"?\"\n\n        source_vals = vals(source_var)\n        out_vals = vals(output_var)\n        self.assertEqual([new_class(v) for v in source_vals], out_vals)\n\n    def test_repeated_class_values_string(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.metas[0])\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.metas[0],\n                             outdata.domain.class_var)\n\n    def test_repeated_class_values_discrete(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self._set_attr(self.zoo.domain.class_var)\n        self._set_repeated()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self._check_repeated(self.zoo, self.zoo.domain.class_var,\n                             outdata.domain.class_var)\n\n    def _set_thal(self):\n        widget = self.widget\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n\n        widget.line_edits[0][0].setText(\"Cls1\")\n        widget.line_edits[1][0].setText(\"Cls2\")\n        widget.line_edits[0][1].setText(\"eversa\")\n        widget.line_edits[1][1].setText(\"efect\")\n\n    def _check_thal(self):\n        widget = self.widget\n        self.assertEqual(widget.attribute.name, \"thal\")\n        # This line indeed tests an implementational detail, but the one I\n        # got wrong. Until implementation changes, it makes me feel safe.\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"Cls1\", \"Cls2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"thal\")[0]\n        thal = self.heart.domain[\"thal\"]\n        reversable = np.equal(attr, thal.values.index(\"reversable defect\"))\n        fixed = np.equal(attr, thal.values.index(\"fixed defect\"))\n        np.testing.assert_equal(classes[reversable], 0)\n        np.testing.assert_equal(classes[fixed], 1)\n        self.assertTrue(np.all(np.isnan(classes[~(reversable | fixed)])))\n\n    def test_flow_and_context_handling(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._test_default_rules()\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", ))\n        classes = outdata.get_column_view(\"class\")[0]\n        np.testing.assert_equal(classes, 0)\n\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        self.assertIs(widget.rules[\"thal\"], widget.active_rules)\n        self._test_default_rules()\n\n        self._set_thal()\n        self._check_thal()\n\n        gender = self.heart.domain[\"gender\"]\n        self._set_attr(gender)\n        self.assertIs(widget.rules[\"gender\"], widget.active_rules)\n        self._test_default_rules()\n\n        widget.line_edits[0][1].setText(\"ema\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"\"]])\n        widget.line_edits[1][1].setText(\"ma\")\n        self._check_counts([[\"97\", \"\"], [\"206\", \"+ 97\"]])\n\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        self.assertEqual(outdata.domain.class_var.values, (\"C1\", \"C2\"))\n        classes = outdata.get_column_view(\"class\")[0]\n        attr = outdata.get_column_view(\"gender\")[0]\n        female = np.equal(attr, gender.values.index(\"female\"))\n        np.testing.assert_equal(classes[female], 0)\n        # pylint: disable=invalid-unary-operand-type\n        np.testing.assert_equal(classes[~female], 1)\n\n        self._set_attr(thal)\n        self._check_thal()\n\n        prev_rules = widget.rules\n        self.send_signal(self.widget.Inputs.data, self.zoo)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        # Check that sending None as data does not ruin the context, and that\n        # the empty context does not match the true one later\n        self.send_signal(self.widget.Inputs.data, None)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n        self.send_signal(self.widget.Inputs.data, self.no_attributes)\n        self.assertIsNot(widget.rules, prev_rules)\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._check_thal()\n\n    def test_add_remove_lines(self):\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self._set_thal()\n        widget.add_row()\n        self.assertEqual(len(widget.line_edits), 3)\n        widget.line_edits[2][0].setText(\"Cls3\")\n        widget.line_edits[2][1].setText(\"a\")\n        # Observing counts suffices to deduct that rules are set correctly\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"]])\n\n        widget.add_row()\n        widget.add_row()\n        widget.line_edits[3][1].setText(\"c\")\n        widget.line_edits[4][1].setText(\"b\")\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        # Ignore classes without labels\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual(outdata.domain.class_var.values,\n                         (\"Cls1\", \"Cls2\", \"Cls3\"))\n\n        widget.remove_buttons[1].click()\n        self._check_counts([[\"117\", \"\"], [\"166\", \"+ 117\"], [\"18\", \"+ 117\"],\n                            [\"\", \"\"], [\"\", \"\"]])\n        self.assertEqual([lab.text() for _, lab in widget.line_edits],\n                         [\"eversa\", \"a\", \"c\", \"b\"])\n\n        # Removal preserves integrity of connections\n        widget.line_edits[1][1].setText(\"efect\")\n        widget.line_edits[2][1].setText(\"a\")\n        self._check_counts([[\"117\", \"\"], [\"18\", \"+ 117\"], [\"166\", \"+ 117\"],\n                            [\"\", \"\"]])\n\n        while widget.remove_buttons:\n            widget.remove_buttons[0].click()\n        widget.apply()\n        outdata = self.get_output(self.widget.Outputs.data)\n        np.testing.assert_equal(self.heart.X, outdata.X)\n        self.assertTrue(np.all(np.isnan(outdata.Y)))\n\n    def test_options(self):\n        def _transformer_flags():\n            widget.apply()\n            outdata = self.get_output(self.widget.Outputs.data)\n            transformer = outdata.domain.class_var.compute_value\n            return transformer.case_sensitive, transformer.match_beginning\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        self.assertEqual(_transformer_flags(), (False, False))\n        widget.controls.case_sensitive.click()\n        self.assertEqual(_transformer_flags(), (True, False))\n        widget.controls.case_sensitive.click()\n        widget.controls.match_beginning.click()\n        self.assertEqual(_transformer_flags(), (False, True))\n\n    def test_report(self):\n        \"\"\"Report does not crash\"\"\"\n        widget = self.widget\n        widget.send_report()\n\n        self.send_signal(self.widget.Inputs.data, self.heart)\n        thal = self.heart.domain[\"thal\"]\n        self._set_attr(thal)\n        widget.line_edits[0][0].setText(\"Cls3\")\n        widget.line_edits[0][1].setText(\"a\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"b\")\n        widget.send_report()\n\n        widget.line_edits[1][1].setText(\"c\")\n        widget.send_report()\n\n    def test_bad_class_name(self):\n        \"\"\"\n        Error shown if class name is duplicated or empty and no data on output.\n        GH-2440\n        \"\"\"\n        def assertError(class_name, class_name_empty, class_name_duplicated, is_out):\n            widget.class_name = class_name\n            widget.apply()\n            output = self.get_output(\"Data\")\n            self.assertEqual(widget.Error.class_name_empty.is_shown(), class_name_empty)\n            self.assertEqual(widget.Error.class_name_duplicated.is_shown(), class_name_duplicated)\n            self.assertEqual(output is not None, is_out)\n\n        widget = self.widget\n        self.send_signal(self.widget.Inputs.data, self.heart)\n\n        assertError(\"\", True, False, False)\n        assertError(\"class\", False, False, True)\n        assertError(\"gender\", False, True, False)\n\n        widget.class_name = \"  class \"\n        widget.apply()\n        self.assertEqual(widget.class_name, \"class\")\n\n    def test_same_class(self):\n        widget1 = self.create_widget(OWCreateClass)\n        self.send_signal(widget1.Inputs.data, self.zoo, widget=widget1)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget1)\n        widget1.line_edits[0][1].setText(\"a\")\n        widget1.apply()\n\n        widget2 = self.create_widget(OWCreateClass)\n        self.send_signal(widget2.Inputs.data, self.zoo, widget=widget2)\n        self._set_attr(self.zoo.domain.metas[0], widget=widget2)\n        widget2.line_edits[0][1].setText(\"a\")\n        widget2.apply()\n\n        self.assertIs(\n            self.get_output(widget1.Outputs.data, widget=widget1).domain.class_var,\n            self.get_output(widget2.Outputs.data, widget=widget2).domain.class_var\n        )\n\n\nif __name__ == \"__main__\":\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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.30.0.dev0+92715a0 to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6\nProcessing dependencies for Orange3==3.30.0.dev0+92715a0\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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages\nSearching for pyqtgraph==0.12.4\nBest match: pyqtgraph 0.12.4\nAdding pyqtgraph 0.12.4 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages\nSearching for httpx==0.16.1\nBest match: httpx 0.16.1\nAdding httpx 0.16.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pyrcc5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pyuic5 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages\nSearching for httpcore==0.12.3\nBest match: httpcore 0.12.3\nAdding httpcore 0.12.3 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages\nSearching for rfc3986==1.5.0\nBest match: rfc3986 1.5.0\nAdding rfc3986 1.5.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.30.0.dev0+92715a0\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 110ms\nPrepared 18 packages in 1ms\nInstalled 18 packages in 108ms\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 53 packages in 295ms\nInstalled 47 packages in 671ms\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.12.3\n + httpx==0.16.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 + rfc3986==1.5.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 39 packages in 90ms\nInstalled 13 packages in 310ms\n + anyqt==0.2.0\n + attrs==24.2.0\n + cattrs==23.1.2\n + commonmark==0.9.1\n + dictdiffer==0.9.0\n + docutils==0.20.1\n + orange-canvas-core==0.1.35\n + orange-widget-base==4.22.0\n + platformdirs==4.0.0\n + pyqtgraph==0.12.4\n + qasync==0.25.0\n + requests-cache==1.1.1\n + url-normalize==1.4.3\nResolved 2 packages in 3ms\nInstalled 2 packages in 8ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 19 packages in 54ms\nInstalled 5 packages in 1.29s\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 2ms\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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:3413:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3413 |   __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:4869:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4869 |   __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:5615:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5615 |           for (__pyx_t_19 = 0; __pyx_t_19 < __pyx_t_18; __pyx_t_19+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5736:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5736 |           __pyx_t_20 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5742:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5742 |           __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:7202:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7202 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c: In function ‘__pyx_pf_6Orange_14classification_13_tree_scorers_16compute_predictions_csc’:\nOrange/classification/_tree_scorers.c:7857:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7857 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7917:143: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7917 |               __pyx_t_15 = (((*((__pyx_t_5numpy_int32_t *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_14 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                               ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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_92715a01b44eb476ed78b04a3c763b592052c4c6/.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 '*.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 '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_92715a01b44eb476ed78b04a3c763b592052c4c6\ncollected 26 items\n\nr2e_tests/test_1.py sss.......................                           [100%]\n\n==================================== PASSES ====================================\n___________________ TestOWCreateClass.test_add_remove_lines ____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_bad_class_name _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_______________ TestOWCreateClass.test_flow_and_context_handling _______________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________________ TestOWCreateClass.test_image_export ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________________ TestOWCreateClass.test_minimum_size ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_msg_base_class _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_no_data ________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_no_useful_data _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_options ________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________ TestOWCreateClass.test_repeated_class_values_discrete _____________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________ TestOWCreateClass.test_repeated_class_values_string ______________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_report _________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n______________________ TestOWCreateClass.test_same_class _______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n______________________ TestOWCreateClass.test_string_data ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestHelpers::test_map_by_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_map_by_substring_with_map_values\nPASSED r2e_tests/test_1.py::TestHelpers::test_unique_in_order_mapping\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_discrete_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_discrete_substring_flags\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_string_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_string_substring_flags\nPASSED r2e_tests/test_1.py::TestHelpers::test_valuefromsdiscretesubstring_equality\nPASSED r2e_tests/test_1.py::TestHelpers::test_valuefromstringsubstring_equality\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_add_remove_lines\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_bad_class_name\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_flow_and_context_handling\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_image_export\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_no_data\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_no_useful_data\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_options\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_repeated_class_values_discrete\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_repeated_class_values_string\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_report\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_same_class\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_string_data\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======================== 23 passed, 3 skipped in 3.97s =========================\nWidgets left: 0    Max widgets: 1040 \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_92715a01b44eb476ed78b04a3c763b592052c4c6\ncollected 26 items\n\nr2e_tests/test_1.py sss..F....................                           [100%]\n\n=================================== FAILURES ===================================\n___________________ TestHelpers.test_unique_in_order_mapping ___________________\n\n    @staticmethod\n    def test_unique_in_order_mapping():\n        u, m = unique_in_order_mapping([])\n        np.testing.assert_equal(u, [])\n        np.testing.assert_equal(m, [])\n        u, m = unique_in_order_mapping([42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0])\n        u, m = unique_in_order_mapping([42, 42])\n        np.testing.assert_equal(u, [42])\n        np.testing.assert_equal(m, [0, 0])\n        u, m = unique_in_order_mapping([2, 1, 0, 3])\n        np.testing.assert_equal(u, [2, 1, 0, 3])\n        np.testing.assert_equal(m, [0, 1, 2, 3])\n        u, m = unique_in_order_mapping([2, 1, 2, 3])\n        np.testing.assert_equal(u, [2, 1, 3])\n        np.testing.assert_equal(m, [0, 1, 0, 2])\n        u, m = unique_in_order_mapping([2, 3, 1])\n        np.testing.assert_equal(u, [2, 3, 1])\n>       np.testing.assert_equal(m, [0, 1, 2])\nE       AssertionError: \nE       Arrays are not equal\nE       \nE       Mismatched elements: 3 / 3 (100%)\nE       Max absolute difference: 2\nE       Max relative difference: 1.\nE        x: array([2, 0, 1])\nE        y: array([0, 1, 2])\n\nr2e_tests/test_1.py:94: AssertionError\n==================================== PASSES ====================================\n___________________ TestOWCreateClass.test_add_remove_lines ____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_bad_class_name _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_______________ TestOWCreateClass.test_flow_and_context_handling _______________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________________ TestOWCreateClass.test_image_export ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________________ TestOWCreateClass.test_minimum_size ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_msg_base_class _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_no_data ________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________________ TestOWCreateClass.test_no_useful_data _____________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_options ________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n____________ TestOWCreateClass.test_repeated_class_values_discrete _____________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n_____________ TestOWCreateClass.test_repeated_class_values_string ______________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n________________________ TestOWCreateClass.test_report _________________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n______________________ TestOWCreateClass.test_same_class _______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n______________________ TestOWCreateClass.test_string_data ______________________\n----------------------------- Captured stderr call -----------------------------\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\nQWidget::setTabOrder: 'first' and 'second' must be in the same window\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestHelpers::test_map_by_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_map_by_substring_with_map_values\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_discrete_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_discrete_substring_flags\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_from_string_substring\nPASSED r2e_tests/test_1.py::TestHelpers::test_value_string_substring_flags\nPASSED r2e_tests/test_1.py::TestHelpers::test_valuefromsdiscretesubstring_equality\nPASSED r2e_tests/test_1.py::TestHelpers::test_valuefromstringsubstring_equality\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_add_remove_lines\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_bad_class_name\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_flow_and_context_handling\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_image_export\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_minimum_size\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_msg_base_class\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_no_data\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_no_useful_data\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_options\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_repeated_class_values_discrete\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_repeated_class_values_string\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_report\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_same_class\nPASSED r2e_tests/test_1.py::TestOWCreateClass::test_string_data\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::TestHelpers::test_unique_in_order_mapping - Asser...\n=================== 1 failed, 22 passed, 3 skipped in 2.85s ====================\nWidgets left: 0    Max widgets: 1040 \n\n",
    "old_commit_res_stderr": ""
}
Orange/widgets/data/owcreateclass.py Orange/widgets/data/tests/test_owcreateclass.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `unique_in_order_mapping` incorrectly maps unique elements for input `[2, 3, 1]`

**Description:**
The `unique_in_order_mapping` function assigns incorrect mapping indices when processing certain input lists. For example, when provided with the input `[2, 3, 1]`, the function is expected to return `unique_in_order` as `[2, 3, 1]` and `mapping` as `[0, 1, 2]`. However, it currently returns `mapping` as `[2, 0, 1]`, which does not accurately represent the indices of the unique elements.

**Example Buggy Code:**
```python
unique_in_order, mapping = unique_in_order_mapping([2, 3, 1])
print(unique_in_order)  # Expected: [2, 3, 1]
print(mapping)          # Expected: [0, 1, 2]
# Actual mapping: [2, 0, 1]
```

**Expected Behavior:**
For the input `[2, 3, 1]`, the `mapping` should correctly map each element to its first occurrence index, resulting in `[0, 1, 2]`.

**Actual Behavior:**
The `mapping` returned is `[2, 0, 1]`, which incorrectly assigns the indices, leading to potential issues in data processing.
[/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/data/owcreateclass.py
"""Widget for creating classes from non-numeric attribute by substrings"""
import re
from itertools import count

import numpy as np

from AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget
from AnyQt.QtCore import QSize, Qt

from Orange.data import StringVariable, DiscreteVariable, Domain
from Orange.data.table import Table
from Orange.statistics.util import bincount
from Orange.preprocess.transformation import Transformation, Lookup
from Orange.widgets import gui, widget
from Orange.widgets.settings import DomainContextHandler, ContextSetting
from Orange.widgets.utils.itemmodels import DomainModel
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import Msg, Input, Output


def map_by_substring(a, patterns, case_sensitive, match_beginning,
                     map_values=None):
    """
    Map values in a using a list of patterns. The patterns are considered in
    order of appearance.

    Args:
        a (np.array): input array of `dtype` `str`
        patterns (list of str): list of strings
        case_sensitive (bool): case sensitive match
        match_beginning (bool): match only at the beginning of the string
        map_values (list of int): list of len(pattens);
                                  contains return values for each pattern

    Returns:
        np.array of floats representing indices of matched patterns
    """
    if map_values is None:
        map_values = np.arange(len(patterns))
    else:
        map_values = np.array(map_values, dtype=int)
    res = np.full(len(a), np.nan)
    if not case_sensitive:
        a = np.char.lower(a)
        patterns = (pattern.lower() for pattern in patterns)
    for val_idx, pattern in reversed(list(enumerate(patterns))):
        indices = np.char.find(a, pattern)
        matches = indices == 0 if match_beginning else indices != -1
        res[matches] = map_values[val_idx]
    return res


class ValueFromStringSubstring(Transformation):
    """
    Transformation that computes a discrete variable from a string variable by
    pattern matching.

    Given patterns `["abc", "a", "bc", ""]`, string data
    `["abcd", "aa", "bcd", "rabc", "x"]` is transformed to values of the new
    attribute with indices`[0, 1, 2, 0, 3]`.

    Args:
        variable (:obj:`~Orange.data.StringVariable`): the original variable
        patterns (list of str): list of string patterns
        case_sensitive (bool, optional): if set to `True`, the match is case
            sensitive
        match_beginning (bool, optional): if set to `True`, the pattern must
            appear at the beginning of the string
    """
    def __init__(self, variable, patterns,
                 case_sensitive=False, match_beginning=False, map_values=None):
        super().__init__(variable)
        self.patterns = patterns
        self.case_sensitive = case_sensitive
        self.match_beginning = match_beginning
        self.map_values = map_values

    def transform(self, c):
        """
        Transform the given data.

        Args:
            c (np.array): an array of type that can be cast to dtype `str`

        Returns:
            np.array of floats representing indices of matched patterns
        """
        nans = np.equal(c, None)
        c = c.astype(str)
        c[nans] = ""
        res = map_by_substring(
            c, self.patterns, self.case_sensitive, self.match_beginning,
            self.map_values)
        res[nans] = np.nan
        return res

    def __eq__(self, other):
        return super().__eq__(other) \
               and self.patterns == other.patterns \
               and self.case_sensitive == other.case_sensitive \
               and self.match_beginning == other.match_beginning \
               and self.map_values == other.map_values

    def __hash__(self):
        return hash((type(self), self.variable,
                     tuple(self.patterns),
                     self.case_sensitive, self.match_beginning,
                     self.map_values))


class ValueFromDiscreteSubstring(Lookup):
    """
    Transformation that computes a discrete variable from discrete variable by
    pattern matching.

    Say that the original attribute has values
    `["abcd", "aa", "bcd", "rabc", "x"]`. Given patterns
    `["abc", "a", "bc", ""]`, the values are mapped to the values of the new
    attribute with indices`[0, 1, 2, 0, 3]`.

    Args:
        variable (:obj:`~Orange.data.DiscreteVariable`): the original variable
        patterns (list of str): list of string patterns
        case_sensitive (bool, optional): if set to `True`, the match is case
            sensitive
        match_beginning (bool, optional): if set to `True`, the pattern must
            appear at the beginning of the string
    """
    def __init__(self, variable, patterns,
                 case_sensitive=False, match_beginning=False,
                 map_values=None):
        super().__init__(variable, [])
        self.case_sensitive = case_sensitive
        self.match_beginning = match_beginning
        self.map_values = map_values
        self.patterns = patterns  # Finally triggers computation of the lookup

    def __setattr__(self, key, value):
        """__setattr__ is overloaded to recompute the lookup table when the
        patterns, the original attribute or the flags change."""
        super().__setattr__(key, value)
        if hasattr(self, "patterns") and \
                key in ("case_sensitive", "match_beginning", "patterns",
                        "variable", "map_values"):
            self.lookup_table = map_by_substring(
                self.variable.values, self.patterns,
                self.case_sensitive, self.match_beginning, self.map_values)


def unique_in_order_mapping(a):
    """ Return
    - unique elements of the input list (in the order of appearance)
    - indices of the input list onto the returned uniques
    """
    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)
    unique_in_order = u[np.argsort(idx)]
    mapping = np.argsort(idx)[inv]
    return unique_in_order, mapping


class OWCreateClass(widget.OWWidget):
    name = "Create Class"
    description = "Create class attribute from a string attribute"
    icon = "icons/CreateClass.svg"
    category = "Data"
    keywords = []

    class Inputs:
        data = Input("Data", Table)

    class Outputs:
        data = Output("Data", Table)

    want_main_area = False
    buttons_area_orientation = Qt.Vertical

    settingsHandler = DomainContextHandler()
    attribute = ContextSetting(None)
    class_name = ContextSetting("class")
    rules = ContextSetting({})
    match_beginning = ContextSetting(False)
    case_sensitive = ContextSetting(False)

    TRANSFORMERS = {StringVariable: ValueFromStringSubstring,
                    DiscreteVariable: ValueFromDiscreteSubstring}

    # Cached variables are used so that two instances of the widget with the
    # same settings will create the same variable. The usual `make` wouldn't
    # work here because variables with `compute_value` are not reused.
    cached_variables = {}

    class Warning(widget.OWWidget.Warning):
        no_nonnumeric_vars = Msg("Data contains only numeric variables.")

    class Error(widget.OWWidget.Error):
        class_name_duplicated = Msg("Class name duplicated.")
        class_name_empty = Msg("Class name should not be empty.")

    def __init__(self):
        super().__init__()
        self.data = None

        # The following lists are of the same length as self.active_rules

        #: list of pairs with counts of matches for each patter when the
        #     patterns are applied in order and when applied on the entire set,
        #     disregarding the preceding patterns
        self.match_counts = []

        #: list of list of QLineEdit: line edit pairs for each pattern
        self.line_edits = []
        #: list of QPushButton: list of remove buttons
        self.remove_buttons = []
        #: list of list of QLabel: pairs of labels with counts
        self.counts = []

        gui.lineEdit(
            self.controlArea, self, "class_name",
            orientation=Qt.Horizontal, box="New Class Name")

        variable_select_box = gui.vBox(self.controlArea, "Match by Substring")

        combo = gui.comboBox(
            variable_select_box, self, "attribute", label="From column:",
            orientation=Qt.Horizontal, searchable=True,
            callback=self.update_rules,
            model=DomainModel(valid_types=(StringVariable, DiscreteVariable)))
        # Don't use setSizePolicy keyword argument here: it applies to box,
        # not the combo
        combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)

        patternbox = gui.vBox(variable_select_box)
        #: QWidget: the box that contains the remove buttons, line edits and
        #    count labels. The lines are added and removed dynamically.
        self.rules_box = rules_box = QGridLayout()
        rules_box.setSpacing(4)
        rules_box.setContentsMargins(4, 4, 4, 4)
        self.rules_box.setColumnMinimumWidth(1, 70)
        self.rules_box.setColumnMinimumWidth(0, 10)
        self.rules_box.setColumnStretch(0, 1)
        self.rules_box.setColumnStretch(1, 1)
        self.rules_box.setColumnStretch(2, 100)
        rules_box.addWidget(QLabel("Name"), 0, 1)
        rules_box.addWidget(QLabel("Substring"), 0, 2)
        rules_box.addWidget(QLabel("Count"), 0, 3, 1, 2)
        self.update_rules()

        widget = QWidget(patternbox)
        widget.setLayout(rules_box)
        patternbox.layout().addWidget(widget)

        box = gui.hBox(patternbox)
        gui.rubber(box)
        gui.button(box, self, "+", callback=self.add_row,
                   autoDefault=False, width=34,
                   sizePolicy=(QSizePolicy.Maximum,
                               QSizePolicy.Maximum))

        optionsbox = gui.vBox(self.controlArea, "Options")
        gui.checkBox(
            optionsbox, self, "match_beginning", "Match only at the beginning",
            callback=self.options_changed)
        gui.checkBox(
            optionsbox, self, "case_sensitive", "Case sensitive",
            callback=self.options_changed)

        gui.rubber(self.controlArea)

        gui.button(self.buttonsArea, self, "Apply", callback=self.apply)

        # TODO: Resizing upon changing the number of rules does not work
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)

    @property
    def active_rules(self):
        """
        Returns the class names and patterns corresponding to the currently
            selected attribute. If the attribute is not yet in the dictionary,
            set the default.
        """
        return self.rules.setdefault(self.attribute and self.attribute.name,
                                     [["", ""], ["", ""]])

    def rules_to_edits(self):
        """Fill the line edites with the rules from the current settings."""
        for editr, textr in zip(self.line_edits, self.active_rules):
            for edit, text in zip(editr, textr):
                edit.setText(text)

    @Inputs.data
    def set_data(self, data):
        """Input data signal handler."""
        self.closeContext()
        self.rules = {}
        self.data = data
        model = self.controls.attribute.model()
        model.set_domain(data.domain if data is not None else None)
        self.Warning.no_nonnumeric_vars(shown=data is not None and not model)
        if not model:
            self.attribute = None
            self.Outputs.data.send(None)
            return
        self.attribute = model[0]
        self.openContext(data)
        self.update_rules()
        self.apply()

    def update_rules(self):
        """Called when the rules are changed: adjust the number of lines in
        the form and fill them, update the counts. The widget does not have
        auto-apply."""
        self.adjust_n_rule_rows()
        self.rules_to_edits()
        self.update_counts()
        # TODO: Indicator that changes need to be applied

    def options_changed(self):
        self.update_counts()

    def adjust_n_rule_rows(self):
        """Add or remove lines if needed and fix the tab order."""
        def _add_line():
            self.line_edits.append([])
            n_lines = len(self.line_edits)
            for coli in range(1, 3):
                edit = QLineEdit()
                self.line_edits[-1].append(edit)
                self.rules_box.addWidget(edit, n_lines, coli)
                edit.textChanged.connect(self.sync_edit)
            button = gui.button(
                None, self, label='×', width=33,
                autoDefault=False, callback=self.remove_row,
                sizePolicy=(QSizePolicy.Maximum,
                            QSizePolicy.Maximum)
            )
            self.remove_buttons.append(button)
            self.rules_box.addWidget(button, n_lines, 0)
            self.counts.append([])
            for coli, kwargs in enumerate(
                    (dict(),
                     dict(styleSheet="color: gray"))):
                label = QLabel(alignment=Qt.AlignCenter, **kwargs)
                self.counts[-1].append(label)
                self.rules_box.addWidget(label, n_lines, 3 + coli)

        def _remove_line():
            for edit in self.line_edits.pop():
                edit.deleteLater()
            self.remove_buttons.pop().deleteLater()
            for label in self.counts.pop():
                label.deleteLater()

        def _fix_tab_order():
            prev = None
            for row, rule in zip(self.line_edits, self.active_rules):
                for col_idx, edit in enumerate(row):
                    edit.row, edit.col_idx = rule, col_idx
                    if prev is not None:
                        self.setTabOrder(prev, edit)
                    prev = edit

        n = len(self.active_rules)
        while n > len(self.line_edits):
            _add_line()
        while len(self.line_edits) > n:
            _remove_line()
        _fix_tab_order()

    def add_row(self):
        """Append a new row at the end."""
        self.active_rules.append(["", ""])
        self.adjust_n_rule_rows()
        self.update_counts()

    def remove_row(self):
        """Remove a row."""
        remove_idx = self.remove_buttons.index(self.sender())
        del self.active_rules[remove_idx]
        self.update_rules()
        self.update_counts()

    def sync_edit(self, text):
        """Handle changes in line edits: update the active rules and counts"""
        edit = self.sender()
        edit.row[edit.col_idx] = text
        self.update_counts()

    def class_labels(self):
        """Construct a list of class labels. Empty labels are replaced with
        C1, C2, C3. If C<n> already appears in the list of values given by
        the user, the labels start at C<n+1> instead.
        """
        largest_c = max((int(label[1:]) for label, _ in self.active_rules
                         if re.match("^C\\d+", label)),
                        default=0)
        class_count = count(largest_c + 1)
        return [label_edit.text() or "C{}".format(next(class_count))
                for label_edit, _ in self.line_edits]

    def update_counts(self):
        """Recompute and update the counts of matches."""
        def _matcher(strings, pattern):
            """Return indices of strings into patterns; consider case
            sensitivity and matching at the beginning. The given strings are
            assumed to be in lower case if match is case insensitive. Patterns
            are fixed on the fly."""
            if not self.case_sensitive:
                pattern = pattern.lower()
            indices = np.char.find(strings, pattern.strip())
            return indices == 0 if self.match_beginning else indices != -1

        def _lower_if_needed(strings):
            return strings if self.case_sensitive else np.char.lower(strings)

        def _string_counts():
            """
            Generate pairs of arrays for each rule until running out of data
            instances. np.sum over the two arrays in each pair gives the
            number of matches of the remaining instances (considering the
            order of patterns) and of the original data.

            For _string_counts, the arrays contain bool masks referring to the
            original data
            """
            nonlocal data
            data = data.astype(str)
            data = data[~np.char.equal(data, "")]
            data = _lower_if_needed(data)
            remaining = np.array(data)
            for _, pattern in self.active_rules:
                matching = _matcher(remaining, pattern)
                total_matching = _matcher(data, pattern)
                yield matching, total_matching
                remaining = remaining[~matching]
                if not remaining.size:
                    break

        def _discrete_counts():
            """
            Generate pairs similar to _string_counts, except that the arrays
            contain bin counts for the attribute's values matching the pattern.
            """
            attr_vals = np.array(attr.values)
            attr_vals = _lower_if_needed(attr_vals)
            bins = bincount(data, max_val=len(attr.values) - 1)[0]
            remaining = np.array(bins)
            for _, pattern in self.active_rules:
                matching = _matcher(attr_vals, pattern)
                yield remaining[matching], bins[matching]
                remaining[matching] = 0
                if not np.any(remaining):
                    break

        def _clear_labels():
            """Clear all labels"""
            for lab_matched, lab_total in self.counts:
                lab_matched.setText("")
                lab_total.setText("")

        def _set_labels():
            """Set the labels to show the counts"""
            for (n_matched, n_total), (lab_matched, lab_total), (lab, patt) in \
                    zip(self.match_counts, self.counts, self.active_rules):
                n_before = n_total - n_matched
                lab_matched.setText("{}".format(n_matched))
                if n_before and (lab or patt):
                    lab_total.setText("+ {}".format(n_before))
                    if n_matched:
                        tip = "{} of the {} matching instances are already " \
                              "covered above".format(n_before, n_total)
                    else:
                        tip = "All matching instances are already covered above"
                    lab_total.setToolTip(tip)
                    lab_matched.setToolTip(tip)

        def _set_placeholders():
            """Set placeholders for empty edit lines"""
            matches = [n for n, _ in self.match_counts] + \
                      [0] * len(self.line_edits)
            for n_matched, (_, patt) in zip(matches, self.line_edits):
                if not patt.text():
                    patt.setPlaceholderText(
                        "(remaining instances)" if n_matched else "(unused)")

            labels = self.class_labels()
            for label, (lab_edit, _) in zip(labels, self.line_edits):
                if not lab_edit.text():
                    lab_edit.setPlaceholderText(label)

        _clear_labels()
        attr = self.attribute
        if attr is None:
            return
        counters = {StringVariable: _string_counts,
                    DiscreteVariable: _discrete_counts}
        data = self.data.get_column_view(attr)[0]
        self.match_counts = [[int(np.sum(x)) for x in matches]
                             for matches in counters[type(attr)]()]
        _set_labels()
        _set_placeholders()

    def apply(self):
        """Output the transformed data."""
        self.Error.clear()
        self.class_name = self.class_name.strip()
        if not self.attribute:
            self.Outputs.data.send(None)
            return
        domain = self.data.domain
        if not self.class_name:
            self.Error.class_name_empty()
        if self.class_name in domain:
            self.Error.class_name_duplicated()
        if not self.class_name or self.class_name in domain:
            self.Outputs.data.send(None)
            return
        new_class = self._create_variable()
        new_domain = Domain(
            domain.attributes, new_class, domain.metas + domain.class_vars)
        new_data = self.data.transform(new_domain)
        self.Outputs.data.send(new_data)

    def _create_variable(self):
        rules = self.active_rules
        # Transposition + stripping
        valid_rules = [label or pattern or n_matches
                       for (label, pattern), n_matches in
                       zip(rules, self.match_counts)]
        patterns = tuple(
            pattern for (_, pattern), valid in zip(rules, valid_rules) if valid)
        names = tuple(
            name for name, valid in zip(self.class_labels(), valid_rules)
            if valid)
        transformer = self.TRANSFORMERS[type(self.attribute)]

        # join patters with the same names
        names, map_values = unique_in_order_mapping(names)
        names = tuple(str(a) for a in names)
        map_values = tuple(map_values)

        var_key = (self.attribute, self.class_name, names,
                   patterns, self.case_sensitive, self.match_beginning, map_values)
        if var_key in self.cached_variables:
            return self.cached_variables[var_key]

        compute_value = transformer(
            self.attribute, patterns, self.case_sensitive, self.match_beginning,
            map_values)
        new_var = DiscreteVariable(
            self.class_name, names, compute_value=compute_value)
        self.cached_variables[var_key] = new_var
        return new_var

    def send_report(self):
        # Pylint gives false positives: these functions are always called from
        # within the loop
        # pylint: disable=undefined-loop-variable
        def _cond_part():
            rule = "<b>{}</b> ".format(class_name)
            if patt:
                rule += "if <b>{}</b> contains <b>{}</b>".format(
                    self.attribute.name, patt)
            else:
                rule += "otherwise"
            return rule

        def _count_part():
            if not n_matched:
                return "all {} matching instances are already covered " \
                       "above".format(n_total)
            elif n_matched < n_total and patt:
                return "{} matching instances (+ {} that are already " \
                       "covered above".format(n_matched, n_total - n_matched)
            else:
                return "{} matching instances".format(n_matched)

        if not self.attribute:
            return
        self.report_items("Input", [("Source attribute", self.attribute.name)])
        output = ""
        names = self.class_labels()
        for (n_matched, n_total), class_name, (lab, patt) in \
                zip(self.match_counts, names, self.active_rules):
            if lab or patt or n_total:
                output += "<li>{}; {}</li>".format(_cond_part(), _count_part())
        if output:
            self.report_items("Output", [("Class name", self.class_name)])
            self.report_raw("<ol>{}</ol>".format(output))


if __name__ == "__main__":  # pragma: no cover
    WidgetPreview(OWCreateClass).run(Table("zoo"))

```
--- 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:** `unique_in_order_mapping` incorrectly maps unique elements for input `[2, 3, 1]`

**Description:**
The `unique_in_order_mapping` function assigns incorrect mapping indices when processing certain input lists. For example, when provided with the input `[2, 3, 1]`, the function is expected to return `unique_in_order` as `[2, 3, 1]` and `mapping` as `[0, 1, 2]`. However, it currently returns `mapping` as `[2, 0, 1]`, which does not accurately represent the indices of the unique elements.

**Example Buggy Code:**
```python
unique_in_order, mapping = unique_in_order_mapping([2, 3, 1])
print(unique_in_order)  # Expected: [2, 3, 1]
print(mapping)          # Expected: [0, 1, 2]
# Actual mapping: [2, 0, 1]
```

**Expected Behavior:**
For the input `[2, 3, 1]`, the `mapping` should correctly map each element to its first occurrence index, resulting in `[0, 1, 2]`.

**Actual Behavior:**
The `mapping` returned is `[2, 0, 1]`, which incorrectly assigns the indices, leading to potential issues in data processing.
[/ISSUE]
{
    "TestHelpers.test_map_by_substring": "PASSED",
    "TestHelpers.test_map_by_substring_with_map_values": "PASSED",
    "TestHelpers.test_unique_in_order_mapping": "PASSED",
    "TestHelpers.test_value_from_discrete_substring": "PASSED",
    "TestHelpers.test_value_from_discrete_substring_flags": "PASSED",
    "TestHelpers.test_value_from_string_substring": "PASSED",
    "TestHelpers.test_value_string_substring_flags": "PASSED",
    "TestHelpers.test_valuefromsdiscretesubstring_equality": "PASSED",
    "TestHelpers.test_valuefromstringsubstring_equality": "PASSED",
    "TestOWCreateClass.test_add_remove_lines": "PASSED",
    "TestOWCreateClass.test_bad_class_name": "PASSED",
    "TestOWCreateClass.test_flow_and_context_handling": "PASSED",
    "TestOWCreateClass.test_image_export": "PASSED",
    "TestOWCreateClass.test_minimum_size": "PASSED",
    "TestOWCreateClass.test_msg_base_class": "PASSED",
    "TestOWCreateClass.test_no_data": "PASSED",
    "TestOWCreateClass.test_no_useful_data": "PASSED",
    "TestOWCreateClass.test_options": "PASSED",
    "TestOWCreateClass.test_repeated_class_values_discrete": "PASSED",
    "TestOWCreateClass.test_repeated_class_values_string": "PASSED",
    "TestOWCreateClass.test_report": "PASSED",
    "TestOWCreateClass.test_same_class": "PASSED",
    "TestOWCreateClass.test_string_data": "PASSED"
}
diff --git a/Orange/widgets/data/owcreateclass.py b/Orange/widgets/data/owcreateclass.py
index bbf200967..d05579c16 100644
--- a/Orange/widgets/data/owcreateclass.py
+++ b/Orange/widgets/data/owcreateclass.py
@@ -152,9 +152,14 @@ def unique_in_order_mapping(a):
     - unique elements of the input list (in the order of appearance)
     - indices of the input list onto the returned uniques
     """
-    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)
-    unique_in_order = u[np.argsort(idx)]
-    mapping = np.argsort(idx)[inv]
+    first_position = {}
+    unique_in_order = []
+    mapping = []
+    for e in a:
+        if e not in first_position:
+            first_position[e] = len(unique_in_order)
+            unique_in_order.append(e)
+        mapping.append(first_position[e])
     return unique_in_order, mapping
 
 

{"Orange/widgets/data/owcreateclass.py": "\"\"\"Widget for creating classes from non-numeric attribute by substrings\"\"\"\nimport re\nfrom itertools import count\n\nimport numpy as np\n\nfrom AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget\nfrom AnyQt.QtCore import QSize, Qt\n\nfrom Orange.data import StringVariable, DiscreteVariable, Domain\nfrom Orange.data.table import Table\nfrom Orange.statistics.util import bincount\nfrom Orange.preprocess.transformation import Transformation, Lookup\nfrom Orange.widgets import gui, widget\nfrom Orange.widgets.settings import DomainContextHandler, ContextSetting\nfrom Orange.widgets.utils.itemmodels import DomainModel\nfrom Orange.widgets.utils.widgetpreview import WidgetPreview\nfrom Orange.widgets.widget import Msg, Input, Output\n\n\ndef map_by_substring(a, patterns, case_sensitive, match_beginning,\n                     map_values=None):\n    \"\"\"\n    Map values in a using a list of patterns. The patterns are considered in\n    order of appearance.\n\n    Args:\n        a (np.array): input array of `dtype` `str`\n        patterns (list of str): list of strings\n        case_sensitive (bool): case sensitive match\n        match_beginning (bool): match only at the beginning of the string\n        map_values (list of int): list of len(pattens);\n                                  contains return values for each pattern\n\n    Returns:\n        np.array of floats representing indices of matched patterns\n    \"\"\"\n    if map_values is None:\n        map_values = np.arange(len(patterns))\n    else:\n        map_values = np.array(map_values, dtype=int)\n    res = np.full(len(a), np.nan)\n    if not case_sensitive:\n        a = np.char.lower(a)\n        patterns = (pattern.lower() for pattern in patterns)\n    for val_idx, pattern in reversed(list(enumerate(patterns))):\n        indices = np.char.find(a, pattern)\n        matches = indices == 0 if match_beginning else indices != -1\n        res[matches] = map_values[val_idx]\n    return res\n\n\nclass ValueFromStringSubstring(Transformation):\n    \"\"\"\n    Transformation that computes a discrete variable from a string variable by\n    pattern matching.\n\n    Given patterns `[\"abc\", \"a\", \"bc\", \"\"]`, string data\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]` is transformed to values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.StringVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False, map_values=None):\n        super().__init__(variable)\n        self.patterns = patterns\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n\n    def transform(self, c):\n        \"\"\"\n        Transform the given data.\n\n        Args:\n            c (np.array): an array of type that can be cast to dtype `str`\n\n        Returns:\n            np.array of floats representing indices of matched patterns\n        \"\"\"\n        nans = np.equal(c, None)\n        c = c.astype(str)\n        c[nans] = \"\"\n        res = map_by_substring(\n            c, self.patterns, self.case_sensitive, self.match_beginning,\n            self.map_values)\n        res[nans] = np.nan\n        return res\n\n    def __eq__(self, other):\n        return super().__eq__(other) \\\n               and self.patterns == other.patterns \\\n               and self.case_sensitive == other.case_sensitive \\\n               and self.match_beginning == other.match_beginning \\\n               and self.map_values == other.map_values\n\n    def __hash__(self):\n        return hash((type(self), self.variable,\n                     tuple(self.patterns),\n                     self.case_sensitive, self.match_beginning,\n                     self.map_values))\n\n\nclass ValueFromDiscreteSubstring(Lookup):\n    \"\"\"\n    Transformation that computes a discrete variable from discrete variable by\n    pattern matching.\n\n    Say that the original attribute has values\n    `[\"abcd\", \"aa\", \"bcd\", \"rabc\", \"x\"]`. Given patterns\n    `[\"abc\", \"a\", \"bc\", \"\"]`, the values are mapped to the values of the new\n    attribute with indices`[0, 1, 2, 0, 3]`.\n\n    Args:\n        variable (:obj:`~Orange.data.DiscreteVariable`): the original variable\n        patterns (list of str): list of string patterns\n        case_sensitive (bool, optional): if set to `True`, the match is case\n            sensitive\n        match_beginning (bool, optional): if set to `True`, the pattern must\n            appear at the beginning of the string\n    \"\"\"\n    def __init__(self, variable, patterns,\n                 case_sensitive=False, match_beginning=False,\n                 map_values=None):\n        super().__init__(variable, [])\n        self.case_sensitive = case_sensitive\n        self.match_beginning = match_beginning\n        self.map_values = map_values\n        self.patterns = patterns  # Finally triggers computation of the lookup\n\n    def __setattr__(self, key, value):\n        \"\"\"__setattr__ is overloaded to recompute the lookup table when the\n        patterns, the original attribute or the flags change.\"\"\"\n        super().__setattr__(key, value)\n        if hasattr(self, \"patterns\") and \\\n                key in (\"case_sensitive\", \"match_beginning\", \"patterns\",\n                        \"variable\", \"map_values\"):\n            self.lookup_table = map_by_substring(\n                self.variable.values, self.patterns,\n                self.case_sensitive, self.match_beginning, self.map_values)\n\n\ndef unique_in_order_mapping(a):\n    \"\"\" Return\n    - unique elements of the input list (in the order of appearance)\n    - indices of the input list onto the returned uniques\n    \"\"\"\n    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)\n    unique_in_order = u[np.argsort(idx)]\n    mapping = np.argsort(idx)[inv]\n    return unique_in_order, mapping\n\n\nclass OWCreateClass(widget.OWWidget):\n    name = \"Create Class\"\n    description = \"Create class attribute from a string attribute\"\n    icon = \"icons/CreateClass.svg\"\n    category = \"Data\"\n    keywords = []\n\n    class Inputs:\n        data = Input(\"Data\", Table)\n\n    class Outputs:\n        data = Output(\"Data\", Table)\n\n    want_main_area = False\n    buttons_area_orientation = Qt.Vertical\n\n    settingsHandler = DomainContextHandler()\n    attribute = ContextSetting(None)\n    class_name = ContextSetting(\"class\")\n    rules = ContextSetting({})\n    match_beginning = ContextSetting(False)\n    case_sensitive = ContextSetting(False)\n\n    TRANSFORMERS = {StringVariable: ValueFromStringSubstring,\n                    DiscreteVariable: ValueFromDiscreteSubstring}\n\n    # Cached variables are used so that two instances of the widget with the\n    # same settings will create the same variable. The usual `make` wouldn't\n    # work here because variables with `compute_value` are not reused.\n    cached_variables = {}\n\n    class Warning(widget.OWWidget.Warning):\n        no_nonnumeric_vars = Msg(\"Data contains only numeric variables.\")\n\n    class Error(widget.OWWidget.Error):\n        class_name_duplicated = Msg(\"Class name duplicated.\")\n        class_name_empty = Msg(\"Class name should not be empty.\")\n\n    def __init__(self):\n        super().__init__()\n        self.data = None\n\n        # The following lists are of the same length as self.active_rules\n\n        #: list of pairs with counts of matches for each patter when the\n        #     patterns are applied in order and when applied on the entire set,\n        #     disregarding the preceding patterns\n        self.match_counts = []\n\n        #: list of list of QLineEdit: line edit pairs for each pattern\n        self.line_edits = []\n        #: list of QPushButton: list of remove buttons\n        self.remove_buttons = []\n        #: list of list of QLabel: pairs of labels with counts\n        self.counts = []\n\n        gui.lineEdit(\n            self.controlArea, self, \"class_name\",\n            orientation=Qt.Horizontal, box=\"New Class Name\")\n\n        variable_select_box = gui.vBox(self.controlArea, \"Match by Substring\")\n\n        combo = gui.comboBox(\n            variable_select_box, self, \"attribute\", label=\"From column:\",\n            orientation=Qt.Horizontal, searchable=True,\n            callback=self.update_rules,\n            model=DomainModel(valid_types=(StringVariable, DiscreteVariable)))\n        # Don't use setSizePolicy keyword argument here: it applies to box,\n        # not the combo\n        combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)\n\n        patternbox = gui.vBox(variable_select_box)\n        #: QWidget: the box that contains the remove buttons, line edits and\n        #    count labels. The lines are added and removed dynamically.\n        self.rules_box = rules_box = QGridLayout()\n        rules_box.setSpacing(4)\n        rules_box.setContentsMargins(4, 4, 4, 4)\n        self.rules_box.setColumnMinimumWidth(1, 70)\n        self.rules_box.setColumnMinimumWidth(0, 10)\n        self.rules_box.setColumnStretch(0, 1)\n        self.rules_box.setColumnStretch(1, 1)\n        self.rules_box.setColumnStretch(2, 100)\n        rules_box.addWidget(QLabel(\"Name\"), 0, 1)\n        rules_box.addWidget(QLabel(\"Substring\"), 0, 2)\n        rules_box.addWidget(QLabel(\"Count\"), 0, 3, 1, 2)\n        self.update_rules()\n\n        widget = QWidget(patternbox)\n        widget.setLayout(rules_box)\n        patternbox.layout().addWidget(widget)\n\n        box = gui.hBox(patternbox)\n        gui.rubber(box)\n        gui.button(box, self, \"+\", callback=self.add_row,\n                   autoDefault=False, width=34,\n                   sizePolicy=(QSizePolicy.Maximum,\n                               QSizePolicy.Maximum))\n\n        optionsbox = gui.vBox(self.controlArea, \"Options\")\n        gui.checkBox(\n            optionsbox, self, \"match_beginning\", \"Match only at the beginning\",\n            callback=self.options_changed)\n        gui.checkBox(\n            optionsbox, self, \"case_sensitive\", \"Case sensitive\",\n            callback=self.options_changed)\n\n        gui.rubber(self.controlArea)\n\n        gui.button(self.buttonsArea, self, \"Apply\", callback=self.apply)\n\n        # TODO: Resizing upon changing the number of rules does not work\n        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)\n\n    @property\n    def active_rules(self):\n        \"\"\"\n        Returns the class names and patterns corresponding to the currently\n            selected attribute. If the attribute is not yet in the dictionary,\n            set the default.\n        \"\"\"\n        return self.rules.setdefault(self.attribute and self.attribute.name,\n                                     [[\"\", \"\"], [\"\", \"\"]])\n\n    def rules_to_edits(self):\n        \"\"\"Fill the line edites with the rules from the current settings.\"\"\"\n        for editr, textr in zip(self.line_edits, self.active_rules):\n            for edit, text in zip(editr, textr):\n                edit.setText(text)\n\n    @Inputs.data\n    def set_data(self, data):\n        \"\"\"Input data signal handler.\"\"\"\n        self.closeContext()\n        self.rules = {}\n        self.data = data\n        model = self.controls.attribute.model()\n        model.set_domain(data.domain if data is not None else None)\n        self.Warning.no_nonnumeric_vars(shown=data is not None and not model)\n        if not model:\n            self.attribute = None\n            self.Outputs.data.send(None)\n            return\n        self.attribute = model[0]\n        self.openContext(data)\n        self.update_rules()\n        self.apply()\n\n    def update_rules(self):\n        \"\"\"Called when the rules are changed: adjust the number of lines in\n        the form and fill them, update the counts. The widget does not have\n        auto-apply.\"\"\"\n        self.adjust_n_rule_rows()\n        self.rules_to_edits()\n        self.update_counts()\n        # TODO: Indicator that changes need to be applied\n\n    def options_changed(self):\n        self.update_counts()\n\n    def adjust_n_rule_rows(self):\n        \"\"\"Add or remove lines if needed and fix the tab order.\"\"\"\n        def _add_line():\n            self.line_edits.append([])\n            n_lines = len(self.line_edits)\n            for coli in range(1, 3):\n                edit = QLineEdit()\n                self.line_edits[-1].append(edit)\n                self.rules_box.addWidget(edit, n_lines, coli)\n                edit.textChanged.connect(self.sync_edit)\n            button = gui.button(\n                None, self, label='\u00d7', width=33,\n                autoDefault=False, callback=self.remove_row,\n                sizePolicy=(QSizePolicy.Maximum,\n                            QSizePolicy.Maximum)\n            )\n            self.remove_buttons.append(button)\n            self.rules_box.addWidget(button, n_lines, 0)\n            self.counts.append([])\n            for coli, kwargs in enumerate(\n                    (dict(),\n                     dict(styleSheet=\"color: gray\"))):\n                label = QLabel(alignment=Qt.AlignCenter, **kwargs)\n                self.counts[-1].append(label)\n                self.rules_box.addWidget(label, n_lines, 3 + coli)\n\n        def _remove_line():\n            for edit in self.line_edits.pop():\n                edit.deleteLater()\n            self.remove_buttons.pop().deleteLater()\n            for label in self.counts.pop():\n                label.deleteLater()\n\n        def _fix_tab_order():\n            prev = None\n            for row, rule in zip(self.line_edits, self.active_rules):\n                for col_idx, edit in enumerate(row):\n                    edit.row, edit.col_idx = rule, col_idx\n                    if prev is not None:\n                        self.setTabOrder(prev, edit)\n                    prev = edit\n\n        n = len(self.active_rules)\n        while n > len(self.line_edits):\n            _add_line()\n        while len(self.line_edits) > n:\n            _remove_line()\n        _fix_tab_order()\n\n    def add_row(self):\n        \"\"\"Append a new row at the end.\"\"\"\n        self.active_rules.append([\"\", \"\"])\n        self.adjust_n_rule_rows()\n        self.update_counts()\n\n    def remove_row(self):\n        \"\"\"Remove a row.\"\"\"\n        remove_idx = self.remove_buttons.index(self.sender())\n        del self.active_rules[remove_idx]\n        self.update_rules()\n        self.update_counts()\n\n    def sync_edit(self, text):\n        \"\"\"Handle changes in line edits: update the active rules and counts\"\"\"\n        edit = self.sender()\n        edit.row[edit.col_idx] = text\n        self.update_counts()\n\n    def class_labels(self):\n        \"\"\"Construct a list of class labels. Empty labels are replaced with\n        C1, C2, C3. If C<n> already appears in the list of values given by\n        the user, the labels start at C<n+1> instead.\n        \"\"\"\n        largest_c = max((int(label[1:]) for label, _ in self.active_rules\n                         if re.match(\"^C\\\\d+\", label)),\n                        default=0)\n        class_count = count(largest_c + 1)\n        return [label_edit.text() or \"C{}\".format(next(class_count))\n                for label_edit, _ in self.line_edits]\n\n    def update_counts(self):\n        \"\"\"Recompute and update the counts of matches.\"\"\"\n        def _matcher(strings, pattern):\n            \"\"\"Return indices of strings into patterns; consider case\n            sensitivity and matching at the beginning. The given strings are\n            assumed to be in lower case if match is case insensitive. Patterns\n            are fixed on the fly.\"\"\"\n            if not self.case_sensitive:\n                pattern = pattern.lower()\n            indices = np.char.find(strings, pattern.strip())\n            return indices == 0 if self.match_beginning else indices != -1\n\n        def _lower_if_needed(strings):\n            return strings if self.case_sensitive else np.char.lower(strings)\n\n        def _string_counts():\n            \"\"\"\n            Generate pairs of arrays for each rule until running out of data\n            instances. np.sum over the two arrays in each pair gives the\n            number of matches of the remaining instances (considering the\n            order of patterns) and of the original data.\n\n            For _string_counts, the arrays contain bool masks referring to the\n            original data\n            \"\"\"\n            nonlocal data\n            data = data.astype(str)\n            data = data[~np.char.equal(data, \"\")]\n            data = _lower_if_needed(data)\n            remaining = np.array(data)\n            for _, pattern in self.active_rules:\n                matching = _matcher(remaining, pattern)\n                total_matching = _matcher(data, pattern)\n                yield matching, total_matching\n                remaining = remaining[~matching]\n                if not remaining.size:\n                    break\n\n        def _discrete_counts():\n            \"\"\"\n            Generate pairs similar to _string_counts, except that the arrays\n            contain bin counts for the attribute's values matching the pattern.\n            \"\"\"\n            attr_vals = np.array(attr.values)\n            attr_vals = _lower_if_needed(attr_vals)\n            bins = bincount(data, max_val=len(attr.values) - 1)[0]\n            remaining = np.array(bins)\n            for _, pattern in self.active_rules:\n                matching = _matcher(attr_vals, pattern)\n                yield remaining[matching], bins[matching]\n                remaining[matching] = 0\n                if not np.any(remaining):\n                    break\n\n        def _clear_labels():\n            \"\"\"Clear all labels\"\"\"\n            for lab_matched, lab_total in self.counts:\n                lab_matched.setText(\"\")\n                lab_total.setText(\"\")\n\n        def _set_labels():\n            \"\"\"Set the labels to show the counts\"\"\"\n            for (n_matched, n_total), (lab_matched, lab_total), (lab, patt) in \\\n                    zip(self.match_counts, self.counts, self.active_rules):\n                n_before = n_total - n_matched\n                lab_matched.setText(\"{}\".format(n_matched))\n                if n_before and (lab or patt):\n                    lab_total.setText(\"+ {}\".format(n_before))\n                    if n_matched:\n                        tip = \"{} of the {} matching instances are already \" \\\n                              \"covered above\".format(n_before, n_total)\n                    else:\n                        tip = \"All matching instances are already covered above\"\n                    lab_total.setToolTip(tip)\n                    lab_matched.setToolTip(tip)\n\n        def _set_placeholders():\n            \"\"\"Set placeholders for empty edit lines\"\"\"\n            matches = [n for n, _ in self.match_counts] + \\\n                      [0] * len(self.line_edits)\n            for n_matched, (_, patt) in zip(matches, self.line_edits):\n                if not patt.text():\n                    patt.setPlaceholderText(\n                        \"(remaining instances)\" if n_matched else \"(unused)\")\n\n            labels = self.class_labels()\n            for label, (lab_edit, _) in zip(labels, self.line_edits):\n                if not lab_edit.text():\n                    lab_edit.setPlaceholderText(label)\n\n        _clear_labels()\n        attr = self.attribute\n        if attr is None:\n            return\n        counters = {StringVariable: _string_counts,\n                    DiscreteVariable: _discrete_counts}\n        data = self.data.get_column_view(attr)[0]\n        self.match_counts = [[int(np.sum(x)) for x in matches]\n                             for matches in counters[type(attr)]()]\n        _set_labels()\n        _set_placeholders()\n\n    def apply(self):\n        \"\"\"Output the transformed data.\"\"\"\n        self.Error.clear()\n        self.class_name = self.class_name.strip()\n        if not self.attribute:\n            self.Outputs.data.send(None)\n            return\n        domain = self.data.domain\n        if not self.class_name:\n            self.Error.class_name_empty()\n        if self.class_name in domain:\n            self.Error.class_name_duplicated()\n        if not self.class_name or self.class_name in domain:\n            self.Outputs.data.send(None)\n            return\n        new_class = self._create_variable()\n        new_domain = Domain(\n            domain.attributes, new_class, domain.metas + domain.class_vars)\n        new_data = self.data.transform(new_domain)\n        self.Outputs.data.send(new_data)\n\n    def _create_variable(self):\n        rules = self.active_rules\n        # Transposition + stripping\n        valid_rules = [label or pattern or n_matches\n                       for (label, pattern), n_matches in\n                       zip(rules, self.match_counts)]\n        patterns = tuple(\n            pattern for (_, pattern), valid in zip(rules, valid_rules) if valid)\n        names = tuple(\n            name for name, valid in zip(self.class_labels(), valid_rules)\n            if valid)\n        transformer = self.TRANSFORMERS[type(self.attribute)]\n\n        # join patters with the same names\n        names, map_values = unique_in_order_mapping(names)\n        names = tuple(str(a) for a in names)\n        map_values = tuple(map_values)\n\n        var_key = (self.attribute, self.class_name, names,\n                   patterns, self.case_sensitive, self.match_beginning, map_values)\n        if var_key in self.cached_variables:\n            return self.cached_variables[var_key]\n\n        compute_value = transformer(\n            self.attribute, patterns, self.case_sensitive, self.match_beginning,\n            map_values)\n        new_var = DiscreteVariable(\n            self.class_name, names, compute_value=compute_value)\n        self.cached_variables[var_key] = new_var\n        return new_var\n\n    def send_report(self):\n        # Pylint gives false positives: these functions are always called from\n        # within the loop\n        # pylint: disable=undefined-loop-variable\n        def _cond_part():\n            rule = \"<b>{}</b> \".format(class_name)\n            if patt:\n                rule += \"if <b>{}</b> contains <b>{}</b>\".format(\n                    self.attribute.name, patt)\n            else:\n                rule += \"otherwise\"\n            return rule\n\n        def _count_part():\n            if not n_matched:\n                return \"all {} matching instances are already covered \" \\\n                       \"above\".format(n_total)\n            elif n_matched < n_total and patt:\n                return \"{} matching instances (+ {} that are already \" \\\n                       \"covered above\".format(n_matched, n_total - n_matched)\n            else:\n                return \"{} matching instances\".format(n_matched)\n\n        if not self.attribute:\n            return\n        self.report_items(\"Input\", [(\"Source attribute\", self.attribute.name)])\n        output = \"\"\n        names = self.class_labels()\n        for (n_matched, n_total), class_name, (lab, patt) in \\\n                zip(self.match_counts, names, self.active_rules):\n            if lab or patt or n_total:\n                output += \"<li>{}; {}</li>\".format(_cond_part(), _count_part())\n        if output:\n            self.report_items(\"Output\", [(\"Class name\", self.class_name)])\n            self.report_raw(\"<ol>{}</ol>\".format(output))\n\n\nif __name__ == \"__main__\":  # pragma: no cover\n    WidgetPreview(OWCreateClass).run(Table(\"zoo\"))\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:** `unique_in_order_mapping` incorrectly maps unique elements for input `[2, 3, 1]`

**Description:**
The `unique_in_order_mapping` function assigns incorrect mapping indices when processing certain input lists. For example, when provided with the input `[2, 3, 1]`, the function is expected to return `unique_in_order` as `[2, 3, 1]` and `mapping` as `[0, 1, 2]`. However, it currently returns `mapping` as `[2, 0, 1]`, which does not accurately represent the indices of the unique elements.

**Example Buggy Code:**
```python
unique_in_order, mapping = unique_in_order_mapping([2, 3, 1])
print(unique_in_order)  # Expected: [2, 3, 1]
print(mapping)          # Expected: [0, 1, 2]
# Actual mapping: [2, 0, 1]
```

**Expected Behavior:**
For the input `[2, 3, 1]`, the `mapping` should correctly map each element to its first occurrence index, resulting in `[0, 1, 2]`.

**Actual Behavior:**
The `mapping` returned is `[2, 0, 1]`, which incorrectly assigns the indices, leading to potential issues in data processing.
[/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/data/owcreateclass.py
"""Widget for creating classes from non-numeric attribute by substrings"""
import re
from itertools import count

import numpy as np

from AnyQt.QtWidgets import QGridLayout, QLabel, QLineEdit, QSizePolicy, QWidget
from AnyQt.QtCore import QSize, Qt

from Orange.data import StringVariable, DiscreteVariable, Domain
from Orange.data.table import Table
from Orange.statistics.util import bincount
from Orange.preprocess.transformation import Transformation, Lookup
from Orange.widgets import gui, widget
from Orange.widgets.settings import DomainContextHandler, ContextSetting
from Orange.widgets.utils.itemmodels import DomainModel
from Orange.widgets.utils.widgetpreview import WidgetPreview
from Orange.widgets.widget import Msg, Input, Output


def map_by_substring(a, patterns, case_sensitive, match_beginning,
                     map_values=None):
    """
    Map values in a using a list of patterns. The patterns are considered in
    order of appearance.

    Args:
        a (np.array): input array of `dtype` `str`
        patterns (list of str): list of strings
        case_sensitive (bool): case sensitive match
        match_beginning (bool): match only at the beginning of the string
        map_values (list of int): list of len(pattens);
                                  contains return values for each pattern

    Returns:
        np.array of floats representing indices of matched patterns
    """
    if map_values is None:
        map_values = np.arange(len(patterns))
    else:
        map_values = np.array(map_values, dtype=int)
    res = np.full(len(a), np.nan)
    if not case_sensitive:
        a = np.char.lower(a)
        patterns = (pattern.lower() for pattern in patterns)
    for val_idx, pattern in reversed(list(enumerate(patterns))):
        indices = np.char.find(a, pattern)
        matches = indices == 0 if match_beginning else indices != -1
        res[matches] = map_values[val_idx]
    return res


class ValueFromStringSubstring(Transformation):
    """
    Transformation that computes a discrete variable from a string variable by
    pattern matching.

    Given patterns `["abc", "a", "bc", ""]`, string data
    `["abcd", "aa", "bcd", "rabc", "x"]` is transformed to values of the new
    attribute with indices`[0, 1, 2, 0, 3]`.

    Args:
        variable (:obj:`~Orange.data.StringVariable`): the original variable
        patterns (list of str): list of string patterns
        case_sensitive (bool, optional): if set to `True`, the match is case
            sensitive
        match_beginning (bool, optional): if set to `True`, the pattern must
            appear at the beginning of the string
    """
    def __init__(self, variable, patterns,
                 case_sensitive=False, match_beginning=False, map_values=None):
        super().__init__(variable)
        self.patterns = patterns
        self.case_sensitive = case_sensitive
        self.match_beginning = match_beginning
        self.map_values = map_values

    def transform(self, c):
        """
        Transform the given data.

        Args:
            c (np.array): an array of type that can be cast to dtype `str`

        Returns:
            np.array of floats representing indices of matched patterns
        """
        nans = np.equal(c, None)
        c = c.astype(str)
        c[nans] = ""
        res = map_by_substring(
            c, self.patterns, self.case_sensitive, self.match_beginning,
            self.map_values)
        res[nans] = np.nan
        return res

    def __eq__(self, other):
        return super().__eq__(other) \
               and self.patterns == other.patterns \
               and self.case_sensitive == other.case_sensitive \
               and self.match_beginning == other.match_beginning \
               and self.map_values == other.map_values

    def __hash__(self):
        return hash((type(self), self.variable,
                     tuple(self.patterns),
                     self.case_sensitive, self.match_beginning,
                     self.map_values))


class ValueFromDiscreteSubstring(Lookup):
    """
    Transformation that computes a discrete variable from discrete variable by
    pattern matching.

    Say that the original attribute has values
    `["abcd", "aa", "bcd", "rabc", "x"]`. Given patterns
    `["abc", "a", "bc", ""]`, the values are mapped to the values of the new
    attribute with indices`[0, 1, 2, 0, 3]`.

    Args:
        variable (:obj:`~Orange.data.DiscreteVariable`): the original variable
        patterns (list of str): list of string patterns
        case_sensitive (bool, optional): if set to `True`, the match is case
            sensitive
        match_beginning (bool, optional): if set to `True`, the pattern must
            appear at the beginning of the string
    """
    def __init__(self, variable, patterns,
                 case_sensitive=False, match_beginning=False,
                 map_values=None):
        super().__init__(variable, [])
        self.case_sensitive = case_sensitive
        self.match_beginning = match_beginning
        self.map_values = map_values
        self.patterns = patterns  # Finally triggers computation of the lookup

    def __setattr__(self, key, value):
        """__setattr__ is overloaded to recompute the lookup table when the
        patterns, the original attribute or the flags change."""
        super().__setattr__(key, value)
        if hasattr(self, "patterns") and \
                key in ("case_sensitive", "match_beginning", "patterns",
                        "variable", "map_values"):
            self.lookup_table = map_by_substring(
                self.variable.values, self.patterns,
                self.case_sensitive, self.match_beginning, self.map_values)


def unique_in_order_mapping(a):
    """ Return
    - unique elements of the input list (in the order of appearance)
    - indices of the input list onto the returned uniques
    """
    u, idx, inv = np.unique(a, return_index=True, return_inverse=True)
    unique_in_order = u[np.argsort(idx)]
    mapping = np.argsort(idx)[inv]
    return unique_in_order, mapping


class OWCreateClass(widget.OWWidget):
    name = "Create Class"
    description = "Create class attribute from a string attribute"
    icon = "icons/CreateClass.svg"
    category = "Data"
    keywords = []

    class Inputs:
        data = Input("Data", Table)

    class Outputs:
        data = Output("Data", Table)

    want_main_area = False
    buttons_area_orientation = Qt.Vertical

    settingsHandler = DomainContextHandler()
    attribute = ContextSetting(None)
    class_name = ContextSetting("class")
    rules = ContextSetting({})
    match_beginning = ContextSetting(False)
    case_sensitive = ContextSetting(False)

    TRANSFORMERS = {StringVariable: ValueFromStringSubstring,
                    DiscreteVariable: ValueFromDiscreteSubstring}

    # Cached variables are used so that two instances of the widget with the
    # same settings will create the same variable. The usual `make` wouldn't
    # work here because variables with `compute_value` are not reused.
    cached_variables = {}

    class Warning(widget.OWWidget.Warning):
        no_nonnumeric_vars = Msg("Data contains only numeric variables.")

    class Error(widget.OWWidget.Error):
        class_name_duplicated = Msg("Class name duplicated.")
        class_name_empty = Msg("Class name should not be empty.")

    def __init__(self):
        super().__init__()
        self.data = None

        # The following lists are of the same length as self.active_rules

        #: list of pairs with counts of matches for each patter when the
        #     patterns are applied in order and when applied on the entire set,
        #     disregarding the preceding patterns
        self.match_counts = []

        #: list of list of QLineEdit: line edit pairs for each pattern
        self.line_edits = []
        #: list of QPushButton: list of remove buttons
        self.remove_buttons = []
        #: list of list of QLabel: pairs of labels with counts
        self.counts = []

        gui.lineEdit(
            self.controlArea, self, "class_name",
            orientation=Qt.Horizontal, box="New Class Name")

        variable_select_box = gui.vBox(self.controlArea, "Match by Substring")

        combo = gui.comboBox(
            variable_select_box, self, "attribute", label="From column:",
            orientation=Qt.Horizontal, searchable=True,
            callback=self.update_rules,
            model=DomainModel(valid_types=(StringVariable, DiscreteVariable)))
        # Don't use setSizePolicy keyword argument here: it applies to box,
        # not the combo
        combo.setSizePolicy(QSizePolicy.MinimumExpanding, QSizePolicy.Preferred)

        patternbox = gui.vBox(variable_select_box)
        #: QWidget: the box that contains the remove buttons, line edits and
        #    count labels. The lines are added and removed dynamically.
        self.rules_box = rules_box = QGridLayout()
        rules_box.setSpacing(4)
        rules_box.setContentsMargins(4, 4, 4, 4)
        self.rules_box.setColumnMinimumWidth(1, 70)
        self.rules_box.setColumnMinimumWidth(0, 10)
        self.rules_box.setColumnStretch(0, 1)
        self.rules_box.setColumnStretch(1, 1)
        self.rules_box.setColumnStretch(2, 100)
        rules_box.addWidget(QLabel("Name"), 0, 1)
        rules_box.addWidget(QLabel("Substring"), 0, 2)
        rules_box.addWidget(QLabel("Count"), 0, 3, 1, 2)
        self.update_rules()

        widget = QWidget(patternbox)
        widget.setLayout(rules_box)
        patternbox.layout().addWidget(widget)

        box = gui.hBox(patternbox)
        gui.rubber(box)
        gui.button(box, self, "+", callback=self.add_row,
                   autoDefault=False, width=34,
                   sizePolicy=(QSizePolicy.Maximum,
                               QSizePolicy.Maximum))

        optionsbox = gui.vBox(self.controlArea, "Options")
        gui.checkBox(
            optionsbox, self, "match_beginning", "Match only at the beginning",
            callback=self.options_changed)
        gui.checkBox(
            optionsbox, self, "case_sensitive", "Case sensitive",
            callback=self.options_changed)

        gui.rubber(self.controlArea)

        gui.button(self.buttonsArea, self, "Apply", callback=self.apply)

        # TODO: Resizing upon changing the number of rules does not work
        self.setSizePolicy(QSizePolicy.Preferred, QSizePolicy.Maximum)

    @property
    def active_rules(self):
        """
        Returns the class names and patterns corresponding to the currently
            selected attribute. If the attribute is not yet in the dictionary,
            set the default.
        """
        return self.rules.setdefault(self.attribute and self.attribute.name,
                                     [["", ""], ["", ""]])

    def rules_to_edits(self):
        """Fill the line edites with the rules from the current settings."""
        for editr, textr in zip(self.line_edits, self.active_rules):
            for edit, text in zip(editr, textr):
                edit.setText(text)

    @Inputs.data
    def set_data(self, data):
        """Input data signal handler."""
        self.closeContext()
        self.rules = {}
        self.data = data
        model = self.controls.attribute.model()
        model.set_domain(data.domain if data is not None else None)
        self.Warning.no_nonnumeric_vars(shown=data is not None and not model)
        if not model:
            self.attribute = None
            self.Outputs.data.send(None)
            return
        self.attribute = model[0]
        self.openContext(data)
        self.update_rules()
        self.apply()

    def update_rules(self):
        """Called when the rules are changed: adjust the number of lines in
        the form and fill them, update the counts. The widget does not have
        auto-apply."""
        self.adjust_n_rule_rows()
        self.rules_to_edits()
        self.update_counts()
        # TODO: Indicator that changes need to be applied

    def options_changed(self):
        self.update_counts()

    def adjust_n_rule_rows(self):
        """Add or remove lines if needed and fix the tab order."""
        def _add_line():
            self.line_edits.append([])
            n_lines = len(self.line_edits)
            for coli in range(1, 3):
                edit = QLineEdit()
                self.line_edits[-1].append(edit)
                self.rules_box.addWidget(edit, n_lines, coli)
                edit.textChanged.connect(self.sync_edit)
            button = gui.button(
                None, self, label='×', width=33,
                autoDefault=False, callback=self.remove_row,
                sizePolicy=(QSizePolicy.Maximum,
                            QSizePolicy.Maximum)
            )
            self.remove_buttons.append(button)
            self.rules_box.addWidget(button, n_lines, 0)
            self.counts.append([])
            for coli, kwargs in enumerate(
                    (dict(),
                     dict(styleSheet="color: gray"))):
                label = QLabel(alignment=Qt.AlignCenter, **kwargs)
                self.counts[-1].append(label)
                self.rules_box.addWidget(label, n_lines, 3 + coli)

        def _remove_line():
            for edit in self.line_edits.pop():
                edit.deleteLater()
            self.remove_buttons.pop().deleteLater()
            for label in self.counts.pop():
                label.deleteLater()

        def _fix_tab_order():
            prev = None
            for row, rule in zip(self.line_edits, self.active_rules):
                for col_idx, edit in enumerate(row):
                    edit.row, edit.col_idx = rule, col_idx
                    if prev is not None:
                        self.setTabOrder(prev, edit)
                    prev = edit

        n = len(self.active_rules)
        while n > len(self.line_edits):
            _add_line()
        while len(self.line_edits) > n:
            _remove_line()
        _fix_tab_order()

    def add_row(self):
        """Append a new row at the end."""
        self.active_rules.append(["", ""])
        self.adjust_n_rule_rows()
        self.update_counts()

    def remove_row(self):
        """Remove a row."""
        remove_idx = self.remove_buttons.index(self.sender())
        del self.active_rules[remove_idx]
        self.update_rules()
        self.update_counts()

    def sync_edit(self, text):
        """Handle changes in line edits: update the active rules and counts"""
        edit = self.sender()
        edit.row[edit.col_idx] = text
        self.update_counts()

    def class_labels(self):
        """Construct a list of class labels. Empty labels are replaced with
        C1, C2, C3. If C<n> already appears in the list of values given by
        the user, the labels start at C<n+1> instead.
        """
        largest_c = max((int(label[1:]) for label, _ in self.active_rules
                         if re.match("^C\\d+", label)),
                        default=0)
        class_count = count(largest_c + 1)
        return [label_edit.text() or "C{}".format(next(class_count))
                for label_edit, _ in self.line_edits]

    def update_counts(self):
        """Recompute and update the counts of matches."""
        def _matcher(strings, pattern):
            """Return indices of strings into patterns; consider case
            sensitivity and matching at the beginning. The given strings are
            assumed to be in lower case if match is case insensitive. Patterns
            are fixed on the fly."""
            if not self.case_sensitive:
                pattern = pattern.lower()
            indices = np.char.find(strings, pattern.strip())
            return indices == 0 if self.match_beginning else indices != -1

        def _lower_if_needed(strings):
            return strings if self.case_sensitive else np.char.lower(strings)

        def _string_counts():
            """
            Generate pairs of arrays for each rule until running out of data
            instances. np.sum over the two arrays in each pair gives the
            number of matches of the remaining instances (considering the
            order of patterns) and of the original data.

            For _string_counts, the arrays contain bool masks referring to the
            original data
            """
            nonlocal data
            data = data.astype(str)
            data = data[~np.char.equal(data, "")]
            data = _lower_if_needed(data)
            remaining = np.array(data)
            for _, pattern in self.active_rules:
                matching = _matcher(remaining, pattern)
                total_matching = _matcher(data, pattern)
                yield matching, total_matching
                remaining = remaining[~matching]
                if not remaining.size:
                    break

        def _discrete_counts():
            """
            Generate pairs similar to _string_counts, except that the arrays
            contain bin counts for the attribute's values matching the pattern.
            """
            attr_vals = np.array(attr.values)
            attr_vals = _lower_if_needed(attr_vals)
            bins = bincount(data, max_val=len(attr.values) - 1)[0]
            remaining = np.array(bins)
            for _, pattern in self.active_rules:
                matching = _matcher(attr_vals, pattern)
                yield remaining[matching], bins[matching]
                remaining[matching] = 0
                if not np.any(remaining):
                    break

        def _clear_labels():
            """Clear all labels"""
            for lab_matched, lab_total in self.counts:
                lab_matched.setText("")
                lab_total.setText("")

        def _set_labels():
            """Set the labels to show the counts"""
            for (n_matched, n_total), (lab_matched, lab_total), (lab, patt) in \
                    zip(self.match_counts, self.counts, self.active_rules):
                n_before = n_total - n_matched
                lab_matched.setText("{}".format(n_matched))
                if n_before and (lab or patt):
                    lab_total.setText("+ {}".format(n_before))
                    if n_matched:
                        tip = "{} of the {} matching instances are already " \
                              "covered above".format(n_before, n_total)
                    else:
                        tip = "All matching instances are already covered above"
                    lab_total.setToolTip(tip)
                    lab_matched.setToolTip(tip)

        def _set_placeholders():
            """Set placeholders for empty edit lines"""
            matches = [n for n, _ in self.match_counts] + \
                      [0] * len(self.line_edits)
            for n_matched, (_, patt) in zip(matches, self.line_edits):
                if not patt.text():
                    patt.setPlaceholderText(
                        "(remaining instances)" if n_matched else "(unused)")

            labels = self.class_labels()
            for label, (lab_edit, _) in zip(labels, self.line_edits):
                if not lab_edit.text():
                    lab_edit.setPlaceholderText(label)

        _clear_labels()
        attr = self.attribute
        if attr is None:
            return
        counters = {StringVariable: _string_counts,
                    DiscreteVariable: _discrete_counts}
        data = self.data.get_column_view(attr)[0]
        self.match_counts = [[int(np.sum(x)) for x in matches]
                             for matches in counters[type(attr)]()]
        _set_labels()
        _set_placeholders()

    def apply(self):
        """Output the transformed data."""
        self.Error.clear()
        self.class_name = self.class_name.strip()
        if not self.attribute:
            self.Outputs.data.send(None)
            return
        domain = self.data.domain
        if not self.class_name:
            self.Error.class_name_empty()
        if self.class_name in domain:
            self.Error.class_name_duplicated()
        if not self.class_name or self.class_name in domain:
            self.Outputs.data.send(None)
            return
        new_class = self._create_variable()
        new_domain = Domain(
            domain.attributes, new_class, domain.metas + domain.class_vars)
        new_data = self.data.transform(new_domain)
        self.Outputs.data.send(new_data)

    def _create_variable(self):
        rules = self.active_rules
        # Transposition + stripping
        valid_rules = [label or pattern or n_matches
                       for (label, pattern), n_matches in
                       zip(rules, self.match_counts)]
        patterns = tuple(
            pattern for (_, pattern), valid in zip(rules, valid_rules) if valid)
        names = tuple(
            name for name, valid in zip(self.class_labels(), valid_rules)
            if valid)
        transformer = self.TRANSFORMERS[type(self.attribute)]

        # join patters with the same names
        names, map_values = unique_in_order_mapping(names)
        names = tuple(str(a) for a in names)
        map_values = tuple(map_values)

        var_key = (self.attribute, self.class_name, names,
                   patterns, self.case_sensitive, self.match_beginning, map_values)
        if var_key in self.cached_variables:
            return self.cached_variables[var_key]

        compute_value = transformer(
            self.attribute, patterns, self.case_sensitive, self.match_beginning,
            map_values)
        new_var = DiscreteVariable(
            self.class_name, names, compute_value=compute_value)
        self.cached_variables[var_key] = new_var
        return new_var

    def send_report(self):
        # Pylint gives false positives: these functions are always called from
        # within the loop
        # pylint: disable=undefined-loop-variable
        def _cond_part():
            rule = "<b>{}</b> ".format(class_name)
            if patt:
                rule += "if <b>{}</b> contains <b>{}</b>".format(
                    self.attribute.name, patt)
            else:
                rule += "otherwise"
            return rule

        def _count_part():
            if not n_matched:
                return "all {} matching instances are already covered " \
                       "above".format(n_total)
            elif n_matched < n_total and patt:
                return "{} matching instances (+ {} that are already " \
                       "covered above".format(n_matched, n_total - n_matched)
            else:
                return "{} matching instances".format(n_matched)

        if not self.attribute:
            return
        self.report_items("Input", [("Source attribute", self.attribute.name)])
        output = ""
        names = self.class_labels()
        for (n_matched, n_total), class_name, (lab, patt) in \
                zip(self.match_counts, names, self.active_rules):
            if lab or patt or n_total:
                output += "<li>{}; {}</li>".format(_cond_part(), _count_part())
        if output:
            self.report_items("Output", [("Class name", self.class_name)])
            self.report_raw("<ol>{}</ol>".format(output))


if __name__ == "__main__":  # pragma: no cover
    WidgetPreview(OWCreateClass).run(Table("zoo"))

```
--- 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