{
    "file_diffs": [
        {
            "old_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\n\nimport sys\nimport math\nimport unittest\nimport pickle\nimport pkgutil\nfrom datetime import datetime, timezone\n\nfrom io import StringIO\n\nimport numpy as np\n\nfrom Orange.data import Variable, ContinuousVariable, DiscreteVariable, \\\n    StringVariable, TimeVariable, Unknown, Value\nfrom Orange.data.io import CSVReader\nfrom Orange.tests.base import create_pickling_tests\n\n\ndef is_on_path(name):\n    \"\"\"\n    Is a top level package/module found on sys.path\n\n    Parameters\n    ----------\n    name : str\n        Top level module/package name\n\n    Returns\n    -------\n    found : bool\n    \"\"\"\n    for loader, name_, ispkg in pkgutil.iter_modules(sys.path):\n        if name == name_:\n            return True\n    else:\n        return False\n\n\n# noinspection PyPep8Naming,PyUnresolvedReferences\nclass VariableTest:\n    def setUp(self):\n        self.varcls._clear_all_caches()\n\n    def test_dont_pickle_anonymous_variables(self):\n        self.assertRaises(pickle.PickleError, pickle.dumps, self.varcls())\n\n    def test_dont_store_anonymous_variables(self):\n        self.varcls()\n        self.assertEqual(len(self.varcls._all_vars), 0)\n\n    def test_dont_make_anonymous_variables(self):\n        self.assertRaises(ValueError, self.varcls.make, \"\")\n\n    def test_copy_copies_attributes(self):\n        var = self.varcls()\n        var.attributes[\"a\"] = \"b\"\n        var2 = var.copy(compute_value=None)\n        self.assertIn(\"a\", var2.attributes)\n        self.assertIsInstance(var2, type(var))\n\n        var2.attributes[\"a\"] = \"c\"\n        # Attributes of original value should not change\n        self.assertEqual(var.attributes[\"a\"], \"b\")\n\n\nclass TestVariable(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.var = Variable(\"x\")\n\n    def test_name(self):\n        self.assertEqual(repr(self.var), \"Variable(name='x')\")\n\n    def test_to_val(self):\n        string_var = StringVariable(\"x\")\n        self.assertEqual(string_var.to_val(\"foo\"), \"foo\")\n        self.assertEqual(string_var.to_val(42), \"42\")\n\n        cont_var = ContinuousVariable(\"x\")\n        self.assertTrue(math.isnan(cont_var.to_val(\"?\")))\n        self.assertTrue(math.isnan(Unknown))\n\n        var = Variable(\"x\")\n        self.assertEqual(var.to_val(\"x\"), \"x\")\n\n    def test_repr_is_abstract(self):\n        self.assertRaises(RuntimeError, self.var.repr_val, None)\n\n    def test_properties(self):\n        a = ContinuousVariable()\n        self.assertTrue(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = DiscreteVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertTrue(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = StringVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertTrue(a.is_string)\n        self.assertFalse(a.is_primitive())\n\n    def test_properties_as_predicates(self):\n        a = ContinuousVariable()\n        self.assertTrue(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertFalse(Variable.is_string(a))\n        self.assertTrue(Variable.is_primitive(a))\n\n        a = StringVariable()\n        self.assertFalse(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertTrue(Variable.is_string(a))\n        self.assertFalse(Variable.is_primitive(a))\n\n    def test_strange_eq(self):\n        a = ContinuousVariable()\n        b = ContinuousVariable()\n        self.assertEqual(a, a)\n        self.assertNotEqual(a, b)\n        self.assertNotEqual(a, \"somestring\")\n        # It the next assert ever fails (randomly) blame @janezd\n        self.assertNotEqual(hash(a), hash(b))\n\n\ndef variabletest(varcls):\n    def decorate(cls):\n        return type(cls.__name__, (cls, unittest.TestCase), {'varcls': varcls})\n    return decorate\n\n\n@variabletest(DiscreteVariable)\nclass TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n\n@variabletest(ContinuousVariable)\nclass TestContinuousVariable(VariableTest):\n    def test_make(self):\n        ContinuousVariable._clear_cache()\n        age1 = ContinuousVariable.make(\"age\")\n        age2 = ContinuousVariable.make(\"age\")\n        age3 = ContinuousVariable(\"age\")\n        self.assertEqual(age1, age2)\n        self.assertNotEqual(age1, age3)\n\n    def test_decimals(self):\n        a = ContinuousVariable(\"a\", 4)\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n        self.assertEqual(a.str_val(Unknown), \"?\")\n\n    def test_adjust_decimals(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.str_val(4.654321), \"4.654\")\n        a.val_from_str_add(\"5\")\n        self.assertEqual(a.str_val(4.654321), \"5\")\n        a.val_from_str_add(\"  5.12    \")\n        self.assertEqual(a.str_val(4.654321), \"4.65\")\n        a.val_from_str_add(\"5.1234\")\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n\n    def test_colors(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.colors, ((0, 0, 255), (255, 255, 0), False))\n        self.assertIs(a.colors, a._colors)\n\n        a = ContinuousVariable(\"a\")\n        a.attributes[\"colors\"] = ['#010203', '#040506', True]\n        self.assertEqual(a.colors, ((1, 2, 3), (4, 5, 6), True))\n\n        a.colors = ((3, 2, 1), (6, 5, 4), True)\n        self.assertEqual(a.colors, ((3, 2, 1), (6, 5, 4), True))\n\n\n@variabletest(StringVariable)\nclass TestStringVariable(VariableTest):\n    def test_val(self):\n        a = StringVariable(\"a\")\n        self.assertEqual(a.to_val(None), \"\")\n        self.assertEqual(a.str_val(\"\"), \"?\")\n        self.assertEqual(a.str_val(Value(a, \"\")), \"?\")\n        self.assertEqual(a.repr_val(Value(a, \"foo\")), '\"foo\"')\n\n\n@variabletest(TimeVariable)\nclass TestTimeVariable(VariableTest):\n    TESTS = [\n        # in str, UTC timestamp, out str (in UTC)\n        ('2015-10-12 14:13:11.01+0200', 1444651991.01, '2015-10-12 14:13:11.010000+0200'),\n        ('2015-10-12T14:13:11.81+0200', 1444651991.81, '2015-10-12 14:13:11.810000+0200'),\n        ('2015-10-12 14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12T14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12 14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12T14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012T141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12 14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12T14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12 14:13', 1444659180, '2015-10-12 14:13:00'),\n        ('20151012T141311', 1444659191, '2015-10-12 14:13:11'),\n        ('20151012141311', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12', 1444608000, '2015-10-12'),\n        ('20151012', 1444608000, '2015-10-12'),\n        ('2015-285', 1444608000, '2015-10-12'),\n        ('2015-10', 1443657600, '2015-10-01'),\n        ('2015', 1420070400, '2015-01-01'),\n        ('01:01:01.01', 3661.01, '01:01:01.010000'),\n        ('010101.01', 3661.01, '01:01:01.010000'),\n        ('01:01:01', 3661, '01:01:01'),\n        ('01:01', 3660, '01:01:00'),\n        ('1970-01-01 00:00:00', 0, '1970-01-01 00:00:00'),\n        ('1969-12-31 23:59:59', -1, '1969-12-31 23:59:59'),\n        ('1969-12-31 23:59:58.9', -1.1, '1969-12-31 23:59:58.900000'),\n        ('1900-01-01', -2208988800, '1900-01-01'),\n        ('nan', np.nan, '?'),\n        ('1444651991.81', 1444651991.81, '2015-10-12 12:13:11.810000'),\n    ]\n\n    def test_parse_repr(self):\n        for datestr, timestamp, outstr in self.TESTS:\n            var = TimeVariable('time')\n            ts = var.to_val(datestr)  # calls parse for strings\n            if not np.isnan(ts):\n                self.assertEqual(ts, timestamp, msg=datestr)\n            self.assertEqual(var.repr_val(ts), outstr, msg=datestr)\n\n    def test_parse_utc(self):\n        var = TimeVariable('time')\n        datestr, offset = '2015-10-18 22:48:20', '+0200'\n        ts1 = var.parse(datestr + offset)\n        self.assertEqual(var.repr_val(ts1), datestr + offset)\n        # Once a value is without a TZ, all the values lose it\n        ts2 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts2), datestr)\n        self.assertEqual(var.repr_val(ts1), '2015-10-18 20:48:20')\n\n    def test_parse_timestamp(self):\n        var = TimeVariable(\"time\")\n        datestr = str(datetime(2016, 6, 14, 23, 8, tzinfo=timezone.utc).timestamp())\n        ts1 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts1), '2016-06-14 23:08:00')\n\n    def test_parse_invalid(self):\n        var = TimeVariable('var')\n        with self.assertRaises(ValueError):\n            var.parse('123')\n\n    def test_have_date(self):\n        var = TimeVariable('time')\n        ts = var.parse('1937-08-02')  # parse date\n        self.assertEqual(var.repr_val(ts), '1937-08-02')\n        ts = var.parse('16:20')  # parse time\n        # observe have datetime\n        self.assertEqual(var.repr_val(ts), '1970-01-01 16:20:00')\n\n    def test_no_date_no_time(self):\n        self.assertEqual(TimeVariable('relative time').repr_val(1.6), '1.6')\n\n    def test_readwrite_timevariable(self):\n        output_csv = StringIO()\n        input_csv = StringIO(\"\"\"\\\nDate,Feature\ntime,continuous\n,\n1920-12-12,1.0\n1920-12-13,3.0\n1920-12-14,5.5\n\"\"\")\n        for stream in (output_csv, input_csv):\n            stream.close = lambda: None  # HACK: Prevent closing of streams\n\n        table = CSVReader(input_csv).read()\n        self.assertIsInstance(table.domain['Date'], TimeVariable)\n        self.assertEqual(table[0, 'Date'], '1920-12-12')\n        # Dates before 1970 are negative\n        self.assertTrue(all(inst['Date'] < 0 for inst in table))\n\n        CSVReader.write_file(output_csv, table)\n        self.assertEqual(input_csv.getvalue().splitlines(),\n                         output_csv.getvalue().splitlines())\n\n    def test_repr_value(self):\n        # https://github.com/biolab/orange3/pull/1760\n        var = TimeVariable('time')\n        self.assertEqual(var.repr_val(Value(var, 416.3)), '416.3')\n\n    def test_have_date_have_time_in_construct(self):\n        \"\"\"Test if have_time and have_date is correctly set\"\"\"\n        var = TimeVariable('time', have_date=1)\n        self.assertTrue(var.have_date)\n        self.assertFalse(var.have_time)\n\n\nPickleContinuousVariable = create_pickling_tests(\n    \"PickleContinuousVariable\",\n    (\"with_name\", lambda: ContinuousVariable(name=\"Feature 0\")),\n)\n\nPickleDiscreteVariable = create_pickling_tests(\n    \"PickleDiscreteVariable\",\n    (\"with_name\", lambda: DiscreteVariable(name=\"Feature 0\")),\n    (\"with_str_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                values=[\"F\", \"M\"])),\n    (\"ordered\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                         values=[\"F\", \"M\"],\n                                         ordered=True)),\n    (\"with_base_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                 values=[\"F\", \"M\"],\n                                                 base_value=0))\n)\n\n\nPickleStringVariable = create_pickling_tests(\n    \"PickleStringVariable\",\n    (\"with_name\", lambda: StringVariable(name=\"Feature 0\"))\n)\n\n\nclass VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp)\n        self.assertIs(abc1p.master, abcp)\n        self.assertIs(abc2p.master, abcp)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")\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\n\nimport sys\nimport math\nimport unittest\nimport pickle\nimport pkgutil\nfrom datetime import datetime, timezone\n\nfrom io import StringIO\n\nimport numpy as np\n\nfrom Orange.data import Variable, ContinuousVariable, DiscreteVariable, \\\n    StringVariable, TimeVariable, Unknown, Value\nfrom Orange.data.io import CSVReader\nfrom Orange.tests.base import create_pickling_tests\n\n\ndef is_on_path(name):\n    \"\"\"\n    Is a top level package/module found on sys.path\n\n    Parameters\n    ----------\n    name : str\n        Top level module/package name\n\n    Returns\n    -------\n    found : bool\n    \"\"\"\n    for loader, name_, ispkg in pkgutil.iter_modules(sys.path):\n        if name == name_:\n            return True\n    else:\n        return False\n\n\n# noinspection PyPep8Naming,PyUnresolvedReferences\nclass VariableTest:\n    def setUp(self):\n        self.varcls._clear_all_caches()\n\n    def test_dont_pickle_anonymous_variables(self):\n        self.assertRaises(pickle.PickleError, pickle.dumps, self.varcls())\n\n    def test_dont_store_anonymous_variables(self):\n        self.varcls()\n        self.assertEqual(len(self.varcls._all_vars), 0)\n\n    def test_dont_make_anonymous_variables(self):\n        self.assertRaises(ValueError, self.varcls.make, \"\")\n\n    def test_copy_copies_attributes(self):\n        var = self.varcls()\n        var.attributes[\"a\"] = \"b\"\n        var2 = var.copy(compute_value=None)\n        self.assertIn(\"a\", var2.attributes)\n        self.assertIsInstance(var2, type(var))\n\n        var2.attributes[\"a\"] = \"c\"\n        # Attributes of original value should not change\n        self.assertEqual(var.attributes[\"a\"], \"b\")\n\n\nclass TestVariable(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.var = Variable(\"x\")\n\n    def test_name(self):\n        self.assertEqual(repr(self.var), \"Variable(name='x')\")\n\n    def test_to_val(self):\n        string_var = StringVariable(\"x\")\n        self.assertEqual(string_var.to_val(\"foo\"), \"foo\")\n        self.assertEqual(string_var.to_val(42), \"42\")\n\n        cont_var = ContinuousVariable(\"x\")\n        self.assertTrue(math.isnan(cont_var.to_val(\"?\")))\n        self.assertTrue(math.isnan(Unknown))\n\n        var = Variable(\"x\")\n        self.assertEqual(var.to_val(\"x\"), \"x\")\n\n    def test_repr_is_abstract(self):\n        self.assertRaises(RuntimeError, self.var.repr_val, None)\n\n    def test_properties(self):\n        a = ContinuousVariable()\n        self.assertTrue(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = DiscreteVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertTrue(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = StringVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertTrue(a.is_string)\n        self.assertFalse(a.is_primitive())\n\n    def test_properties_as_predicates(self):\n        a = ContinuousVariable()\n        self.assertTrue(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertFalse(Variable.is_string(a))\n        self.assertTrue(Variable.is_primitive(a))\n\n        a = StringVariable()\n        self.assertFalse(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertTrue(Variable.is_string(a))\n        self.assertFalse(Variable.is_primitive(a))\n\n    def test_strange_eq(self):\n        a = ContinuousVariable()\n        b = ContinuousVariable()\n        self.assertEqual(a, a)\n        self.assertNotEqual(a, b)\n        self.assertNotEqual(a, \"somestring\")\n        # It the next assert ever fails (randomly) blame @janezd\n        self.assertNotEqual(hash(a), hash(b))\n\n\ndef variabletest(varcls):\n    def decorate(cls):\n        return type(cls.__name__, (cls, unittest.TestCase), {'varcls': varcls})\n    return decorate\n\n\n@variabletest(DiscreteVariable)\nclass TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n        self.assertSequenceEqual(d2.values, d2_values)\n        self.assertSequenceEqual(d1c.values, d1.values)\n        s = pickle.dumps(d2)\n        DiscreteVariable._clear_all_caches()  # [comment redacted]\n        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])\n        d2 = pickle.loads(s)\n        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])\n\n\n@variabletest(ContinuousVariable)\nclass TestContinuousVariable(VariableTest):\n    def test_make(self):\n        ContinuousVariable._clear_cache()\n        age1 = ContinuousVariable.make(\"age\")\n        age2 = ContinuousVariable.make(\"age\")\n        age3 = ContinuousVariable(\"age\")\n        self.assertEqual(age1, age2)\n        self.assertNotEqual(age1, age3)\n\n    def test_decimals(self):\n        a = ContinuousVariable(\"a\", 4)\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n        self.assertEqual(a.str_val(Unknown), \"?\")\n\n    def test_adjust_decimals(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.str_val(4.654321), \"4.654\")\n        a.val_from_str_add(\"5\")\n        self.assertEqual(a.str_val(4.654321), \"5\")\n        a.val_from_str_add(\"  5.12    \")\n        self.assertEqual(a.str_val(4.654321), \"4.65\")\n        a.val_from_str_add(\"5.1234\")\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n\n    def test_colors(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.colors, ((0, 0, 255), (255, 255, 0), False))\n        self.assertIs(a.colors, a._colors)\n\n        a = ContinuousVariable(\"a\")\n        a.attributes[\"colors\"] = ['#010203', '#040506', True]\n        self.assertEqual(a.colors, ((1, 2, 3), (4, 5, 6), True))\n\n        a.colors = ((3, 2, 1), (6, 5, 4), True)\n        self.assertEqual(a.colors, ((3, 2, 1), (6, 5, 4), True))\n\n\n@variabletest(StringVariable)\nclass TestStringVariable(VariableTest):\n    def test_val(self):\n        a = StringVariable(\"a\")\n        self.assertEqual(a.to_val(None), \"\")\n        self.assertEqual(a.str_val(\"\"), \"?\")\n        self.assertEqual(a.str_val(Value(a, \"\")), \"?\")\n        self.assertEqual(a.repr_val(Value(a, \"foo\")), '\"foo\"')\n\n\n@variabletest(TimeVariable)\nclass TestTimeVariable(VariableTest):\n    TESTS = [\n        # in str, UTC timestamp, out str (in UTC)\n        ('2015-10-12 14:13:11.01+0200', 1444651991.01, '2015-10-12 14:13:11.010000+0200'),\n        ('2015-10-12T14:13:11.81+0200', 1444651991.81, '2015-10-12 14:13:11.810000+0200'),\n        ('2015-10-12 14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12T14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12 14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12T14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012T141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12 14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12T14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12 14:13', 1444659180, '2015-10-12 14:13:00'),\n        ('20151012T141311', 1444659191, '2015-10-12 14:13:11'),\n        ('20151012141311', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12', 1444608000, '2015-10-12'),\n        ('20151012', 1444608000, '2015-10-12'),\n        ('2015-285', 1444608000, '2015-10-12'),\n        ('2015-10', 1443657600, '2015-10-01'),\n        ('2015', 1420070400, '2015-01-01'),\n        ('01:01:01.01', 3661.01, '01:01:01.010000'),\n        ('010101.01', 3661.01, '01:01:01.010000'),\n        ('01:01:01', 3661, '01:01:01'),\n        ('01:01', 3660, '01:01:00'),\n        ('1970-01-01 00:00:00', 0, '1970-01-01 00:00:00'),\n        ('1969-12-31 23:59:59', -1, '1969-12-31 23:59:59'),\n        ('1969-12-31 23:59:58.9', -1.1, '1969-12-31 23:59:58.900000'),\n        ('1900-01-01', -2208988800, '1900-01-01'),\n        ('nan', np.nan, '?'),\n        ('1444651991.81', 1444651991.81, '2015-10-12 12:13:11.810000'),\n    ]\n\n    def test_parse_repr(self):\n        for datestr, timestamp, outstr in self.TESTS:\n            var = TimeVariable('time')\n            ts = var.to_val(datestr)  # calls parse for strings\n            if not np.isnan(ts):\n                self.assertEqual(ts, timestamp, msg=datestr)\n            self.assertEqual(var.repr_val(ts), outstr, msg=datestr)\n\n    def test_parse_utc(self):\n        var = TimeVariable('time')\n        datestr, offset = '2015-10-18 22:48:20', '+0200'\n        ts1 = var.parse(datestr + offset)\n        self.assertEqual(var.repr_val(ts1), datestr + offset)\n        # Once a value is without a TZ, all the values lose it\n        ts2 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts2), datestr)\n        self.assertEqual(var.repr_val(ts1), '2015-10-18 20:48:20')\n\n    def test_parse_timestamp(self):\n        var = TimeVariable(\"time\")\n        datestr = str(datetime(2016, 6, 14, 23, 8, tzinfo=timezone.utc).timestamp())\n        ts1 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts1), '2016-06-14 23:08:00')\n\n    def test_parse_invalid(self):\n        var = TimeVariable('var')\n        with self.assertRaises(ValueError):\n            var.parse('123')\n\n    def test_have_date(self):\n        var = TimeVariable('time')\n        ts = var.parse('1937-08-02')  # parse date\n        self.assertEqual(var.repr_val(ts), '1937-08-02')\n        ts = var.parse('16:20')  # parse time\n        # observe have datetime\n        self.assertEqual(var.repr_val(ts), '1970-01-01 16:20:00')\n\n    def test_no_date_no_time(self):\n        self.assertEqual(TimeVariable('relative time').repr_val(1.6), '1.6')\n\n    def test_readwrite_timevariable(self):\n        output_csv = StringIO()\n        input_csv = StringIO(\"\"\"\\\nDate,Feature\ntime,continuous\n,\n1920-12-12,1.0\n1920-12-13,3.0\n1920-12-14,5.5\n\"\"\")\n        for stream in (output_csv, input_csv):\n            stream.close = lambda: None  # HACK: Prevent closing of streams\n\n        table = CSVReader(input_csv).read()\n        self.assertIsInstance(table.domain['Date'], TimeVariable)\n        self.assertEqual(table[0, 'Date'], '1920-12-12')\n        # Dates before 1970 are negative\n        self.assertTrue(all(inst['Date'] < 0 for inst in table))\n\n        CSVReader.write_file(output_csv, table)\n        self.assertEqual(input_csv.getvalue().splitlines(),\n                         output_csv.getvalue().splitlines())\n\n    def test_repr_value(self):\n        # https://github.com/biolab/orange3/pull/1760\n        var = TimeVariable('time')\n        self.assertEqual(var.repr_val(Value(var, 416.3)), '416.3')\n\n    def test_have_date_have_time_in_construct(self):\n        \"\"\"Test if have_time and have_date is correctly set\"\"\"\n        var = TimeVariable('time', have_date=1)\n        self.assertTrue(var.have_date)\n        self.assertFalse(var.have_time)\n\n\nPickleContinuousVariable = create_pickling_tests(\n    \"PickleContinuousVariable\",\n    (\"with_name\", lambda: ContinuousVariable(name=\"Feature 0\")),\n)\n\nPickleDiscreteVariable = create_pickling_tests(\n    \"PickleDiscreteVariable\",\n    (\"with_name\", lambda: DiscreteVariable(name=\"Feature 0\")),\n    (\"with_str_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                values=[\"F\", \"M\"])),\n    (\"ordered\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                         values=[\"F\", \"M\"],\n                                         ordered=True)),\n    (\"with_base_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                 values=[\"F\", \"M\"],\n                                                 base_value=0))\n)\n\n\nPickleStringVariable = create_pickling_tests(\n    \"PickleStringVariable\",\n    (\"with_name\", lambda: StringVariable(name=\"Feature 0\"))\n)\n\n\nclass VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp.master)\n        self.assertIs(abc1p.master, abcp.master)\n        self.assertIs(abc2p.master, abcp.master)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")\n\n\nif __name__ == \"__main__\":\n    unittest.main()\n",
            "header": {
                "file": {
                    "path": "Orange/data/tests/test_variable.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "59af00418",
                "new_commit_hash": "4a3c21a73",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/data/tests/test_variable.py"
            },
            "plus_file": {
                "path": "b/Orange/data/tests/test_variable.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 266,
                            "length": 6
                        },
                        "new_range": {
                            "start": 266,
                            "length": 23
                        },
                        "section": "class TestDiscreteVariable(VariableTest):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertRaises(TypeError, a.add_value, 42)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_unpickle(self):",
                                "type": "added"
                            },
                            {
                                "content": "        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])",
                                "type": "added"
                            },
                            {
                                "content": "        s = pickle.dumps(d1)",
                                "type": "added"
                            },
                            {
                                "content": "        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])",
                                "type": "added"
                            },
                            {
                                "content": "        d2_values = tuple(d2.values)",
                                "type": "added"
                            },
                            {
                                "content": "        d1c = pickle.loads(s)",
                                "type": "added"
                            },
                            {
                                "content": "        # See: gh-3238",
                                "type": "added"
                            },
                            {
                                "content": "        # The unpickle reconstruction picks an existing variable (d2), on which",
                                "type": "added"
                            },
                            {
                                "content": "        # __setstate__ or __dict__.update is called",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertSequenceEqual(d2.values, d2_values)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertSequenceEqual(d1c.values, d1.values)",
                                "type": "added"
                            },
                            {
                                "content": "        s = pickle.dumps(d2)",
                                "type": "added"
                            },
                            {
                                "content": "        DiscreteVariable._clear_all_caches()  # [comment redacted]",
                                "type": "added"
                            },
                            {
                                "content": "        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])",
                                "type": "added"
                            },
                            {
                                "content": "        d2 = pickle.loads(s)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "@variabletest(ContinuousVariable)",
                                "type": "context"
                            },
                            {
                                "content": "class TestContinuousVariable(VariableTest):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_variable.py",
                            "type": "class",
                            "name": "TestDiscreteVariable",
                            "content": "class TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n        self.assertSequenceEqual(d2.values, d2_values)\n        self.assertSequenceEqual(d1c.values, d1.values)\n        s = pickle.dumps(d2)\n        DiscreteVariable._clear_all_caches()  # [comment redacted]\n        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])\n        d2 = pickle.loads(s)\n        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 140,
                            "end_lineno": 284,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "Orange/data/tests/test_variable.py",
                            "type": "method",
                            "name": "TestDiscreteVariable.test_unpickle",
                            "content": "class TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n        self.assertSequenceEqual(d2.values, d2_values)\n        self.assertSequenceEqual(d1c.values, d1.values)\n        s = pickle.dumps(d2)\n        DiscreteVariable._clear_all_caches()  # [comment redacted]\n        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])\n        d2 = pickle.loads(s)\n        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 269,
                            "end_lineno": 284,
                            "parent": {
                                "file_name": "Orange/data/tests/test_variable.py",
                                "type": "class",
                                "name": "TestDiscreteVariable",
                                "content": "class TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n        self.assertSequenceEqual(d2.values, d2_values)\n        self.assertSequenceEqual(d1c.values, d1.values)\n        s = pickle.dumps(d2)\n        DiscreteVariable._clear_all_caches()  # [comment redacted]\n        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])\n        d2 = pickle.loads(s)\n        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 140,
                                "end_lineno": 284,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 474,
                            "length": 9
                        },
                        "new_range": {
                            "start": 491,
                            "length": 9
                        },
                        "section": "class VariableTestMakeProxy(unittest.TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        self.assertEqual(abc1p, abc)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertIs(abcp.master, abcp)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertIs(abc1p.master, abcp)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertIs(abc2p.master, abcp)",
                                "type": "deleted"
                            },
                            {
                                "content": "        self.assertIs(abcp.master, abcp.master)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertIs(abc1p.master, abcp.master)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertIs(abc2p.master, abcp.master)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertEqual(abcp, abc1p)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(abcp, abc2p)",
                                "type": "context"
                            },
                            {
                                "content": "        self.assertEqual(abc1p, abc2p)",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/tests/test_variable.py",
                            "type": "class",
                            "name": "VariableTestMakeProxy",
                            "content": "class VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp)\n        self.assertIs(abc1p.master, abcp)\n        self.assertIs(abc2p.master, abcp)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 452,
                            "end_lineno": 523,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/data/tests/test_variable.py",
                            "type": "method",
                            "name": "VariableTestMakeProxy.test_make_proxy_disc",
                            "content": "class VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp)\n        self.assertIs(abc1p.master, abcp)\n        self.assertIs(abc2p.master, abcp)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 456,
                            "end_lineno": 482,
                            "parent": {
                                "file_name": "Orange/data/tests/test_variable.py",
                                "type": "class",
                                "name": "VariableTestMakeProxy",
                                "content": "class VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp)\n        self.assertIs(abc1p.master, abcp)\n        self.assertIs(abc2p.master, abcp)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 452,
                                "end_lineno": 523,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "import collections\nimport re\n\nfrom datetime import datetime, timedelta, timezone\nfrom numbers import Number, Real, Integral\nfrom math import isnan, floor\nfrom pickle import PickleError\n\nimport numpy as np\n\nfrom Orange.data import _variable\nfrom Orange.util import Registry, color_to_hex, hex_to_color, Reprable\n\n__all__ = [\"Unknown\", \"MISSING_VALUES\", \"make_variable\", \"is_discrete_values\",\n           \"Value\", \"Variable\", \"ContinuousVariable\", \"DiscreteVariable\",\n           \"StringVariable\", \"TimeVariable\"]\n\n\n# For storing unknowns\nUnknown = ValueUnknown = float(\"nan\")\n# For checking for unknowns\nMISSING_VALUES = {np.nan, \"?\", \"nan\", \".\", \"\", \"NA\", \"~\", None}\n\nDISCRETE_MAX_VALUES = 3  # == 2 + nan\n\n\ndef make_variable(cls, compute_value, *args):\n    if compute_value is not None:\n        return cls(*args, compute_value=compute_value)\n    return cls.make(*args)\n\n\ndef is_discrete_values(values):\n    \"\"\"\n    Return set of uniques if `values` is an iterable of discrete values\n    else False if non-discrete, or None if indeterminate.\n\n    Note\n    ----\n    Assumes consistent type of items of `values`.\n    \"\"\"\n    if not len(values):\n        return None\n    # If the first few values are, or can be converted to, floats,\n    # the type is numeric\n    try:\n        isinstance(next(iter(values)), Number) or \\\n        [float(v) for _, v in zip(range(min(3, len(values))), values)]\n    except ValueError:\n        is_numeric = False\n        max_values = int(round(len(values)**.7))\n    else:\n        is_numeric = True\n        max_values = DISCRETE_MAX_VALUES\n\n    # If more than max values => not discrete\n    unique = set()\n    for i in values:\n        unique.add(i)\n        if len(unique) > max_values:\n            return False\n\n    # Strip NaN from unique\n    unique = {i for i in unique\n              if (not i in MISSING_VALUES and\n                  not (isinstance(i, Number) and np.isnan(i)))}\n\n    # All NaNs => indeterminate\n    if not unique:\n        return None\n\n    # Strings with |values| < max_unique\n    if not is_numeric:\n        return unique\n\n    # Handle numbers\n    try:\n        unique_float = set(map(float, unique))\n    except ValueError:\n        # Converting all the values to floats resulted in an error.\n        # Since the values have enough unique values, they are probably\n        # string values and discrete.\n        return unique\n\n    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete\n    return (not (unique_float - {0, 1}) or\n            not (unique_float - {1, 2})) and unique\n\n\nclass Value(float):\n    \"\"\"\n    The class representing a value. The class is not used to store values but\n    only to return them in contexts in which we want the value to be accompanied\n    with the descriptor, for instance to print the symbolic value of discrete\n    variables.\n\n    The class is derived from `float`, with an additional attribute `variable`\n    which holds the descriptor of type :obj:`Orange.data.Variable`. If the\n    value continuous or discrete, it is stored as a float. Other types of\n    values, like strings, are stored in the attribute `value`.\n\n    The class overloads the methods for printing out the value:\n    `variable.repr_val` and `variable.str_val` are used to get a suitable\n    representation of the value.\n\n    Equivalence operator is overloaded as follows:\n\n    - unknown values are equal; if one value is unknown and the other is not,\n      they are different;\n\n    - if the value is compared with the string, the value is converted to a\n      string using `variable.str_val` and the two strings are compared\n\n    - if the value is stored in attribute `value`, it is compared with the\n      given other value\n\n    - otherwise, the inherited comparison operator for `float` is called.\n\n    Finally, value defines a hash, so values can be put in sets and appear as\n    keys in dictionaries.\n\n    .. attribute:: variable (:obj:`Orange.data.Variable`)\n\n        Descriptor; used for printing out and for comparing with strings\n\n    .. attribute:: value\n\n        Value; the value can be of arbitrary type and is used only for variables\n        that are neither discrete nor continuous. If `value` is `None`, the\n        derived `float` value is used.\n    \"\"\"\n    __slots__ = \"variable\", \"_value\"\n\n    def __new__(cls, variable, value=Unknown):\n        \"\"\"\n        Construct a new instance of Value with the given descriptor and value.\n        If the argument `value` can be converted to float, it is stored as\n        `float` and the attribute `value` is set to `None`. Otherwise, the\n        inherited float is set to `Unknown` and the value is held by the\n        attribute `value`.\n\n        :param variable: descriptor\n        :type variable: Orange.data.Variable\n        :param value: value\n        \"\"\"\n        if variable.is_primitive():\n            self = super().__new__(cls, value)\n            self.variable = variable\n            self._value = None\n        else:\n            isunknown = value == variable.Unknown\n            self = super().__new__(\n                cls, np.nan if isunknown else np.finfo(float).min)\n            self.variable = variable\n            self._value = value\n        return self\n\n    def __init__(self, _, __=Unknown):\n        pass\n\n    def __repr__(self):\n        return \"Value('%s', %s)\" % (self.variable.name,\n                                    self.variable.repr_val(self))\n\n    def __str__(self):\n        return self.variable.str_val(self)\n\n    def __eq__(self, other):\n        if isinstance(self, Real) and isnan(self):\n            return (isinstance(other, Real) and isnan(other)\n                    or other in self.variable.unknown_str)\n        if isinstance(other, str):\n            return self.variable.str_val(self) == other\n        if isinstance(other, Value):\n            return self.value == other.value\n        return super().__eq__(other)\n\n    def __ne__(self, other):\n        return not self.__eq__(other)\n\n    def __lt__(self, other):\n        if self.variable.is_primitive():\n            if isinstance(other, str):\n                return super().__lt__(self.variable.to_val(other))\n            else:\n                return super().__lt__(other)\n        else:\n            if isinstance(other, str):\n                return self.value < other\n            else:\n                return self.value < other.value\n\n    def __le__(self, other):\n        return self.__lt__(other) or self.__eq__(other)\n\n    def __gt__(self, other):\n        return not self.__le__(other)\n\n    def __ge__(self, other):\n        return not self.__lt__(other)\n\n    def __contains__(self, other):\n        if (self._value is not None\n                and isinstance(self._value, str)\n                and isinstance(other, str)):\n            return other in self._value\n        raise TypeError(\"invalid operation on Value()\")\n\n    def __hash__(self):\n        if self.variable.is_discrete:\n            # It is not possible to hash the id and the domain value to the same number as required by __eq__.\n            # hash(1) == hash(Value(DiscreteVariable(\"var\", [\"red\", \"green\", \"blue\"]), 1)) == hash(\"green\")\n            # User should hash directly ids or domain values instead.\n            raise TypeError(\"unhashable type - cannot hash values of discrete variables!\")\n        if self._value is None:\n            return super().__hash__()\n        else:\n            return hash(self._value)\n\n    @property\n    def value(self):\n        if self.variable.is_discrete:\n            return Unknown if isnan(self) else self.variable.values[int(self)]\n        if self.variable.is_string:\n            return self._value\n        return float(self)\n\n    def __getnewargs__(self):\n        return self.variable, float(self)\n\n    def __getstate__(self):\n        return dict(value=getattr(self, '_value', None))\n\n    def __setstate__(self, state):\n        self._value = state.get('value', None)\n\n\nclass VariableMeta(Registry):\n    def __new__(cls, name, bases, attrs):\n        obj = super().__new__(cls, name, bases, attrs)\n        if not hasattr(obj, '_all_vars') or obj._all_vars is Variable._all_vars:\n            obj._all_vars = {}\n        return obj\n\n\nclass _predicatedescriptor(property):\n    \"\"\"\n    A property that behaves as a class method if accessed via a class\n    >>> class A:\n    ...     foo = False\n    ...     @_predicatedescriptor\n    ...     def is_foo(self):\n    ...         return self.foo\n    ...\n    >>> a = A()\n    >>> a.is_foo\n    False\n    >>> A.is_foo(a)\n    False\n    \"\"\"\n    def __get__(self, instance, objtype=None):\n        if instance is None:\n            return self.fget\n        else:\n            return super().__get__(instance, objtype)\n\n\nclass Variable(Reprable, metaclass=VariableMeta):\n    \"\"\"\n    The base class for variable descriptors contains the variable's\n    name and some basic properties.\n\n    .. attribute:: name\n\n        The name of the variable.\n\n    .. attribute:: unknown_str\n\n        A set of values that represent unknowns in conversion from textual\n        formats. Default is `{\"?\", \".\", \"\", \"NA\", \"~\", None}`.\n\n    .. attribute:: compute_value\n\n        A function for computing the variable's value when converting from\n        another domain which does not contain this variable. The function will\n        be called with a data set (`Orange.data.Table`) and has to return\n        an array of computed values for all its instances. The base class\n        defines a static method `compute_value`, which returns `Unknown`.\n        Non-primitive variables must redefine it to return `None`.\n\n    .. attribute:: sparse\n\n        A flag about sparsity of the variable. When set, the variable suggests\n        it should be stored in a sparse matrix.\n\n    .. attribute:: source_variable\n\n        An optional descriptor of the source variable - if any - from which\n        this variable is derived and computed via :obj:`compute_value`.\n\n    .. attribute:: attributes\n\n        A dictionary with user-defined attributes of the variable\n\n    .. attribute:: master\n\n        The variable that this variable is a copy of. If a copy is made from a\n        copy, the copy has a reference to the original master. If the variable\n        is not a copy, it is its own master.\n    \"\"\"\n    Unknown = ValueUnknown\n\n    def __init__(self, name=\"\", compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a variable descriptor.\n        \"\"\"\n        self.name = name\n        self._compute_value = compute_value\n        self.unknown_str = MISSING_VALUES\n        self.source_variable = None\n        self.sparse = sparse\n        self.attributes = {}\n        self.master = self\n        if name and compute_value is None:\n            if isinstance(self._all_vars, collections.defaultdict):\n                self._all_vars[name].append(self)\n            else:\n                self._all_vars[name] = self\n        self._colors = None\n\n    def make_proxy(self):\n        \"\"\"\n        Copy the variable and set the master to `self.master` or to `self`.\n\n        :return: copy of self\n        :rtype: Variable\n        \"\"\"\n        var = self.__class__()\n        var.__dict__.update(self.__dict__)\n        var.attributes = dict(self.attributes)\n        var.master = self.master\n        return var\n\n    def __eq__(self, other):\n        \"\"\"Two variables are equivalent if the originate from the same master\"\"\"\n        return hasattr(other, \"master\") and self.master is other.master\n\n    def __hash__(self):\n        if self.master is not self:\n            return hash(self.master)\n        else:\n            return super().__hash__()\n\n    @classmethod\n    def make(cls, name):\n        \"\"\"\n        Return an existing continuous variable with the given name, or\n        construct and return a new one.\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._all_vars.get(name) or cls(name)\n        return var.make_proxy()\n\n    @classmethod\n    def _clear_cache(cls):\n        \"\"\"\n        Clear the list of variables for reuse by :obj:`make`.\n        \"\"\"\n        cls._all_vars.clear()\n\n    @staticmethod\n    def _clear_all_caches():\n        \"\"\"\n        Clears list of stored variables for all subclasses\n        \"\"\"\n        for cls in Variable.registry.values():\n            cls._clear_cache()\n\n    @classmethod\n    def is_primitive(cls, var=None):\n        \"\"\"\n        `True` if the variable's values are stored as floats.\n        Non-primitive variables can appear in the data only as meta attributes.\n        \"\"\"\n        to_check = cls if var is None else type(var)\n        return issubclass(to_check, (DiscreteVariable, ContinuousVariable))\n\n    @_predicatedescriptor\n    def is_discrete(self):\n        return isinstance(self, DiscreteVariable)\n\n    @_predicatedescriptor\n    def is_continuous(self):\n        return isinstance(self, ContinuousVariable)\n\n    @_predicatedescriptor\n    def is_string(self):\n        return isinstance(self, StringVariable)\n\n    @_predicatedescriptor\n    def is_time(self):\n        return isinstance(self, TimeVariable)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of variable's value `val`. Argument\n        `val` must be a float (for primitive variables) or an arbitrary\n        Python object (for non-primitives).\n\n        Derived classes must overload the function.\n        \"\"\"\n        raise RuntimeError(\"variable descriptors must overload repr_val()\")\n\n    str_val = repr_val\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable. The\n        argument can be a string, a number or `None`. For primitive variables,\n        the base class provides a method that returns\n        :obj:`~Orange.data.Unknown` if `s` is found in\n        :obj:`~Orange.data.Variable.unknown_str`, and raises an exception\n        otherwise. For non-primitive variables it returns the argument itself.\n\n        Derived classes of primitive variables must overload the function.\n\n        :param s: value, represented as a number, string or `None`\n        :type s: str, float or None\n        :rtype: float or object\n        \"\"\"\n        if not self.is_primitive():\n            return s\n        if s in self.unknown_str:\n            return Unknown\n        raise RuntimeError(\n            \"primitive variable descriptors must overload to_val()\")\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert the given string to a value of the variable. The method\n        is similar to :obj:`to_val` except that it only accepts strings and\n        that it adds new values to the variable's domain where applicable.\n\n        The base class method calls `to_val`.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float or object\n        \"\"\"\n        return self.to_val(s)\n\n    def __str__(self):\n        return self.name\n\n    @property\n    def compute_value(self):\n        return self._compute_value\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n\n        # Use make to unpickle variables.\n        # \"master\" attribute is removed from the dict since make will point\n        # it to the correct variable. If we did not remove it, the (pickled)\n        # value would replace the one set by make.\n        __dict__ = dict(self.__dict__)\n        __dict__.pop(\"master\", None)\n        return make_variable, (self.__class__, self._compute_value, self.name), __dict__\n\n    def copy(self, compute_value):\n        var = type(self)(self.name, compute_value=compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\ndel _predicatedescriptor\n\n\nclass ContinuousVariable(Variable):\n    \"\"\"\n    Descriptor for continuous variables.\n\n    .. attribute:: number_of_decimals\n\n        The number of decimals when the value is printed out (default: 3).\n\n    .. attribute:: adjust_decimals\n\n        A flag regulating whether the `number_of_decimals` is being adjusted\n        by :obj:`to_val`.\n\n    The value of `number_of_decimals` is set to 3 and `adjust_decimals`\n    is set to 2. When :obj:`val_from_str_add` is called for the first\n    time with a string as an argument, `number_of_decimals` is set to the\n    number of decimals in the string and `adjust_decimals` is set to 1.\n    In the subsequent calls of `to_val`, the nubmer of decimals is\n    increased if the string argument has a larger number of decimals.\n\n    If the `number_of_decimals` is set manually, `adjust_decimals` is\n    set to 0 to prevent changes by `to_val`.\n    \"\"\"\n\n    TYPE_HEADERS = ('continuous', 'c', 'numeric', 'n')\n\n    def __init__(self, name=\"\", number_of_decimals=None, compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a new continuous variable. The number of decimals is set to\n        three, but adjusted at the first call of :obj:`to_val`.\n        \"\"\"\n        super().__init__(name, compute_value, sparse=sparse)\n        if number_of_decimals is None:\n            self.number_of_decimals = 3\n            self.adjust_decimals = 2\n        else:\n            self.number_of_decimals = number_of_decimals\n\n    @property\n    def number_of_decimals(self):\n        return self._number_of_decimals\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            try:\n                col1, col2, black = self.attributes[\"colors\"]\n                self._colors = (hex_to_color(col1), hex_to_color(col2), black)\n            except (KeyError, ValueError):\n                # Stored colors were not available or invalid, use defaults\n                self._colors = ((0, 0, 255), (255, 255, 0), False)\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        col1, col2, black = self._colors = value\n        self.attributes[\"colors\"] = \\\n            [color_to_hex(col1), color_to_hex(col2), black]\n\n    # noinspection PyAttributeOutsideInit\n    @number_of_decimals.setter\n    def number_of_decimals(self, x):\n        self._number_of_decimals = x\n        self.adjust_decimals = 0\n        self._out_format = \"%.{}f\".format(self.number_of_decimals)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if s in self.unknown_str:\n            return Unknown\n        return float(s)\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert a value from a string and adjust the number of decimals if\n        `adjust_decimals` is non-zero.\n        \"\"\"\n        return _variable.val_from_str_add_cont(self, s)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return the value as a string with the prescribed number of decimals.\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return self._out_format % val\n\n    str_val = repr_val\n\n    def copy(self, compute_value=None):\n        var = type(self)(self.name, self.number_of_decimals, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass StringVariable(Variable):\n    \"\"\"\n    Descriptor for string variables. String variables can only appear as\n    meta attributes.\n    \"\"\"\n    Unknown = \"\"\n    TYPE_HEADERS = ('string', 's', 'text')\n\n    def to_val(self, s):\n        \"\"\"\n        Return the value as a string. If it is already a string, the same\n        object is returned.\n        \"\"\"\n        if s is None:\n            return \"\"\n        if isinstance(s, str):\n            return s\n        return str(s)\n\n    val_from_str_add = to_val\n\n    @staticmethod\n    def str_val(val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        if val is \"\":\n            return \"?\"\n        if isinstance(val, Value):\n            if val.value is \"\":\n                return \"?\"\n            val = val.value\n        return str(val)\n\n    def repr_val(self, val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        return '\"{}\"'.format(self.str_val(val))\n\n\nclass TimeVariable(ContinuousVariable):\n    \"\"\"\n    TimeVariable is a continuous variable with Unix epoch\n    (1970-01-01 00:00:00+0000) as the origin (0.0). Later dates are positive\n    real numbers (equivalent to Unix timestamp, with microseconds in the\n    fraction part), and the dates before it map to the negative real numbers.\n\n    Unfortunately due to limitation of Python datetime, only dates\n    with year >= 1 (A.D.) are supported.\n\n    If time is specified without a date, Unix epoch is assumed.\n\n    If time is specified wihout an UTC offset, localtime is assumed.\n    \"\"\"\n    _all_vars = {}\n    TYPE_HEADERS = ('time', 't')\n    UNIX_EPOCH = datetime(1970, 1, 1)\n    _ISO_FORMATS = [\n        # have_date, have_time, format_str\n        # in order of decreased probability\n        (1, 1, '%Y-%m-%d %H:%M:%S%z'),\n        (1, 1, '%Y-%m-%d %H:%M:%S'),\n        (1, 1, '%Y-%m-%d %H:%M'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S'),\n\n        (1, 0, '%Y-%m-%d'),\n\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f%z'),\n\n        (1, 1, '%Y%m%dT%H%M%S%z'),\n        (1, 1, '%Y%m%d%H%M%S%z'),\n\n        (0, 1, '%H:%M:%S.%f'),\n        (0, 1, '%H:%M:%S'),\n        (0, 1, '%H:%M'),\n\n        # These parse as continuous features (plain numbers)\n        (1, 1, '%Y%m%dT%H%M%S'),\n        (1, 1, '%Y%m%d%H%M%S'),\n        (1, 0, '%Y%m%d'),\n        (1, 0, '%Y%j'),\n        (1, 0, '%Y'),\n        (0, 1, '%H%M%S.%f'),\n\n        # BUG: In Python as in C, %j doesn't necessitate 0-padding,\n        # so these two lines must be in this order\n        (1, 0, '%Y-%m'),\n        (1, 0, '%Y-%j'),\n    ]\n    # The regex that matches all above formats\n    REGEX = (r'^('\n             r'\\d{1,4}-\\d{2}-\\d{2}([ T]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?([+-]\\d{4})?)?)?|'\n             r'\\d{1,4}\\d{2}\\d{2}(T?\\d{2}\\d{2}\\d{2}([+-]\\d{4})?)?|'\n             r'\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?|'\n             r'\\d{2}\\d{2}\\d{2}\\.\\d+|'\n             r'\\d{1,4}(-?\\d{2,3})?'\n             r')$')\n    _matches_iso_format = re.compile(REGEX).match\n\n    # UTC offset and associated timezone. If parsed datetime values provide an\n    # offset, it is used for display. If not all values have the same offset,\n    # +0000 (=UTC) timezone is used and utc_offset is set to False.\n    utc_offset = None\n    timezone = timezone.utc\n\n    def __init__(self, *args, have_date=0, have_time=0, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.have_date = have_date\n        self.have_time = have_time\n\n    def copy(self, compute_value=None):\n        copy = super().copy(compute_value=compute_value)\n        copy.have_date = self.have_date\n        copy.have_time = self.have_time\n        return copy\n\n    @staticmethod\n    def _tzre_sub(s, _subtz=re.compile(r'([+-])(\\d\\d):(\\d\\d)$').sub):\n        # Replace +ZZ:ZZ with ISO-compatible +ZZZZ, or strip +0000\n        return s[:-6] if s.endswith(('+00:00', '-00:00')) else _subtz(r'\\1\\2\\3', s)\n\n    def repr_val(self, val):\n        if isnan(val):\n            return '?'\n        if not self.have_date and not self.have_time:\n            # The time is relative, unitless. The value is absolute.\n            return str(val.value) if isinstance(val, Value) else str(val)\n\n        # If you know how to simplify this, be my guest\n        seconds = int(val)\n        microseconds = int(round((val - seconds) * 1e6))\n        if val < 0:\n            if microseconds:\n                seconds, microseconds = seconds - 1, int(1e6) + microseconds\n            date = datetime.fromtimestamp(0, tz=self.timezone) + timedelta(seconds=seconds)\n        else:\n            date = datetime.fromtimestamp(seconds, tz=self.timezone)\n        date = str(date.replace(microsecond=microseconds))\n\n        if self.have_date and not self.have_time:\n            date = date.split()[0]\n        elif not self.have_date and self.have_time:\n            date = date.split()[1]\n        date = self._tzre_sub(date)\n        return date\n\n    str_val = repr_val\n\n    def parse(self, datestr):\n        \"\"\"\n        Return `datestr`, a datetime provided in one of ISO 8601 formats,\n        parsed as a real number. Value 0 marks the Unix epoch, positive values\n        are the dates after it, negative before.\n\n        If date is unspecified, epoch date is assumed.\n\n        If time is unspecified, 00:00:00.0 is assumed.\n\n        If timezone is unspecified, local time is assumed.\n        \"\"\"\n        if datestr in MISSING_VALUES:\n            return Unknown\n        datestr = datestr.strip().rstrip('Z')\n\n        ERROR = ValueError(\"Invalid datetime format '{}'. \"\n                           \"Only ISO 8601 supported.\".format(datestr))\n        if not self._matches_iso_format(datestr):\n            try:\n                # If it is a number, assume it is a unix timestamp\n                value = float(datestr)\n                self.have_date = self.have_time = 1\n                return value\n            except ValueError:\n                raise ERROR\n\n        for i, (have_date, have_time, fmt) in enumerate(self._ISO_FORMATS):\n            try:\n                dt = datetime.strptime(datestr, fmt)\n            except ValueError:\n                continue\n            else:\n                # Pop this most-recently-used format to front\n                if 0 < i < len(self._ISO_FORMATS) - 2:\n                    self._ISO_FORMATS[i], self._ISO_FORMATS[0] = \\\n                        self._ISO_FORMATS[0], self._ISO_FORMATS[i]\n\n                self.have_date |= have_date\n                self.have_time |= have_time\n                if not have_date:\n                    dt = dt.replace(self.UNIX_EPOCH.year,\n                                    self.UNIX_EPOCH.month,\n                                    self.UNIX_EPOCH.day)\n                break\n        else:\n            raise ERROR\n\n        # Remember UTC offset. If not all parsed values share the same offset,\n        # remember none of it.\n        offset = dt.utcoffset()\n        if self.utc_offset is not False:\n            if offset and self.utc_offset is None:\n                self.utc_offset = offset\n                self.timezone = timezone(offset)\n            elif self.utc_offset != offset:\n                self.utc_offset = False\n                self.timezone = timezone.utc\n\n        # Convert time to UTC timezone. In dates without timezone,\n        # localtime is assumed. See also:\n        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp\n        if dt.tzinfo:\n            dt -= dt.utcoffset()\n        dt = dt.replace(tzinfo=timezone.utc)\n\n        # Unix epoch is the origin, older dates are negative\n        try:\n            return dt.timestamp()\n        except OverflowError:\n            return -(self.UNIX_EPOCH - dt).total_seconds()\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if isinstance(s, str):\n            return self.parse(s)\n        else:\n            return super().to_val(s)\n",
            "new_file_content": "import collections\nimport re\n\nfrom datetime import datetime, timedelta, timezone\nfrom numbers import Number, Real, Integral\nfrom math import isnan, floor\nfrom pickle import PickleError\n\nimport numpy as np\n\nfrom Orange.data import _variable\nfrom Orange.util import Registry, color_to_hex, hex_to_color, Reprable\n\n__all__ = [\"Unknown\", \"MISSING_VALUES\", \"make_variable\", \"is_discrete_values\",\n           \"Value\", \"Variable\", \"ContinuousVariable\", \"DiscreteVariable\",\n           \"StringVariable\", \"TimeVariable\"]\n\n\n# For storing unknowns\nUnknown = ValueUnknown = float(\"nan\")\n# For checking for unknowns\nMISSING_VALUES = {np.nan, \"?\", \"nan\", \".\", \"\", \"NA\", \"~\", None}\n\nDISCRETE_MAX_VALUES = 3  # == 2 + nan\n\n\ndef make_variable(cls, compute_value, *args):\n    if compute_value is not None:\n        return cls(*args, compute_value=compute_value)\n    if issubclass(cls, DiscreteVariable):\n        name, values = args[:2]\n        var = cls.make(*args)\n        # The `var.values` are in general a superset of `values` with different\n        # order. Only use it if it is a structural subtype of the requested\n        # descriptor so any indices/codes retain their proper interpretation on\n        # deserialization.\n        if var.values[:len(values)] == values:\n            return var\n        else:\n            return cls(*args)\n    else:\n        return cls.make(*args)\n\n\ndef is_discrete_values(values):\n    \"\"\"\n    Return set of uniques if `values` is an iterable of discrete values\n    else False if non-discrete, or None if indeterminate.\n\n    Note\n    ----\n    Assumes consistent type of items of `values`.\n    \"\"\"\n    if not len(values):\n        return None\n    # If the first few values are, or can be converted to, floats,\n    # the type is numeric\n    try:\n        isinstance(next(iter(values)), Number) or \\\n        [float(v) for _, v in zip(range(min(3, len(values))), values)]\n    except ValueError:\n        is_numeric = False\n        max_values = int(round(len(values)**.7))\n    else:\n        is_numeric = True\n        max_values = DISCRETE_MAX_VALUES\n\n    # If more than max values => not discrete\n    unique = set()\n    for i in values:\n        unique.add(i)\n        if len(unique) > max_values:\n            return False\n\n    # Strip NaN from unique\n    unique = {i for i in unique\n              if (not i in MISSING_VALUES and\n                  not (isinstance(i, Number) and np.isnan(i)))}\n\n    # All NaNs => indeterminate\n    if not unique:\n        return None\n\n    # Strings with |values| < max_unique\n    if not is_numeric:\n        return unique\n\n    # Handle numbers\n    try:\n        unique_float = set(map(float, unique))\n    except ValueError:\n        # Converting all the values to floats resulted in an error.\n        # Since the values have enough unique values, they are probably\n        # string values and discrete.\n        return unique\n\n    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete\n    return (not (unique_float - {0, 1}) or\n            not (unique_float - {1, 2})) and unique\n\n\nclass Value(float):\n    \"\"\"\n    The class representing a value. The class is not used to store values but\n    only to return them in contexts in which we want the value to be accompanied\n    with the descriptor, for instance to print the symbolic value of discrete\n    variables.\n\n    The class is derived from `float`, with an additional attribute `variable`\n    which holds the descriptor of type :obj:`Orange.data.Variable`. If the\n    value continuous or discrete, it is stored as a float. Other types of\n    values, like strings, are stored in the attribute `value`.\n\n    The class overloads the methods for printing out the value:\n    `variable.repr_val` and `variable.str_val` are used to get a suitable\n    representation of the value.\n\n    Equivalence operator is overloaded as follows:\n\n    - unknown values are equal; if one value is unknown and the other is not,\n      they are different;\n\n    - if the value is compared with the string, the value is converted to a\n      string using `variable.str_val` and the two strings are compared\n\n    - if the value is stored in attribute `value`, it is compared with the\n      given other value\n\n    - otherwise, the inherited comparison operator for `float` is called.\n\n    Finally, value defines a hash, so values can be put in sets and appear as\n    keys in dictionaries.\n\n    .. attribute:: variable (:obj:`Orange.data.Variable`)\n\n        Descriptor; used for printing out and for comparing with strings\n\n    .. attribute:: value\n\n        Value; the value can be of arbitrary type and is used only for variables\n        that are neither discrete nor continuous. If `value` is `None`, the\n        derived `float` value is used.\n    \"\"\"\n    __slots__ = \"variable\", \"_value\"\n\n    def __new__(cls, variable, value=Unknown):\n        \"\"\"\n        Construct a new instance of Value with the given descriptor and value.\n        If the argument `value` can be converted to float, it is stored as\n        `float` and the attribute `value` is set to `None`. Otherwise, the\n        inherited float is set to `Unknown` and the value is held by the\n        attribute `value`.\n\n        :param variable: descriptor\n        :type variable: Orange.data.Variable\n        :param value: value\n        \"\"\"\n        if variable.is_primitive():\n            self = super().__new__(cls, value)\n            self.variable = variable\n            self._value = None\n        else:\n            isunknown = value == variable.Unknown\n            self = super().__new__(\n                cls, np.nan if isunknown else np.finfo(float).min)\n            self.variable = variable\n            self._value = value\n        return self\n\n    def __init__(self, _, __=Unknown):\n        pass\n\n    def __repr__(self):\n        return \"Value('%s', %s)\" % (self.variable.name,\n                                    self.variable.repr_val(self))\n\n    def __str__(self):\n        return self.variable.str_val(self)\n\n    def __eq__(self, other):\n        if isinstance(self, Real) and isnan(self):\n            return (isinstance(other, Real) and isnan(other)\n                    or other in self.variable.unknown_str)\n        if isinstance(other, str):\n            return self.variable.str_val(self) == other\n        if isinstance(other, Value):\n            return self.value == other.value\n        return super().__eq__(other)\n\n    def __ne__(self, other):\n        return not self.__eq__(other)\n\n    def __lt__(self, other):\n        if self.variable.is_primitive():\n            if isinstance(other, str):\n                return super().__lt__(self.variable.to_val(other))\n            else:\n                return super().__lt__(other)\n        else:\n            if isinstance(other, str):\n                return self.value < other\n            else:\n                return self.value < other.value\n\n    def __le__(self, other):\n        return self.__lt__(other) or self.__eq__(other)\n\n    def __gt__(self, other):\n        return not self.__le__(other)\n\n    def __ge__(self, other):\n        return not self.__lt__(other)\n\n    def __contains__(self, other):\n        if (self._value is not None\n                and isinstance(self._value, str)\n                and isinstance(other, str)):\n            return other in self._value\n        raise TypeError(\"invalid operation on Value()\")\n\n    def __hash__(self):\n        if self.variable.is_discrete:\n            # It is not possible to hash the id and the domain value to the same number as required by __eq__.\n            # hash(1) == hash(Value(DiscreteVariable(\"var\", [\"red\", \"green\", \"blue\"]), 1)) == hash(\"green\")\n            # User should hash directly ids or domain values instead.\n            raise TypeError(\"unhashable type - cannot hash values of discrete variables!\")\n        if self._value is None:\n            return super().__hash__()\n        else:\n            return hash(self._value)\n\n    @property\n    def value(self):\n        if self.variable.is_discrete:\n            return Unknown if isnan(self) else self.variable.values[int(self)]\n        if self.variable.is_string:\n            return self._value\n        return float(self)\n\n    def __getnewargs__(self):\n        return self.variable, float(self)\n\n    def __getstate__(self):\n        return dict(value=getattr(self, '_value', None))\n\n    def __setstate__(self, state):\n        self._value = state.get('value', None)\n\n\nclass VariableMeta(Registry):\n    def __new__(cls, name, bases, attrs):\n        obj = super().__new__(cls, name, bases, attrs)\n        if not hasattr(obj, '_all_vars') or obj._all_vars is Variable._all_vars:\n            obj._all_vars = {}\n        return obj\n\n\nclass _predicatedescriptor(property):\n    \"\"\"\n    A property that behaves as a class method if accessed via a class\n    >>> class A:\n    ...     foo = False\n    ...     @_predicatedescriptor\n    ...     def is_foo(self):\n    ...         return self.foo\n    ...\n    >>> a = A()\n    >>> a.is_foo\n    False\n    >>> A.is_foo(a)\n    False\n    \"\"\"\n    def __get__(self, instance, objtype=None):\n        if instance is None:\n            return self.fget\n        else:\n            return super().__get__(instance, objtype)\n\n\nclass Variable(Reprable, metaclass=VariableMeta):\n    \"\"\"\n    The base class for variable descriptors contains the variable's\n    name and some basic properties.\n\n    .. attribute:: name\n\n        The name of the variable.\n\n    .. attribute:: unknown_str\n\n        A set of values that represent unknowns in conversion from textual\n        formats. Default is `{\"?\", \".\", \"\", \"NA\", \"~\", None}`.\n\n    .. attribute:: compute_value\n\n        A function for computing the variable's value when converting from\n        another domain which does not contain this variable. The function will\n        be called with a data set (`Orange.data.Table`) and has to return\n        an array of computed values for all its instances. The base class\n        defines a static method `compute_value`, which returns `Unknown`.\n        Non-primitive variables must redefine it to return `None`.\n\n    .. attribute:: sparse\n\n        A flag about sparsity of the variable. When set, the variable suggests\n        it should be stored in a sparse matrix.\n\n    .. attribute:: source_variable\n\n        An optional descriptor of the source variable - if any - from which\n        this variable is derived and computed via :obj:`compute_value`.\n\n    .. attribute:: attributes\n\n        A dictionary with user-defined attributes of the variable\n\n    .. attribute:: master\n\n        The variable that this variable is a copy of. If a copy is made from a\n        copy, the copy has a reference to the original master. If the variable\n        is not a copy, it is its own master.\n    \"\"\"\n    Unknown = ValueUnknown\n\n    def __init__(self, name=\"\", compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a variable descriptor.\n        \"\"\"\n        self.name = name\n        self._compute_value = compute_value\n        self.unknown_str = MISSING_VALUES\n        self.source_variable = None\n        self.sparse = sparse\n        self.attributes = {}\n        self.master = self\n        if name and compute_value is None:\n            if isinstance(self._all_vars, collections.defaultdict):\n                self._all_vars[name].append(self)\n            else:\n                self._all_vars[name] = self\n        self._colors = None\n\n    def make_proxy(self):\n        \"\"\"\n        Copy the variable and set the master to `self.master` or to `self`.\n\n        :return: copy of self\n        :rtype: Variable\n        \"\"\"\n        var = self.__class__()\n        var.__dict__.update(self.__dict__)\n        var.attributes = dict(self.attributes)\n        var.master = self.master\n        return var\n\n    def __eq__(self, other):\n        \"\"\"Two variables are equivalent if the originate from the same master\"\"\"\n        return hasattr(other, \"master\") and self.master is other.master\n\n    def __hash__(self):\n        if self.master is not self:\n            return hash(self.master)\n        else:\n            return super().__hash__()\n\n    @classmethod\n    def make(cls, name):\n        \"\"\"\n        Return an existing continuous variable with the given name, or\n        construct and return a new one.\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._all_vars.get(name) or cls(name)\n        return var.make_proxy()\n\n    @classmethod\n    def _clear_cache(cls):\n        \"\"\"\n        Clear the list of variables for reuse by :obj:`make`.\n        \"\"\"\n        cls._all_vars.clear()\n\n    @staticmethod\n    def _clear_all_caches():\n        \"\"\"\n        Clears list of stored variables for all subclasses\n        \"\"\"\n        for cls in Variable.registry.values():\n            cls._clear_cache()\n\n    @classmethod\n    def is_primitive(cls, var=None):\n        \"\"\"\n        `True` if the variable's values are stored as floats.\n        Non-primitive variables can appear in the data only as meta attributes.\n        \"\"\"\n        to_check = cls if var is None else type(var)\n        return issubclass(to_check, (DiscreteVariable, ContinuousVariable))\n\n    @_predicatedescriptor\n    def is_discrete(self):\n        return isinstance(self, DiscreteVariable)\n\n    @_predicatedescriptor\n    def is_continuous(self):\n        return isinstance(self, ContinuousVariable)\n\n    @_predicatedescriptor\n    def is_string(self):\n        return isinstance(self, StringVariable)\n\n    @_predicatedescriptor\n    def is_time(self):\n        return isinstance(self, TimeVariable)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of variable's value `val`. Argument\n        `val` must be a float (for primitive variables) or an arbitrary\n        Python object (for non-primitives).\n\n        Derived classes must overload the function.\n        \"\"\"\n        raise RuntimeError(\"variable descriptors must overload repr_val()\")\n\n    str_val = repr_val\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable. The\n        argument can be a string, a number or `None`. For primitive variables,\n        the base class provides a method that returns\n        :obj:`~Orange.data.Unknown` if `s` is found in\n        :obj:`~Orange.data.Variable.unknown_str`, and raises an exception\n        otherwise. For non-primitive variables it returns the argument itself.\n\n        Derived classes of primitive variables must overload the function.\n\n        :param s: value, represented as a number, string or `None`\n        :type s: str, float or None\n        :rtype: float or object\n        \"\"\"\n        if not self.is_primitive():\n            return s\n        if s in self.unknown_str:\n            return Unknown\n        raise RuntimeError(\n            \"primitive variable descriptors must overload to_val()\")\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert the given string to a value of the variable. The method\n        is similar to :obj:`to_val` except that it only accepts strings and\n        that it adds new values to the variable's domain where applicable.\n\n        The base class method calls `to_val`.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float or object\n        \"\"\"\n        return self.to_val(s)\n\n    def __str__(self):\n        return self.name\n\n    @property\n    def compute_value(self):\n        return self._compute_value\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n\n        # Use make to unpickle variables.\n        # \"master\" attribute is removed from the dict since make will point\n        # it to the correct variable. If we did not remove it, the (pickled)\n        # value would replace the one set by make.\n        __dict__ = dict(self.__dict__)\n        __dict__.pop(\"master\", None)\n        return make_variable, (self.__class__, self._compute_value, self.name), __dict__\n\n    def copy(self, compute_value):\n        var = type(self)(self.name, compute_value=compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\ndel _predicatedescriptor\n\n\nclass ContinuousVariable(Variable):\n    \"\"\"\n    Descriptor for continuous variables.\n\n    .. attribute:: number_of_decimals\n\n        The number of decimals when the value is printed out (default: 3).\n\n    .. attribute:: adjust_decimals\n\n        A flag regulating whether the `number_of_decimals` is being adjusted\n        by :obj:`to_val`.\n\n    The value of `number_of_decimals` is set to 3 and `adjust_decimals`\n    is set to 2. When :obj:`val_from_str_add` is called for the first\n    time with a string as an argument, `number_of_decimals` is set to the\n    number of decimals in the string and `adjust_decimals` is set to 1.\n    In the subsequent calls of `to_val`, the nubmer of decimals is\n    increased if the string argument has a larger number of decimals.\n\n    If the `number_of_decimals` is set manually, `adjust_decimals` is\n    set to 0 to prevent changes by `to_val`.\n    \"\"\"\n\n    TYPE_HEADERS = ('continuous', 'c', 'numeric', 'n')\n\n    def __init__(self, name=\"\", number_of_decimals=None, compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a new continuous variable. The number of decimals is set to\n        three, but adjusted at the first call of :obj:`to_val`.\n        \"\"\"\n        super().__init__(name, compute_value, sparse=sparse)\n        if number_of_decimals is None:\n            self.number_of_decimals = 3\n            self.adjust_decimals = 2\n        else:\n            self.number_of_decimals = number_of_decimals\n\n    @property\n    def number_of_decimals(self):\n        return self._number_of_decimals\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            try:\n                col1, col2, black = self.attributes[\"colors\"]\n                self._colors = (hex_to_color(col1), hex_to_color(col2), black)\n            except (KeyError, ValueError):\n                # Stored colors were not available or invalid, use defaults\n                self._colors = ((0, 0, 255), (255, 255, 0), False)\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        col1, col2, black = self._colors = value\n        self.attributes[\"colors\"] = \\\n            [color_to_hex(col1), color_to_hex(col2), black]\n\n    # noinspection PyAttributeOutsideInit\n    @number_of_decimals.setter\n    def number_of_decimals(self, x):\n        self._number_of_decimals = x\n        self.adjust_decimals = 0\n        self._out_format = \"%.{}f\".format(self.number_of_decimals)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if s in self.unknown_str:\n            return Unknown\n        return float(s)\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert a value from a string and adjust the number of decimals if\n        `adjust_decimals` is non-zero.\n        \"\"\"\n        return _variable.val_from_str_add_cont(self, s)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return the value as a string with the prescribed number of decimals.\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return self._out_format % val\n\n    str_val = repr_val\n\n    def copy(self, compute_value=None):\n        var = type(self)(self.name, self.number_of_decimals, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        __dict__ = dict(self.__dict__)\n        __dict__.pop(\"master\")\n        __dict__.pop(\"values\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            __dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var.make_proxy()\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass StringVariable(Variable):\n    \"\"\"\n    Descriptor for string variables. String variables can only appear as\n    meta attributes.\n    \"\"\"\n    Unknown = \"\"\n    TYPE_HEADERS = ('string', 's', 'text')\n\n    def to_val(self, s):\n        \"\"\"\n        Return the value as a string. If it is already a string, the same\n        object is returned.\n        \"\"\"\n        if s is None:\n            return \"\"\n        if isinstance(s, str):\n            return s\n        return str(s)\n\n    val_from_str_add = to_val\n\n    @staticmethod\n    def str_val(val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        if val is \"\":\n            return \"?\"\n        if isinstance(val, Value):\n            if val.value is \"\":\n                return \"?\"\n            val = val.value\n        return str(val)\n\n    def repr_val(self, val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        return '\"{}\"'.format(self.str_val(val))\n\n\nclass TimeVariable(ContinuousVariable):\n    \"\"\"\n    TimeVariable is a continuous variable with Unix epoch\n    (1970-01-01 00:00:00+0000) as the origin (0.0). Later dates are positive\n    real numbers (equivalent to Unix timestamp, with microseconds in the\n    fraction part), and the dates before it map to the negative real numbers.\n\n    Unfortunately due to limitation of Python datetime, only dates\n    with year >= 1 (A.D.) are supported.\n\n    If time is specified without a date, Unix epoch is assumed.\n\n    If time is specified wihout an UTC offset, localtime is assumed.\n    \"\"\"\n    _all_vars = {}\n    TYPE_HEADERS = ('time', 't')\n    UNIX_EPOCH = datetime(1970, 1, 1)\n    _ISO_FORMATS = [\n        # have_date, have_time, format_str\n        # in order of decreased probability\n        (1, 1, '%Y-%m-%d %H:%M:%S%z'),\n        (1, 1, '%Y-%m-%d %H:%M:%S'),\n        (1, 1, '%Y-%m-%d %H:%M'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S'),\n\n        (1, 0, '%Y-%m-%d'),\n\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f%z'),\n\n        (1, 1, '%Y%m%dT%H%M%S%z'),\n        (1, 1, '%Y%m%d%H%M%S%z'),\n\n        (0, 1, '%H:%M:%S.%f'),\n        (0, 1, '%H:%M:%S'),\n        (0, 1, '%H:%M'),\n\n        # These parse as continuous features (plain numbers)\n        (1, 1, '%Y%m%dT%H%M%S'),\n        (1, 1, '%Y%m%d%H%M%S'),\n        (1, 0, '%Y%m%d'),\n        (1, 0, '%Y%j'),\n        (1, 0, '%Y'),\n        (0, 1, '%H%M%S.%f'),\n\n        # BUG: In Python as in C, %j doesn't necessitate 0-padding,\n        # so these two lines must be in this order\n        (1, 0, '%Y-%m'),\n        (1, 0, '%Y-%j'),\n    ]\n    # The regex that matches all above formats\n    REGEX = (r'^('\n             r'\\d{1,4}-\\d{2}-\\d{2}([ T]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?([+-]\\d{4})?)?)?|'\n             r'\\d{1,4}\\d{2}\\d{2}(T?\\d{2}\\d{2}\\d{2}([+-]\\d{4})?)?|'\n             r'\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?|'\n             r'\\d{2}\\d{2}\\d{2}\\.\\d+|'\n             r'\\d{1,4}(-?\\d{2,3})?'\n             r')$')\n    _matches_iso_format = re.compile(REGEX).match\n\n    # UTC offset and associated timezone. If parsed datetime values provide an\n    # offset, it is used for display. If not all values have the same offset,\n    # +0000 (=UTC) timezone is used and utc_offset is set to False.\n    utc_offset = None\n    timezone = timezone.utc\n\n    def __init__(self, *args, have_date=0, have_time=0, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.have_date = have_date\n        self.have_time = have_time\n\n    def copy(self, compute_value=None):\n        copy = super().copy(compute_value=compute_value)\n        copy.have_date = self.have_date\n        copy.have_time = self.have_time\n        return copy\n\n    @staticmethod\n    def _tzre_sub(s, _subtz=re.compile(r'([+-])(\\d\\d):(\\d\\d)$').sub):\n        # Replace +ZZ:ZZ with ISO-compatible +ZZZZ, or strip +0000\n        return s[:-6] if s.endswith(('+00:00', '-00:00')) else _subtz(r'\\1\\2\\3', s)\n\n    def repr_val(self, val):\n        if isnan(val):\n            return '?'\n        if not self.have_date and not self.have_time:\n            # The time is relative, unitless. The value is absolute.\n            return str(val.value) if isinstance(val, Value) else str(val)\n\n        # If you know how to simplify this, be my guest\n        seconds = int(val)\n        microseconds = int(round((val - seconds) * 1e6))\n        if val < 0:\n            if microseconds:\n                seconds, microseconds = seconds - 1, int(1e6) + microseconds\n            date = datetime.fromtimestamp(0, tz=self.timezone) + timedelta(seconds=seconds)\n        else:\n            date = datetime.fromtimestamp(seconds, tz=self.timezone)\n        date = str(date.replace(microsecond=microseconds))\n\n        if self.have_date and not self.have_time:\n            date = date.split()[0]\n        elif not self.have_date and self.have_time:\n            date = date.split()[1]\n        date = self._tzre_sub(date)\n        return date\n\n    str_val = repr_val\n\n    def parse(self, datestr):\n        \"\"\"\n        Return `datestr`, a datetime provided in one of ISO 8601 formats,\n        parsed as a real number. Value 0 marks the Unix epoch, positive values\n        are the dates after it, negative before.\n\n        If date is unspecified, epoch date is assumed.\n\n        If time is unspecified, 00:00:00.0 is assumed.\n\n        If timezone is unspecified, local time is assumed.\n        \"\"\"\n        if datestr in MISSING_VALUES:\n            return Unknown\n        datestr = datestr.strip().rstrip('Z')\n\n        ERROR = ValueError(\"Invalid datetime format '{}'. \"\n                           \"Only ISO 8601 supported.\".format(datestr))\n        if not self._matches_iso_format(datestr):\n            try:\n                # If it is a number, assume it is a unix timestamp\n                value = float(datestr)\n                self.have_date = self.have_time = 1\n                return value\n            except ValueError:\n                raise ERROR\n\n        for i, (have_date, have_time, fmt) in enumerate(self._ISO_FORMATS):\n            try:\n                dt = datetime.strptime(datestr, fmt)\n            except ValueError:\n                continue\n            else:\n                # Pop this most-recently-used format to front\n                if 0 < i < len(self._ISO_FORMATS) - 2:\n                    self._ISO_FORMATS[i], self._ISO_FORMATS[0] = \\\n                        self._ISO_FORMATS[0], self._ISO_FORMATS[i]\n\n                self.have_date |= have_date\n                self.have_time |= have_time\n                if not have_date:\n                    dt = dt.replace(self.UNIX_EPOCH.year,\n                                    self.UNIX_EPOCH.month,\n                                    self.UNIX_EPOCH.day)\n                break\n        else:\n            raise ERROR\n\n        # Remember UTC offset. If not all parsed values share the same offset,\n        # remember none of it.\n        offset = dt.utcoffset()\n        if self.utc_offset is not False:\n            if offset and self.utc_offset is None:\n                self.utc_offset = offset\n                self.timezone = timezone(offset)\n            elif self.utc_offset != offset:\n                self.utc_offset = False\n                self.timezone = timezone.utc\n\n        # Convert time to UTC timezone. In dates without timezone,\n        # localtime is assumed. See also:\n        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp\n        if dt.tzinfo:\n            dt -= dt.utcoffset()\n        dt = dt.replace(tzinfo=timezone.utc)\n\n        # Unix epoch is the origin, older dates are negative\n        try:\n            return dt.timestamp()\n        except OverflowError:\n            return -(self.UNIX_EPOCH - dt).total_seconds()\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if isinstance(s, str):\n            return self.parse(s)\n        else:\n            return super().to_val(s)\n",
            "header": {
                "file": {
                    "path": "Orange/data/variable.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "838b4a66c",
                "new_commit_hash": "e3b7564f9",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/data/variable.py"
            },
            "plus_file": {
                "path": "b/Orange/data/variable.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 27,
                            "length": 7
                        },
                        "new_range": {
                            "start": 27,
                            "length": 19
                        },
                        "section": "DISCRETE_MAX_VALUES = 3  # == 2 + nan"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "def make_variable(cls, compute_value, *args):",
                                "type": "context"
                            },
                            {
                                "content": "    if compute_value is not None:",
                                "type": "context"
                            },
                            {
                                "content": "        return cls(*args, compute_value=compute_value)",
                                "type": "context"
                            },
                            {
                                "content": "    return cls.make(*args)",
                                "type": "deleted"
                            },
                            {
                                "content": "    if issubclass(cls, DiscreteVariable):",
                                "type": "added"
                            },
                            {
                                "content": "        name, values = args[:2]",
                                "type": "added"
                            },
                            {
                                "content": "        var = cls.make(*args)",
                                "type": "added"
                            },
                            {
                                "content": "        # The `var.values` are in general a superset of `values` with different",
                                "type": "added"
                            },
                            {
                                "content": "        # order. Only use it if it is a structural subtype of the requested",
                                "type": "added"
                            },
                            {
                                "content": "        # descriptor so any indices/codes retain their proper interpretation on",
                                "type": "added"
                            },
                            {
                                "content": "        # deserialization.",
                                "type": "added"
                            },
                            {
                                "content": "        if var.values[:len(values)] == values:",
                                "type": "added"
                            },
                            {
                                "content": "            return var",
                                "type": "added"
                            },
                            {
                                "content": "        else:",
                                "type": "added"
                            },
                            {
                                "content": "            return cls(*args)",
                                "type": "added"
                            },
                            {
                                "content": "    else:",
                                "type": "added"
                            },
                            {
                                "content": "        return cls.make(*args)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "def is_discrete_values(values):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/variable.py",
                            "type": "function",
                            "name": "make_variable",
                            "content": "def make_variable(cls, compute_value, *args):\n    if compute_value is not None:\n        return cls(*args, compute_value=compute_value)\n    return cls.make(*args)",
                            "ast_type_str": "FunctionDef",
                            "start_lineno": 27,
                            "end_lineno": 30,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 707,
                            "length": 9
                        },
                        "new_range": {
                            "start": 719,
                            "length": 12
                        },
                        "section": "class DiscreteVariable(Variable):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "    def __reduce__(self):",
                                "type": "context"
                            },
                            {
                                "content": "        if not self.name:",
                                "type": "context"
                            },
                            {
                                "content": "            raise PickleError(\"Variables without names cannot be pickled\")",
                                "type": "context"
                            },
                            {
                                "content": "        __dict__ = dict(self.__dict__)",
                                "type": "added"
                            },
                            {
                                "content": "        __dict__.pop(\"master\")",
                                "type": "added"
                            },
                            {
                                "content": "        __dict__.pop(\"values\")",
                                "type": "added"
                            },
                            {
                                "content": "        return make_variable, (self.__class__, self._compute_value, self.name,",
                                "type": "context"
                            },
                            {
                                "content": "                               self.values, self.ordered, self.base_value), \\",
                                "type": "context"
                            },
                            {
                                "content": "            self.__dict__",
                                "type": "deleted"
                            },
                            {
                                "content": "            __dict__",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    @classmethod",
                                "type": "context"
                            },
                            {
                                "content": "    def make(cls, name, values=(), ordered=False, base_value=-1):",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/variable.py",
                            "type": "method",
                            "name": "DiscreteVariable.__reduce__",
                            "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 707,
                            "end_lineno": 712,
                            "parent": {
                                "file_name": "Orange/data/variable.py",
                                "type": "class",
                                "name": "DiscreteVariable",
                                "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 578,
                                "end_lineno": 830,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/data/variable.py",
                            "type": "class",
                            "name": "DiscreteVariable",
                            "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 578,
                            "end_lineno": 830,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                },
                {
                    "descriptor": {
                        "old_range": {
                            "start": 742,
                            "length": 7
                        },
                        "new_range": {
                            "start": 757,
                            "length": 7
                        },
                        "section": "class DiscreteVariable(Variable):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "        var = cls._find_compatible(",
                                "type": "context"
                            },
                            {
                                "content": "            name, values, ordered, base_value)",
                                "type": "context"
                            },
                            {
                                "content": "        if var:",
                                "type": "context"
                            },
                            {
                                "content": "            return var",
                                "type": "deleted"
                            },
                            {
                                "content": "            return var.make_proxy()",
                                "type": "added"
                            },
                            {
                                "content": "        if not ordered:",
                                "type": "context"
                            },
                            {
                                "content": "            base_value_rep = base_value != -1 and values[base_value]",
                                "type": "context"
                            },
                            {
                                "content": "            values = cls.ordered_values(values)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/data/variable.py",
                            "type": "class",
                            "name": "DiscreteVariable",
                            "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 578,
                            "end_lineno": 830,
                            "parent": null
                        },
                        {
                            "file_name": "Orange/data/variable.py",
                            "type": "method",
                            "name": "DiscreteVariable.make",
                            "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 715,
                            "end_lineno": 751,
                            "parent": {
                                "file_name": "Orange/data/variable.py",
                                "type": "class",
                                "name": "DiscreteVariable",
                                "content": "class DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 578,
                                "end_lineno": 830,
                                "parent": null
                            }
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "a95245e37f35446f9870feb68f5ebb97d1c279ce^",
    "new_commit_hash": "a95245e37f35446f9870feb68f5ebb97d1c279ce",
    "commit_message": "Merge pull request #3242 from ales-erjavec/var-reconstruct\n\n[FIX] DiscreteVariable reconstruction",
    "commit_date": "2018-09-12T14:29:31+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "a95245e37f35446f9870feb68f5ebb97d1c279ce",
    "test_file_codes": [
        "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\n\nimport sys\nimport math\nimport unittest\nimport pickle\nimport pkgutil\nfrom datetime import datetime, timezone\n\nfrom io import StringIO\n\nimport numpy as np\n\nfrom Orange.data import Variable, ContinuousVariable, DiscreteVariable, \\\n    StringVariable, TimeVariable, Unknown, Value\nfrom Orange.data.io import CSVReader\nfrom Orange.tests.base import create_pickling_tests\n\n\ndef is_on_path(name):\n    \"\"\"\n    Is a top level package/module found on sys.path\n\n    Parameters\n    ----------\n    name : str\n        Top level module/package name\n\n    Returns\n    -------\n    found : bool\n    \"\"\"\n    for loader, name_, ispkg in pkgutil.iter_modules(sys.path):\n        if name == name_:\n            return True\n    else:\n        return False\n\n\n# noinspection PyPep8Naming,PyUnresolvedReferences\nclass VariableTest:\n    def setUp(self):\n        self.varcls._clear_all_caches()\n\n    def test_dont_pickle_anonymous_variables(self):\n        self.assertRaises(pickle.PickleError, pickle.dumps, self.varcls())\n\n    def test_dont_store_anonymous_variables(self):\n        self.varcls()\n        self.assertEqual(len(self.varcls._all_vars), 0)\n\n    def test_dont_make_anonymous_variables(self):\n        self.assertRaises(ValueError, self.varcls.make, \"\")\n\n    def test_copy_copies_attributes(self):\n        var = self.varcls()\n        var.attributes[\"a\"] = \"b\"\n        var2 = var.copy(compute_value=None)\n        self.assertIn(\"a\", var2.attributes)\n        self.assertIsInstance(var2, type(var))\n\n        var2.attributes[\"a\"] = \"c\"\n        # Attributes of original value should not change\n        self.assertEqual(var.attributes[\"a\"], \"b\")\n\n\nclass TestVariable(unittest.TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.var = Variable(\"x\")\n\n    def test_name(self):\n        self.assertEqual(repr(self.var), \"Variable(name='x')\")\n\n    def test_to_val(self):\n        string_var = StringVariable(\"x\")\n        self.assertEqual(string_var.to_val(\"foo\"), \"foo\")\n        self.assertEqual(string_var.to_val(42), \"42\")\n\n        cont_var = ContinuousVariable(\"x\")\n        self.assertTrue(math.isnan(cont_var.to_val(\"?\")))\n        self.assertTrue(math.isnan(Unknown))\n\n        var = Variable(\"x\")\n        self.assertEqual(var.to_val(\"x\"), \"x\")\n\n    def test_repr_is_abstract(self):\n        self.assertRaises(RuntimeError, self.var.repr_val, None)\n\n    def test_properties(self):\n        a = ContinuousVariable()\n        self.assertTrue(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = DiscreteVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertTrue(a.is_discrete)\n        self.assertFalse(a.is_string)\n        self.assertTrue(a.is_primitive())\n\n        a = StringVariable()\n        self.assertFalse(a.is_continuous)\n        self.assertFalse(a.is_discrete)\n        self.assertTrue(a.is_string)\n        self.assertFalse(a.is_primitive())\n\n    def test_properties_as_predicates(self):\n        a = ContinuousVariable()\n        self.assertTrue(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertFalse(Variable.is_string(a))\n        self.assertTrue(Variable.is_primitive(a))\n\n        a = StringVariable()\n        self.assertFalse(Variable.is_continuous(a))\n        self.assertFalse(Variable.is_discrete(a))\n        self.assertTrue(Variable.is_string(a))\n        self.assertFalse(Variable.is_primitive(a))\n\n    def test_strange_eq(self):\n        a = ContinuousVariable()\n        b = ContinuousVariable()\n        self.assertEqual(a, a)\n        self.assertNotEqual(a, b)\n        self.assertNotEqual(a, \"somestring\")\n        # It the next assert ever fails (randomly) blame @janezd\n        self.assertNotEqual(hash(a), hash(b))\n\n\ndef variabletest(varcls):\n    def decorate(cls):\n        return type(cls.__name__, (cls, unittest.TestCase), {'varcls': varcls})\n    return decorate\n\n\n@variabletest(DiscreteVariable)\nclass TestDiscreteVariable(VariableTest):\n    def test_to_val(self):\n        values = [\"F\", \"M\"]\n        var = DiscreteVariable(name=\"Feature 0\", values=values)\n\n        self.assertEqual(var.to_val(0), 0)\n        self.assertEqual(var.to_val(\"F\"), 0)\n        self.assertEqual(var.to_val(0.), 0)\n        self.assertTrue(math.isnan(var.to_val(\"?\")))\n\n        # TODO: with self.assertRaises(ValueError): var.to_val(2)\n        with self.assertRaises(ValueError):\n            var.to_val(\"G\")\n\n    def test_find_compatible_unordered(self):\n        gend = DiscreteVariable(\"gend\", values=[\"F\", \"M\"])\n\n        find_comp = DiscreteVariable._find_compatible\n        self.assertIs(find_comp(\"gend\"), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"M\"]), gend)\n        self.assertIs(find_comp(\"gend\", values=[\"M\", \"F\"]), gend)\n\n        # Incompatible since it is ordered\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\", \"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\", \"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"F\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"M\"], ordered=True))\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"], ordered=True))\n\n        # Incompatible due to empty intersection\n        self.assertIsNone(find_comp(\"gend\", values=[\"N\"]))\n\n        # Compatible, adds values\n        self.assertIs(find_comp(\"gend\", values=[\"F\", \"N\", \"R\"]), gend)\n        self.assertEqual(gend.values, [\"F\", \"M\", \"N\", \"R\"])\n\n    def test_find_compatible_ordered(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n\n        find_comp = DiscreteVariable._find_compatible\n\n        self.assertIsNone(find_comp(\"abc\"))\n        self.assertIsNone(find_comp(\"abc\", list(\"abc\")))\n        self.assertIs(find_comp(\"abc\", ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\"], ordered=True), abc)\n        self.assertIs(find_comp(\"abc\", [\"a\", \"b\", \"c\", \"d\"], ordered=True), abc)\n\n        abd = DiscreteVariable.make(\n            \"abc\", values=[\"a\", \"d\", \"b\"], ordered=True)\n        self.assertIsNot(abc, abd)\n\n        abc_un = DiscreteVariable.make(\"abc\", values=[\"a\", \"b\", \"c\"])\n        self.assertIsNot(abc_un, abc)\n\n        self.assertIs(\n            find_comp(\"abc\", values=[\"a\", \"d\", \"b\"], ordered=True), abd)\n        self.assertIs(find_comp(\"abc\", values=[\"a\", \"b\", \"c\"]), abc_un)\n\n    def test_make(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsInstance(var, DiscreteVariable)\n        self.assertEqual(var.name, \"a\")\n        self.assertEqual(var.values, [\"F\", \"M\"])\n\n    def test_val_from_str(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertTrue(math.isnan(var.to_val(None)))\n        self.assertEqual(var.to_val(1), 1)\n\n    def test_repr(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'])\")\n        var.base_value = 1\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], base_value=1)\")\n        var.ordered = True\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['F', 'M'], \"\n            \"ordered=True, base_value=1)\")\n\n        var = DiscreteVariable.make(\"a\", values=\"1234567\")\n        self.assertEqual(\n            repr(var),\n            \"DiscreteVariable(name='a', values=['1', '2', '3', '4', '5', '6', '7'])\")\n\n    @unittest.skipUnless(is_on_path(\"PyQt4\") or is_on_path(\"PyQt5\"), \"PyQt is not importable\")\n    def test_colors(self):\n        var = DiscreteVariable.make(\"a\", values=[\"F\", \"M\"])\n        self.assertIsNone(var._colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertIs(var._colors, var.colors)\n        self.assertEqual(var.colors.shape, (2, 3))\n        self.assertFalse(var.colors.flags.writeable)\n\n        var.colors = np.arange(6).reshape((2, 3))\n        np.testing.assert_almost_equal(var.colors, [[0, 1, 2], [3, 4, 5]])\n        self.assertFalse(var.colors.flags.writeable)\n        with self.assertRaises(ValueError):\n            var.colors[0] = [42, 41, 40]\n        var.set_color(0, [42, 41, 40])\n        np.testing.assert_almost_equal(var.colors, [[42, 41, 40], [3, 4, 5]])\n\n        var = DiscreteVariable.make(\"x\", values=[\"A\", \"B\"])\n        var.attributes[\"colors\"] = ['#0a0b0c', '#0d0e0f']\n        np.testing.assert_almost_equal(var.colors, [[10, 11, 12], [13, 14, 15]])\n\n        # Test ncolors adapts to nvalues\n        var = DiscreteVariable.make('foo', values=['d', 'r'])\n        self.assertEqual(len(var.colors), 2)\n        var.add_value('e')\n        self.assertEqual(len(var.colors), 3)\n        user_defined = (0, 0, 0)\n        var.set_color(2, user_defined)\n        var.add_value('k')\n        self.assertEqual(len(var.colors), 4)\n        np.testing.assert_array_equal(var.colors[2], user_defined)\n\n    def test_no_nonstringvalues(self):\n        self.assertRaises(TypeError, DiscreteVariable, \"foo\", values=[\"a\", 42])\n        a = DiscreteVariable(\"foo\", values=[\"a\", \"b\", \"c\"])\n        self.assertRaises(TypeError, a.add_value, 42)\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n        self.assertSequenceEqual(d2.values, d2_values)\n        self.assertSequenceEqual(d1c.values, d1.values)\n        s = pickle.dumps(d2)\n        DiscreteVariable._clear_all_caches()  # [comment redacted]\n        d1 = DiscreteVariable(\"A\", values=[\"one\", \"two\"])\n        d2 = pickle.loads(s)\n        self.assertSequenceEqual(d2.values, [\"two\", \"one\", \"three\"])\n\n\n@variabletest(ContinuousVariable)\nclass TestContinuousVariable(VariableTest):\n    def test_make(self):\n        ContinuousVariable._clear_cache()\n        age1 = ContinuousVariable.make(\"age\")\n        age2 = ContinuousVariable.make(\"age\")\n        age3 = ContinuousVariable(\"age\")\n        self.assertEqual(age1, age2)\n        self.assertNotEqual(age1, age3)\n\n    def test_decimals(self):\n        a = ContinuousVariable(\"a\", 4)\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n        self.assertEqual(a.str_val(Unknown), \"?\")\n\n    def test_adjust_decimals(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.str_val(4.654321), \"4.654\")\n        a.val_from_str_add(\"5\")\n        self.assertEqual(a.str_val(4.654321), \"5\")\n        a.val_from_str_add(\"  5.12    \")\n        self.assertEqual(a.str_val(4.654321), \"4.65\")\n        a.val_from_str_add(\"5.1234\")\n        self.assertEqual(a.str_val(4.654321), \"4.6543\")\n\n    def test_colors(self):\n        a = ContinuousVariable(\"a\")\n        self.assertEqual(a.colors, ((0, 0, 255), (255, 255, 0), False))\n        self.assertIs(a.colors, a._colors)\n\n        a = ContinuousVariable(\"a\")\n        a.attributes[\"colors\"] = ['#010203', '#040506', True]\n        self.assertEqual(a.colors, ((1, 2, 3), (4, 5, 6), True))\n\n        a.colors = ((3, 2, 1), (6, 5, 4), True)\n        self.assertEqual(a.colors, ((3, 2, 1), (6, 5, 4), True))\n\n\n@variabletest(StringVariable)\nclass TestStringVariable(VariableTest):\n    def test_val(self):\n        a = StringVariable(\"a\")\n        self.assertEqual(a.to_val(None), \"\")\n        self.assertEqual(a.str_val(\"\"), \"?\")\n        self.assertEqual(a.str_val(Value(a, \"\")), \"?\")\n        self.assertEqual(a.repr_val(Value(a, \"foo\")), '\"foo\"')\n\n\n@variabletest(TimeVariable)\nclass TestTimeVariable(VariableTest):\n    TESTS = [\n        # in str, UTC timestamp, out str (in UTC)\n        ('2015-10-12 14:13:11.01+0200', 1444651991.01, '2015-10-12 14:13:11.010000+0200'),\n        ('2015-10-12T14:13:11.81+0200', 1444651991.81, '2015-10-12 14:13:11.810000+0200'),\n        ('2015-10-12 14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12T14:13:11.81', 1444659191.81, '2015-10-12 14:13:11.810000'),\n        ('2015-10-12 14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12T14:13:11+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012T141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('20151012141311+0200', 1444651991, '2015-10-12 14:13:11+0200'),\n        ('2015-10-12 14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12T14:13:11', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12 14:13', 1444659180, '2015-10-12 14:13:00'),\n        ('20151012T141311', 1444659191, '2015-10-12 14:13:11'),\n        ('20151012141311', 1444659191, '2015-10-12 14:13:11'),\n        ('2015-10-12', 1444608000, '2015-10-12'),\n        ('20151012', 1444608000, '2015-10-12'),\n        ('2015-285', 1444608000, '2015-10-12'),\n        ('2015-10', 1443657600, '2015-10-01'),\n        ('2015', 1420070400, '2015-01-01'),\n        ('01:01:01.01', 3661.01, '01:01:01.010000'),\n        ('010101.01', 3661.01, '01:01:01.010000'),\n        ('01:01:01', 3661, '01:01:01'),\n        ('01:01', 3660, '01:01:00'),\n        ('1970-01-01 00:00:00', 0, '1970-01-01 00:00:00'),\n        ('1969-12-31 23:59:59', -1, '1969-12-31 23:59:59'),\n        ('1969-12-31 23:59:58.9', -1.1, '1969-12-31 23:59:58.900000'),\n        ('1900-01-01', -2208988800, '1900-01-01'),\n        ('nan', np.nan, '?'),\n        ('1444651991.81', 1444651991.81, '2015-10-12 12:13:11.810000'),\n    ]\n\n    def test_parse_repr(self):\n        for datestr, timestamp, outstr in self.TESTS:\n            var = TimeVariable('time')\n            ts = var.to_val(datestr)  # calls parse for strings\n            if not np.isnan(ts):\n                self.assertEqual(ts, timestamp, msg=datestr)\n            self.assertEqual(var.repr_val(ts), outstr, msg=datestr)\n\n    def test_parse_utc(self):\n        var = TimeVariable('time')\n        datestr, offset = '2015-10-18 22:48:20', '+0200'\n        ts1 = var.parse(datestr + offset)\n        self.assertEqual(var.repr_val(ts1), datestr + offset)\n        # Once a value is without a TZ, all the values lose it\n        ts2 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts2), datestr)\n        self.assertEqual(var.repr_val(ts1), '2015-10-18 20:48:20')\n\n    def test_parse_timestamp(self):\n        var = TimeVariable(\"time\")\n        datestr = str(datetime(2016, 6, 14, 23, 8, tzinfo=timezone.utc).timestamp())\n        ts1 = var.parse(datestr)\n        self.assertEqual(var.repr_val(ts1), '2016-06-14 23:08:00')\n\n    def test_parse_invalid(self):\n        var = TimeVariable('var')\n        with self.assertRaises(ValueError):\n            var.parse('123')\n\n    def test_have_date(self):\n        var = TimeVariable('time')\n        ts = var.parse('1937-08-02')  # parse date\n        self.assertEqual(var.repr_val(ts), '1937-08-02')\n        ts = var.parse('16:20')  # parse time\n        # observe have datetime\n        self.assertEqual(var.repr_val(ts), '1970-01-01 16:20:00')\n\n    def test_no_date_no_time(self):\n        self.assertEqual(TimeVariable('relative time').repr_val(1.6), '1.6')\n\n    def test_readwrite_timevariable(self):\n        output_csv = StringIO()\n        input_csv = StringIO(\"\"\"\\\nDate,Feature\ntime,continuous\n,\n1920-12-12,1.0\n1920-12-13,3.0\n1920-12-14,5.5\n\"\"\")\n        for stream in (output_csv, input_csv):\n            stream.close = lambda: None  # HACK: Prevent closing of streams\n\n        table = CSVReader(input_csv).read()\n        self.assertIsInstance(table.domain['Date'], TimeVariable)\n        self.assertEqual(table[0, 'Date'], '1920-12-12')\n        # Dates before 1970 are negative\n        self.assertTrue(all(inst['Date'] < 0 for inst in table))\n\n        CSVReader.write_file(output_csv, table)\n        self.assertEqual(input_csv.getvalue().splitlines(),\n                         output_csv.getvalue().splitlines())\n\n    def test_repr_value(self):\n        # https://github.com/biolab/orange3/pull/1760\n        var = TimeVariable('time')\n        self.assertEqual(var.repr_val(Value(var, 416.3)), '416.3')\n\n    def test_have_date_have_time_in_construct(self):\n        \"\"\"Test if have_time and have_date is correctly set\"\"\"\n        var = TimeVariable('time', have_date=1)\n        self.assertTrue(var.have_date)\n        self.assertFalse(var.have_time)\n\n\nPickleContinuousVariable = create_pickling_tests(\n    \"PickleContinuousVariable\",\n    (\"with_name\", lambda: ContinuousVariable(name=\"Feature 0\")),\n)\n\nPickleDiscreteVariable = create_pickling_tests(\n    \"PickleDiscreteVariable\",\n    (\"with_name\", lambda: DiscreteVariable(name=\"Feature 0\")),\n    (\"with_str_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                values=[\"F\", \"M\"])),\n    (\"ordered\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                         values=[\"F\", \"M\"],\n                                         ordered=True)),\n    (\"with_base_value\", lambda: DiscreteVariable(name=\"Feature 0\",\n                                                 values=[\"F\", \"M\"],\n                                                 base_value=0))\n)\n\n\nPickleStringVariable = create_pickling_tests(\n    \"PickleStringVariable\",\n    (\"with_name\", lambda: StringVariable(name=\"Feature 0\"))\n)\n\n\nclass VariableTestMakeProxy(unittest.TestCase):\n    def setUp(self):\n        Variable._clear_all_caches()\n\n    def test_make_proxy_disc(self):\n        abc = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n        abcx = DiscreteVariable(\"abc\", values=\"abc\", ordered=True)\n        self.assertNotEqual(abc, abcx)\n\n        abc1p = pickle.loads(pickle.dumps(abc1))\n        self.assertIs(abc1p.master, abc)\n        self.assertEqual(abc1p, abc)\n\n        abcp, abc1p, abc2p = pickle.loads(pickle.dumps((abc, abc1, abc2)))\n        self.assertIs(abcp.master, abcp.master)\n        self.assertIs(abc1p.master, abcp.master)\n        self.assertIs(abc2p.master, abcp.master)\n        self.assertEqual(abcp, abc1p)\n        self.assertEqual(abcp, abc2p)\n        self.assertEqual(abc1p, abc2p)\n\n    def test_make_proxy_cont(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n        self.assertIs(abc.master, abc)\n        self.assertIs(abc1.master, abc)\n        self.assertIs(abc2.master, abc)\n        self.assertEqual(abc, abc1)\n        self.assertEqual(abc, abc2)\n        self.assertEqual(abc1, abc2)\n        self.assertEqual(hash(abc), hash(abc1))\n        self.assertEqual(hash(abc1), hash(abc2))\n\n    def test_proxy_has_separate_colors(self):\n        abc = ContinuousVariable(\"abc\")\n        abc1 = abc.make_proxy()\n        abc2 = abc1.make_proxy()\n\n        original_colors = abc.colors\n        red_to_green = (255, 0, 0), (0, 255, 0), False\n        blue_to_red = (0, 0, 255), (255, 0, 0), False\n\n        abc1.colors = red_to_green\n        abc2.colors = blue_to_red\n        self.assertEqual(abc.colors, original_colors)\n        self.assertEqual(abc1.colors, red_to_green)\n        self.assertEqual(abc2.colors, blue_to_red)\n\n    def test_proxy_has_separate_attributes(self):\n        image = StringVariable(\"image\")\n        image1 = image.make_proxy()\n        image2 = image1.make_proxy()\n\n        image.attributes[\"origin\"] = \"a\"\n        image1.attributes[\"origin\"] = \"b\"\n        image2.attributes[\"origin\"] = \"c\"\n\n        self.assertEqual(image.attributes[\"origin\"], \"a\")\n        self.assertEqual(image1.attributes[\"origin\"], \"b\")\n        self.assertEqual(image2.attributes[\"origin\"], \"c\")\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...\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nrunning build_ext\nrunning build_src\nbuild_src\nbuilding extension \"Orange.classification._simple_tree\" sources\nbuilding extension \"Orange.classification._tree_scorers\" sources\nbuilding extension \"Orange.data._valuecount\" sources\nbuilding extension \"Orange.data._contingency\" sources\nbuilding extension \"Orange.data._io\" sources\nbuilding extension \"Orange.data._variable\" sources\nbuilding extension \"Orange.distance._distance\" sources\nbuilding extension \"Orange.preprocess._discretize\" sources\nbuilding extension \"Orange.preprocess._relieff\" sources\nbuilding extension \"Orange.widgets.utils._grid_density\" sources\nbuild_src: building npy-pkg config files\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmpgq2kl9qs/tmp\ncreating /tmp/tmpgq2kl9qs/tmp/tmpgq2kl9qs\ncompile options: '-MMD -MF /tmp/tmpgq2kl9qs/file.c.d -c'\ncc: /tmp/tmpgq2kl9qs/file.c\ncustomize UnixCCompiler using build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmp_7lb3ydf/tmp\ncreating /tmp/tmp_7lb3ydf/tmp/tmp_7lb3ydf\ncompile options: '-MMD -MF /tmp/tmp_7lb3ydf/file.c.d -c'\ncc: /tmp/tmp_7lb3ydf/file.c\ncustomize UnixCCompiler using build_ext\nbuilding 'Orange.classification._simple_tree' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange\ncreating build/temp.linux-x86_64-3.7/Orange/classification\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/classification/_simple_tree.c\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 Orange/classification/_simple_tree.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.classification._tree_scorers' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/classification/_tree_scorers.c\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 Orange/classification/_tree_scorers.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._valuecount' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/data\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_valuecount.c\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 Orange/data/_valuecount.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._contingency' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_contingency.c\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 Orange/data/_contingency.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._io' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_io.c\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 Orange/data/_io.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.data._variable' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/data/_variable.c\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 Orange/data/_variable.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.distance._distance' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/distance\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/distance/_distance.c\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 Orange/distance/_distance.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._discretize' extension\ncompiling C sources\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/preprocess\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\ncc: Orange/preprocess/_discretize.c\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 Orange/preprocess/_discretize.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.preprocess._relieff' extension\ncompiling C++ sources\nC compiler: c++ -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\nc++: Orange/preprocess/_relieff.cpp\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 Orange/preprocess/_relieff.cpython-37m-x86_64-linux-gnu.so\nbuilding 'Orange.widgets.utils._grid_density' extension\ncompiling C++ sources\nC compiler: c++ -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating build/temp.linux-x86_64-3.7/Orange/widgets\ncreating build/temp.linux-x86_64-3.7/Orange/widgets/utils\ncompile options: '-I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/include -I/home/gcpuser/.local/share/uv/python/cpython-3.7.9-linux-x86_64-gnu/include/python3.7m -c'\nc++: Orange/widgets/utils/_grid_density.cpp\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 Orange/widgets/utils/_grid_density.cpython-37m-x86_64-linux-gnu.so\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nWarning: 'keywords' should be a list, got type 'tuple'\nWarning: 'classifiers' should be a list, got type 'tuple'\nrunning develop\nrunning build_scripts\nrunning egg_info\nrunning build_src\nbuild_src\nbuilding extension \"Orange.classification._simple_tree\" sources\nbuilding extension \"Orange.classification._tree_scorers\" sources\nbuilding extension \"Orange.data._valuecount\" sources\nbuilding extension \"Orange.data._contingency\" sources\nbuilding extension \"Orange.data._io\" sources\nbuilding extension \"Orange.data._variable\" sources\nbuilding extension \"Orange.distance._distance\" sources\nbuilding extension \"Orange.preprocess._discretize\" sources\nbuilding extension \"Orange.preprocess._relieff\" sources\nbuilding extension \"Orange.widgets.utils._grid_density\" sources\nbuild_src: building npy-pkg config files\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'\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 '*.html' under directory 'Orange/canvas'\nwarning: no files found matching '*.css' under directory 'Orange/widgets'\nwarning: no files found matching 'COPYING'\nadding license file 'LICENSE'\nwriting manifest file 'Orange3.egg-info/SOURCES.txt'\nrunning build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmps6ni8kpg/tmp\ncreating /tmp/tmps6ni8kpg/tmp/tmps6ni8kpg\ncompile options: '-MMD -MF /tmp/tmps6ni8kpg/file.c.d -c'\ncc: /tmp/tmps6ni8kpg/file.c\ncustomize UnixCCompiler using build_ext\ncustomize UnixCCompiler\nC compiler: cc -pthread -Wno-unused-result -Wsign-compare -Wunreachable-code -DNDEBUG -g -fwrapv -O3 -Wall -fPIC -I/tools/deps/include -I/tools/deps/include/ncursesw -fPIC\n\ncreating /tmp/tmpw536k0fk/tmp\ncreating /tmp/tmpw536k0fk/tmp/tmpw536k0fk\ncompile options: '-MMD -MF /tmp/tmpw536k0fk/file.c.d -c'\ncc: /tmp/tmpw536k0fk/file.c\ncustomize UnixCCompiler using build_ext\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.16.0.dev0+a95245e to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce\nProcessing dependencies for Orange3==3.16.0.dev0+a95245e\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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.16.0.dev0+a95245e\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 260ms\nPrepared 18 packages in 1ms\nInstalled 18 packages in 403ms\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 31 packages in 170ms\nInstalled 26 packages in 405ms\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 + 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 + more-itertools==9.1.0\n + networkx==2.6.3\n + pip==24.0\n + pycparser==2.21\n + python-louvain==0.16\n + requests==2.31.0\n + scikit-learn==1.0.2\n + scipy==1.7.3\n + secretstorage==3.3.3\n + serverfiles==0.3.1\n + threadpoolctl==3.1.0\n + urllib3==2.0.7\n + xlrd==2.0.1\nResolved 14 packages in 63ms\nInstalled 11 packages in 128ms\n + anyqt==0.2.0\n + cycler==0.11.0\n + docutils==0.20.1\n + fonttools==4.38.0\n + kiwisolver==1.4.5\n + matplotlib==3.5.3\n + pillow==9.5.0\n + pyparsing==3.1.4\n + pyqtgraph==0.12.4\n + python-dateutil==2.9.0.post0\n + six==1.17.0\nResolved 2 packages in 3ms\nInstalled 2 packages in 7ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 5 packages in 15ms\nInstalled 2 packages in 112ms\n + pandas==1.3.5\n + pytz==2024.2\nAudited 2 packages in 4ms\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      |         ^~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/classification/_tree_scorers.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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:3115:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 3115 |   __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:4619:27: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 4619 |   __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:5396:43: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5396 |           for (__pyx_t_22 = 0; __pyx_t_22 < __pyx_t_21; __pyx_t_22+=1) {\n      |                                           ^\nOrange/classification/_tree_scorers.c:5517:39: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5517 |           __pyx_t_27 = ((__pyx_v_left >= __pyx_v_min_leaf) != 0);\n      |                                       ^~\nOrange/classification/_tree_scorers.c:5523:53: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 5523 |           __pyx_t_27 = (((__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:7051:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7051 |         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:7741:41: warning: comparison of integer expressions of different signedness: ‘unsigned int’ and ‘int’ [-Wsign-compare]\n 7741 |         for (__pyx_t_11 = 0; __pyx_t_11 < __pyx_t_10; __pyx_t_11+=1) {\n      |                                         ^\nOrange/classification/_tree_scorers.c:7801:143: warning: comparison of integer expressions of different signedness: ‘__pyx_t_5numpy_int32_t’ {aka ‘int’} and ‘unsigned int’ [-Wsign-compare]\n 7801 |               __pyx_t_17 = (((*((__pyx_t_5numpy_int32_t *) ( /* dim=0 */ (__pyx_v_indices.data + __pyx_t_18 * __pyx_v_indices.strides[0]) ))) != __pyx_v_i) != 0);\n      |                                                                                                                                               ^~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_valuecount.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/data/_contingency.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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:3881:24: warning: ‘__pyx_v_decs’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 3881 |           __pyx_v_decs = (__pyx_v_decs / 10.0);\n      |           ~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:4070:24: warning: ‘__pyx_v_value’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 4070 |           __pyx_t_10 = PyFloat_FromDouble(__pyx_v_value); if (unlikely(!__pyx_t_10)) __PYX_ERR(0, 221, __pyx_L5_error)\n      |                        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:480:40: warning: ‘__pyx_v_attr_index’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n  480 |   #define PyInt_FromLong               PyLong_FromLong\n      |                                        ^~~~~~~~~~~~~~~\nOrange/data/_io.c:1301:7: note: ‘__pyx_v_attr_index’ was declared here\n 1301 |   int __pyx_v_attr_index;\n      |       ^~~~~~~~~~~~~~~~~~\nOrange/data/_io.c:2935:25: warning: ‘__pyx_v_atomp’ may be used uninitialized in this function [-Wmaybe-uninitialized]\n 2935 |           __pyx_v_atomp = (__pyx_v_atomp + 1);\n      |           ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~\nIn file included from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/distance/_distance.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_discretize.c:567:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/arrayobject.h:4,\n                 from Orange/preprocess/_relieff.cpp:581:\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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      |  ^~~~~~~\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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_a95245e37f35446f9870feb68f5ebb97d1c279ce/.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,\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_a95245e37f35446f9870feb68f5ebb97d1c279ce/.venv/lib/python3.7/site-packages/setuptools/command/egg_info.py:628: SetuptoolsDeprecationWarning: Custom 'build_py' does not implement 'get_data_files_without_manifest'.\nPlease extend command classes from setuptools instead of distutils.\n  SetuptoolsDeprecationWarning\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_a95245e37f35446f9870feb68f5ebb97d1c279ce\ncollected 55 items\n\nr2e_tests/test_1.py .................................................... [ 94%]\n...                                                                      [100%]\n\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestVariable::test_name\nPASSED r2e_tests/test_1.py::TestVariable::test_properties\nPASSED r2e_tests/test_1.py::TestVariable::test_properties_as_predicates\nPASSED r2e_tests/test_1.py::TestVariable::test_repr_is_abstract\nPASSED r2e_tests/test_1.py::TestVariable::test_strange_eq\nPASSED r2e_tests/test_1.py::TestVariable::test_to_val\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_colors\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_find_compatible_ordered\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_find_compatible_unordered\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_make\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_no_nonstringvalues\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_repr\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_to_val\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_unpickle\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_val_from_str\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_adjust_decimals\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_colors\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_decimals\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_make\nPASSED r2e_tests/test_1.py::TestStringVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_val\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date_have_time_in_construct\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_no_date_no_time\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_invalid\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_repr\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_timestamp\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_utc\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_readwrite_timevariable\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_repr_value\nPASSED r2e_tests/test_1.py::PickleContinuousVariable::test_with_name\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_ordered\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_base_value\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_name\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_str_value\nPASSED r2e_tests/test_1.py::PickleStringVariable::test_with_name\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_make_proxy_cont\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_make_proxy_disc\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_proxy_has_separate_attributes\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_proxy_has_separate_colors\n============================== 55 passed in 0.72s ==============================\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_a95245e37f35446f9870feb68f5ebb97d1c279ce\ncollected 55 items\n\nr2e_tests/test_1.py .................F.................................. [ 94%]\n...                                                                      [100%]\n\n=================================== FAILURES ===================================\n______________________ TestDiscreteVariable.test_unpickle ______________________\n\nself = <r2e_tests.test_1.TestDiscreteVariable testMethod=test_unpickle>\n\n    def test_unpickle(self):\n        d1 = DiscreteVariable(\"A\", values=[\"two\", \"one\"])\n        s = pickle.dumps(d1)\n        d2 = DiscreteVariable.make(\"A\", values=[\"one\", \"two\", \"three\"])\n        d2_values = tuple(d2.values)\n        d1c = pickle.loads(s)\n        # See: gh-3238\n        # The unpickle reconstruction picks an existing variable (d2), on which\n        # __setstate__ or __dict__.update is called\n>       self.assertSequenceEqual(d2.values, d2_values)\nE       AssertionError: Sequences differ: ['two', 'one'] != ('two', 'one', 'three')\nE       \nE       Second sequence contains 1 additional elements.\nE       First extra element 2:\nE       'three'\nE       \nE       - ['two', 'one']\nE       + ('two', 'one', 'three')\n\nr2e_tests/test_1.py:278: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestVariable::test_name\nPASSED r2e_tests/test_1.py::TestVariable::test_properties\nPASSED r2e_tests/test_1.py::TestVariable::test_properties_as_predicates\nPASSED r2e_tests/test_1.py::TestVariable::test_repr_is_abstract\nPASSED r2e_tests/test_1.py::TestVariable::test_strange_eq\nPASSED r2e_tests/test_1.py::TestVariable::test_to_val\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_colors\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_find_compatible_ordered\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_find_compatible_unordered\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_make\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_no_nonstringvalues\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_repr\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_to_val\nPASSED r2e_tests/test_1.py::TestDiscreteVariable::test_val_from_str\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_adjust_decimals\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_colors\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_decimals\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestContinuousVariable::test_make\nPASSED r2e_tests/test_1.py::TestStringVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestStringVariable::test_val\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_copy_copies_attributes\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_make_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_pickle_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_dont_store_anonymous_variables\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_have_date_have_time_in_construct\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_no_date_no_time\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_invalid\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_repr\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_timestamp\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_parse_utc\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_readwrite_timevariable\nPASSED r2e_tests/test_1.py::TestTimeVariable::test_repr_value\nPASSED r2e_tests/test_1.py::PickleContinuousVariable::test_with_name\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_ordered\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_base_value\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_name\nPASSED r2e_tests/test_1.py::PickleDiscreteVariable::test_with_str_value\nPASSED r2e_tests/test_1.py::PickleStringVariable::test_with_name\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_make_proxy_cont\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_make_proxy_disc\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_proxy_has_separate_attributes\nPASSED r2e_tests/test_1.py::VariableTestMakeProxy::test_proxy_has_separate_colors\nFAILED r2e_tests/test_1.py::TestDiscreteVariable::test_unpickle - AssertionEr...\n========================= 1 failed, 54 passed in 0.88s =========================\n",
    "old_commit_res_stderr": ""
}
Orange/data/tests/test_variable.py Orange/data/variable.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** Unpickling `DiscreteVariable` Adds Unexpected Values Leading to Inconsistencies

**Description:**

When attempting to unpickle a `DiscreteVariable` with a predefined set of values, the resulting object unexpectedly includes additional values that were not present in the original. This leads to discrepancies between the expected and actual values of the variable, potentially causing issues in data processing workflows.

**Example:**

```python
import pickle
from Orange.data import DiscreteVariable

# Original DiscreteVariable with values ['two', 'one']
d1 = DiscreteVariable('A', values=['two', 'one'])
s = pickle.dumps(d1)

# Creating another DiscreteVariable with an extended set of values
d2 = DiscreteVariable.make('A', values=['one', 'two', 'three'])
d1c = pickle.loads(s)

print(d2.values)   # Expected: ['one', 'two', 'three']
print(d1c.values)  # Actual: ['two', 'one', 'three']
```

**Expected Behavior:**
Unpickling a `DiscreteVariable` should accurately reconstruct the original set of values without introducing any additional elements. The `values` attribute of the unpickled object should match exactly what was initially serialized.

**Actual Behavior:**
The unpickled `DiscreteVariable` includes an extra value (`'three'`) that was not part of the original object. This results in `d1c.values` being `['two', 'one', 'three']` instead of the expected `['two', 'one']`.

This inconsistency can lead to unexpected behavior in applications relying on the integrity of the `DiscreteVariable`'s values, such as data analysis, serialization, and deserialization processes.
[/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/data/variable.py
import collections
import re

from datetime import datetime, timedelta, timezone
from numbers import Number, Real, Integral
from math import isnan, floor
from pickle import PickleError

import numpy as np

from Orange.data import _variable
from Orange.util import Registry, color_to_hex, hex_to_color, Reprable

__all__ = ["Unknown", "MISSING_VALUES", "make_variable", "is_discrete_values",
           "Value", "Variable", "ContinuousVariable", "DiscreteVariable",
           "StringVariable", "TimeVariable"]


# For storing unknowns
Unknown = ValueUnknown = float("nan")
# For checking for unknowns
MISSING_VALUES = {np.nan, "?", "nan", ".", "", "NA", "~", None}

DISCRETE_MAX_VALUES = 3  # == 2 + nan


def make_variable(cls, compute_value, *args):
    if compute_value is not None:
        return cls(*args, compute_value=compute_value)
    return cls.make(*args)


def is_discrete_values(values):
    """
    Return set of uniques if `values` is an iterable of discrete values
    else False if non-discrete, or None if indeterminate.

    Note
    ----
    Assumes consistent type of items of `values`.
    """
    if not len(values):
        return None
    # If the first few values are, or can be converted to, floats,
    # the type is numeric
    try:
        isinstance(next(iter(values)), Number) or \
        [float(v) for _, v in zip(range(min(3, len(values))), values)]
    except ValueError:
        is_numeric = False
        max_values = int(round(len(values)**.7))
    else:
        is_numeric = True
        max_values = DISCRETE_MAX_VALUES

    # If more than max values => not discrete
    unique = set()
    for i in values:
        unique.add(i)
        if len(unique) > max_values:
            return False

    # Strip NaN from unique
    unique = {i for i in unique
              if (not i in MISSING_VALUES and
                  not (isinstance(i, Number) and np.isnan(i)))}

    # All NaNs => indeterminate
    if not unique:
        return None

    # Strings with |values| < max_unique
    if not is_numeric:
        return unique

    # Handle numbers
    try:
        unique_float = set(map(float, unique))
    except ValueError:
        # Converting all the values to floats resulted in an error.
        # Since the values have enough unique values, they are probably
        # string values and discrete.
        return unique

    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete
    return (not (unique_float - {0, 1}) or
            not (unique_float - {1, 2})) and unique


class Value(float):
    """
    The class representing a value. The class is not used to store values but
    only to return them in contexts in which we want the value to be accompanied
    with the descriptor, for instance to print the symbolic value of discrete
    variables.

    The class is derived from `float`, with an additional attribute `variable`
    which holds the descriptor of type :obj:`Orange.data.Variable`. If the
    value continuous or discrete, it is stored as a float. Other types of
    values, like strings, are stored in the attribute `value`.

    The class overloads the methods for printing out the value:
    `variable.repr_val` and `variable.str_val` are used to get a suitable
    representation of the value.

    Equivalence operator is overloaded as follows:

    - unknown values are equal; if one value is unknown and the other is not,
      they are different;

    - if the value is compared with the string, the value is converted to a
      string using `variable.str_val` and the two strings are compared

    - if the value is stored in attribute `value`, it is compared with the
      given other value

    - otherwise, the inherited comparison operator for `float` is called.

    Finally, value defines a hash, so values can be put in sets and appear as
    keys in dictionaries.

    .. attribute:: variable (:obj:`Orange.data.Variable`)

        Descriptor; used for printing out and for comparing with strings

    .. attribute:: value

        Value; the value can be of arbitrary type and is used only for variables
        that are neither discrete nor continuous. If `value` is `None`, the
        derived `float` value is used.
    """
    __slots__ = "variable", "_value"

    def __new__(cls, variable, value=Unknown):
        """
        Construct a new instance of Value with the given descriptor and value.
        If the argument `value` can be converted to float, it is stored as
        `float` and the attribute `value` is set to `None`. Otherwise, the
        inherited float is set to `Unknown` and the value is held by the
        attribute `value`.

        :param variable: descriptor
        :type variable: Orange.data.Variable
        :param value: value
        """
        if variable.is_primitive():
            self = super().__new__(cls, value)
            self.variable = variable
            self._value = None
        else:
            isunknown = value == variable.Unknown
            self = super().__new__(
                cls, np.nan if isunknown else np.finfo(float).min)
            self.variable = variable
            self._value = value
        return self

    def __init__(self, _, __=Unknown):
        pass

    def __repr__(self):
        return "Value('%s', %s)" % (self.variable.name,
                                    self.variable.repr_val(self))

    def __str__(self):
        return self.variable.str_val(self)

    def __eq__(self, other):
        if isinstance(self, Real) and isnan(self):
            return (isinstance(other, Real) and isnan(other)
                    or other in self.variable.unknown_str)
        if isinstance(other, str):
            return self.variable.str_val(self) == other
        if isinstance(other, Value):
            return self.value == other.value
        return super().__eq__(other)

    def __ne__(self, other):
        return not self.__eq__(other)

    def __lt__(self, other):
        if self.variable.is_primitive():
            if isinstance(other, str):
                return super().__lt__(self.variable.to_val(other))
            else:
                return super().__lt__(other)
        else:
            if isinstance(other, str):
                return self.value < other
            else:
                return self.value < other.value

    def __le__(self, other):
        return self.__lt__(other) or self.__eq__(other)

    def __gt__(self, other):
        return not self.__le__(other)

    def __ge__(self, other):
        return not self.__lt__(other)

    def __contains__(self, other):
        if (self._value is not None
                and isinstance(self._value, str)
                and isinstance(other, str)):
            return other in self._value
        raise TypeError("invalid operation on Value()")

    def __hash__(self):
        if self.variable.is_discrete:
            # It is not possible to hash the id and the domain value to the same number as required by __eq__.
            # hash(1) == hash(Value(DiscreteVariable("var", ["red", "green", "blue"]), 1)) == hash("green")
            # User should hash directly ids or domain values instead.
            raise TypeError("unhashable type - cannot hash values of discrete variables!")
        if self._value is None:
            return super().__hash__()
        else:
            return hash(self._value)

    @property
    def value(self):
        if self.variable.is_discrete:
            return Unknown if isnan(self) else self.variable.values[int(self)]
        if self.variable.is_string:
            return self._value
        return float(self)

    def __getnewargs__(self):
        return self.variable, float(self)

    def __getstate__(self):
        return dict(value=getattr(self, '_value', None))

    def __setstate__(self, state):
        self._value = state.get('value', None)


class VariableMeta(Registry):
    def __new__(cls, name, bases, attrs):
        obj = super().__new__(cls, name, bases, attrs)
        if not hasattr(obj, '_all_vars') or obj._all_vars is Variable._all_vars:
            obj._all_vars = {}
        return obj


class _predicatedescriptor(property):
    """
    A property that behaves as a class method if accessed via a class
    >>> class A:
    ...     foo = False
    ...     @_predicatedescriptor
    ...     def is_foo(self):
    ...         return self.foo
    ...
    >>> a = A()
    >>> a.is_foo
    False
    >>> A.is_foo(a)
    False
    """
    def __get__(self, instance, objtype=None):
        if instance is None:
            return self.fget
        else:
            return super().__get__(instance, objtype)


class Variable(Reprable, metaclass=VariableMeta):
    """
    The base class for variable descriptors contains the variable's
    name and some basic properties.

    .. attribute:: name

        The name of the variable.

    .. attribute:: unknown_str

        A set of values that represent unknowns in conversion from textual
        formats. Default is `{"?", ".", "", "NA", "~", None}`.

    .. attribute:: compute_value

        A function for computing the variable's value when converting from
        another domain which does not contain this variable. The function will
        be called with a data set (`Orange.data.Table`) and has to return
        an array of computed values for all its instances. The base class
        defines a static method `compute_value`, which returns `Unknown`.
        Non-primitive variables must redefine it to return `None`.

    .. attribute:: sparse

        A flag about sparsity of the variable. When set, the variable suggests
        it should be stored in a sparse matrix.

    .. attribute:: source_variable

        An optional descriptor of the source variable - if any - from which
        this variable is derived and computed via :obj:`compute_value`.

    .. attribute:: attributes

        A dictionary with user-defined attributes of the variable

    .. attribute:: master

        The variable that this variable is a copy of. If a copy is made from a
        copy, the copy has a reference to the original master. If the variable
        is not a copy, it is its own master.
    """
    Unknown = ValueUnknown

    def __init__(self, name="", compute_value=None, *, sparse=False):
        """
        Construct a variable descriptor.
        """
        self.name = name
        self._compute_value = compute_value
        self.unknown_str = MISSING_VALUES
        self.source_variable = None
        self.sparse = sparse
        self.attributes = {}
        self.master = self
        if name and compute_value is None:
            if isinstance(self._all_vars, collections.defaultdict):
                self._all_vars[name].append(self)
            else:
                self._all_vars[name] = self
        self._colors = None

    def make_proxy(self):
        """
        Copy the variable and set the master to `self.master` or to `self`.

        :return: copy of self
        :rtype: Variable
        """
        var = self.__class__()
        var.__dict__.update(self.__dict__)
        var.attributes = dict(self.attributes)
        var.master = self.master
        return var

    def __eq__(self, other):
        """Two variables are equivalent if the originate from the same master"""
        return hasattr(other, "master") and self.master is other.master

    def __hash__(self):
        if self.master is not self:
            return hash(self.master)
        else:
            return super().__hash__()

    @classmethod
    def make(cls, name):
        """
        Return an existing continuous variable with the given name, or
        construct and return a new one.
        """
        if not name:
            raise ValueError("Variables without names cannot be stored or made")
        var = cls._all_vars.get(name) or cls(name)
        return var.make_proxy()

    @classmethod
    def _clear_cache(cls):
        """
        Clear the list of variables for reuse by :obj:`make`.
        """
        cls._all_vars.clear()

    @staticmethod
    def _clear_all_caches():
        """
        Clears list of stored variables for all subclasses
        """
        for cls in Variable.registry.values():
            cls._clear_cache()

    @classmethod
    def is_primitive(cls, var=None):
        """
        `True` if the variable's values are stored as floats.
        Non-primitive variables can appear in the data only as meta attributes.
        """
        to_check = cls if var is None else type(var)
        return issubclass(to_check, (DiscreteVariable, ContinuousVariable))

    @_predicatedescriptor
    def is_discrete(self):
        return isinstance(self, DiscreteVariable)

    @_predicatedescriptor
    def is_continuous(self):
        return isinstance(self, ContinuousVariable)

    @_predicatedescriptor
    def is_string(self):
        return isinstance(self, StringVariable)

    @_predicatedescriptor
    def is_time(self):
        return isinstance(self, TimeVariable)

    def repr_val(self, val):
        """
        Return a textual representation of variable's value `val`. Argument
        `val` must be a float (for primitive variables) or an arbitrary
        Python object (for non-primitives).

        Derived classes must overload the function.
        """
        raise RuntimeError("variable descriptors must overload repr_val()")

    str_val = repr_val

    def to_val(self, s):
        """
        Convert the given argument to a value of the variable. The
        argument can be a string, a number or `None`. For primitive variables,
        the base class provides a method that returns
        :obj:`~Orange.data.Unknown` if `s` is found in
        :obj:`~Orange.data.Variable.unknown_str`, and raises an exception
        otherwise. For non-primitive variables it returns the argument itself.

        Derived classes of primitive variables must overload the function.

        :param s: value, represented as a number, string or `None`
        :type s: str, float or None
        :rtype: float or object
        """
        if not self.is_primitive():
            return s
        if s in self.unknown_str:
            return Unknown
        raise RuntimeError(
            "primitive variable descriptors must overload to_val()")

    def val_from_str_add(self, s):
        """
        Convert the given string to a value of the variable. The method
        is similar to :obj:`to_val` except that it only accepts strings and
        that it adds new values to the variable's domain where applicable.

        The base class method calls `to_val`.

        :param s: symbolic representation of the value
        :type s: str
        :rtype: float or object
        """
        return self.to_val(s)

    def __str__(self):
        return self.name

    @property
    def compute_value(self):
        return self._compute_value

    def __reduce__(self):
        if not self.name:
            raise PickleError("Variables without names cannot be pickled")

        # Use make to unpickle variables.
        # "master" attribute is removed from the dict since make will point
        # it to the correct variable. If we did not remove it, the (pickled)
        # value would replace the one set by make.
        __dict__ = dict(self.__dict__)
        __dict__.pop("master", None)
        return make_variable, (self.__class__, self._compute_value, self.name), __dict__

    def copy(self, compute_value):
        var = type(self)(self.name, compute_value=compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


del _predicatedescriptor


class ContinuousVariable(Variable):
    """
    Descriptor for continuous variables.

    .. attribute:: number_of_decimals

        The number of decimals when the value is printed out (default: 3).

    .. attribute:: adjust_decimals

        A flag regulating whether the `number_of_decimals` is being adjusted
        by :obj:`to_val`.

    The value of `number_of_decimals` is set to 3 and `adjust_decimals`
    is set to 2. When :obj:`val_from_str_add` is called for the first
    time with a string as an argument, `number_of_decimals` is set to the
    number of decimals in the string and `adjust_decimals` is set to 1.
    In the subsequent calls of `to_val`, the nubmer of decimals is
    increased if the string argument has a larger number of decimals.

    If the `number_of_decimals` is set manually, `adjust_decimals` is
    set to 0 to prevent changes by `to_val`.
    """

    TYPE_HEADERS = ('continuous', 'c', 'numeric', 'n')

    def __init__(self, name="", number_of_decimals=None, compute_value=None, *, sparse=False):
        """
        Construct a new continuous variable. The number of decimals is set to
        three, but adjusted at the first call of :obj:`to_val`.
        """
        super().__init__(name, compute_value, sparse=sparse)
        if number_of_decimals is None:
            self.number_of_decimals = 3
            self.adjust_decimals = 2
        else:
            self.number_of_decimals = number_of_decimals

    @property
    def number_of_decimals(self):
        return self._number_of_decimals

    @property
    def colors(self):
        if self._colors is None:
            try:
                col1, col2, black = self.attributes["colors"]
                self._colors = (hex_to_color(col1), hex_to_color(col2), black)
            except (KeyError, ValueError):
                # Stored colors were not available or invalid, use defaults
                self._colors = ((0, 0, 255), (255, 255, 0), False)
        return self._colors

    @colors.setter
    def colors(self, value):
        col1, col2, black = self._colors = value
        self.attributes["colors"] = \
            [color_to_hex(col1), color_to_hex(col2), black]

    # noinspection PyAttributeOutsideInit
    @number_of_decimals.setter
    def number_of_decimals(self, x):
        self._number_of_decimals = x
        self.adjust_decimals = 0
        self._out_format = "%.{}f".format(self.number_of_decimals)

    def to_val(self, s):
        """
        Convert a value, given as an instance of an arbitrary type, to a float.
        """
        if s in self.unknown_str:
            return Unknown
        return float(s)

    def val_from_str_add(self, s):
        """
        Convert a value from a string and adjust the number of decimals if
        `adjust_decimals` is non-zero.
        """
        return _variable.val_from_str_add_cont(self, s)

    def repr_val(self, val):
        """
        Return the value as a string with the prescribed number of decimals.
        """
        if isnan(val):
            return "?"
        return self._out_format % val

    str_val = repr_val

    def copy(self, compute_value=None):
        var = type(self)(self.name, self.number_of_decimals, compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


class DiscreteVariable(Variable):
    """
    Descriptor for symbolic, discrete variables. Values of discrete variables
    are stored as floats; the numbers corresponds to indices in the list of
    values.

    .. attribute:: values

        A list of variable's values.

    .. attribute:: ordered

        Some algorithms (and, in particular, visualizations) may
        sometime reorder the values of the variable, e.g. alphabetically.
        This flag hints that the given order of values is "natural"
        (e.g. "small", "middle", "large") and should not be changed.

    .. attribute:: base_value

        The index of the base value, or -1 if there is none. The base value is
        used in some methods like, for instance, when creating dummy variables
        for regression.
    """

    TYPE_HEADERS = ('discrete', 'd', 'categorical')

    _all_vars = collections.defaultdict(list)
    presorted_values = []

    def __init__(self, name="", values=(), ordered=False, base_value=-1,
                 compute_value=None, *, sparse=False):
        """ Construct a discrete variable descriptor with the given values. """
        self.values = list(values)
        if not all(isinstance(value, str) for value in self.values):
            raise TypeError("values of DiscreteVariables must be strings")
        super().__init__(name, compute_value, sparse=sparse)
        self.ordered = ordered
        self.base_value = base_value

    @property
    def colors(self):
        if self._colors is None:
            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator
            self._colors = ColorPaletteGenerator.palette(self)
            colors = self.attributes.get('colors')
            if colors:
                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]
            self._colors.flags.writeable = False
        return self._colors

    @colors.setter
    def colors(self, value):
        self._colors = value
        self._colors.flags.writeable = False
        self.attributes["colors"] = [color_to_hex(col) for col in value]

    def set_color(self, i, color):
        self.colors = self.colors
        self._colors.flags.writeable = True
        self._colors[i, :] = color
        self._colors.flags.writeable = False
        self.attributes["colors"][i] = color_to_hex(color)

    def to_val(self, s):
        """
        Convert the given argument to a value of the variable (`float`).
        If the argument is numeric, its value is returned without checking
        whether it is integer and within bounds. `Unknown` is returned if the
        argument is one of the representations for unknown values. Otherwise,
        the argument must be a string and the method returns its index in
        :obj:`values`.

        :param s: values, represented as a number, string or `None`
        :rtype: float
        """
        if s is None:
            return ValueUnknown

        if isinstance(s, Integral):
            return s
        if isinstance(s, Real):
            return s if isnan(s) else floor(s + 0.25)
        if s in self.unknown_str:
            return ValueUnknown
        if not isinstance(s, str):
            raise TypeError('Cannot convert {} to value of "{}"'.format(
                type(s).__name__, self.name))
        return self.values.index(s)

    def add_value(self, s):
        """ Add a value `s` to the list of values.
        """
        if not isinstance(s, str):
            raise TypeError("values of DiscreteVariables must be strings")
        self.values.append(s)
        self._colors = None

    def val_from_str_add(self, s):
        """
        Similar to :obj:`to_val`, except that it accepts only strings and that
        it adds the value to the list if it does not exist yet.

        :param s: symbolic representation of the value
        :type s: str
        :rtype: float
        """
        s = str(s) if s is not None else s
        try:
            return ValueUnknown if s in self.unknown_str \
                else self.values.index(s)
        except ValueError:
            self.add_value(s)
            return len(self.values) - 1

    def repr_val(self, val):
        """
        Return a textual representation of the value (`self.values[int(val)]`)
        or "?" if the value is unknown.

        :param val: value
        :type val: float (should be whole number)
        :rtype: str
        """
        if isnan(val):
            return "?"
        return '{}'.format(self.values[int(val)])

    str_val = repr_val

    def __reduce__(self):
        if not self.name:
            raise PickleError("Variables without names cannot be pickled")
        return make_variable, (self.__class__, self._compute_value, self.name,
                               self.values, self.ordered, self.base_value), \
            self.__dict__

    @classmethod
    def make(cls, name, values=(), ordered=False, base_value=-1):
        """
        Return a variable with the given name and other properties. The method
        first looks for a compatible existing variable: the existing
        variable must have the same name and both variables must have either
        ordered or unordered values. If values are ordered, the order must be
        compatible: all common values must have the same order. If values are
        unordered, the existing variable must have at least one common value
        with the new one, except when any of the two lists of values is empty.

        If a compatible variable is find, it is returned, with missing values
        appended to the end of the list. If there is no explicit order, the
        values are ordered using :obj:`ordered_values`. Otherwise, it
        constructs and returns a new variable descriptor.

        :param name: the name of the variable
        :type name: str
        :param values: symbolic values for the variable
        :type values: list
        :param ordered: tells whether the order of values is fixed
        :type ordered: bool
        :param base_value: the index of the base value, or -1 if there is none
        :type base_value: int
        :returns: an existing compatible variable or `None`
        """
        if not name:
            raise ValueError("Variables without names cannot be stored or made")
        var = cls._find_compatible(
            name, values, ordered, base_value)
        if var:
            return var
        if not ordered:
            base_value_rep = base_value != -1 and values[base_value]
            values = cls.ordered_values(values)
            if base_value != -1:
                base_value = values.index(base_value_rep)
        return cls(name, values, ordered, base_value)

    @classmethod
    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):
        """
        Return a compatible existing value, or `None` if there is None.
        See :obj:`make` for details; this function differs by returning `None`
        instead of constructing a new descriptor. (Method :obj:`make` calls
        this function.)

        :param name: the name of the variable
        :type name: str
        :param values: symbolic values for the variable
        :type values: list
        :param ordered: tells whether the order of values is fixed
        :type ordered: bool
        :param base_value: the index of the base value, or -1 if there is none
        :type base_value: int
        :returns: an existing compatible variable or `None`
        """
        base_rep = base_value != -1 and values[base_value]
        existing = cls._all_vars.get(name)
        if existing is None:
            return None
        if not ordered:
            values = cls.ordered_values(values)
        for var in existing:
            if (var.ordered != ordered or
                    var.base_value != -1
                    and var.values[var.base_value] != base_rep):
                continue
            if not values:
                break  # we have the variable - any existing values are OK
            if not set(var.values) & set(values):
                continue  # empty intersection of values; not compatible
            if ordered:
                i = 0
                for val in var.values:
                    if values[i] == val:
                        i += 1
                        if i == len(values):
                            break  # we have all the values
                else:  # we have some remaining values: check them, add them
                    if set(values[i:]) & set(var.values):
                        continue  # next var in existing
                    for val in values[i:]:
                        var.add_value(val)
                break  # we have the variable
            else:  # not ordered
                vv = set(var.values)
                for val in values:
                    if val not in vv:
                        var.add_value(val)
                break  # we have the variable
        else:
            return None
        if base_value != -1 and var.base_value == -1:
            var.base_value = var.values.index(base_rep)
        return var

    @staticmethod
    def ordered_values(values):
        """
        Return a sorted list of values. If there exists a prescribed order for
        such set of values, it is returned. Otherwise, values are sorted
        alphabetically.
        """
        for presorted in DiscreteVariable.presorted_values:
            if values == set(presorted):
                return presorted
        try:
            return sorted(values, key=float)
        except ValueError:
            return sorted(values)

    def copy(self, compute_value=None):
        var = DiscreteVariable(self.name, self.values, self.ordered,
                               self.base_value, compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


class StringVariable(Variable):
    """
    Descriptor for string variables. String variables can only appear as
    meta attributes.
    """
    Unknown = ""
    TYPE_HEADERS = ('string', 's', 'text')

    def to_val(self, s):
        """
        Return the value as a string. If it is already a string, the same
        object is returned.
        """
        if s is None:
            return ""
        if isinstance(s, str):
            return s
        return str(s)

    val_from_str_add = to_val

    @staticmethod
    def str_val(val):
        """Return a string representation of the value."""
        if val is "":
            return "?"
        if isinstance(val, Value):
            if val.value is "":
                return "?"
            val = val.value
        return str(val)

    def repr_val(self, val):
        """Return a string representation of the value."""
        return '"{}"'.format(self.str_val(val))


class TimeVariable(ContinuousVariable):
    """
    TimeVariable is a continuous variable with Unix epoch
    (1970-01-01 00:00:00+0000) as the origin (0.0). Later dates are positive
    real numbers (equivalent to Unix timestamp, with microseconds in the
    fraction part), and the dates before it map to the negative real numbers.

    Unfortunately due to limitation of Python datetime, only dates
    with year >= 1 (A.D.) are supported.

    If time is specified without a date, Unix epoch is assumed.

    If time is specified wihout an UTC offset, localtime is assumed.
    """
    _all_vars = {}
    TYPE_HEADERS = ('time', 't')
    UNIX_EPOCH = datetime(1970, 1, 1)
    _ISO_FORMATS = [
        # have_date, have_time, format_str
        # in order of decreased probability
        (1, 1, '%Y-%m-%d %H:%M:%S%z'),
        (1, 1, '%Y-%m-%d %H:%M:%S'),
        (1, 1, '%Y-%m-%d %H:%M'),
        (1, 1, '%Y-%m-%dT%H:%M:%S%z'),
        (1, 1, '%Y-%m-%dT%H:%M:%S'),

        (1, 0, '%Y-%m-%d'),

        (1, 1, '%Y-%m-%d %H:%M:%S.%f'),
        (1, 1, '%Y-%m-%dT%H:%M:%S.%f'),
        (1, 1, '%Y-%m-%d %H:%M:%S.%f%z'),
        (1, 1, '%Y-%m-%dT%H:%M:%S.%f%z'),

        (1, 1, '%Y%m%dT%H%M%S%z'),
        (1, 1, '%Y%m%d%H%M%S%z'),

        (0, 1, '%H:%M:%S.%f'),
        (0, 1, '%H:%M:%S'),
        (0, 1, '%H:%M'),

        # These parse as continuous features (plain numbers)
        (1, 1, '%Y%m%dT%H%M%S'),
        (1, 1, '%Y%m%d%H%M%S'),
        (1, 0, '%Y%m%d'),
        (1, 0, '%Y%j'),
        (1, 0, '%Y'),
        (0, 1, '%H%M%S.%f'),

        # BUG: In Python as in C, %j doesn't necessitate 0-padding,
        # so these two lines must be in this order
        (1, 0, '%Y-%m'),
        (1, 0, '%Y-%j'),
    ]
    # The regex that matches all above formats
    REGEX = (r'^('
             r'\d{1,4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?([+-]\d{4})?)?)?|'
             r'\d{1,4}\d{2}\d{2}(T?\d{2}\d{2}\d{2}([+-]\d{4})?)?|'
             r'\d{2}:\d{2}(:\d{2}(\.\d+)?)?|'
             r'\d{2}\d{2}\d{2}\.\d+|'
             r'\d{1,4}(-?\d{2,3})?'
             r')$')
    _matches_iso_format = re.compile(REGEX).match

    # UTC offset and associated timezone. If parsed datetime values provide an
    # offset, it is used for display. If not all values have the same offset,
    # +0000 (=UTC) timezone is used and utc_offset is set to False.
    utc_offset = None
    timezone = timezone.utc

    def __init__(self, *args, have_date=0, have_time=0, **kwargs):
        super().__init__(*args, **kwargs)
        self.have_date = have_date
        self.have_time = have_time

    def copy(self, compute_value=None):
        copy = super().copy(compute_value=compute_value)
        copy.have_date = self.have_date
        copy.have_time = self.have_time
        return copy

    @staticmethod
    def _tzre_sub(s, _subtz=re.compile(r'([+-])(\d\d):(\d\d)$').sub):
        # Replace +ZZ:ZZ with ISO-compatible +ZZZZ, or strip +0000
        return s[:-6] if s.endswith(('+00:00', '-00:00')) else _subtz(r'\1\2\3', s)

    def repr_val(self, val):
        if isnan(val):
            return '?'
        if not self.have_date and not self.have_time:
            # The time is relative, unitless. The value is absolute.
            return str(val.value) if isinstance(val, Value) else str(val)

        # If you know how to simplify this, be my guest
        seconds = int(val)
        microseconds = int(round((val - seconds) * 1e6))
        if val < 0:
            if microseconds:
                seconds, microseconds = seconds - 1, int(1e6) + microseconds
            date = datetime.fromtimestamp(0, tz=self.timezone) + timedelta(seconds=seconds)
        else:
            date = datetime.fromtimestamp(seconds, tz=self.timezone)
        date = str(date.replace(microsecond=microseconds))

        if self.have_date and not self.have_time:
            date = date.split()[0]
        elif not self.have_date and self.have_time:
            date = date.split()[1]
        date = self._tzre_sub(date)
        return date

    str_val = repr_val

    def parse(self, datestr):
        """
        Return `datestr`, a datetime provided in one of ISO 8601 formats,
        parsed as a real number. Value 0 marks the Unix epoch, positive values
        are the dates after it, negative before.

        If date is unspecified, epoch date is assumed.

        If time is unspecified, 00:00:00.0 is assumed.

        If timezone is unspecified, local time is assumed.
        """
        if datestr in MISSING_VALUES:
            return Unknown
        datestr = datestr.strip().rstrip('Z')

        ERROR = ValueError("Invalid datetime format '{}'. "
                           "Only ISO 8601 supported.".format(datestr))
        if not self._matches_iso_format(datestr):
            try:
                # If it is a number, assume it is a unix timestamp
                value = float(datestr)
                self.have_date = self.have_time = 1
                return value
            except ValueError:
                raise ERROR

        for i, (have_date, have_time, fmt) in enumerate(self._ISO_FORMATS):
            try:
                dt = datetime.strptime(datestr, fmt)
            except ValueError:
                continue
            else:
                # Pop this most-recently-used format to front
                if 0 < i < len(self._ISO_FORMATS) - 2:
                    self._ISO_FORMATS[i], self._ISO_FORMATS[0] = \
                        self._ISO_FORMATS[0], self._ISO_FORMATS[i]

                self.have_date |= have_date
                self.have_time |= have_time
                if not have_date:
                    dt = dt.replace(self.UNIX_EPOCH.year,
                                    self.UNIX_EPOCH.month,
                                    self.UNIX_EPOCH.day)
                break
        else:
            raise ERROR

        # Remember UTC offset. If not all parsed values share the same offset,
        # remember none of it.
        offset = dt.utcoffset()
        if self.utc_offset is not False:
            if offset and self.utc_offset is None:
                self.utc_offset = offset
                self.timezone = timezone(offset)
            elif self.utc_offset != offset:
                self.utc_offset = False
                self.timezone = timezone.utc

        # Convert time to UTC timezone. In dates without timezone,
        # localtime is assumed. See also:
        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp
        if dt.tzinfo:
            dt -= dt.utcoffset()
        dt = dt.replace(tzinfo=timezone.utc)

        # Unix epoch is the origin, older dates are negative
        try:
            return dt.timestamp()
        except OverflowError:
            return -(self.UNIX_EPOCH - dt).total_seconds()

    def to_val(self, s):
        """
        Convert a value, given as an instance of an arbitrary type, to a float.
        """
        if isinstance(s, str):
            return self.parse(s)
        else:
            return super().to_val(s)

```
--- 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:** Unpickling `DiscreteVariable` Adds Unexpected Values Leading to Inconsistencies

**Description:**

When attempting to unpickle a `DiscreteVariable` with a predefined set of values, the resulting object unexpectedly includes additional values that were not present in the original. This leads to discrepancies between the expected and actual values of the variable, potentially causing issues in data processing workflows.

**Example:**

```python
import pickle
from Orange.data import DiscreteVariable

# Original DiscreteVariable with values ['two', 'one']
d1 = DiscreteVariable('A', values=['two', 'one'])
s = pickle.dumps(d1)

# Creating another DiscreteVariable with an extended set of values
d2 = DiscreteVariable.make('A', values=['one', 'two', 'three'])
d1c = pickle.loads(s)

print(d2.values)   # Expected: ['one', 'two', 'three']
print(d1c.values)  # Actual: ['two', 'one', 'three']
```

**Expected Behavior:**
Unpickling a `DiscreteVariable` should accurately reconstruct the original set of values without introducing any additional elements. The `values` attribute of the unpickled object should match exactly what was initially serialized.

**Actual Behavior:**
The unpickled `DiscreteVariable` includes an extra value (`'three'`) that was not part of the original object. This results in `d1c.values` being `['two', 'one', 'three']` instead of the expected `['two', 'one']`.

This inconsistency can lead to unexpected behavior in applications relying on the integrity of the `DiscreteVariable`'s values, such as data analysis, serialization, and deserialization processes.
[/ISSUE]
{
    "TestVariable.test_name": "PASSED",
    "TestVariable.test_properties": "PASSED",
    "TestVariable.test_properties_as_predicates": "PASSED",
    "TestVariable.test_repr_is_abstract": "PASSED",
    "TestVariable.test_strange_eq": "PASSED",
    "TestVariable.test_to_val": "PASSED",
    "TestDiscreteVariable.test_colors": "PASSED",
    "TestDiscreteVariable.test_copy_copies_attributes": "PASSED",
    "TestDiscreteVariable.test_dont_make_anonymous_variables": "PASSED",
    "TestDiscreteVariable.test_dont_pickle_anonymous_variables": "PASSED",
    "TestDiscreteVariable.test_dont_store_anonymous_variables": "PASSED",
    "TestDiscreteVariable.test_find_compatible_ordered": "PASSED",
    "TestDiscreteVariable.test_find_compatible_unordered": "PASSED",
    "TestDiscreteVariable.test_make": "PASSED",
    "TestDiscreteVariable.test_no_nonstringvalues": "PASSED",
    "TestDiscreteVariable.test_repr": "PASSED",
    "TestDiscreteVariable.test_to_val": "PASSED",
    "TestDiscreteVariable.test_unpickle": "PASSED",
    "TestDiscreteVariable.test_val_from_str": "PASSED",
    "TestContinuousVariable.test_adjust_decimals": "PASSED",
    "TestContinuousVariable.test_colors": "PASSED",
    "TestContinuousVariable.test_copy_copies_attributes": "PASSED",
    "TestContinuousVariable.test_decimals": "PASSED",
    "TestContinuousVariable.test_dont_make_anonymous_variables": "PASSED",
    "TestContinuousVariable.test_dont_pickle_anonymous_variables": "PASSED",
    "TestContinuousVariable.test_dont_store_anonymous_variables": "PASSED",
    "TestContinuousVariable.test_make": "PASSED",
    "TestStringVariable.test_copy_copies_attributes": "PASSED",
    "TestStringVariable.test_dont_make_anonymous_variables": "PASSED",
    "TestStringVariable.test_dont_pickle_anonymous_variables": "PASSED",
    "TestStringVariable.test_dont_store_anonymous_variables": "PASSED",
    "TestStringVariable.test_val": "PASSED",
    "TestTimeVariable.test_copy_copies_attributes": "PASSED",
    "TestTimeVariable.test_dont_make_anonymous_variables": "PASSED",
    "TestTimeVariable.test_dont_pickle_anonymous_variables": "PASSED",
    "TestTimeVariable.test_dont_store_anonymous_variables": "PASSED",
    "TestTimeVariable.test_have_date": "PASSED",
    "TestTimeVariable.test_have_date_have_time_in_construct": "PASSED",
    "TestTimeVariable.test_no_date_no_time": "PASSED",
    "TestTimeVariable.test_parse_invalid": "PASSED",
    "TestTimeVariable.test_parse_repr": "PASSED",
    "TestTimeVariable.test_parse_timestamp": "PASSED",
    "TestTimeVariable.test_parse_utc": "PASSED",
    "TestTimeVariable.test_readwrite_timevariable": "PASSED",
    "TestTimeVariable.test_repr_value": "PASSED",
    "PickleContinuousVariable.test_with_name": "PASSED",
    "PickleDiscreteVariable.test_ordered": "PASSED",
    "PickleDiscreteVariable.test_with_base_value": "PASSED",
    "PickleDiscreteVariable.test_with_name": "PASSED",
    "PickleDiscreteVariable.test_with_str_value": "PASSED",
    "PickleStringVariable.test_with_name": "PASSED",
    "VariableTestMakeProxy.test_make_proxy_cont": "PASSED",
    "VariableTestMakeProxy.test_make_proxy_disc": "PASSED",
    "VariableTestMakeProxy.test_proxy_has_separate_attributes": "PASSED",
    "VariableTestMakeProxy.test_proxy_has_separate_colors": "PASSED"
}
diff --git a/Orange/data/variable.py b/Orange/data/variable.py
index 838b4a66c..e3b7564f9 100644
--- a/Orange/data/variable.py
+++ b/Orange/data/variable.py
@@ -27,7 +27,19 @@ DISCRETE_MAX_VALUES = 3  # == 2 + nan
 def make_variable(cls, compute_value, *args):
     if compute_value is not None:
         return cls(*args, compute_value=compute_value)
-    return cls.make(*args)
+    if issubclass(cls, DiscreteVariable):
+        name, values = args[:2]
+        var = cls.make(*args)
+        # The `var.values` are in general a superset of `values` with different
+        # order. Only use it if it is a structural subtype of the requested
+        # descriptor so any indices/codes retain their proper interpretation on
+        # deserialization.
+        if var.values[:len(values)] == values:
+            return var
+        else:
+            return cls(*args)
+    else:
+        return cls.make(*args)
 
 
 def is_discrete_values(values):
@@ -707,9 +719,12 @@ class DiscreteVariable(Variable):
     def __reduce__(self):
         if not self.name:
             raise PickleError("Variables without names cannot be pickled")
+        __dict__ = dict(self.__dict__)
+        __dict__.pop("master")
+        __dict__.pop("values")
         return make_variable, (self.__class__, self._compute_value, self.name,
                                self.values, self.ordered, self.base_value), \
-            self.__dict__
+            __dict__
 
     @classmethod
     def make(cls, name, values=(), ordered=False, base_value=-1):
@@ -742,7 +757,7 @@ class DiscreteVariable(Variable):
         var = cls._find_compatible(
             name, values, ordered, base_value)
         if var:
-            return var
+            return var.make_proxy()
         if not ordered:
             base_value_rep = base_value != -1 and values[base_value]
             values = cls.ordered_values(values)
 

{"Orange/data/variable.py": "import collections\nimport re\n\nfrom datetime import datetime, timedelta, timezone\nfrom numbers import Number, Real, Integral\nfrom math import isnan, floor\nfrom pickle import PickleError\n\nimport numpy as np\n\nfrom Orange.data import _variable\nfrom Orange.util import Registry, color_to_hex, hex_to_color, Reprable\n\n__all__ = [\"Unknown\", \"MISSING_VALUES\", \"make_variable\", \"is_discrete_values\",\n           \"Value\", \"Variable\", \"ContinuousVariable\", \"DiscreteVariable\",\n           \"StringVariable\", \"TimeVariable\"]\n\n\n# For storing unknowns\nUnknown = ValueUnknown = float(\"nan\")\n# For checking for unknowns\nMISSING_VALUES = {np.nan, \"?\", \"nan\", \".\", \"\", \"NA\", \"~\", None}\n\nDISCRETE_MAX_VALUES = 3  # == 2 + nan\n\n\ndef make_variable(cls, compute_value, *args):\n    if compute_value is not None:\n        return cls(*args, compute_value=compute_value)\n    return cls.make(*args)\n\n\ndef is_discrete_values(values):\n    \"\"\"\n    Return set of uniques if `values` is an iterable of discrete values\n    else False if non-discrete, or None if indeterminate.\n\n    Note\n    ----\n    Assumes consistent type of items of `values`.\n    \"\"\"\n    if not len(values):\n        return None\n    # If the first few values are, or can be converted to, floats,\n    # the type is numeric\n    try:\n        isinstance(next(iter(values)), Number) or \\\n        [float(v) for _, v in zip(range(min(3, len(values))), values)]\n    except ValueError:\n        is_numeric = False\n        max_values = int(round(len(values)**.7))\n    else:\n        is_numeric = True\n        max_values = DISCRETE_MAX_VALUES\n\n    # If more than max values => not discrete\n    unique = set()\n    for i in values:\n        unique.add(i)\n        if len(unique) > max_values:\n            return False\n\n    # Strip NaN from unique\n    unique = {i for i in unique\n              if (not i in MISSING_VALUES and\n                  not (isinstance(i, Number) and np.isnan(i)))}\n\n    # All NaNs => indeterminate\n    if not unique:\n        return None\n\n    # Strings with |values| < max_unique\n    if not is_numeric:\n        return unique\n\n    # Handle numbers\n    try:\n        unique_float = set(map(float, unique))\n    except ValueError:\n        # Converting all the values to floats resulted in an error.\n        # Since the values have enough unique values, they are probably\n        # string values and discrete.\n        return unique\n\n    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete\n    return (not (unique_float - {0, 1}) or\n            not (unique_float - {1, 2})) and unique\n\n\nclass Value(float):\n    \"\"\"\n    The class representing a value. The class is not used to store values but\n    only to return them in contexts in which we want the value to be accompanied\n    with the descriptor, for instance to print the symbolic value of discrete\n    variables.\n\n    The class is derived from `float`, with an additional attribute `variable`\n    which holds the descriptor of type :obj:`Orange.data.Variable`. If the\n    value continuous or discrete, it is stored as a float. Other types of\n    values, like strings, are stored in the attribute `value`.\n\n    The class overloads the methods for printing out the value:\n    `variable.repr_val` and `variable.str_val` are used to get a suitable\n    representation of the value.\n\n    Equivalence operator is overloaded as follows:\n\n    - unknown values are equal; if one value is unknown and the other is not,\n      they are different;\n\n    - if the value is compared with the string, the value is converted to a\n      string using `variable.str_val` and the two strings are compared\n\n    - if the value is stored in attribute `value`, it is compared with the\n      given other value\n\n    - otherwise, the inherited comparison operator for `float` is called.\n\n    Finally, value defines a hash, so values can be put in sets and appear as\n    keys in dictionaries.\n\n    .. attribute:: variable (:obj:`Orange.data.Variable`)\n\n        Descriptor; used for printing out and for comparing with strings\n\n    .. attribute:: value\n\n        Value; the value can be of arbitrary type and is used only for variables\n        that are neither discrete nor continuous. If `value` is `None`, the\n        derived `float` value is used.\n    \"\"\"\n    __slots__ = \"variable\", \"_value\"\n\n    def __new__(cls, variable, value=Unknown):\n        \"\"\"\n        Construct a new instance of Value with the given descriptor and value.\n        If the argument `value` can be converted to float, it is stored as\n        `float` and the attribute `value` is set to `None`. Otherwise, the\n        inherited float is set to `Unknown` and the value is held by the\n        attribute `value`.\n\n        :param variable: descriptor\n        :type variable: Orange.data.Variable\n        :param value: value\n        \"\"\"\n        if variable.is_primitive():\n            self = super().__new__(cls, value)\n            self.variable = variable\n            self._value = None\n        else:\n            isunknown = value == variable.Unknown\n            self = super().__new__(\n                cls, np.nan if isunknown else np.finfo(float).min)\n            self.variable = variable\n            self._value = value\n        return self\n\n    def __init__(self, _, __=Unknown):\n        pass\n\n    def __repr__(self):\n        return \"Value('%s', %s)\" % (self.variable.name,\n                                    self.variable.repr_val(self))\n\n    def __str__(self):\n        return self.variable.str_val(self)\n\n    def __eq__(self, other):\n        if isinstance(self, Real) and isnan(self):\n            return (isinstance(other, Real) and isnan(other)\n                    or other in self.variable.unknown_str)\n        if isinstance(other, str):\n            return self.variable.str_val(self) == other\n        if isinstance(other, Value):\n            return self.value == other.value\n        return super().__eq__(other)\n\n    def __ne__(self, other):\n        return not self.__eq__(other)\n\n    def __lt__(self, other):\n        if self.variable.is_primitive():\n            if isinstance(other, str):\n                return super().__lt__(self.variable.to_val(other))\n            else:\n                return super().__lt__(other)\n        else:\n            if isinstance(other, str):\n                return self.value < other\n            else:\n                return self.value < other.value\n\n    def __le__(self, other):\n        return self.__lt__(other) or self.__eq__(other)\n\n    def __gt__(self, other):\n        return not self.__le__(other)\n\n    def __ge__(self, other):\n        return not self.__lt__(other)\n\n    def __contains__(self, other):\n        if (self._value is not None\n                and isinstance(self._value, str)\n                and isinstance(other, str)):\n            return other in self._value\n        raise TypeError(\"invalid operation on Value()\")\n\n    def __hash__(self):\n        if self.variable.is_discrete:\n            # It is not possible to hash the id and the domain value to the same number as required by __eq__.\n            # hash(1) == hash(Value(DiscreteVariable(\"var\", [\"red\", \"green\", \"blue\"]), 1)) == hash(\"green\")\n            # User should hash directly ids or domain values instead.\n            raise TypeError(\"unhashable type - cannot hash values of discrete variables!\")\n        if self._value is None:\n            return super().__hash__()\n        else:\n            return hash(self._value)\n\n    @property\n    def value(self):\n        if self.variable.is_discrete:\n            return Unknown if isnan(self) else self.variable.values[int(self)]\n        if self.variable.is_string:\n            return self._value\n        return float(self)\n\n    def __getnewargs__(self):\n        return self.variable, float(self)\n\n    def __getstate__(self):\n        return dict(value=getattr(self, '_value', None))\n\n    def __setstate__(self, state):\n        self._value = state.get('value', None)\n\n\nclass VariableMeta(Registry):\n    def __new__(cls, name, bases, attrs):\n        obj = super().__new__(cls, name, bases, attrs)\n        if not hasattr(obj, '_all_vars') or obj._all_vars is Variable._all_vars:\n            obj._all_vars = {}\n        return obj\n\n\nclass _predicatedescriptor(property):\n    \"\"\"\n    A property that behaves as a class method if accessed via a class\n    >>> class A:\n    ...     foo = False\n    ...     @_predicatedescriptor\n    ...     def is_foo(self):\n    ...         return self.foo\n    ...\n    >>> a = A()\n    >>> a.is_foo\n    False\n    >>> A.is_foo(a)\n    False\n    \"\"\"\n    def __get__(self, instance, objtype=None):\n        if instance is None:\n            return self.fget\n        else:\n            return super().__get__(instance, objtype)\n\n\nclass Variable(Reprable, metaclass=VariableMeta):\n    \"\"\"\n    The base class for variable descriptors contains the variable's\n    name and some basic properties.\n\n    .. attribute:: name\n\n        The name of the variable.\n\n    .. attribute:: unknown_str\n\n        A set of values that represent unknowns in conversion from textual\n        formats. Default is `{\"?\", \".\", \"\", \"NA\", \"~\", None}`.\n\n    .. attribute:: compute_value\n\n        A function for computing the variable's value when converting from\n        another domain which does not contain this variable. The function will\n        be called with a data set (`Orange.data.Table`) and has to return\n        an array of computed values for all its instances. The base class\n        defines a static method `compute_value`, which returns `Unknown`.\n        Non-primitive variables must redefine it to return `None`.\n\n    .. attribute:: sparse\n\n        A flag about sparsity of the variable. When set, the variable suggests\n        it should be stored in a sparse matrix.\n\n    .. attribute:: source_variable\n\n        An optional descriptor of the source variable - if any - from which\n        this variable is derived and computed via :obj:`compute_value`.\n\n    .. attribute:: attributes\n\n        A dictionary with user-defined attributes of the variable\n\n    .. attribute:: master\n\n        The variable that this variable is a copy of. If a copy is made from a\n        copy, the copy has a reference to the original master. If the variable\n        is not a copy, it is its own master.\n    \"\"\"\n    Unknown = ValueUnknown\n\n    def __init__(self, name=\"\", compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a variable descriptor.\n        \"\"\"\n        self.name = name\n        self._compute_value = compute_value\n        self.unknown_str = MISSING_VALUES\n        self.source_variable = None\n        self.sparse = sparse\n        self.attributes = {}\n        self.master = self\n        if name and compute_value is None:\n            if isinstance(self._all_vars, collections.defaultdict):\n                self._all_vars[name].append(self)\n            else:\n                self._all_vars[name] = self\n        self._colors = None\n\n    def make_proxy(self):\n        \"\"\"\n        Copy the variable and set the master to `self.master` or to `self`.\n\n        :return: copy of self\n        :rtype: Variable\n        \"\"\"\n        var = self.__class__()\n        var.__dict__.update(self.__dict__)\n        var.attributes = dict(self.attributes)\n        var.master = self.master\n        return var\n\n    def __eq__(self, other):\n        \"\"\"Two variables are equivalent if the originate from the same master\"\"\"\n        return hasattr(other, \"master\") and self.master is other.master\n\n    def __hash__(self):\n        if self.master is not self:\n            return hash(self.master)\n        else:\n            return super().__hash__()\n\n    @classmethod\n    def make(cls, name):\n        \"\"\"\n        Return an existing continuous variable with the given name, or\n        construct and return a new one.\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._all_vars.get(name) or cls(name)\n        return var.make_proxy()\n\n    @classmethod\n    def _clear_cache(cls):\n        \"\"\"\n        Clear the list of variables for reuse by :obj:`make`.\n        \"\"\"\n        cls._all_vars.clear()\n\n    @staticmethod\n    def _clear_all_caches():\n        \"\"\"\n        Clears list of stored variables for all subclasses\n        \"\"\"\n        for cls in Variable.registry.values():\n            cls._clear_cache()\n\n    @classmethod\n    def is_primitive(cls, var=None):\n        \"\"\"\n        `True` if the variable's values are stored as floats.\n        Non-primitive variables can appear in the data only as meta attributes.\n        \"\"\"\n        to_check = cls if var is None else type(var)\n        return issubclass(to_check, (DiscreteVariable, ContinuousVariable))\n\n    @_predicatedescriptor\n    def is_discrete(self):\n        return isinstance(self, DiscreteVariable)\n\n    @_predicatedescriptor\n    def is_continuous(self):\n        return isinstance(self, ContinuousVariable)\n\n    @_predicatedescriptor\n    def is_string(self):\n        return isinstance(self, StringVariable)\n\n    @_predicatedescriptor\n    def is_time(self):\n        return isinstance(self, TimeVariable)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of variable's value `val`. Argument\n        `val` must be a float (for primitive variables) or an arbitrary\n        Python object (for non-primitives).\n\n        Derived classes must overload the function.\n        \"\"\"\n        raise RuntimeError(\"variable descriptors must overload repr_val()\")\n\n    str_val = repr_val\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable. The\n        argument can be a string, a number or `None`. For primitive variables,\n        the base class provides a method that returns\n        :obj:`~Orange.data.Unknown` if `s` is found in\n        :obj:`~Orange.data.Variable.unknown_str`, and raises an exception\n        otherwise. For non-primitive variables it returns the argument itself.\n\n        Derived classes of primitive variables must overload the function.\n\n        :param s: value, represented as a number, string or `None`\n        :type s: str, float or None\n        :rtype: float or object\n        \"\"\"\n        if not self.is_primitive():\n            return s\n        if s in self.unknown_str:\n            return Unknown\n        raise RuntimeError(\n            \"primitive variable descriptors must overload to_val()\")\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert the given string to a value of the variable. The method\n        is similar to :obj:`to_val` except that it only accepts strings and\n        that it adds new values to the variable's domain where applicable.\n\n        The base class method calls `to_val`.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float or object\n        \"\"\"\n        return self.to_val(s)\n\n    def __str__(self):\n        return self.name\n\n    @property\n    def compute_value(self):\n        return self._compute_value\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n\n        # Use make to unpickle variables.\n        # \"master\" attribute is removed from the dict since make will point\n        # it to the correct variable. If we did not remove it, the (pickled)\n        # value would replace the one set by make.\n        __dict__ = dict(self.__dict__)\n        __dict__.pop(\"master\", None)\n        return make_variable, (self.__class__, self._compute_value, self.name), __dict__\n\n    def copy(self, compute_value):\n        var = type(self)(self.name, compute_value=compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\ndel _predicatedescriptor\n\n\nclass ContinuousVariable(Variable):\n    \"\"\"\n    Descriptor for continuous variables.\n\n    .. attribute:: number_of_decimals\n\n        The number of decimals when the value is printed out (default: 3).\n\n    .. attribute:: adjust_decimals\n\n        A flag regulating whether the `number_of_decimals` is being adjusted\n        by :obj:`to_val`.\n\n    The value of `number_of_decimals` is set to 3 and `adjust_decimals`\n    is set to 2. When :obj:`val_from_str_add` is called for the first\n    time with a string as an argument, `number_of_decimals` is set to the\n    number of decimals in the string and `adjust_decimals` is set to 1.\n    In the subsequent calls of `to_val`, the nubmer of decimals is\n    increased if the string argument has a larger number of decimals.\n\n    If the `number_of_decimals` is set manually, `adjust_decimals` is\n    set to 0 to prevent changes by `to_val`.\n    \"\"\"\n\n    TYPE_HEADERS = ('continuous', 'c', 'numeric', 'n')\n\n    def __init__(self, name=\"\", number_of_decimals=None, compute_value=None, *, sparse=False):\n        \"\"\"\n        Construct a new continuous variable. The number of decimals is set to\n        three, but adjusted at the first call of :obj:`to_val`.\n        \"\"\"\n        super().__init__(name, compute_value, sparse=sparse)\n        if number_of_decimals is None:\n            self.number_of_decimals = 3\n            self.adjust_decimals = 2\n        else:\n            self.number_of_decimals = number_of_decimals\n\n    @property\n    def number_of_decimals(self):\n        return self._number_of_decimals\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            try:\n                col1, col2, black = self.attributes[\"colors\"]\n                self._colors = (hex_to_color(col1), hex_to_color(col2), black)\n            except (KeyError, ValueError):\n                # Stored colors were not available or invalid, use defaults\n                self._colors = ((0, 0, 255), (255, 255, 0), False)\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        col1, col2, black = self._colors = value\n        self.attributes[\"colors\"] = \\\n            [color_to_hex(col1), color_to_hex(col2), black]\n\n    # noinspection PyAttributeOutsideInit\n    @number_of_decimals.setter\n    def number_of_decimals(self, x):\n        self._number_of_decimals = x\n        self.adjust_decimals = 0\n        self._out_format = \"%.{}f\".format(self.number_of_decimals)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if s in self.unknown_str:\n            return Unknown\n        return float(s)\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Convert a value from a string and adjust the number of decimals if\n        `adjust_decimals` is non-zero.\n        \"\"\"\n        return _variable.val_from_str_add_cont(self, s)\n\n    def repr_val(self, val):\n        \"\"\"\n        Return the value as a string with the prescribed number of decimals.\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return self._out_format % val\n\n    str_val = repr_val\n\n    def copy(self, compute_value=None):\n        var = type(self)(self.name, self.number_of_decimals, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass DiscreteVariable(Variable):\n    \"\"\"\n    Descriptor for symbolic, discrete variables. Values of discrete variables\n    are stored as floats; the numbers corresponds to indices in the list of\n    values.\n\n    .. attribute:: values\n\n        A list of variable's values.\n\n    .. attribute:: ordered\n\n        Some algorithms (and, in particular, visualizations) may\n        sometime reorder the values of the variable, e.g. alphabetically.\n        This flag hints that the given order of values is \"natural\"\n        (e.g. \"small\", \"middle\", \"large\") and should not be changed.\n\n    .. attribute:: base_value\n\n        The index of the base value, or -1 if there is none. The base value is\n        used in some methods like, for instance, when creating dummy variables\n        for regression.\n    \"\"\"\n\n    TYPE_HEADERS = ('discrete', 'd', 'categorical')\n\n    _all_vars = collections.defaultdict(list)\n    presorted_values = []\n\n    def __init__(self, name=\"\", values=(), ordered=False, base_value=-1,\n                 compute_value=None, *, sparse=False):\n        \"\"\" Construct a discrete variable descriptor with the given values. \"\"\"\n        self.values = list(values)\n        if not all(isinstance(value, str) for value in self.values):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        super().__init__(name, compute_value, sparse=sparse)\n        self.ordered = ordered\n        self.base_value = base_value\n\n    @property\n    def colors(self):\n        if self._colors is None:\n            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator\n            self._colors = ColorPaletteGenerator.palette(self)\n            colors = self.attributes.get('colors')\n            if colors:\n                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]\n            self._colors.flags.writeable = False\n        return self._colors\n\n    @colors.setter\n    def colors(self, value):\n        self._colors = value\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"] = [color_to_hex(col) for col in value]\n\n    def set_color(self, i, color):\n        self.colors = self.colors\n        self._colors.flags.writeable = True\n        self._colors[i, :] = color\n        self._colors.flags.writeable = False\n        self.attributes[\"colors\"][i] = color_to_hex(color)\n\n    def to_val(self, s):\n        \"\"\"\n        Convert the given argument to a value of the variable (`float`).\n        If the argument is numeric, its value is returned without checking\n        whether it is integer and within bounds. `Unknown` is returned if the\n        argument is one of the representations for unknown values. Otherwise,\n        the argument must be a string and the method returns its index in\n        :obj:`values`.\n\n        :param s: values, represented as a number, string or `None`\n        :rtype: float\n        \"\"\"\n        if s is None:\n            return ValueUnknown\n\n        if isinstance(s, Integral):\n            return s\n        if isinstance(s, Real):\n            return s if isnan(s) else floor(s + 0.25)\n        if s in self.unknown_str:\n            return ValueUnknown\n        if not isinstance(s, str):\n            raise TypeError('Cannot convert {} to value of \"{}\"'.format(\n                type(s).__name__, self.name))\n        return self.values.index(s)\n\n    def add_value(self, s):\n        \"\"\" Add a value `s` to the list of values.\n        \"\"\"\n        if not isinstance(s, str):\n            raise TypeError(\"values of DiscreteVariables must be strings\")\n        self.values.append(s)\n        self._colors = None\n\n    def val_from_str_add(self, s):\n        \"\"\"\n        Similar to :obj:`to_val`, except that it accepts only strings and that\n        it adds the value to the list if it does not exist yet.\n\n        :param s: symbolic representation of the value\n        :type s: str\n        :rtype: float\n        \"\"\"\n        s = str(s) if s is not None else s\n        try:\n            return ValueUnknown if s in self.unknown_str \\\n                else self.values.index(s)\n        except ValueError:\n            self.add_value(s)\n            return len(self.values) - 1\n\n    def repr_val(self, val):\n        \"\"\"\n        Return a textual representation of the value (`self.values[int(val)]`)\n        or \"?\" if the value is unknown.\n\n        :param val: value\n        :type val: float (should be whole number)\n        :rtype: str\n        \"\"\"\n        if isnan(val):\n            return \"?\"\n        return '{}'.format(self.values[int(val)])\n\n    str_val = repr_val\n\n    def __reduce__(self):\n        if not self.name:\n            raise PickleError(\"Variables without names cannot be pickled\")\n        return make_variable, (self.__class__, self._compute_value, self.name,\n                               self.values, self.ordered, self.base_value), \\\n            self.__dict__\n\n    @classmethod\n    def make(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a variable with the given name and other properties. The method\n        first looks for a compatible existing variable: the existing\n        variable must have the same name and both variables must have either\n        ordered or unordered values. If values are ordered, the order must be\n        compatible: all common values must have the same order. If values are\n        unordered, the existing variable must have at least one common value\n        with the new one, except when any of the two lists of values is empty.\n\n        If a compatible variable is find, it is returned, with missing values\n        appended to the end of the list. If there is no explicit order, the\n        values are ordered using :obj:`ordered_values`. Otherwise, it\n        constructs and returns a new variable descriptor.\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        if not name:\n            raise ValueError(\"Variables without names cannot be stored or made\")\n        var = cls._find_compatible(\n            name, values, ordered, base_value)\n        if var:\n            return var\n        if not ordered:\n            base_value_rep = base_value != -1 and values[base_value]\n            values = cls.ordered_values(values)\n            if base_value != -1:\n                base_value = values.index(base_value_rep)\n        return cls(name, values, ordered, base_value)\n\n    @classmethod\n    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):\n        \"\"\"\n        Return a compatible existing value, or `None` if there is None.\n        See :obj:`make` for details; this function differs by returning `None`\n        instead of constructing a new descriptor. (Method :obj:`make` calls\n        this function.)\n\n        :param name: the name of the variable\n        :type name: str\n        :param values: symbolic values for the variable\n        :type values: list\n        :param ordered: tells whether the order of values is fixed\n        :type ordered: bool\n        :param base_value: the index of the base value, or -1 if there is none\n        :type base_value: int\n        :returns: an existing compatible variable or `None`\n        \"\"\"\n        base_rep = base_value != -1 and values[base_value]\n        existing = cls._all_vars.get(name)\n        if existing is None:\n            return None\n        if not ordered:\n            values = cls.ordered_values(values)\n        for var in existing:\n            if (var.ordered != ordered or\n                    var.base_value != -1\n                    and var.values[var.base_value] != base_rep):\n                continue\n            if not values:\n                break  # we have the variable - any existing values are OK\n            if not set(var.values) & set(values):\n                continue  # empty intersection of values; not compatible\n            if ordered:\n                i = 0\n                for val in var.values:\n                    if values[i] == val:\n                        i += 1\n                        if i == len(values):\n                            break  # we have all the values\n                else:  # we have some remaining values: check them, add them\n                    if set(values[i:]) & set(var.values):\n                        continue  # next var in existing\n                    for val in values[i:]:\n                        var.add_value(val)\n                break  # we have the variable\n            else:  # not ordered\n                vv = set(var.values)\n                for val in values:\n                    if val not in vv:\n                        var.add_value(val)\n                break  # we have the variable\n        else:\n            return None\n        if base_value != -1 and var.base_value == -1:\n            var.base_value = var.values.index(base_rep)\n        return var\n\n    @staticmethod\n    def ordered_values(values):\n        \"\"\"\n        Return a sorted list of values. If there exists a prescribed order for\n        such set of values, it is returned. Otherwise, values are sorted\n        alphabetically.\n        \"\"\"\n        for presorted in DiscreteVariable.presorted_values:\n            if values == set(presorted):\n                return presorted\n        try:\n            return sorted(values, key=float)\n        except ValueError:\n            return sorted(values)\n\n    def copy(self, compute_value=None):\n        var = DiscreteVariable(self.name, self.values, self.ordered,\n                               self.base_value, compute_value, sparse=self.sparse)\n        var.attributes = dict(self.attributes)\n        return var\n\n\nclass StringVariable(Variable):\n    \"\"\"\n    Descriptor for string variables. String variables can only appear as\n    meta attributes.\n    \"\"\"\n    Unknown = \"\"\n    TYPE_HEADERS = ('string', 's', 'text')\n\n    def to_val(self, s):\n        \"\"\"\n        Return the value as a string. If it is already a string, the same\n        object is returned.\n        \"\"\"\n        if s is None:\n            return \"\"\n        if isinstance(s, str):\n            return s\n        return str(s)\n\n    val_from_str_add = to_val\n\n    @staticmethod\n    def str_val(val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        if val is \"\":\n            return \"?\"\n        if isinstance(val, Value):\n            if val.value is \"\":\n                return \"?\"\n            val = val.value\n        return str(val)\n\n    def repr_val(self, val):\n        \"\"\"Return a string representation of the value.\"\"\"\n        return '\"{}\"'.format(self.str_val(val))\n\n\nclass TimeVariable(ContinuousVariable):\n    \"\"\"\n    TimeVariable is a continuous variable with Unix epoch\n    (1970-01-01 00:00:00+0000) as the origin (0.0). Later dates are positive\n    real numbers (equivalent to Unix timestamp, with microseconds in the\n    fraction part), and the dates before it map to the negative real numbers.\n\n    Unfortunately due to limitation of Python datetime, only dates\n    with year >= 1 (A.D.) are supported.\n\n    If time is specified without a date, Unix epoch is assumed.\n\n    If time is specified wihout an UTC offset, localtime is assumed.\n    \"\"\"\n    _all_vars = {}\n    TYPE_HEADERS = ('time', 't')\n    UNIX_EPOCH = datetime(1970, 1, 1)\n    _ISO_FORMATS = [\n        # have_date, have_time, format_str\n        # in order of decreased probability\n        (1, 1, '%Y-%m-%d %H:%M:%S%z'),\n        (1, 1, '%Y-%m-%d %H:%M:%S'),\n        (1, 1, '%Y-%m-%d %H:%M'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S'),\n\n        (1, 0, '%Y-%m-%d'),\n\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f'),\n        (1, 1, '%Y-%m-%d %H:%M:%S.%f%z'),\n        (1, 1, '%Y-%m-%dT%H:%M:%S.%f%z'),\n\n        (1, 1, '%Y%m%dT%H%M%S%z'),\n        (1, 1, '%Y%m%d%H%M%S%z'),\n\n        (0, 1, '%H:%M:%S.%f'),\n        (0, 1, '%H:%M:%S'),\n        (0, 1, '%H:%M'),\n\n        # These parse as continuous features (plain numbers)\n        (1, 1, '%Y%m%dT%H%M%S'),\n        (1, 1, '%Y%m%d%H%M%S'),\n        (1, 0, '%Y%m%d'),\n        (1, 0, '%Y%j'),\n        (1, 0, '%Y'),\n        (0, 1, '%H%M%S.%f'),\n\n        # BUG: In Python as in C, %j doesn't necessitate 0-padding,\n        # so these two lines must be in this order\n        (1, 0, '%Y-%m'),\n        (1, 0, '%Y-%j'),\n    ]\n    # The regex that matches all above formats\n    REGEX = (r'^('\n             r'\\d{1,4}-\\d{2}-\\d{2}([ T]\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?([+-]\\d{4})?)?)?|'\n             r'\\d{1,4}\\d{2}\\d{2}(T?\\d{2}\\d{2}\\d{2}([+-]\\d{4})?)?|'\n             r'\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?|'\n             r'\\d{2}\\d{2}\\d{2}\\.\\d+|'\n             r'\\d{1,4}(-?\\d{2,3})?'\n             r')$')\n    _matches_iso_format = re.compile(REGEX).match\n\n    # UTC offset and associated timezone. If parsed datetime values provide an\n    # offset, it is used for display. If not all values have the same offset,\n    # +0000 (=UTC) timezone is used and utc_offset is set to False.\n    utc_offset = None\n    timezone = timezone.utc\n\n    def __init__(self, *args, have_date=0, have_time=0, **kwargs):\n        super().__init__(*args, **kwargs)\n        self.have_date = have_date\n        self.have_time = have_time\n\n    def copy(self, compute_value=None):\n        copy = super().copy(compute_value=compute_value)\n        copy.have_date = self.have_date\n        copy.have_time = self.have_time\n        return copy\n\n    @staticmethod\n    def _tzre_sub(s, _subtz=re.compile(r'([+-])(\\d\\d):(\\d\\d)$').sub):\n        # Replace +ZZ:ZZ with ISO-compatible +ZZZZ, or strip +0000\n        return s[:-6] if s.endswith(('+00:00', '-00:00')) else _subtz(r'\\1\\2\\3', s)\n\n    def repr_val(self, val):\n        if isnan(val):\n            return '?'\n        if not self.have_date and not self.have_time:\n            # The time is relative, unitless. The value is absolute.\n            return str(val.value) if isinstance(val, Value) else str(val)\n\n        # If you know how to simplify this, be my guest\n        seconds = int(val)\n        microseconds = int(round((val - seconds) * 1e6))\n        if val < 0:\n            if microseconds:\n                seconds, microseconds = seconds - 1, int(1e6) + microseconds\n            date = datetime.fromtimestamp(0, tz=self.timezone) + timedelta(seconds=seconds)\n        else:\n            date = datetime.fromtimestamp(seconds, tz=self.timezone)\n        date = str(date.replace(microsecond=microseconds))\n\n        if self.have_date and not self.have_time:\n            date = date.split()[0]\n        elif not self.have_date and self.have_time:\n            date = date.split()[1]\n        date = self._tzre_sub(date)\n        return date\n\n    str_val = repr_val\n\n    def parse(self, datestr):\n        \"\"\"\n        Return `datestr`, a datetime provided in one of ISO 8601 formats,\n        parsed as a real number. Value 0 marks the Unix epoch, positive values\n        are the dates after it, negative before.\n\n        If date is unspecified, epoch date is assumed.\n\n        If time is unspecified, 00:00:00.0 is assumed.\n\n        If timezone is unspecified, local time is assumed.\n        \"\"\"\n        if datestr in MISSING_VALUES:\n            return Unknown\n        datestr = datestr.strip().rstrip('Z')\n\n        ERROR = ValueError(\"Invalid datetime format '{}'. \"\n                           \"Only ISO 8601 supported.\".format(datestr))\n        if not self._matches_iso_format(datestr):\n            try:\n                # If it is a number, assume it is a unix timestamp\n                value = float(datestr)\n                self.have_date = self.have_time = 1\n                return value\n            except ValueError:\n                raise ERROR\n\n        for i, (have_date, have_time, fmt) in enumerate(self._ISO_FORMATS):\n            try:\n                dt = datetime.strptime(datestr, fmt)\n            except ValueError:\n                continue\n            else:\n                # Pop this most-recently-used format to front\n                if 0 < i < len(self._ISO_FORMATS) - 2:\n                    self._ISO_FORMATS[i], self._ISO_FORMATS[0] = \\\n                        self._ISO_FORMATS[0], self._ISO_FORMATS[i]\n\n                self.have_date |= have_date\n                self.have_time |= have_time\n                if not have_date:\n                    dt = dt.replace(self.UNIX_EPOCH.year,\n                                    self.UNIX_EPOCH.month,\n                                    self.UNIX_EPOCH.day)\n                break\n        else:\n            raise ERROR\n\n        # Remember UTC offset. If not all parsed values share the same offset,\n        # remember none of it.\n        offset = dt.utcoffset()\n        if self.utc_offset is not False:\n            if offset and self.utc_offset is None:\n                self.utc_offset = offset\n                self.timezone = timezone(offset)\n            elif self.utc_offset != offset:\n                self.utc_offset = False\n                self.timezone = timezone.utc\n\n        # Convert time to UTC timezone. In dates without timezone,\n        # localtime is assumed. See also:\n        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp\n        if dt.tzinfo:\n            dt -= dt.utcoffset()\n        dt = dt.replace(tzinfo=timezone.utc)\n\n        # Unix epoch is the origin, older dates are negative\n        try:\n            return dt.timestamp()\n        except OverflowError:\n            return -(self.UNIX_EPOCH - dt).total_seconds()\n\n    def to_val(self, s):\n        \"\"\"\n        Convert a value, given as an instance of an arbitrary type, to a float.\n        \"\"\"\n        if isinstance(s, str):\n            return self.parse(s)\n        else:\n            return super().to_val(s)\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:** Unpickling `DiscreteVariable` Adds Unexpected Values Leading to Inconsistencies

**Description:**

When attempting to unpickle a `DiscreteVariable` with a predefined set of values, the resulting object unexpectedly includes additional values that were not present in the original. This leads to discrepancies between the expected and actual values of the variable, potentially causing issues in data processing workflows.

**Example:**

```python
import pickle
from Orange.data import DiscreteVariable

# Original DiscreteVariable with values ['two', 'one']
d1 = DiscreteVariable('A', values=['two', 'one'])
s = pickle.dumps(d1)

# Creating another DiscreteVariable with an extended set of values
d2 = DiscreteVariable.make('A', values=['one', 'two', 'three'])
d1c = pickle.loads(s)

print(d2.values)   # Expected: ['one', 'two', 'three']
print(d1c.values)  # Actual: ['two', 'one', 'three']
```

**Expected Behavior:**
Unpickling a `DiscreteVariable` should accurately reconstruct the original set of values without introducing any additional elements. The `values` attribute of the unpickled object should match exactly what was initially serialized.

**Actual Behavior:**
The unpickled `DiscreteVariable` includes an extra value (`'three'`) that was not part of the original object. This results in `d1c.values` being `['two', 'one', 'three']` instead of the expected `['two', 'one']`.

This inconsistency can lead to unexpected behavior in applications relying on the integrity of the `DiscreteVariable`'s values, such as data analysis, serialization, and deserialization processes.
[/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/data/variable.py
import collections
import re

from datetime import datetime, timedelta, timezone
from numbers import Number, Real, Integral
from math import isnan, floor
from pickle import PickleError

import numpy as np

from Orange.data import _variable
from Orange.util import Registry, color_to_hex, hex_to_color, Reprable

__all__ = ["Unknown", "MISSING_VALUES", "make_variable", "is_discrete_values",
           "Value", "Variable", "ContinuousVariable", "DiscreteVariable",
           "StringVariable", "TimeVariable"]


# For storing unknowns
Unknown = ValueUnknown = float("nan")
# For checking for unknowns
MISSING_VALUES = {np.nan, "?", "nan", ".", "", "NA", "~", None}

DISCRETE_MAX_VALUES = 3  # == 2 + nan


def make_variable(cls, compute_value, *args):
    if compute_value is not None:
        return cls(*args, compute_value=compute_value)
    return cls.make(*args)


def is_discrete_values(values):
    """
    Return set of uniques if `values` is an iterable of discrete values
    else False if non-discrete, or None if indeterminate.

    Note
    ----
    Assumes consistent type of items of `values`.
    """
    if not len(values):
        return None
    # If the first few values are, or can be converted to, floats,
    # the type is numeric
    try:
        isinstance(next(iter(values)), Number) or \
        [float(v) for _, v in zip(range(min(3, len(values))), values)]
    except ValueError:
        is_numeric = False
        max_values = int(round(len(values)**.7))
    else:
        is_numeric = True
        max_values = DISCRETE_MAX_VALUES

    # If more than max values => not discrete
    unique = set()
    for i in values:
        unique.add(i)
        if len(unique) > max_values:
            return False

    # Strip NaN from unique
    unique = {i for i in unique
              if (not i in MISSING_VALUES and
                  not (isinstance(i, Number) and np.isnan(i)))}

    # All NaNs => indeterminate
    if not unique:
        return None

    # Strings with |values| < max_unique
    if not is_numeric:
        return unique

    # Handle numbers
    try:
        unique_float = set(map(float, unique))
    except ValueError:
        # Converting all the values to floats resulted in an error.
        # Since the values have enough unique values, they are probably
        # string values and discrete.
        return unique

    # If only values are {0, 1} or {1, 2} (or a subset of those sets) => discrete
    return (not (unique_float - {0, 1}) or
            not (unique_float - {1, 2})) and unique


class Value(float):
    """
    The class representing a value. The class is not used to store values but
    only to return them in contexts in which we want the value to be accompanied
    with the descriptor, for instance to print the symbolic value of discrete
    variables.

    The class is derived from `float`, with an additional attribute `variable`
    which holds the descriptor of type :obj:`Orange.data.Variable`. If the
    value continuous or discrete, it is stored as a float. Other types of
    values, like strings, are stored in the attribute `value`.

    The class overloads the methods for printing out the value:
    `variable.repr_val` and `variable.str_val` are used to get a suitable
    representation of the value.

    Equivalence operator is overloaded as follows:

    - unknown values are equal; if one value is unknown and the other is not,
      they are different;

    - if the value is compared with the string, the value is converted to a
      string using `variable.str_val` and the two strings are compared

    - if the value is stored in attribute `value`, it is compared with the
      given other value

    - otherwise, the inherited comparison operator for `float` is called.

    Finally, value defines a hash, so values can be put in sets and appear as
    keys in dictionaries.

    .. attribute:: variable (:obj:`Orange.data.Variable`)

        Descriptor; used for printing out and for comparing with strings

    .. attribute:: value

        Value; the value can be of arbitrary type and is used only for variables
        that are neither discrete nor continuous. If `value` is `None`, the
        derived `float` value is used.
    """
    __slots__ = "variable", "_value"

    def __new__(cls, variable, value=Unknown):
        """
        Construct a new instance of Value with the given descriptor and value.
        If the argument `value` can be converted to float, it is stored as
        `float` and the attribute `value` is set to `None`. Otherwise, the
        inherited float is set to `Unknown` and the value is held by the
        attribute `value`.

        :param variable: descriptor
        :type variable: Orange.data.Variable
        :param value: value
        """
        if variable.is_primitive():
            self = super().__new__(cls, value)
            self.variable = variable
            self._value = None
        else:
            isunknown = value == variable.Unknown
            self = super().__new__(
                cls, np.nan if isunknown else np.finfo(float).min)
            self.variable = variable
            self._value = value
        return self

    def __init__(self, _, __=Unknown):
        pass

    def __repr__(self):
        return "Value('%s', %s)" % (self.variable.name,
                                    self.variable.repr_val(self))

    def __str__(self):
        return self.variable.str_val(self)

    def __eq__(self, other):
        if isinstance(self, Real) and isnan(self):
            return (isinstance(other, Real) and isnan(other)
                    or other in self.variable.unknown_str)
        if isinstance(other, str):
            return self.variable.str_val(self) == other
        if isinstance(other, Value):
            return self.value == other.value
        return super().__eq__(other)

    def __ne__(self, other):
        return not self.__eq__(other)

    def __lt__(self, other):
        if self.variable.is_primitive():
            if isinstance(other, str):
                return super().__lt__(self.variable.to_val(other))
            else:
                return super().__lt__(other)
        else:
            if isinstance(other, str):
                return self.value < other
            else:
                return self.value < other.value

    def __le__(self, other):
        return self.__lt__(other) or self.__eq__(other)

    def __gt__(self, other):
        return not self.__le__(other)

    def __ge__(self, other):
        return not self.__lt__(other)

    def __contains__(self, other):
        if (self._value is not None
                and isinstance(self._value, str)
                and isinstance(other, str)):
            return other in self._value
        raise TypeError("invalid operation on Value()")

    def __hash__(self):
        if self.variable.is_discrete:
            # It is not possible to hash the id and the domain value to the same number as required by __eq__.
            # hash(1) == hash(Value(DiscreteVariable("var", ["red", "green", "blue"]), 1)) == hash("green")
            # User should hash directly ids or domain values instead.
            raise TypeError("unhashable type - cannot hash values of discrete variables!")
        if self._value is None:
            return super().__hash__()
        else:
            return hash(self._value)

    @property
    def value(self):
        if self.variable.is_discrete:
            return Unknown if isnan(self) else self.variable.values[int(self)]
        if self.variable.is_string:
            return self._value
        return float(self)

    def __getnewargs__(self):
        return self.variable, float(self)

    def __getstate__(self):
        return dict(value=getattr(self, '_value', None))

    def __setstate__(self, state):
        self._value = state.get('value', None)


class VariableMeta(Registry):
    def __new__(cls, name, bases, attrs):
        obj = super().__new__(cls, name, bases, attrs)
        if not hasattr(obj, '_all_vars') or obj._all_vars is Variable._all_vars:
            obj._all_vars = {}
        return obj


class _predicatedescriptor(property):
    """
    A property that behaves as a class method if accessed via a class
    >>> class A:
    ...     foo = False
    ...     @_predicatedescriptor
    ...     def is_foo(self):
    ...         return self.foo
    ...
    >>> a = A()
    >>> a.is_foo
    False
    >>> A.is_foo(a)
    False
    """
    def __get__(self, instance, objtype=None):
        if instance is None:
            return self.fget
        else:
            return super().__get__(instance, objtype)


class Variable(Reprable, metaclass=VariableMeta):
    """
    The base class for variable descriptors contains the variable's
    name and some basic properties.

    .. attribute:: name

        The name of the variable.

    .. attribute:: unknown_str

        A set of values that represent unknowns in conversion from textual
        formats. Default is `{"?", ".", "", "NA", "~", None}`.

    .. attribute:: compute_value

        A function for computing the variable's value when converting from
        another domain which does not contain this variable. The function will
        be called with a data set (`Orange.data.Table`) and has to return
        an array of computed values for all its instances. The base class
        defines a static method `compute_value`, which returns `Unknown`.
        Non-primitive variables must redefine it to return `None`.

    .. attribute:: sparse

        A flag about sparsity of the variable. When set, the variable suggests
        it should be stored in a sparse matrix.

    .. attribute:: source_variable

        An optional descriptor of the source variable - if any - from which
        this variable is derived and computed via :obj:`compute_value`.

    .. attribute:: attributes

        A dictionary with user-defined attributes of the variable

    .. attribute:: master

        The variable that this variable is a copy of. If a copy is made from a
        copy, the copy has a reference to the original master. If the variable
        is not a copy, it is its own master.
    """
    Unknown = ValueUnknown

    def __init__(self, name="", compute_value=None, *, sparse=False):
        """
        Construct a variable descriptor.
        """
        self.name = name
        self._compute_value = compute_value
        self.unknown_str = MISSING_VALUES
        self.source_variable = None
        self.sparse = sparse
        self.attributes = {}
        self.master = self
        if name and compute_value is None:
            if isinstance(self._all_vars, collections.defaultdict):
                self._all_vars[name].append(self)
            else:
                self._all_vars[name] = self
        self._colors = None

    def make_proxy(self):
        """
        Copy the variable and set the master to `self.master` or to `self`.

        :return: copy of self
        :rtype: Variable
        """
        var = self.__class__()
        var.__dict__.update(self.__dict__)
        var.attributes = dict(self.attributes)
        var.master = self.master
        return var

    def __eq__(self, other):
        """Two variables are equivalent if the originate from the same master"""
        return hasattr(other, "master") and self.master is other.master

    def __hash__(self):
        if self.master is not self:
            return hash(self.master)
        else:
            return super().__hash__()

    @classmethod
    def make(cls, name):
        """
        Return an existing continuous variable with the given name, or
        construct and return a new one.
        """
        if not name:
            raise ValueError("Variables without names cannot be stored or made")
        var = cls._all_vars.get(name) or cls(name)
        return var.make_proxy()

    @classmethod
    def _clear_cache(cls):
        """
        Clear the list of variables for reuse by :obj:`make`.
        """
        cls._all_vars.clear()

    @staticmethod
    def _clear_all_caches():
        """
        Clears list of stored variables for all subclasses
        """
        for cls in Variable.registry.values():
            cls._clear_cache()

    @classmethod
    def is_primitive(cls, var=None):
        """
        `True` if the variable's values are stored as floats.
        Non-primitive variables can appear in the data only as meta attributes.
        """
        to_check = cls if var is None else type(var)
        return issubclass(to_check, (DiscreteVariable, ContinuousVariable))

    @_predicatedescriptor
    def is_discrete(self):
        return isinstance(self, DiscreteVariable)

    @_predicatedescriptor
    def is_continuous(self):
        return isinstance(self, ContinuousVariable)

    @_predicatedescriptor
    def is_string(self):
        return isinstance(self, StringVariable)

    @_predicatedescriptor
    def is_time(self):
        return isinstance(self, TimeVariable)

    def repr_val(self, val):
        """
        Return a textual representation of variable's value `val`. Argument
        `val` must be a float (for primitive variables) or an arbitrary
        Python object (for non-primitives).

        Derived classes must overload the function.
        """
        raise RuntimeError("variable descriptors must overload repr_val()")

    str_val = repr_val

    def to_val(self, s):
        """
        Convert the given argument to a value of the variable. The
        argument can be a string, a number or `None`. For primitive variables,
        the base class provides a method that returns
        :obj:`~Orange.data.Unknown` if `s` is found in
        :obj:`~Orange.data.Variable.unknown_str`, and raises an exception
        otherwise. For non-primitive variables it returns the argument itself.

        Derived classes of primitive variables must overload the function.

        :param s: value, represented as a number, string or `None`
        :type s: str, float or None
        :rtype: float or object
        """
        if not self.is_primitive():
            return s
        if s in self.unknown_str:
            return Unknown
        raise RuntimeError(
            "primitive variable descriptors must overload to_val()")

    def val_from_str_add(self, s):
        """
        Convert the given string to a value of the variable. The method
        is similar to :obj:`to_val` except that it only accepts strings and
        that it adds new values to the variable's domain where applicable.

        The base class method calls `to_val`.

        :param s: symbolic representation of the value
        :type s: str
        :rtype: float or object
        """
        return self.to_val(s)

    def __str__(self):
        return self.name

    @property
    def compute_value(self):
        return self._compute_value

    def __reduce__(self):
        if not self.name:
            raise PickleError("Variables without names cannot be pickled")

        # Use make to unpickle variables.
        # "master" attribute is removed from the dict since make will point
        # it to the correct variable. If we did not remove it, the (pickled)
        # value would replace the one set by make.
        __dict__ = dict(self.__dict__)
        __dict__.pop("master", None)
        return make_variable, (self.__class__, self._compute_value, self.name), __dict__

    def copy(self, compute_value):
        var = type(self)(self.name, compute_value=compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


del _predicatedescriptor


class ContinuousVariable(Variable):
    """
    Descriptor for continuous variables.

    .. attribute:: number_of_decimals

        The number of decimals when the value is printed out (default: 3).

    .. attribute:: adjust_decimals

        A flag regulating whether the `number_of_decimals` is being adjusted
        by :obj:`to_val`.

    The value of `number_of_decimals` is set to 3 and `adjust_decimals`
    is set to 2. When :obj:`val_from_str_add` is called for the first
    time with a string as an argument, `number_of_decimals` is set to the
    number of decimals in the string and `adjust_decimals` is set to 1.
    In the subsequent calls of `to_val`, the nubmer of decimals is
    increased if the string argument has a larger number of decimals.

    If the `number_of_decimals` is set manually, `adjust_decimals` is
    set to 0 to prevent changes by `to_val`.
    """

    TYPE_HEADERS = ('continuous', 'c', 'numeric', 'n')

    def __init__(self, name="", number_of_decimals=None, compute_value=None, *, sparse=False):
        """
        Construct a new continuous variable. The number of decimals is set to
        three, but adjusted at the first call of :obj:`to_val`.
        """
        super().__init__(name, compute_value, sparse=sparse)
        if number_of_decimals is None:
            self.number_of_decimals = 3
            self.adjust_decimals = 2
        else:
            self.number_of_decimals = number_of_decimals

    @property
    def number_of_decimals(self):
        return self._number_of_decimals

    @property
    def colors(self):
        if self._colors is None:
            try:
                col1, col2, black = self.attributes["colors"]
                self._colors = (hex_to_color(col1), hex_to_color(col2), black)
            except (KeyError, ValueError):
                # Stored colors were not available or invalid, use defaults
                self._colors = ((0, 0, 255), (255, 255, 0), False)
        return self._colors

    @colors.setter
    def colors(self, value):
        col1, col2, black = self._colors = value
        self.attributes["colors"] = \
            [color_to_hex(col1), color_to_hex(col2), black]

    # noinspection PyAttributeOutsideInit
    @number_of_decimals.setter
    def number_of_decimals(self, x):
        self._number_of_decimals = x
        self.adjust_decimals = 0
        self._out_format = "%.{}f".format(self.number_of_decimals)

    def to_val(self, s):
        """
        Convert a value, given as an instance of an arbitrary type, to a float.
        """
        if s in self.unknown_str:
            return Unknown
        return float(s)

    def val_from_str_add(self, s):
        """
        Convert a value from a string and adjust the number of decimals if
        `adjust_decimals` is non-zero.
        """
        return _variable.val_from_str_add_cont(self, s)

    def repr_val(self, val):
        """
        Return the value as a string with the prescribed number of decimals.
        """
        if isnan(val):
            return "?"
        return self._out_format % val

    str_val = repr_val

    def copy(self, compute_value=None):
        var = type(self)(self.name, self.number_of_decimals, compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


class DiscreteVariable(Variable):
    """
    Descriptor for symbolic, discrete variables. Values of discrete variables
    are stored as floats; the numbers corresponds to indices in the list of
    values.

    .. attribute:: values

        A list of variable's values.

    .. attribute:: ordered

        Some algorithms (and, in particular, visualizations) may
        sometime reorder the values of the variable, e.g. alphabetically.
        This flag hints that the given order of values is "natural"
        (e.g. "small", "middle", "large") and should not be changed.

    .. attribute:: base_value

        The index of the base value, or -1 if there is none. The base value is
        used in some methods like, for instance, when creating dummy variables
        for regression.
    """

    TYPE_HEADERS = ('discrete', 'd', 'categorical')

    _all_vars = collections.defaultdict(list)
    presorted_values = []

    def __init__(self, name="", values=(), ordered=False, base_value=-1,
                 compute_value=None, *, sparse=False):
        """ Construct a discrete variable descriptor with the given values. """
        self.values = list(values)
        if not all(isinstance(value, str) for value in self.values):
            raise TypeError("values of DiscreteVariables must be strings")
        super().__init__(name, compute_value, sparse=sparse)
        self.ordered = ordered
        self.base_value = base_value

    @property
    def colors(self):
        if self._colors is None:
            from Orange.widgets.utils.colorpalette import ColorPaletteGenerator
            self._colors = ColorPaletteGenerator.palette(self)
            colors = self.attributes.get('colors')
            if colors:
                self._colors[:len(colors)] = [hex_to_color(color) for color in colors]
            self._colors.flags.writeable = False
        return self._colors

    @colors.setter
    def colors(self, value):
        self._colors = value
        self._colors.flags.writeable = False
        self.attributes["colors"] = [color_to_hex(col) for col in value]

    def set_color(self, i, color):
        self.colors = self.colors
        self._colors.flags.writeable = True
        self._colors[i, :] = color
        self._colors.flags.writeable = False
        self.attributes["colors"][i] = color_to_hex(color)

    def to_val(self, s):
        """
        Convert the given argument to a value of the variable (`float`).
        If the argument is numeric, its value is returned without checking
        whether it is integer and within bounds. `Unknown` is returned if the
        argument is one of the representations for unknown values. Otherwise,
        the argument must be a string and the method returns its index in
        :obj:`values`.

        :param s: values, represented as a number, string or `None`
        :rtype: float
        """
        if s is None:
            return ValueUnknown

        if isinstance(s, Integral):
            return s
        if isinstance(s, Real):
            return s if isnan(s) else floor(s + 0.25)
        if s in self.unknown_str:
            return ValueUnknown
        if not isinstance(s, str):
            raise TypeError('Cannot convert {} to value of "{}"'.format(
                type(s).__name__, self.name))
        return self.values.index(s)

    def add_value(self, s):
        """ Add a value `s` to the list of values.
        """
        if not isinstance(s, str):
            raise TypeError("values of DiscreteVariables must be strings")
        self.values.append(s)
        self._colors = None

    def val_from_str_add(self, s):
        """
        Similar to :obj:`to_val`, except that it accepts only strings and that
        it adds the value to the list if it does not exist yet.

        :param s: symbolic representation of the value
        :type s: str
        :rtype: float
        """
        s = str(s) if s is not None else s
        try:
            return ValueUnknown if s in self.unknown_str \
                else self.values.index(s)
        except ValueError:
            self.add_value(s)
            return len(self.values) - 1

    def repr_val(self, val):
        """
        Return a textual representation of the value (`self.values[int(val)]`)
        or "?" if the value is unknown.

        :param val: value
        :type val: float (should be whole number)
        :rtype: str
        """
        if isnan(val):
            return "?"
        return '{}'.format(self.values[int(val)])

    str_val = repr_val

    def __reduce__(self):
        if not self.name:
            raise PickleError("Variables without names cannot be pickled")
        return make_variable, (self.__class__, self._compute_value, self.name,
                               self.values, self.ordered, self.base_value), \
            self.__dict__

    @classmethod
    def make(cls, name, values=(), ordered=False, base_value=-1):
        """
        Return a variable with the given name and other properties. The method
        first looks for a compatible existing variable: the existing
        variable must have the same name and both variables must have either
        ordered or unordered values. If values are ordered, the order must be
        compatible: all common values must have the same order. If values are
        unordered, the existing variable must have at least one common value
        with the new one, except when any of the two lists of values is empty.

        If a compatible variable is find, it is returned, with missing values
        appended to the end of the list. If there is no explicit order, the
        values are ordered using :obj:`ordered_values`. Otherwise, it
        constructs and returns a new variable descriptor.

        :param name: the name of the variable
        :type name: str
        :param values: symbolic values for the variable
        :type values: list
        :param ordered: tells whether the order of values is fixed
        :type ordered: bool
        :param base_value: the index of the base value, or -1 if there is none
        :type base_value: int
        :returns: an existing compatible variable or `None`
        """
        if not name:
            raise ValueError("Variables without names cannot be stored or made")
        var = cls._find_compatible(
            name, values, ordered, base_value)
        if var:
            return var
        if not ordered:
            base_value_rep = base_value != -1 and values[base_value]
            values = cls.ordered_values(values)
            if base_value != -1:
                base_value = values.index(base_value_rep)
        return cls(name, values, ordered, base_value)

    @classmethod
    def _find_compatible(cls, name, values=(), ordered=False, base_value=-1):
        """
        Return a compatible existing value, or `None` if there is None.
        See :obj:`make` for details; this function differs by returning `None`
        instead of constructing a new descriptor. (Method :obj:`make` calls
        this function.)

        :param name: the name of the variable
        :type name: str
        :param values: symbolic values for the variable
        :type values: list
        :param ordered: tells whether the order of values is fixed
        :type ordered: bool
        :param base_value: the index of the base value, or -1 if there is none
        :type base_value: int
        :returns: an existing compatible variable or `None`
        """
        base_rep = base_value != -1 and values[base_value]
        existing = cls._all_vars.get(name)
        if existing is None:
            return None
        if not ordered:
            values = cls.ordered_values(values)
        for var in existing:
            if (var.ordered != ordered or
                    var.base_value != -1
                    and var.values[var.base_value] != base_rep):
                continue
            if not values:
                break  # we have the variable - any existing values are OK
            if not set(var.values) & set(values):
                continue  # empty intersection of values; not compatible
            if ordered:
                i = 0
                for val in var.values:
                    if values[i] == val:
                        i += 1
                        if i == len(values):
                            break  # we have all the values
                else:  # we have some remaining values: check them, add them
                    if set(values[i:]) & set(var.values):
                        continue  # next var in existing
                    for val in values[i:]:
                        var.add_value(val)
                break  # we have the variable
            else:  # not ordered
                vv = set(var.values)
                for val in values:
                    if val not in vv:
                        var.add_value(val)
                break  # we have the variable
        else:
            return None
        if base_value != -1 and var.base_value == -1:
            var.base_value = var.values.index(base_rep)
        return var

    @staticmethod
    def ordered_values(values):
        """
        Return a sorted list of values. If there exists a prescribed order for
        such set of values, it is returned. Otherwise, values are sorted
        alphabetically.
        """
        for presorted in DiscreteVariable.presorted_values:
            if values == set(presorted):
                return presorted
        try:
            return sorted(values, key=float)
        except ValueError:
            return sorted(values)

    def copy(self, compute_value=None):
        var = DiscreteVariable(self.name, self.values, self.ordered,
                               self.base_value, compute_value, sparse=self.sparse)
        var.attributes = dict(self.attributes)
        return var


class StringVariable(Variable):
    """
    Descriptor for string variables. String variables can only appear as
    meta attributes.
    """
    Unknown = ""
    TYPE_HEADERS = ('string', 's', 'text')

    def to_val(self, s):
        """
        Return the value as a string. If it is already a string, the same
        object is returned.
        """
        if s is None:
            return ""
        if isinstance(s, str):
            return s
        return str(s)

    val_from_str_add = to_val

    @staticmethod
    def str_val(val):
        """Return a string representation of the value."""
        if val is "":
            return "?"
        if isinstance(val, Value):
            if val.value is "":
                return "?"
            val = val.value
        return str(val)

    def repr_val(self, val):
        """Return a string representation of the value."""
        return '"{}"'.format(self.str_val(val))


class TimeVariable(ContinuousVariable):
    """
    TimeVariable is a continuous variable with Unix epoch
    (1970-01-01 00:00:00+0000) as the origin (0.0). Later dates are positive
    real numbers (equivalent to Unix timestamp, with microseconds in the
    fraction part), and the dates before it map to the negative real numbers.

    Unfortunately due to limitation of Python datetime, only dates
    with year >= 1 (A.D.) are supported.

    If time is specified without a date, Unix epoch is assumed.

    If time is specified wihout an UTC offset, localtime is assumed.
    """
    _all_vars = {}
    TYPE_HEADERS = ('time', 't')
    UNIX_EPOCH = datetime(1970, 1, 1)
    _ISO_FORMATS = [
        # have_date, have_time, format_str
        # in order of decreased probability
        (1, 1, '%Y-%m-%d %H:%M:%S%z'),
        (1, 1, '%Y-%m-%d %H:%M:%S'),
        (1, 1, '%Y-%m-%d %H:%M'),
        (1, 1, '%Y-%m-%dT%H:%M:%S%z'),
        (1, 1, '%Y-%m-%dT%H:%M:%S'),

        (1, 0, '%Y-%m-%d'),

        (1, 1, '%Y-%m-%d %H:%M:%S.%f'),
        (1, 1, '%Y-%m-%dT%H:%M:%S.%f'),
        (1, 1, '%Y-%m-%d %H:%M:%S.%f%z'),
        (1, 1, '%Y-%m-%dT%H:%M:%S.%f%z'),

        (1, 1, '%Y%m%dT%H%M%S%z'),
        (1, 1, '%Y%m%d%H%M%S%z'),

        (0, 1, '%H:%M:%S.%f'),
        (0, 1, '%H:%M:%S'),
        (0, 1, '%H:%M'),

        # These parse as continuous features (plain numbers)
        (1, 1, '%Y%m%dT%H%M%S'),
        (1, 1, '%Y%m%d%H%M%S'),
        (1, 0, '%Y%m%d'),
        (1, 0, '%Y%j'),
        (1, 0, '%Y'),
        (0, 1, '%H%M%S.%f'),

        # BUG: In Python as in C, %j doesn't necessitate 0-padding,
        # so these two lines must be in this order
        (1, 0, '%Y-%m'),
        (1, 0, '%Y-%j'),
    ]
    # The regex that matches all above formats
    REGEX = (r'^('
             r'\d{1,4}-\d{2}-\d{2}([ T]\d{2}:\d{2}(:\d{2}(\.\d+)?([+-]\d{4})?)?)?|'
             r'\d{1,4}\d{2}\d{2}(T?\d{2}\d{2}\d{2}([+-]\d{4})?)?|'
             r'\d{2}:\d{2}(:\d{2}(\.\d+)?)?|'
             r'\d{2}\d{2}\d{2}\.\d+|'
             r'\d{1,4}(-?\d{2,3})?'
             r')$')
    _matches_iso_format = re.compile(REGEX).match

    # UTC offset and associated timezone. If parsed datetime values provide an
    # offset, it is used for display. If not all values have the same offset,
    # +0000 (=UTC) timezone is used and utc_offset is set to False.
    utc_offset = None
    timezone = timezone.utc

    def __init__(self, *args, have_date=0, have_time=0, **kwargs):
        super().__init__(*args, **kwargs)
        self.have_date = have_date
        self.have_time = have_time

    def copy(self, compute_value=None):
        copy = super().copy(compute_value=compute_value)
        copy.have_date = self.have_date
        copy.have_time = self.have_time
        return copy

    @staticmethod
    def _tzre_sub(s, _subtz=re.compile(r'([+-])(\d\d):(\d\d)$').sub):
        # Replace +ZZ:ZZ with ISO-compatible +ZZZZ, or strip +0000
        return s[:-6] if s.endswith(('+00:00', '-00:00')) else _subtz(r'\1\2\3', s)

    def repr_val(self, val):
        if isnan(val):
            return '?'
        if not self.have_date and not self.have_time:
            # The time is relative, unitless. The value is absolute.
            return str(val.value) if isinstance(val, Value) else str(val)

        # If you know how to simplify this, be my guest
        seconds = int(val)
        microseconds = int(round((val - seconds) * 1e6))
        if val < 0:
            if microseconds:
                seconds, microseconds = seconds - 1, int(1e6) + microseconds
            date = datetime.fromtimestamp(0, tz=self.timezone) + timedelta(seconds=seconds)
        else:
            date = datetime.fromtimestamp(seconds, tz=self.timezone)
        date = str(date.replace(microsecond=microseconds))

        if self.have_date and not self.have_time:
            date = date.split()[0]
        elif not self.have_date and self.have_time:
            date = date.split()[1]
        date = self._tzre_sub(date)
        return date

    str_val = repr_val

    def parse(self, datestr):
        """
        Return `datestr`, a datetime provided in one of ISO 8601 formats,
        parsed as a real number. Value 0 marks the Unix epoch, positive values
        are the dates after it, negative before.

        If date is unspecified, epoch date is assumed.

        If time is unspecified, 00:00:00.0 is assumed.

        If timezone is unspecified, local time is assumed.
        """
        if datestr in MISSING_VALUES:
            return Unknown
        datestr = datestr.strip().rstrip('Z')

        ERROR = ValueError("Invalid datetime format '{}'. "
                           "Only ISO 8601 supported.".format(datestr))
        if not self._matches_iso_format(datestr):
            try:
                # If it is a number, assume it is a unix timestamp
                value = float(datestr)
                self.have_date = self.have_time = 1
                return value
            except ValueError:
                raise ERROR

        for i, (have_date, have_time, fmt) in enumerate(self._ISO_FORMATS):
            try:
                dt = datetime.strptime(datestr, fmt)
            except ValueError:
                continue
            else:
                # Pop this most-recently-used format to front
                if 0 < i < len(self._ISO_FORMATS) - 2:
                    self._ISO_FORMATS[i], self._ISO_FORMATS[0] = \
                        self._ISO_FORMATS[0], self._ISO_FORMATS[i]

                self.have_date |= have_date
                self.have_time |= have_time
                if not have_date:
                    dt = dt.replace(self.UNIX_EPOCH.year,
                                    self.UNIX_EPOCH.month,
                                    self.UNIX_EPOCH.day)
                break
        else:
            raise ERROR

        # Remember UTC offset. If not all parsed values share the same offset,
        # remember none of it.
        offset = dt.utcoffset()
        if self.utc_offset is not False:
            if offset and self.utc_offset is None:
                self.utc_offset = offset
                self.timezone = timezone(offset)
            elif self.utc_offset != offset:
                self.utc_offset = False
                self.timezone = timezone.utc

        # Convert time to UTC timezone. In dates without timezone,
        # localtime is assumed. See also:
        # https://docs.python.org/3.4/library/datetime.html#datetime.datetime.timestamp
        if dt.tzinfo:
            dt -= dt.utcoffset()
        dt = dt.replace(tzinfo=timezone.utc)

        # Unix epoch is the origin, older dates are negative
        try:
            return dt.timestamp()
        except OverflowError:
            return -(self.UNIX_EPOCH - dt).total_seconds()

    def to_val(self, s):
        """
        Convert a value, given as an instance of an arbitrary type, to a float.
        """
        if isinstance(s, str):
            return self.parse(s)
        else:
            return super().to_val(s)

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