{
    "file_diffs": [
        {
            "old_file_content": "import numpy as np\n\nfrom Orange.data import Table, StringVariable, Domain\nfrom Orange.data.io import detect_encoding\nfrom Orange.util import deprecated\n\n\nclass DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr.item()\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")\n",
            "new_file_content": "import numpy as np\n\nfrom Orange.data import Table, StringVariable, Domain\nfrom Orange.data.io import detect_encoding\nfrom Orange.util import deprecated\n\n\nclass DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr[()]\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")\n",
            "header": {
                "file": {
                    "path": "Orange/misc/distmatrix.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "e995e68fb",
                "new_commit_hash": "4ded41737",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/misc/distmatrix.py"
            },
            "plus_file": {
                "path": "b/Orange/misc/distmatrix.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 51,
                            "length": 7
                        },
                        "new_range": {
                            "start": 51,
                            "length": 7
                        },
                        "section": "class DistMatrix(np.ndarray):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def __array_wrap__(self, out_arr, context=None):",
                                "type": "context"
                            },
                            {
                                "content": "        if out_arr.ndim == 0:  # a single scalar",
                                "type": "context"
                            },
                            {
                                "content": "            return out_arr.item()",
                                "type": "deleted"
                            },
                            {
                                "content": "            return out_arr[()]",
                                "type": "added"
                            },
                            {
                                "content": "        return np.ndarray.__array_wrap__(self, out_arr, context)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    \"\"\"",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/misc/distmatrix.py",
                            "type": "method",
                            "name": "DistMatrix.__array_wrap__",
                            "content": "class DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr.item()\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 52,
                            "end_lineno": 55,
                            "parent": {
                                "file_name": "Orange/misc/distmatrix.py",
                                "type": "class",
                                "name": "DistMatrix",
                                "content": "class DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr.item()\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 8,
                                "end_lineno": 271,
                                "parent": null
                            }
                        },
                        {
                            "file_name": "Orange/misc/distmatrix.py",
                            "type": "class",
                            "name": "DistMatrix",
                            "content": "class DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr.item()\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 8,
                            "end_lineno": 271,
                            "parent": null
                        }
                    ],
                    "added_entities": [],
                    "deleted_entities": []
                }
            ]
        },
        {
            "old_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\n\nfrom unittest import TestCase\nimport pickle\n\nimport numpy as np\nimport scipy\nimport scipy.spatial\nimport scipy.stats\nfrom scipy.sparse import csr_matrix\n\nfrom Orange.data import (Table, Domain, ContinuousVariable,\n                         DiscreteVariable, StringVariable, Instance)\nfrom Orange.distance import (Euclidean, SpearmanR, SpearmanRAbsolute,\n                             PearsonR, PearsonRAbsolute, Manhattan, Cosine,\n                             Jaccard, _preprocess, MahalanobisDistance)\nfrom Orange.distance.distance import _spearmanr2, _corrcoef2\nfrom Orange.misc import DistMatrix\nfrom Orange.tests import named_file, test_filename\nfrom Orange.util import OrangeDeprecationWarning\n\n\ndef tables_equal(tab1, tab2):\n    # TODO: introduce Table.__eq__() ???\n    return (tab1 == tab2 or  # catches None\n            np.all([i == j for i, j in zip(tab1, tab2)]))\n\n\nclass TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n\n# noinspection PyTypeChecker\nclass TestEuclidean(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Euclidean\n\n    def test_euclidean_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.53851648071346281]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.53851648071346281]]))\n\n    def test_euclidean_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 2.48394847, 5.09313263, 6.78969808],\n                      [2.48394847, 0., 2.64007576, 4.327817],\n                      [5.09313263, 2.64007576, 0., 1.69705627],\n                      [6.78969808, 4.327817, 1.69705627, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n    def test_euclidean_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 3.74165739, 6.164414],\n                      [3.74165739, 0., 4.47213595],\n                      [6.164414, 4.47213595, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 4.12310563, 3.31662479],\n                      [4.12310563, 0., 6.164414],\n                      [3.31662479, 6.164414, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 3.74165739],\n                      [3.74165739, 0.]]))\n\n    def test_euclidean_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n\n# noinspection PyTypeChecker\nclass TestManhattan(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Manhattan\n\n    def test_manhattan_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.7]]))\n\n    def test_manhattan_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 3.5, 7.2, 9.6],\n                      [3.5, 0., 3.7, 6.1],\n                      [7.2, 3.7, 0., 2.4],\n                      [9.6, 6.1, 2.4, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n    def test_manhattan_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 6., 10.],\n                      [6., 0., 6.],\n                      [10., 6., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 5., 5.],\n                      [5., 0., 10.],\n                      [5., 10., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 6.],\n                      [6., 0.]]))\n\n    def test_manhattan_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestCosine(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Cosine\n\n    def test_cosine_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]), np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.00142084]]))\n\n    def test_cosine_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04],\n                      [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n    def test_cosine_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0.0, 1.00000000e+00, 7.20627882e-01],\n                      [1.00000000e+00, 0.0, 2.19131191e-01],\n                      [7.20627882e-01, 2.19131191e-01, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0.0, 7.57464375e-01, 1.68109669e-01],\n                      [7.57464375e-01, 0.0, 1.00000000e+00],\n                      [1.68109669e-01, 1.00000000e+00, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0.0, 1.00000000e+00],\n                      [1.00000000e+00, 0.0]]))\n\n    def test_cosine_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n\n# noinspection PyTypeChecker\nclass TestJaccard(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.titanic = Table('titanic')[173:177]\n        cls.dist = Jaccard\n\n    def test_jaccard_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2]),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2], axis=1),\n            np.array([[0.5]]))\n\n    def test_jaccard_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic, axis=0),\n            np.array([[0., 1., 0.5],\n                      [1., 0., 1.],\n                      [0.5, 1., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2], self.titanic[:3]),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[3]),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[:3]),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n    def test_jaccard_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0].x, self.titanic[2].x, axis=1),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic.X),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2].x, self.titanic[:3].X),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[3].x),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[:3].X),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanR\n\n    def test_spearmanr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.5083333333333333]]))\n\n    def test_spearmanr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333],\n                      [0.61666667, 0.53333333, 0.63333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr2(self):\n        # Test that _spearnmanr2 returns the same result that stats.spearmanr\n        # would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = scipy.stats.spearmanr(X1, X2, axis=1)[0][:n, n:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = scipy.stats.spearmanr(X1, X2, axis=0)[0][:m, m:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanRAbsolute\n\n    def test_spearmanrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.49166666666666664]]))\n\n    def test_spearmanrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.49166667, 0.075, 0.38333333],\n                      [0.49166667, 0., 0.38333333, 0.46666667],\n                      [0.075, 0.38333333, 0., 0.36666667]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3], self.breast[:4]),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4], self.breast[3]),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n    def test_spearmanrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3].x, self.breast[:4].X),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4].X, self.breast[3].x),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n\n# noinspection PyTypeChecker\nclass TestPearsonR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonR\n\n    def test_pearsonr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.5016744],\n                      [0.48462294, 0., 0.32783865, 0.57317387],\n                      [0.10133593, 0.32783865, 0., 0.63789635]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_pearsonr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_corrcoef2(self):\n        # Test that _corrcoef2 returns the same result that np.corrcoef would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = np.corrcoef(X1, X2, rowvar=True)[:n, n:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = np.corrcoef(X1, X2, rowvar=False)[:m, m:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n        with self.assertRaises(ValueError):\n            _corrcoef2(X1, X2, axis=10)\n\n\n# noinspection PyTypeChecker\nclass TestPearsonRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonRAbsolute\n\n    def test_pearsonrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.4983256],\n                      [0.48462294, 0., 0.32783865, 0.42682613],\n                      [0.10133593, 0.32783865, 0., 0.36210365]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2], self.breast[3]),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n    def test_pearsonrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X, self.breast[3].x),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n\n# noinspection PyTypeChecker\n# Pylint doesn't get magic __new__ operators\n# pylint: disable=not-callable\nclass TestMahalanobis(TestCase):\n    def setUp(self):\n        self.n, self.m = 10, 5\n        self.x = np.random.rand(self.n, self.m)\n        self.x1 = np.random.rand(self.m)\n        self.x2 = np.random.rand(self.m)\n\n    def test_correctness(self):\n        mah = MahalanobisDistance(self.x)\n        d = scipy.spatial.distance.pdist(self.x, 'mahalanobis')\n        d = scipy.spatial.distance.squareform(d)\n        for i in range(self.n):\n            for j in range(self.n):\n                self.assertAlmostEqual(d[i][j], mah(self.x[i], self.x[j]),\n                                       delta=1e-5)\n\n    def test_attributes(self):\n        metric = MahalanobisDistance(self.x)\n        self.assertEqual(metric(self.x[0], self.x[1]).shape, (1, 1))\n        self.assertEqual(metric(self.x).shape, (self.n, self.n))\n        self.assertEqual(metric(self.x[0:3], self.x[5:7]).shape, (3, 2))\n        self.assertEqual(metric(self.x1, self.x2).shape, (1, 1))\n        metric(self.x, impute=True)\n        metric(self.x[:-1, :])\n        self.assertRaises(ValueError, metric, self.x[:, :-1])\n        self.assertRaises(ValueError, metric, self.x1[:-1], self.x2)\n        self.assertRaises(ValueError, metric, self.x1, self.x2[:-1])\n        self.assertRaises(ValueError, metric, self.x.T)\n\n    def test_iris(self):\n        tab = Table('iris')\n        metric = MahalanobisDistance(tab)\n        self.assertEqual(metric(tab).shape, (150, 150))\n        self.assertEqual(metric(tab[0], tab[1]).shape, (1, 1))\n\n    def test_dimensions(self):\n        x = Table('iris')[:20].X\n        xt = Table('iris')[:20].X.T\n        mah = MahalanobisDistance(x)\n        mah(x[0], x[1])\n        mah = MahalanobisDistance(xt)\n        mah(xt[0], xt[1])\n\n\nclass TestDistances(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.test5 = Table(test_filename('datasets/test5.tab'))\n\n    def test_preprocess(self):\n        domain = Domain([ContinuousVariable(\"c\"),\n                         DiscreteVariable(\"d\", values=['a', 'b'])],\n                        [DiscreteVariable(\"cls\", values=['e', 'f'])],\n                        [StringVariable(\"m\")])\n        table = Table(domain, [[1, 'a', 'e', 'm1'],\n                               [2, 'b', 'f', 'm2']])\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.X, table.X[:, 0].reshape(2, 1))\n        np.testing.assert_equal(new_table.Y, table.Y)\n        np.testing.assert_equal(new_table.metas, table.metas)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n        self.assertEqual(new_table.domain.metas, table.domain.metas)\n\n    def test_preprocess_multiclass(self):\n        table = self.test5\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.Y, table.Y)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n\n    def test_preprocess_impute(self):\n        new_table = _preprocess(self.test5)\n        self.assertFalse(np.isnan(new_table.X).any())\n\n    def test_distance_to_instance(self):\n        iris = Table('iris')\n        inst = Instance(iris.domain, np.concatenate((iris[1].x, iris[1].y)))\n        self.assertEqual(Euclidean(iris[1], inst), 0)\n",
            "new_file_content": "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\n\nfrom unittest import TestCase\nimport pickle\n\nimport numpy as np\nimport scipy\nimport scipy.spatial\nimport scipy.stats\nfrom scipy.sparse import csr_matrix\n\nfrom Orange.data import (Table, Domain, ContinuousVariable,\n                         DiscreteVariable, StringVariable, Instance)\nfrom Orange.distance import (Euclidean, SpearmanR, SpearmanRAbsolute,\n                             PearsonR, PearsonRAbsolute, Manhattan, Cosine,\n                             Jaccard, _preprocess, MahalanobisDistance)\nfrom Orange.distance.distance import _spearmanr2, _corrcoef2\nfrom Orange.misc import DistMatrix\nfrom Orange.tests import named_file, test_filename\nfrom Orange.util import OrangeDeprecationWarning\n\n\ndef tables_equal(tab1, tab2):\n    # TODO: introduce Table.__eq__() ???\n    return (tab1 == tab2 or  # catches None\n            np.all([i == j for i, j in zip(tab1, tab2)]))\n\n\nclass TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n\n        self.assertIsInstance(dm1.max(), np.int64)\n        self.assertNotIsInstance(dm1.max(), int)\n        with self.assertRaises(AssertionError):\n            np.testing.assert_array_equal(dm1, dm2)\n\n\n# noinspection PyTypeChecker\nclass TestEuclidean(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Euclidean\n\n    def test_euclidean_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.53851648071346281]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.53851648071346281]]))\n\n    def test_euclidean_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 2.48394847, 5.09313263, 6.78969808],\n                      [2.48394847, 0., 2.64007576, 4.327817],\n                      [5.09313263, 2.64007576, 0., 1.69705627],\n                      [6.78969808, 4.327817, 1.69705627, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n    def test_euclidean_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 3.74165739, 6.164414],\n                      [3.74165739, 0., 4.47213595],\n                      [6.164414, 4.47213595, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 4.12310563, 3.31662479],\n                      [4.12310563, 0., 6.164414],\n                      [3.31662479, 6.164414, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 3.74165739],\n                      [3.74165739, 0.]]))\n\n    def test_euclidean_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n\n# noinspection PyTypeChecker\nclass TestManhattan(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Manhattan\n\n    def test_manhattan_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.7]]))\n\n    def test_manhattan_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 3.5, 7.2, 9.6],\n                      [3.5, 0., 3.7, 6.1],\n                      [7.2, 3.7, 0., 2.4],\n                      [9.6, 6.1, 2.4, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n    def test_manhattan_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 6., 10.],\n                      [6., 0., 6.],\n                      [10., 6., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 5., 5.],\n                      [5., 0., 10.],\n                      [5., 10., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 6.],\n                      [6., 0.]]))\n\n    def test_manhattan_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestCosine(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Cosine\n\n    def test_cosine_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]), np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.00142084]]))\n\n    def test_cosine_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04],\n                      [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n    def test_cosine_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0.0, 1.00000000e+00, 7.20627882e-01],\n                      [1.00000000e+00, 0.0, 2.19131191e-01],\n                      [7.20627882e-01, 2.19131191e-01, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0.0, 7.57464375e-01, 1.68109669e-01],\n                      [7.57464375e-01, 0.0, 1.00000000e+00],\n                      [1.68109669e-01, 1.00000000e+00, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0.0, 1.00000000e+00],\n                      [1.00000000e+00, 0.0]]))\n\n    def test_cosine_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n\n# noinspection PyTypeChecker\nclass TestJaccard(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.titanic = Table('titanic')[173:177]\n        cls.dist = Jaccard\n\n    def test_jaccard_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2]),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2], axis=1),\n            np.array([[0.5]]))\n\n    def test_jaccard_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic, axis=0),\n            np.array([[0., 1., 0.5],\n                      [1., 0., 1.],\n                      [0.5, 1., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2], self.titanic[:3]),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[3]),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[:3]),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n    def test_jaccard_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0].x, self.titanic[2].x, axis=1),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic.X),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2].x, self.titanic[:3].X),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[3].x),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[:3].X),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanR\n\n    def test_spearmanr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.5083333333333333]]))\n\n    def test_spearmanr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333],\n                      [0.61666667, 0.53333333, 0.63333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr2(self):\n        # Test that _spearnmanr2 returns the same result that stats.spearmanr\n        # would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = scipy.stats.spearmanr(X1, X2, axis=1)[0][:n, n:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = scipy.stats.spearmanr(X1, X2, axis=0)[0][:m, m:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanRAbsolute\n\n    def test_spearmanrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.49166666666666664]]))\n\n    def test_spearmanrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.49166667, 0.075, 0.38333333],\n                      [0.49166667, 0., 0.38333333, 0.46666667],\n                      [0.075, 0.38333333, 0., 0.36666667]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3], self.breast[:4]),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4], self.breast[3]),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n    def test_spearmanrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3].x, self.breast[:4].X),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4].X, self.breast[3].x),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n\n# noinspection PyTypeChecker\nclass TestPearsonR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonR\n\n    def test_pearsonr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.5016744],\n                      [0.48462294, 0., 0.32783865, 0.57317387],\n                      [0.10133593, 0.32783865, 0., 0.63789635]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_pearsonr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_corrcoef2(self):\n        # Test that _corrcoef2 returns the same result that np.corrcoef would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = np.corrcoef(X1, X2, rowvar=True)[:n, n:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = np.corrcoef(X1, X2, rowvar=False)[:m, m:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n        with self.assertRaises(ValueError):\n            _corrcoef2(X1, X2, axis=10)\n\n\n# noinspection PyTypeChecker\nclass TestPearsonRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonRAbsolute\n\n    def test_pearsonrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.4983256],\n                      [0.48462294, 0., 0.32783865, 0.42682613],\n                      [0.10133593, 0.32783865, 0., 0.36210365]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2], self.breast[3]),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n    def test_pearsonrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X, self.breast[3].x),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n\n# noinspection PyTypeChecker\n# Pylint doesn't get magic __new__ operators\n# pylint: disable=not-callable\nclass TestMahalanobis(TestCase):\n    def setUp(self):\n        self.n, self.m = 10, 5\n        self.x = np.random.rand(self.n, self.m)\n        self.x1 = np.random.rand(self.m)\n        self.x2 = np.random.rand(self.m)\n\n    def test_correctness(self):\n        mah = MahalanobisDistance(self.x)\n        d = scipy.spatial.distance.pdist(self.x, 'mahalanobis')\n        d = scipy.spatial.distance.squareform(d)\n        for i in range(self.n):\n            for j in range(self.n):\n                self.assertAlmostEqual(d[i][j], mah(self.x[i], self.x[j]),\n                                       delta=1e-5)\n\n    def test_attributes(self):\n        metric = MahalanobisDistance(self.x)\n        self.assertEqual(metric(self.x[0], self.x[1]).shape, (1, 1))\n        self.assertEqual(metric(self.x).shape, (self.n, self.n))\n        self.assertEqual(metric(self.x[0:3], self.x[5:7]).shape, (3, 2))\n        self.assertEqual(metric(self.x1, self.x2).shape, (1, 1))\n        metric(self.x, impute=True)\n        metric(self.x[:-1, :])\n        self.assertRaises(ValueError, metric, self.x[:, :-1])\n        self.assertRaises(ValueError, metric, self.x1[:-1], self.x2)\n        self.assertRaises(ValueError, metric, self.x1, self.x2[:-1])\n        self.assertRaises(ValueError, metric, self.x.T)\n\n    def test_iris(self):\n        tab = Table('iris')\n        metric = MahalanobisDistance(tab)\n        self.assertEqual(metric(tab).shape, (150, 150))\n        self.assertEqual(metric(tab[0], tab[1]).shape, (1, 1))\n\n    def test_dimensions(self):\n        x = Table('iris')[:20].X\n        xt = Table('iris')[:20].X.T\n        mah = MahalanobisDistance(x)\n        mah(x[0], x[1])\n        mah = MahalanobisDistance(xt)\n        mah(xt[0], xt[1])\n\n\nclass TestDistances(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.test5 = Table(test_filename('datasets/test5.tab'))\n\n    def test_preprocess(self):\n        domain = Domain([ContinuousVariable(\"c\"),\n                         DiscreteVariable(\"d\", values=['a', 'b'])],\n                        [DiscreteVariable(\"cls\", values=['e', 'f'])],\n                        [StringVariable(\"m\")])\n        table = Table(domain, [[1, 'a', 'e', 'm1'],\n                               [2, 'b', 'f', 'm2']])\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.X, table.X[:, 0].reshape(2, 1))\n        np.testing.assert_equal(new_table.Y, table.Y)\n        np.testing.assert_equal(new_table.metas, table.metas)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n        self.assertEqual(new_table.domain.metas, table.domain.metas)\n\n    def test_preprocess_multiclass(self):\n        table = self.test5\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.Y, table.Y)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n\n    def test_preprocess_impute(self):\n        new_table = _preprocess(self.test5)\n        self.assertFalse(np.isnan(new_table.X).any())\n\n    def test_distance_to_instance(self):\n        iris = Table('iris')\n        inst = Instance(iris.domain, np.concatenate((iris[1].x, iris[1].y)))\n        self.assertEqual(Euclidean(iris[1], inst), 0)\n",
            "header": {
                "file": {
                    "path": "Orange/tests/test_distances.py"
                },
                "misc_line": null
            },
            "index_line": {
                "old_commit_hash": "65b07f8c4",
                "new_commit_hash": "907b84a19",
                "mode": "100644"
            },
            "is_binary_file": false,
            "binary_line": null,
            "minus_file": {
                "path": "a/Orange/tests/test_distances.py"
            },
            "plus_file": {
                "path": "b/Orange/tests/test_distances.py"
            },
            "hunks": [
                {
                    "descriptor": {
                        "old_range": {
                            "start": 186,
                            "length": 6
                        },
                        "new_range": {
                            "start": 186,
                            "length": 17
                        },
                        "section": "class TestDistMatrix(TestCase):"
                    },
                    "line_group": {
                        "all_lines": [
                            {
                                "content": "                             [\"danny\", \"eve\", \"frank\"])",
                                "type": "context"
                            },
                            {
                                "content": "            self.assertEqual(m.axis, 0)",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "    def test_numpy_type(self):",
                                "type": "added"
                            },
                            {
                                "content": "        \"\"\"GH-3658\"\"\"",
                                "type": "added"
                            },
                            {
                                "content": "        data1 = np.array([1, 2], dtype=np.int64)",
                                "type": "added"
                            },
                            {
                                "content": "        data2 = np.array([2, 3], dtype=np.int64)",
                                "type": "added"
                            },
                            {
                                "content": "        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertIsInstance(dm1.max(), np.int64)",
                                "type": "added"
                            },
                            {
                                "content": "        self.assertNotIsInstance(dm1.max(), int)",
                                "type": "added"
                            },
                            {
                                "content": "        with self.assertRaises(AssertionError):",
                                "type": "added"
                            },
                            {
                                "content": "            np.testing.assert_array_equal(dm1, dm2)",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "added"
                            },
                            {
                                "content": "",
                                "type": "context"
                            },
                            {
                                "content": "# noinspection PyTypeChecker",
                                "type": "context"
                            },
                            {
                                "content": "class TestEuclidean(TestCase):",
                                "type": "context"
                            },
                            {
                                "content": "",
                                "type": "context"
                            }
                        ]
                    },
                    "modified_entities": [
                        {
                            "file_name": "Orange/tests/test_distances.py",
                            "type": "class",
                            "name": "TestDistMatrix",
                            "content": "class TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n\n        self.assertIsInstance(dm1.max(), np.int64)\n        self.assertNotIsInstance(dm1.max(), int)\n        with self.assertRaises(AssertionError):\n            np.testing.assert_array_equal(dm1, dm2)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 30,
                            "end_lineno": 198,
                            "parent": null
                        }
                    ],
                    "added_entities": [
                        {
                            "file_name": "Orange/tests/test_distances.py",
                            "type": "method",
                            "name": "TestDistMatrix.test_numpy_type",
                            "content": "class TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n\n        self.assertIsInstance(dm1.max(), np.int64)\n        self.assertNotIsInstance(dm1.max(), int)\n        with self.assertRaises(AssertionError):\n            np.testing.assert_array_equal(dm1, dm2)",
                            "ast_type_str": "ClassDef",
                            "start_lineno": 189,
                            "end_lineno": 198,
                            "parent": {
                                "file_name": "Orange/tests/test_distances.py",
                                "type": "class",
                                "name": "TestDistMatrix",
                                "content": "class TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n\n        self.assertIsInstance(dm1.max(), np.int64)\n        self.assertNotIsInstance(dm1.max(), int)\n        with self.assertRaises(AssertionError):\n            np.testing.assert_array_equal(dm1, dm2)",
                                "ast_type_str": "ClassDef",
                                "start_lineno": 30,
                                "end_lineno": 198,
                                "parent": null
                            }
                        }
                    ],
                    "deleted_entities": []
                }
            ]
        }
    ],
    "old_commit_hash": "74ffccc1d4a1dbb877490c9d6b59e6f501d5e438^",
    "new_commit_hash": "74ffccc1d4a1dbb877490c9d6b59e6f501d5e438",
    "commit_message": "Merge pull request #3865 from robertcv/fix/distmatrix_datatype\n\n[FIX] DistMatrix should return numpy datatypes",
    "commit_date": "2019-06-07T16:32:48+02:00",
    "metadata": {}
}
{
    "repo_name": "orange3",
    "new_commit_hash": "74ffccc1d4a1dbb877490c9d6b59e6f501d5e438",
    "test_file_codes": [
        "# Test methods with long descriptive names can omit docstrings\n# pylint: disable=missing-docstring\n\nfrom unittest import TestCase\nimport pickle\n\nimport numpy as np\nimport scipy\nimport scipy.spatial\nimport scipy.stats\nfrom scipy.sparse import csr_matrix\n\nfrom Orange.data import (Table, Domain, ContinuousVariable,\n                         DiscreteVariable, StringVariable, Instance)\nfrom Orange.distance import (Euclidean, SpearmanR, SpearmanRAbsolute,\n                             PearsonR, PearsonRAbsolute, Manhattan, Cosine,\n                             Jaccard, _preprocess, MahalanobisDistance)\nfrom Orange.distance.distance import _spearmanr2, _corrcoef2\nfrom Orange.misc import DistMatrix\nfrom Orange.tests import named_file, test_filename\nfrom Orange.util import OrangeDeprecationWarning\n\n\ndef tables_equal(tab1, tab2):\n    # TODO: introduce Table.__eq__() ???\n    return (tab1 == tab2 or  # catches None\n            np.all([i == j for i, j in zip(tab1, tab2)]))\n\n\nclass TestDistMatrix(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.dist = Euclidean(cls.iris)\n\n    # pylint: disable=unsubscriptable-object\n    def test_submatrix(self):\n        sub = self.dist.submatrix([2, 3, 4])\n        np.testing.assert_equal(sub, self.dist[2:5, 2:5])\n        self.assertTrue(tables_equal(sub.row_items, self.dist.row_items[2:5]))\n\n    def test_pickling(self):\n        unpickled_dist = pickle.loads(pickle.dumps(self.dist))\n        np.testing.assert_equal(unpickled_dist, self.dist)\n        self.assertTrue(tables_equal(unpickled_dist.row_items,\n                                     self.dist.row_items))\n        self.assertTrue(tables_equal(unpickled_dist.col_items,\n                                     self.dist.col_items))\n        self.assertEqual(unpickled_dist.axis, self.dist.axis)\n\n    def test_deprecated(self):\n        a9 = np.arange(9).reshape(3, 3)\n        m = DistMatrix(a9)\n        with self.assertWarns(OrangeDeprecationWarning):\n            self.assertEqual(m.dim, 3)\n        with self.assertWarns(OrangeDeprecationWarning):\n            np.testing.assert_almost_equal(m.X, a9)\n\n    def test_from_file(self):\n        with named_file(\n                \"\"\"3 axis=0 asymmetric col_labels row_labels\n                    ann\tbert\tchad\n                    danny\t0.12\t3.45\t6.78\n                    eve\t9.01\t2.34\t5.67\n                    frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n        with named_file(\n                \"\"\"3 axis=1 row_labels\n                    danny\t0.12\t3.45\t6.78\n                    eve \t9.01\t2.34\t5.67\n                    frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=1 symmetric\n                0.12\t3.45\t6.78\n                9.01\t2.34\t5.67\n                8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n        np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                    [9.01, 2.34, 0],\n                                                    [8.90, 0, 0]]))\n\n        with named_file(\n            \"\"\"3 row_labels\n                starič\t0.12\t3.45\t6.78\n                aleš\t9.01\t2.34\t5.67\n                anže\t8.90\"\"\", encoding=\"utf-8\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"starič\", \"aleš\", \"anže\"])\n            self.assertEqual(m.axis, 1)\n\n        def assertErrorMsg(content, msg):\n            with named_file(content) as name:\n                with self.assertRaises(ValueError) as cm:\n                    DistMatrix.from_file(name)\n                self.assertEqual(str(cm.exception), msg)\n\n        assertErrorMsg(\"\",\n                       \"empty file\")\n        assertErrorMsg(\"axis=1\\n1\\t3\\n4\",\n                       \"distance file must begin with dimension\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"3 col_labels\\na\\tb\\tc\\td\\n1\\n\\2\\n3\",\n                       \"mismatching number of column labels\")\n        assertErrorMsg(\"2\\n  1\\t2\\t3\\n  5\",\n                       \"too many columns in matrix row 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\t2\\t3\\nb\\t5\",\n                       \"too many columns in matrix row 'a'\")\n        assertErrorMsg(\"2 noflag\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag'\")\n        assertErrorMsg(\"2 noflag=5\\n  1\\t2\\t3\\n  5\",\n                       \"invalid flag 'noflag=5'\")\n        assertErrorMsg(\"2\\n1\\n2\\n3\",\n                       \"too many rows\")\n        assertErrorMsg(\"2\\n1\\nasd\",\n                       \"invalid element at row 2, column 1\")\n        assertErrorMsg(\"2 row_labels\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 1\")\n        assertErrorMsg(\"2 col_labels row_labels\\nd\\te\\na\\t1\\nb\\tasd\",\n                       \"invalid element at row 'b', column 'd'\")\n        assertErrorMsg(\"2 col_labels\\nd\\te\\n1\\nasd\",\n                       \"invalid element at row 2, column 'd'\")\n\n    def test_save(self):\n        with named_file(\n            \"\"\"3 axis=1 row_labels\n                danny\t0.12\t3.45\t6.78\n                eve \t9.01\t2.34\t5.67\n                frank\t8.90\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 9.01, 8.90],\n                                                        [9.01, 2.34, 0],\n                                                        [8.90, 0, 0]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsNone(m.col_items)\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 1)\n\n        with named_file(\n            \"\"\"3 axis=0 asymmetric col_labels row_labels\n                         ann\tbert\tchad\n                danny\t0.12\t3.45\t6.78\n                  eve\t9.01\t2.34\t5.67\n                frank\t8.90\t1.23\t4.56\"\"\") as name:\n            m = DistMatrix.from_file(name)\n            m.save(name)\n            m = DistMatrix.from_file(name)\n            np.testing.assert_almost_equal(m, np.array([[0.12, 3.45, 6.78],\n                                                        [9.01, 2.34, 5.67],\n                                                        [8.90, 1.23, 4.56]]))\n            self.assertIsInstance(m.row_items, Table)\n            self.assertIsInstance(m.col_items, Table)\n            self.assertEqual([e.metas[0] for e in m.col_items],\n                             [\"ann\", \"bert\", \"chad\"])\n            self.assertEqual([e.metas[0] for e in m.row_items],\n                             [\"danny\", \"eve\", \"frank\"])\n            self.assertEqual(m.axis, 0)\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n\n        self.assertIsInstance(dm1.max(), np.int64)\n        self.assertNotIsInstance(dm1.max(), int)\n        with self.assertRaises(AssertionError):\n            np.testing.assert_array_equal(dm1, dm2)\n\n\n# noinspection PyTypeChecker\nclass TestEuclidean(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Euclidean\n\n    def test_euclidean_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.53851648071346281]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.53851648071346281]]))\n\n    def test_euclidean_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 2.48394847, 5.09313263, 6.78969808],\n                      [2.48394847, 0., 2.64007576, 4.327817],\n                      [5.09313263, 2.64007576, 0., 1.69705627],\n                      [6.78969808, 4.327817, 1.69705627, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n    def test_euclidean_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 3.74165739, 6.164414],\n                      [3.74165739, 0., 4.47213595],\n                      [6.164414, 4.47213595, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 4.12310563, 3.31662479],\n                      [4.12310563, 0., 6.164414],\n                      [3.31662479, 6.164414, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 3.74165739],\n                      [3.74165739, 0.]]))\n\n    def test_euclidean_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.53851648],\n                      [0.53851648, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np. array([[0.50990195, 0.3, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.64807407],\n                      [0.33166248]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.53851648, 0.50990195],\n                      [0.53851648, 0., 0.3]]))\n\n\n# noinspection PyTypeChecker\nclass TestManhattan(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Manhattan\n\n    def test_manhattan_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.7]]))\n\n    def test_manhattan_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0., 3.5, 7.2, 9.6],\n                      [3.5, 0., 3.7, 6.1],\n                      [7.2, 3.7, 0., 2.4],\n                      [9.6, 6.1, 2.4, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n    def test_manhattan_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0., 6., 10.],\n                      [6., 0., 6.],\n                      [10., 6., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0., 5., 5.],\n                      [5., 0., 10.],\n                      [5., 10., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0., 6.],\n                      [6., 0.]]))\n\n    def test_manhattan_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.7]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 0.7],\n                      [0.7, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[0.8, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[1.],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0., 0.7, 0.8],\n                      [0.7, 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestCosine(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.iris = Table('iris')\n        cls.sparse = Table(csr_matrix([[1, 2, 0], [0, 0, 3], [4, 0, 5]]))\n        cls.dist = Cosine\n\n    def test_cosine_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0]), np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1]),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0], self.iris[1], axis=1),\n            np.array([[0.00142084]]))\n\n    def test_cosine_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2]),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], axis=0),\n            np.array([[0.0, 1.61124231e-03, 1.99940020e-04, 1.99940020e-04],\n                      [1.61124231e-03, 0.0, 2.94551450e-03, 2.94551450e-03],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0],\n                      [1.99940020e-04, 2.94551450e-03, 0.0, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2], self.iris[:3]),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[3]),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2], self.iris[:3]),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n    def test_cosine_distance_sparse(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse),\n            np.array([[0.0, 1.00000000e+00, 7.20627882e-01],\n                      [1.00000000e+00, 0.0, 2.19131191e-01],\n                      [7.20627882e-01, 2.19131191e-01, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse, axis=0),\n            np.array([[0.0, 7.57464375e-01, 1.68109669e-01],\n                      [7.57464375e-01, 0.0, 1.00000000e+00],\n                      [1.68109669e-01, 1.00000000e+00, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.sparse[:2]),\n            np.array([[0.0, 1.00000000e+00],\n                      [1.00000000e+00, 0.0]]))\n\n    def test_cosine_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[0].x, self.iris[1].x, axis=1),\n            np.array([[0.00142084]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X),\n            np.array([[0., 1.42083650e-03],\n                      [1.42083650e-03, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[2].x, self.iris[:3].X),\n            np.array([[1.26527175e-05, 1.20854727e-03, 0.0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[3].x),\n            np.array([[0.00089939],\n                      [0.00120607]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.iris[:2].X, self.iris[:3].X),\n            np.array([[0.0, 1.42083650e-03, 1.26527175e-05],\n                      [1.42083650e-03, 0.0, 1.20854727e-03]]))\n\n\n# noinspection PyTypeChecker\nclass TestJaccard(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.titanic = Table('titanic')[173:177]\n        cls.dist = Jaccard\n\n    def test_jaccard_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2]),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0], self.titanic[2], axis=1),\n            np.array([[0.5]]))\n\n    def test_jaccard_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic, axis=0),\n            np.array([[0., 1., 0.5],\n                      [1., 0., 1.],\n                      [0.5, 1., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2], self.titanic[:3]),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[3]),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2], self.titanic[:3]),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n    def test_jaccard_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[0].x, self.titanic[2].x, axis=1),\n            np.array([[0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic.X),\n            np.array([[0., 0., 0.5, 0.5],\n                      [0., 0., 0.5, 0.5],\n                      [0.5, 0.5, 0., 0.],\n                      [0.5, 0.5, 0., 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[2].x, self.titanic[:3].X),\n            np.array([[0.5, 0.5, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[3].x),\n            np.array([[0.5],\n                      [0.5]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.titanic[:2].X, self.titanic[:3].X),\n            np.array([[0., 0., 0.5],\n                      [0., 0., 0.5]]))\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanR\n\n    def test_spearmanr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.5083333333333333]]))\n\n    def test_spearmanr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333],\n                      [0.61666667, 0.53333333, 0.63333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.75, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.75, 0.25, 0.75, 0.25, 0.25, 0.25, 0., 0.25, 1.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.75],\n                      [0.25, 0.75, 0.25, 0.75, 0.75, 0.75, 1., 0.75, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.50833333, 0.075, 0.61666667],\n                      [0.50833333, 0., 0.38333333, 0.53333333],\n                      [0.075, 0.38333333, 0., 0.63333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.5083333333333333]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.5083333333333333],\n                      [0.5083333333333333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.075, 0.3833333, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.075],\n                      [0.3833333],\n                      [0.]]))\n\n    def test_spearmanr2(self):\n        # Test that _spearnmanr2 returns the same result that stats.spearmanr\n        # would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = scipy.stats.spearmanr(X1, X2, axis=1)[0][:n, n:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = scipy.stats.spearmanr(X1, X2, axis=0)[0][:m, m:]\n        np.testing.assert_almost_equal(\n            _spearmanr2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n\n# noinspection PyTypeChecker\nclass TestSpearmanRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = SpearmanRAbsolute\n\n    def test_spearmanrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.49166666666666664]]))\n\n    def test_spearmanrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], axis=0),\n            np.array([[0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0., 0.25, 0., 0.25, 0.25, 0.25, 0.25, 0.25, 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.],\n                      [0.25, 0., 0.25, 0., 0., 0., 0.25, 0., 0.25],\n                      [0.25, 0.25, 0.25, 0.25, 0.25, 0.25, 0., 0.25, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.49166667, 0.075, 0.38333333],\n                      [0.49166667, 0., 0.38333333, 0.46666667],\n                      [0.075, 0.38333333, 0., 0.36666667]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3], self.breast[:4]),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4], self.breast[3]),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n    def test_spearmanrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.49166666666666664]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.49166667],\n                      [0.49166667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[3].x, self.breast[:4].X),\n            np.array([[0.3833333, 0.4666667, 0.3666667, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:4].X, self.breast[3].x),\n            np.array([[0.3833333],\n                      [0.4666667],\n                      [0.3666667],\n                      [0.]]))\n\n\n# noinspection PyTypeChecker\nclass TestPearsonR(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonR\n\n    def test_pearsonr_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonr_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.57976119],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.57976119, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.5016744],\n                      [0.48462294, 0., 0.32783865, 0.57317387],\n                      [0.10133593, 0.32783865, 0., 0.63789635]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[2]),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_pearsonr_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3].X, self.breast[2].x),\n            np.array([[0.10133593],\n                      [0.32783865],\n                      [0.]]))\n\n    def test_corrcoef2(self):\n        # Test that _corrcoef2 returns the same result that np.corrcoef would\n        n, m = tuple(np.random.randint(2, 5, size=2))\n        mean = np.random.uniform(-1, 1, size=m)\n        cov = np.random.uniform(0, 1./m, size=(m, m))\n        cov = (cov + cov.T) / 2\n        cov.flat[::m + 1] = 1.0\n        X1 = np.random.multivariate_normal(mean, cov, size=n)\n        X2 = np.random.multivariate_normal(mean, cov, size=n)\n        expected = np.corrcoef(X1, X2, rowvar=True)[:n, n:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=1),\n            expected,\n            decimal=9\n        )\n\n        expected = np.corrcoef(X1, X2, rowvar=False)[:m, m:]\n        np.testing.assert_almost_equal(\n            _corrcoef2(X1, X2, axis=0),\n            expected,\n            decimal=9,\n        )\n\n        with self.assertRaises(ValueError):\n            _corrcoef2(X1, X2, axis=10)\n\n\n# noinspection PyTypeChecker\nclass TestPearsonRAbsolute(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.breast = Table(test_filename(\n            \"datasets/breast-cancer-wisconsin.tab\"))\n        cls.dist = PearsonRAbsolute\n\n    def test_pearsonrabsolute_distance_one_example(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0]),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[0], axis=1),\n            np.array([[0]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1]),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0], self.breast[1], axis=1),\n            np.array([[0.48462293898088876]]))\n\n    def test_pearsonrabsolute_distance_many_examples(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2]),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        # pylint: disable=line-too-long\n        # Because it looks better\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:20], axis=0),\n            np.array([[0., 0.10239274, 0.12786763, 0.13435117, 0.15580385, 0.27429811, 0.21006195, 0.24072005, 0.42847752],\n                      [0.10239274, 0., 0.01695375, 0.10313851, 0.1138925, 0.16978203, 0.1155948, 0.08043531, 0.43326547],\n                      [0.12786763, 0.01695375, 0., 0.16049178, 0.13692762, 0.21784201, 0.11607395, 0.06493949, 0.46590168],\n                      [0.13435117, 0.10313851, 0.16049178, 0., 0.07181648, 0.15585667, 0.13891172, 0.21622332, 0.37404826],\n                      [0.15580385, 0.1138925, 0.13692762, 0.07181648, 0., 0.16301705, 0.17324382, 0.21452448, 0.42283252],\n                      [0.27429811, 0.16978203, 0.21784201, 0.15585667, 0.16301705, 0., 0.25512861, 0.29560909, 0.42766076],\n                      [0.21006195, 0.1155948, 0.11607395, 0.13891172, 0.17324382, 0.25512861, 0., 0.14419442, 0.42023881],\n                      [0.24072005, 0.08043531, 0.06493949, 0.21622332, 0.21452448, 0.29560909, 0.14419442, 0., 0.45930368],\n                      [0.42847752, 0.43326547, 0.46590168, 0.37404826, 0.42283252, 0.42766076, 0.42023881, 0.45930368, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:3], self.breast[:4]),\n            np.array([[0., 0.48462294, 0.10133593, 0.4983256],\n                      [0.48462294, 0., 0.32783865, 0.42682613],\n                      [0.10133593, 0.32783865, 0., 0.36210365]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2], self.breast[:3]),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2], self.breast[3]),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n    def test_pearsonrabsolute_distance_numpy(self):\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[0].x, self.breast[1].x, axis=1),\n            np.array([[0.48462293898088876]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X),\n            np.array([[0., 0.48462294],\n                      [0.48462294, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[2].x, self.breast[:3].X),\n            np.array([[0.10133593, 0.32783865, 0.]]))\n        np.testing.assert_almost_equal(\n            self.dist(self.breast[:2].X, self.breast[3].x),\n            np.array([[0.4983256],\n                      [0.42682613]]))\n\n\n# noinspection PyTypeChecker\n# Pylint doesn't get magic __new__ operators\n# pylint: disable=not-callable\nclass TestMahalanobis(TestCase):\n    def setUp(self):\n        self.n, self.m = 10, 5\n        self.x = np.random.rand(self.n, self.m)\n        self.x1 = np.random.rand(self.m)\n        self.x2 = np.random.rand(self.m)\n\n    def test_correctness(self):\n        mah = MahalanobisDistance(self.x)\n        d = scipy.spatial.distance.pdist(self.x, 'mahalanobis')\n        d = scipy.spatial.distance.squareform(d)\n        for i in range(self.n):\n            for j in range(self.n):\n                self.assertAlmostEqual(d[i][j], mah(self.x[i], self.x[j]),\n                                       delta=1e-5)\n\n    def test_attributes(self):\n        metric = MahalanobisDistance(self.x)\n        self.assertEqual(metric(self.x[0], self.x[1]).shape, (1, 1))\n        self.assertEqual(metric(self.x).shape, (self.n, self.n))\n        self.assertEqual(metric(self.x[0:3], self.x[5:7]).shape, (3, 2))\n        self.assertEqual(metric(self.x1, self.x2).shape, (1, 1))\n        metric(self.x, impute=True)\n        metric(self.x[:-1, :])\n        self.assertRaises(ValueError, metric, self.x[:, :-1])\n        self.assertRaises(ValueError, metric, self.x1[:-1], self.x2)\n        self.assertRaises(ValueError, metric, self.x1, self.x2[:-1])\n        self.assertRaises(ValueError, metric, self.x.T)\n\n    def test_iris(self):\n        tab = Table('iris')\n        metric = MahalanobisDistance(tab)\n        self.assertEqual(metric(tab).shape, (150, 150))\n        self.assertEqual(metric(tab[0], tab[1]).shape, (1, 1))\n\n    def test_dimensions(self):\n        x = Table('iris')[:20].X\n        xt = Table('iris')[:20].X.T\n        mah = MahalanobisDistance(x)\n        mah(x[0], x[1])\n        mah = MahalanobisDistance(xt)\n        mah(xt[0], xt[1])\n\n\nclass TestDistances(TestCase):\n    @classmethod\n    def setUpClass(cls):\n        cls.test5 = Table(test_filename('datasets/test5.tab'))\n\n    def test_preprocess(self):\n        domain = Domain([ContinuousVariable(\"c\"),\n                         DiscreteVariable(\"d\", values=['a', 'b'])],\n                        [DiscreteVariable(\"cls\", values=['e', 'f'])],\n                        [StringVariable(\"m\")])\n        table = Table(domain, [[1, 'a', 'e', 'm1'],\n                               [2, 'b', 'f', 'm2']])\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.X, table.X[:, 0].reshape(2, 1))\n        np.testing.assert_equal(new_table.Y, table.Y)\n        np.testing.assert_equal(new_table.metas, table.metas)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n        self.assertEqual(new_table.domain.metas, table.domain.metas)\n\n    def test_preprocess_multiclass(self):\n        table = self.test5\n        new_table = _preprocess(table)\n        np.testing.assert_equal(new_table.Y, table.Y)\n        self.assertEqual([a.name for a in new_table.domain.attributes],\n                         [a.name for a in table.domain.attributes\n                          if a.is_continuous])\n        self.assertEqual(new_table.domain.class_vars, table.domain.class_vars)\n\n    def test_preprocess_impute(self):\n        new_table = _preprocess(self.test5)\n        self.assertFalse(np.isnan(new_table.X).any())\n\n    def test_distance_to_instance(self):\n        iris = Table('iris')\n        inst = Instance(iris.domain, np.concatenate((iris[1].x, iris[1].y)))\n        self.assertEqual(Euclidean(iris[1], inst), 0)\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/tmpel1almvl/tmp\ncreating /tmp/tmpel1almvl/tmp/tmpel1almvl\ncompile options: '-MMD -MF /tmp/tmpel1almvl/file.c.d -c'\ncc: /tmp/tmpel1almvl/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/tmps80m029d/tmp\ncreating /tmp/tmps80m029d/tmp/tmps80m029d\ncompile options: '-MMD -MF /tmp/tmps80m029d/file.c.d -c'\ncc: /tmp/tmps80m029d/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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include -I/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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/tmpf3k5wktx/tmp\ncreating /tmp/tmpf3k5wktx/tmp/tmpf3k5wktx\ncompile options: '-MMD -MF /tmp/tmpf3k5wktx/file.c.d -c'\ncc: /tmp/tmpf3k5wktx/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/tmp1gam_wku/tmp\ncreating /tmp/tmp1gam_wku/tmp/tmp1gam_wku\ncompile options: '-MMD -MF /tmp/tmp1gam_wku/file.c.d -c'\ncc: /tmp/tmp1gam_wku/file.c\ncustomize UnixCCompiler using build_ext\nCreating /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/Orange3.egg-link (link to .)\nAdding Orange3 3.22.0.dev0+74ffccc to easy-install.pth file\nInstalling orange-canvas script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nInstalled /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438\nProcessing dependencies for Orange3==3.22.0.dev0+74ffccc\nSearching for XlsxWriter==3.2.0\nBest match: XlsxWriter 3.2.0\nAdding XlsxWriter 3.2.0 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages\nSearching for xlrd==2.0.1\nBest match: xlrd 2.0.1\nAdding xlrd 2.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling pip3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling pip3.10 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages\nSearching for openTSNE==1.0.1\nBest match: openTSNE 1.0.1\nAdding openTSNE 1.0.1 to easy-install.pth file\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling f2py3 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling f2py3.7 script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling pyftmerge script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling pyftsubset script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\nInstalling ttx script to /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/bin\n\nUsing /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages\nFinished processing dependencies for Orange3==3.22.0.dev0+74ffccc\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 73ms\nPrepared 18 packages in 15ms\nInstalled 18 packages in 176ms\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 33 packages in 163ms\nInstalled 28 packages in 252ms\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 + opentsne==1.0.1\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\n + xlsxwriter==3.2.0\nResolved 14 packages in 54ms\nInstalled 11 packages in 383ms\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 4ms\nInstalled 2 packages in 52ms\n + psycopg2==2.9.9\n + pymssql==2.3.2\nResolved 5 packages in 23ms\nInstalled 2 packages in 239ms\n + pandas==1.3.5\n + pytz==2024.2\nAudited 2 packages in 2ms\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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarraytypes.h:1830,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.venv/lib/python3.7/site-packages/numpy/core/include/numpy/ndarrayobject.h:12,\n                 from /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/.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": 1,
    "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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438\ncollected 44 items\n\nr2e_tests/test_1.py E...........................................         [100%]\n\n==================================== ERRORS ====================================\n_______________________ ERROR at setup of test_filename ________________________\nfile /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/Orange/tests/__init__.py, line 65\n  def test_filename(path):\nE       fixture 'path' not found\n>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory\n>       use 'pytest --fixtures [testpath]' for help on them.\n\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/Orange/tests/__init__.py:65\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_deprecated\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_from_file\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_numpy_type\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_pickling\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_save\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_submatrix\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_many_examples\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_numpy\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_one_example\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_sparse\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_many_examples\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_numpy\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_one_example\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_sparse\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_many_examples\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_numpy\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_one_example\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_sparse\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_many_examples\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_numpy\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_one_example\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr2\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_many_examples\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_numpy\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_one_example\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_many_examples\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_numpy\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_one_example\nPASSED r2e_tests/test_1.py::TestPearsonR::test_corrcoef2\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_many_examples\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_numpy\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_one_example\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_many_examples\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_numpy\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_one_example\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_attributes\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_correctness\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_dimensions\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_iris\nPASSED r2e_tests/test_1.py::TestDistances::test_distance_to_instance\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess_impute\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess_multiclass\nERROR r2e_tests/test_1.py::test_filename\n========================= 43 passed, 1 error in 2.03s ==========================\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_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438\ncollected 44 items\n\nr2e_tests/test_1.py E..F........................................         [100%]\n\n==================================== ERRORS ====================================\n_______________________ ERROR at setup of test_filename ________________________\nfile /home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/Orange/tests/__init__.py, line 65\n  def test_filename(path):\nE       fixture 'path' not found\n>       available fixtures: cache, capfd, capfdbinary, caplog, capsys, capsysbinary, doctest_namespace, monkeypatch, pytestconfig, record_property, record_testsuite_property, record_xml_attribute, recwarn, tmp_path, tmp_path_factory, tmpdir, tmpdir_factory\n>       use 'pytest --fixtures [testpath]' for help on them.\n\n/home/gcpuser/buckets/local_repoeval_bucket/repos/orange3_74ffccc1d4a1dbb877490c9d6b59e6f501d5e438/Orange/tests/__init__.py:65\n=================================== FAILURES ===================================\n________________________ TestDistMatrix.test_numpy_type ________________________\n\nself = <r2e_tests.test_1.TestDistMatrix testMethod=test_numpy_type>\n\n    def test_numpy_type(self):\n        \"\"\"GH-3658\"\"\"\n        data1 = np.array([1, 2], dtype=np.int64)\n        data2 = np.array([2, 3], dtype=np.int64)\n        dm1, dm2 = DistMatrix(data1), DistMatrix(data2)\n    \n>       self.assertIsInstance(dm1.max(), np.int64)\nE       AssertionError: 2 is not an instance of <class 'numpy.int64'>\n\nr2e_tests/test_1.py:195: AssertionError\n==================================== PASSES ====================================\n=========================== short test summary info ============================\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_deprecated\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_from_file\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_pickling\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_save\nPASSED r2e_tests/test_1.py::TestDistMatrix::test_submatrix\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_many_examples\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_numpy\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_one_example\nPASSED r2e_tests/test_1.py::TestEuclidean::test_euclidean_distance_sparse\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_many_examples\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_numpy\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_one_example\nPASSED r2e_tests/test_1.py::TestManhattan::test_manhattan_distance_sparse\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_many_examples\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_numpy\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_one_example\nPASSED r2e_tests/test_1.py::TestCosine::test_cosine_distance_sparse\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_many_examples\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_numpy\nPASSED r2e_tests/test_1.py::TestJaccard::test_jaccard_distance_one_example\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr2\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_many_examples\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_numpy\nPASSED r2e_tests/test_1.py::TestSpearmanR::test_spearmanr_distance_one_example\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_many_examples\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_numpy\nPASSED r2e_tests/test_1.py::TestSpearmanRAbsolute::test_spearmanrabsolute_distance_one_example\nPASSED r2e_tests/test_1.py::TestPearsonR::test_corrcoef2\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_many_examples\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_numpy\nPASSED r2e_tests/test_1.py::TestPearsonR::test_pearsonr_distance_one_example\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_many_examples\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_numpy\nPASSED r2e_tests/test_1.py::TestPearsonRAbsolute::test_pearsonrabsolute_distance_one_example\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_attributes\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_correctness\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_dimensions\nPASSED r2e_tests/test_1.py::TestMahalanobis::test_iris\nPASSED r2e_tests/test_1.py::TestDistances::test_distance_to_instance\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess_impute\nPASSED r2e_tests/test_1.py::TestDistances::test_preprocess_multiclass\nERROR r2e_tests/test_1.py::test_filename\nFAILED r2e_tests/test_1.py::TestDistMatrix::test_numpy_type - AssertionError:...\n==================== 1 failed, 42 passed, 1 error in 2.01s =====================\n",
    "old_commit_res_stderr": ""
}
Orange/misc/distmatrix.py Orange/tests/test_distances.py
We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
[ISSUE]
**Title:** `DistMatrix.max()` Returns Python `int` Instead of `numpy.int64`

**Description:**
When using the `DistMatrix` class, calling the `max()` method returns a Python `int` instead of a `numpy.int64`. This type mismatch can lead to unexpected behavior in parts of the code that expect NumPy data types.

**Example Code:**
```python
import numpy as np
from Orange.misc.distmatrix import DistMatrix

data = np.array([1, 2], dtype=np.int64)
dm = DistMatrix(data)
max_value = dm.max()
print(type(max_value))  # Outputs: <class 'int'>
```

**Expected Behavior:**
The `max()` method should return a `numpy.int64` object, ensuring consistency with NumPy data types.

**Actual Behavior:**
The `max()` method returns a Python `int` object, causing type inconsistencies.

[/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/misc/distmatrix.py
import numpy as np

from Orange.data import Table, StringVariable, Domain
from Orange.data.io import detect_encoding
from Orange.util import deprecated


class DistMatrix(np.ndarray):
    """
    Distance matrix. Extends ``numpy.ndarray``.

    .. attribute:: row_items

        Items corresponding to matrix rows.

    .. attribute:: col_items

        Items corresponding to matrix columns.

    .. attribute:: axis

        If axis=1 we calculate distances between rows,
        if axis=0 we calculate distances between columns.
    """
    def __new__(cls, data, row_items=None, col_items=None, axis=1):
        """Construct a new distance matrix containing the given data.

        :param data: Distance matrix
        :type data: numpy array
        :param row_items: Items in matrix rows
        :type row_items: `Orange.data.Table` or `Orange.data.Instance`
        :param col_items: Items in matrix columns
        :type col_items: `Orange.data.Table` or `Orange.data.Instance`
        :param axis: The axis along which the distances are calculated
        :type axis: int

        """
        obj = np.asarray(data).view(cls)
        obj.row_items = row_items
        obj.col_items = col_items
        obj.axis = axis
        return obj

    def __array_finalize__(self, obj):
        """See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html"""
        if obj is None:
            return
        self.row_items = getattr(obj, 'row_items', None)
        self.col_items = getattr(obj, 'col_items', None)
        self.axis = getattr(obj, 'axis', 1)

    def __array_wrap__(self, out_arr, context=None):
        if out_arr.ndim == 0:  # a single scalar
            return out_arr.item()
        return np.ndarray.__array_wrap__(self, out_arr, context)

    """
    __reduce__() and __setstate__() ensure DistMatrix is picklable.
    """
    def __reduce__(self):
        state = super().__reduce__()
        newstate = state[2] + (self.row_items, self.col_items, self.axis)
        return state[0], state[1], newstate

    # noinspection PyMethodOverriding,PyArgumentList
    def __setstate__(self, state):
        self.row_items = state[-3]
        self.col_items = state[-2]
        self.axis = state[-1]
        super().__setstate__(state[0:-3])

    @property
    @deprecated
    def dim(self):
        """Returns the single dimension of the symmetric square matrix."""
        return self.shape[0]

    # noinspection PyPep8Naming
    @property
    @deprecated
    def X(self):
        return self

    @property
    def flat(self):
        return self[np.triu_indices(self.shape[0], 1)]

    def submatrix(self, row_items, col_items=None):
        """
        Return a submatrix

        Args:
            row_items: indices of rows
            col_items: incides of columns
        """
        if not col_items:
            col_items = row_items
        obj = self[np.ix_(row_items, col_items)]
        if self.row_items is not None:
            obj.row_items = self.row_items[row_items]
        if self.col_items is not None:
            if self.col_items is self.row_items and row_items is col_items:
                obj.col_items = obj.row_items
            else:
                obj.col_items = self.col_items[col_items]
        return obj

    @classmethod
    def from_file(cls, filename):
        """
        Load distance matrix from a file

        The file should be preferrably encoded in ascii/utf-8. White space at
        the beginning and end of lines is ignored.

        The first line of the file starts with the matrix dimension. It
        can be followed by a list flags

        - *axis=<number>*: the axis number
        - *symmetric*: the matrix is symmetric; when reading the element (i, j)
          it's value is also assigned to (j, i)
        - *asymmetric*: the matrix is asymmetric
        - *row_labels*: the file contains row labels
        - *col_labels*: the file contains column labels

        By default, matrices are symmetric, have axis 1 and no labels are given.
        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.

        If the file has column labels, they follow in the second line.
        Row labels appear at the beginning of each row.
        Labels are arbitrary strings that cannot contain newlines and
        tabulators. Labels are stored as instances of `Table` with a single
        meta attribute named "label".

        The remaining lines contain tab-separated numbers, preceded with labels,
        if present. Lines are padded with zeros if necessary. If the matrix is
        symmetric, the file contains the lower triangle; any data above the
        diagonal is ignored.

        Args:
            filename: file name
        """
        with open(filename, encoding=detect_encoding(filename)) as fle:
            line = fle.readline()
            if not line:
                raise ValueError("empty file")
            data = line.strip().split()
            if not data[0].strip().isdigit():
                raise ValueError("distance file must begin with dimension")
            n = int(data.pop(0))
            symmetric = True
            axis = 1
            col_labels = row_labels = None
            for flag in data:
                if flag in ("labelled", "labeled", "row_labels"):
                    row_labels = []
                elif flag == "col_labels":
                    col_labels = []
                elif flag == "symmetric":
                    symmetric = True
                elif flag == "asymmetric":
                    symmetric = False
                else:
                    flag_data = flag.split("=")
                    if len(flag_data) == 2:
                        name, value = map(str.strip, flag_data)
                    else:
                        name, value = "", None
                    if name == "axis" and value.isdigit():
                        axis = int(value)
                    else:
                        raise ValueError("invalid flag '{}'".format(
                            flag, filename))
            if col_labels is not None:
                col_labels = [x.strip()
                              for x in fle.readline().strip().split("\t")]
                if len(col_labels) != n:
                    raise ValueError("mismatching number of column labels")

            matrix = np.zeros((n, n))
            for i, line in enumerate(fle):
                if i >= n:
                    raise ValueError("too many rows".format(filename))
                line = line.strip().split("\t")
                if row_labels is not None:
                    row_labels.append(line.pop(0).strip())
                if len(line) > n:
                    raise ValueError("too many columns in matrix row {}".
                                     format("'{}'".format(row_labels[i])
                                            if row_labels else i + 1))
                for j, e in enumerate(line[:i + 1 if symmetric else n]):
                    try:
                        matrix[i, j] = float(e)
                    except ValueError as exc:
                        raise ValueError(
                            "invalid element at row {}, column {}".format(
                                "'{}'".format(row_labels[i])
                                if row_labels else i + 1,
                                "'{}'".format(col_labels[j])
                                if col_labels else j + 1)) from exc
                    if symmetric:
                        matrix[j, i] = matrix[i, j]
        if col_labels:
            col_labels = Table.from_list(
                Domain([], metas=[StringVariable("label")]),
                [[item] for item in col_labels])
        if row_labels:
            row_labels = Table.from_list(
                Domain([], metas=[StringVariable("label")]),
                [[item] for item in row_labels])
        return cls(matrix, row_labels, col_labels, axis)

    @staticmethod
    def _trivial_labels(items):
        return items and \
               isinstance(items, Table) and \
               len(items.domain.metas) == 1 and \
               isinstance(items.domain.metas[0], StringVariable)

    def has_row_labels(self):
        """
        Returns `True` if row labels can be automatically determined from data

        For this, the `row_items` must be an instance of `Orange.data.Table`
        whose domain contains a single meta attribute, which has to be a string.
        The domain may contain other variables, but not meta attributes.
        """
        return self._trivial_labels(self.row_items)

    def has_col_labels(self):
        """
        Returns `True` if column labels can be automatically determined from
        data

        For this, the `col_items` must be an instance of `Orange.data.Table`
        whose domain contains a single meta attribute, which has to be a string.
        The domain may contain other variables, but not meta attributes.
        """
        return self._trivial_labels(self.col_items)

    def save(self, filename):
        """
        Save the distance matrix to a file in the file format described at
        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.

        Args:
            filename: file name
        """
        n = len(self)
        data = "{}\taxis={}".format(n, self.axis)
        row_labels = col_labels = None
        if self.has_col_labels():
            data += "\tcol_labels"
            col_labels = self.col_items
        if self.has_row_labels():
            data += "\trow_labels"
            row_labels = self.row_items
        symmetric = np.allclose(self, self.T)
        if not symmetric:
            data += "\tasymmetric"
        with open(filename, "wt") as fle:
            fle.write(data + "\n")
            if col_labels is not None:
                fle.write("\t".join(str(e.metas[0]) for e in col_labels) + "\n")
            for i, row in enumerate(self):
                if row_labels is not None:
                    fle.write(str(row_labels[i].metas[0]) + "\t")
                if symmetric:
                    fle.write("\t".join(map(str, row[:i + 1])) + "\n")
                else:
                    fle.write("\t".join(map(str, row)) + "\n")

```
--- 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:** `DistMatrix.max()` Returns Python `int` Instead of `numpy.int64`

**Description:**
When using the `DistMatrix` class, calling the `max()` method returns a Python `int` instead of a `numpy.int64`. This type mismatch can lead to unexpected behavior in parts of the code that expect NumPy data types.

**Example Code:**
```python
import numpy as np
from Orange.misc.distmatrix import DistMatrix

data = np.array([1, 2], dtype=np.int64)
dm = DistMatrix(data)
max_value = dm.max()
print(type(max_value))  # Outputs: <class 'int'>
```

**Expected Behavior:**
The `max()` method should return a `numpy.int64` object, ensuring consistency with NumPy data types.

**Actual Behavior:**
The `max()` method returns a Python `int` object, causing type inconsistencies.

[/ISSUE]
{
    "TestDistMatrix.test_deprecated": "PASSED",
    "TestDistMatrix.test_from_file": "PASSED",
    "TestDistMatrix.test_numpy_type": "PASSED",
    "TestDistMatrix.test_pickling": "PASSED",
    "TestDistMatrix.test_save": "PASSED",
    "TestDistMatrix.test_submatrix": "PASSED",
    "TestEuclidean.test_euclidean_distance_many_examples": "PASSED",
    "TestEuclidean.test_euclidean_distance_numpy": "PASSED",
    "TestEuclidean.test_euclidean_distance_one_example": "PASSED",
    "TestEuclidean.test_euclidean_distance_sparse": "PASSED",
    "TestManhattan.test_manhattan_distance_many_examples": "PASSED",
    "TestManhattan.test_manhattan_distance_numpy": "PASSED",
    "TestManhattan.test_manhattan_distance_one_example": "PASSED",
    "TestManhattan.test_manhattan_distance_sparse": "PASSED",
    "TestCosine.test_cosine_distance_many_examples": "PASSED",
    "TestCosine.test_cosine_distance_numpy": "PASSED",
    "TestCosine.test_cosine_distance_one_example": "PASSED",
    "TestCosine.test_cosine_distance_sparse": "PASSED",
    "TestJaccard.test_jaccard_distance_many_examples": "PASSED",
    "TestJaccard.test_jaccard_distance_numpy": "PASSED",
    "TestJaccard.test_jaccard_distance_one_example": "PASSED",
    "TestSpearmanR.test_spearmanr2": "PASSED",
    "TestSpearmanR.test_spearmanr_distance_many_examples": "PASSED",
    "TestSpearmanR.test_spearmanr_distance_numpy": "PASSED",
    "TestSpearmanR.test_spearmanr_distance_one_example": "PASSED",
    "TestSpearmanRAbsolute.test_spearmanrabsolute_distance_many_examples": "PASSED",
    "TestSpearmanRAbsolute.test_spearmanrabsolute_distance_numpy": "PASSED",
    "TestSpearmanRAbsolute.test_spearmanrabsolute_distance_one_example": "PASSED",
    "TestPearsonR.test_corrcoef2": "PASSED",
    "TestPearsonR.test_pearsonr_distance_many_examples": "PASSED",
    "TestPearsonR.test_pearsonr_distance_numpy": "PASSED",
    "TestPearsonR.test_pearsonr_distance_one_example": "PASSED",
    "TestPearsonRAbsolute.test_pearsonrabsolute_distance_many_examples": "PASSED",
    "TestPearsonRAbsolute.test_pearsonrabsolute_distance_numpy": "PASSED",
    "TestPearsonRAbsolute.test_pearsonrabsolute_distance_one_example": "PASSED",
    "TestMahalanobis.test_attributes": "PASSED",
    "TestMahalanobis.test_correctness": "PASSED",
    "TestMahalanobis.test_dimensions": "PASSED",
    "TestMahalanobis.test_iris": "PASSED",
    "TestDistances.test_distance_to_instance": "PASSED",
    "TestDistances.test_preprocess": "PASSED",
    "TestDistances.test_preprocess_impute": "PASSED",
    "TestDistances.test_preprocess_multiclass": "PASSED",
    "test_filename": "ERROR"
}
diff --git a/Orange/misc/distmatrix.py b/Orange/misc/distmatrix.py
index e995e68fb..4ded41737 100644
--- a/Orange/misc/distmatrix.py
+++ b/Orange/misc/distmatrix.py
@@ -51,7 +51,7 @@ class DistMatrix(np.ndarray):
 
     def __array_wrap__(self, out_arr, context=None):
         if out_arr.ndim == 0:  # a single scalar
-            return out_arr.item()
+            return out_arr[()]
         return np.ndarray.__array_wrap__(self, out_arr, context)
 
     """

{"Orange/misc/distmatrix.py": "import numpy as np\n\nfrom Orange.data import Table, StringVariable, Domain\nfrom Orange.data.io import detect_encoding\nfrom Orange.util import deprecated\n\n\nclass DistMatrix(np.ndarray):\n    \"\"\"\n    Distance matrix. Extends ``numpy.ndarray``.\n\n    .. attribute:: row_items\n\n        Items corresponding to matrix rows.\n\n    .. attribute:: col_items\n\n        Items corresponding to matrix columns.\n\n    .. attribute:: axis\n\n        If axis=1 we calculate distances between rows,\n        if axis=0 we calculate distances between columns.\n    \"\"\"\n    def __new__(cls, data, row_items=None, col_items=None, axis=1):\n        \"\"\"Construct a new distance matrix containing the given data.\n\n        :param data: Distance matrix\n        :type data: numpy array\n        :param row_items: Items in matrix rows\n        :type row_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param col_items: Items in matrix columns\n        :type col_items: `Orange.data.Table` or `Orange.data.Instance`\n        :param axis: The axis along which the distances are calculated\n        :type axis: int\n\n        \"\"\"\n        obj = np.asarray(data).view(cls)\n        obj.row_items = row_items\n        obj.col_items = col_items\n        obj.axis = axis\n        return obj\n\n    def __array_finalize__(self, obj):\n        \"\"\"See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html\"\"\"\n        if obj is None:\n            return\n        self.row_items = getattr(obj, 'row_items', None)\n        self.col_items = getattr(obj, 'col_items', None)\n        self.axis = getattr(obj, 'axis', 1)\n\n    def __array_wrap__(self, out_arr, context=None):\n        if out_arr.ndim == 0:  # a single scalar\n            return out_arr.item()\n        return np.ndarray.__array_wrap__(self, out_arr, context)\n\n    \"\"\"\n    __reduce__() and __setstate__() ensure DistMatrix is picklable.\n    \"\"\"\n    def __reduce__(self):\n        state = super().__reduce__()\n        newstate = state[2] + (self.row_items, self.col_items, self.axis)\n        return state[0], state[1], newstate\n\n    # noinspection PyMethodOverriding,PyArgumentList\n    def __setstate__(self, state):\n        self.row_items = state[-3]\n        self.col_items = state[-2]\n        self.axis = state[-1]\n        super().__setstate__(state[0:-3])\n\n    @property\n    @deprecated\n    def dim(self):\n        \"\"\"Returns the single dimension of the symmetric square matrix.\"\"\"\n        return self.shape[0]\n\n    # noinspection PyPep8Naming\n    @property\n    @deprecated\n    def X(self):\n        return self\n\n    @property\n    def flat(self):\n        return self[np.triu_indices(self.shape[0], 1)]\n\n    def submatrix(self, row_items, col_items=None):\n        \"\"\"\n        Return a submatrix\n\n        Args:\n            row_items: indices of rows\n            col_items: incides of columns\n        \"\"\"\n        if not col_items:\n            col_items = row_items\n        obj = self[np.ix_(row_items, col_items)]\n        if self.row_items is not None:\n            obj.row_items = self.row_items[row_items]\n        if self.col_items is not None:\n            if self.col_items is self.row_items and row_items is col_items:\n                obj.col_items = obj.row_items\n            else:\n                obj.col_items = self.col_items[col_items]\n        return obj\n\n    @classmethod\n    def from_file(cls, filename):\n        \"\"\"\n        Load distance matrix from a file\n\n        The file should be preferrably encoded in ascii/utf-8. White space at\n        the beginning and end of lines is ignored.\n\n        The first line of the file starts with the matrix dimension. It\n        can be followed by a list flags\n\n        - *axis=<number>*: the axis number\n        - *symmetric*: the matrix is symmetric; when reading the element (i, j)\n          it's value is also assigned to (j, i)\n        - *asymmetric*: the matrix is asymmetric\n        - *row_labels*: the file contains row labels\n        - *col_labels*: the file contains column labels\n\n        By default, matrices are symmetric, have axis 1 and no labels are given.\n        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.\n\n        If the file has column labels, they follow in the second line.\n        Row labels appear at the beginning of each row.\n        Labels are arbitrary strings that cannot contain newlines and\n        tabulators. Labels are stored as instances of `Table` with a single\n        meta attribute named \"label\".\n\n        The remaining lines contain tab-separated numbers, preceded with labels,\n        if present. Lines are padded with zeros if necessary. If the matrix is\n        symmetric, the file contains the lower triangle; any data above the\n        diagonal is ignored.\n\n        Args:\n            filename: file name\n        \"\"\"\n        with open(filename, encoding=detect_encoding(filename)) as fle:\n            line = fle.readline()\n            if not line:\n                raise ValueError(\"empty file\")\n            data = line.strip().split()\n            if not data[0].strip().isdigit():\n                raise ValueError(\"distance file must begin with dimension\")\n            n = int(data.pop(0))\n            symmetric = True\n            axis = 1\n            col_labels = row_labels = None\n            for flag in data:\n                if flag in (\"labelled\", \"labeled\", \"row_labels\"):\n                    row_labels = []\n                elif flag == \"col_labels\":\n                    col_labels = []\n                elif flag == \"symmetric\":\n                    symmetric = True\n                elif flag == \"asymmetric\":\n                    symmetric = False\n                else:\n                    flag_data = flag.split(\"=\")\n                    if len(flag_data) == 2:\n                        name, value = map(str.strip, flag_data)\n                    else:\n                        name, value = \"\", None\n                    if name == \"axis\" and value.isdigit():\n                        axis = int(value)\n                    else:\n                        raise ValueError(\"invalid flag '{}'\".format(\n                            flag, filename))\n            if col_labels is not None:\n                col_labels = [x.strip()\n                              for x in fle.readline().strip().split(\"\\t\")]\n                if len(col_labels) != n:\n                    raise ValueError(\"mismatching number of column labels\")\n\n            matrix = np.zeros((n, n))\n            for i, line in enumerate(fle):\n                if i >= n:\n                    raise ValueError(\"too many rows\".format(filename))\n                line = line.strip().split(\"\\t\")\n                if row_labels is not None:\n                    row_labels.append(line.pop(0).strip())\n                if len(line) > n:\n                    raise ValueError(\"too many columns in matrix row {}\".\n                                     format(\"'{}'\".format(row_labels[i])\n                                            if row_labels else i + 1))\n                for j, e in enumerate(line[:i + 1 if symmetric else n]):\n                    try:\n                        matrix[i, j] = float(e)\n                    except ValueError as exc:\n                        raise ValueError(\n                            \"invalid element at row {}, column {}\".format(\n                                \"'{}'\".format(row_labels[i])\n                                if row_labels else i + 1,\n                                \"'{}'\".format(col_labels[j])\n                                if col_labels else j + 1)) from exc\n                    if symmetric:\n                        matrix[j, i] = matrix[i, j]\n        if col_labels:\n            col_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in col_labels])\n        if row_labels:\n            row_labels = Table.from_list(\n                Domain([], metas=[StringVariable(\"label\")]),\n                [[item] for item in row_labels])\n        return cls(matrix, row_labels, col_labels, axis)\n\n    @staticmethod\n    def _trivial_labels(items):\n        return items and \\\n               isinstance(items, Table) and \\\n               len(items.domain.metas) == 1 and \\\n               isinstance(items.domain.metas[0], StringVariable)\n\n    def has_row_labels(self):\n        \"\"\"\n        Returns `True` if row labels can be automatically determined from data\n\n        For this, the `row_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.row_items)\n\n    def has_col_labels(self):\n        \"\"\"\n        Returns `True` if column labels can be automatically determined from\n        data\n\n        For this, the `col_items` must be an instance of `Orange.data.Table`\n        whose domain contains a single meta attribute, which has to be a string.\n        The domain may contain other variables, but not meta attributes.\n        \"\"\"\n        return self._trivial_labels(self.col_items)\n\n    def save(self, filename):\n        \"\"\"\n        Save the distance matrix to a file in the file format described at\n        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.\n\n        Args:\n            filename: file name\n        \"\"\"\n        n = len(self)\n        data = \"{}\\taxis={}\".format(n, self.axis)\n        row_labels = col_labels = None\n        if self.has_col_labels():\n            data += \"\\tcol_labels\"\n            col_labels = self.col_items\n        if self.has_row_labels():\n            data += \"\\trow_labels\"\n            row_labels = self.row_items\n        symmetric = np.allclose(self, self.T)\n        if not symmetric:\n            data += \"\\tasymmetric\"\n        with open(filename, \"wt\") as fle:\n            fle.write(data + \"\\n\")\n            if col_labels is not None:\n                fle.write(\"\\t\".join(str(e.metas[0]) for e in col_labels) + \"\\n\")\n            for i, row in enumerate(self):\n                if row_labels is not None:\n                    fle.write(str(row_labels[i].metas[0]) + \"\\t\")\n                if symmetric:\n                    fle.write(\"\\t\".join(map(str, row[:i + 1])) + \"\\n\")\n                else:\n                    fle.write(\"\\t\".join(map(str, row)) + \"\\n\")\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:** `DistMatrix.max()` Returns Python `int` Instead of `numpy.int64`

**Description:**
When using the `DistMatrix` class, calling the `max()` method returns a Python `int` instead of a `numpy.int64`. This type mismatch can lead to unexpected behavior in parts of the code that expect NumPy data types.

**Example Code:**
```python
import numpy as np
from Orange.misc.distmatrix import DistMatrix

data = np.array([1, 2], dtype=np.int64)
dm = DistMatrix(data)
max_value = dm.max()
print(type(max_value))  # Outputs: <class 'int'>
```

**Expected Behavior:**
The `max()` method should return a `numpy.int64` object, ensuring consistency with NumPy data types.

**Actual Behavior:**
The `max()` method returns a Python `int` object, causing type inconsistencies.

[/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/misc/distmatrix.py
import numpy as np

from Orange.data import Table, StringVariable, Domain
from Orange.data.io import detect_encoding
from Orange.util import deprecated


class DistMatrix(np.ndarray):
    """
    Distance matrix. Extends ``numpy.ndarray``.

    .. attribute:: row_items

        Items corresponding to matrix rows.

    .. attribute:: col_items

        Items corresponding to matrix columns.

    .. attribute:: axis

        If axis=1 we calculate distances between rows,
        if axis=0 we calculate distances between columns.
    """
    def __new__(cls, data, row_items=None, col_items=None, axis=1):
        """Construct a new distance matrix containing the given data.

        :param data: Distance matrix
        :type data: numpy array
        :param row_items: Items in matrix rows
        :type row_items: `Orange.data.Table` or `Orange.data.Instance`
        :param col_items: Items in matrix columns
        :type col_items: `Orange.data.Table` or `Orange.data.Instance`
        :param axis: The axis along which the distances are calculated
        :type axis: int

        """
        obj = np.asarray(data).view(cls)
        obj.row_items = row_items
        obj.col_items = col_items
        obj.axis = axis
        return obj

    def __array_finalize__(self, obj):
        """See http://docs.scipy.org/doc/numpy/user/basics.subclassing.html"""
        if obj is None:
            return
        self.row_items = getattr(obj, 'row_items', None)
        self.col_items = getattr(obj, 'col_items', None)
        self.axis = getattr(obj, 'axis', 1)

    def __array_wrap__(self, out_arr, context=None):
        if out_arr.ndim == 0:  # a single scalar
            return out_arr.item()
        return np.ndarray.__array_wrap__(self, out_arr, context)

    """
    __reduce__() and __setstate__() ensure DistMatrix is picklable.
    """
    def __reduce__(self):
        state = super().__reduce__()
        newstate = state[2] + (self.row_items, self.col_items, self.axis)
        return state[0], state[1], newstate

    # noinspection PyMethodOverriding,PyArgumentList
    def __setstate__(self, state):
        self.row_items = state[-3]
        self.col_items = state[-2]
        self.axis = state[-1]
        super().__setstate__(state[0:-3])

    @property
    @deprecated
    def dim(self):
        """Returns the single dimension of the symmetric square matrix."""
        return self.shape[0]

    # noinspection PyPep8Naming
    @property
    @deprecated
    def X(self):
        return self

    @property
    def flat(self):
        return self[np.triu_indices(self.shape[0], 1)]

    def submatrix(self, row_items, col_items=None):
        """
        Return a submatrix

        Args:
            row_items: indices of rows
            col_items: incides of columns
        """
        if not col_items:
            col_items = row_items
        obj = self[np.ix_(row_items, col_items)]
        if self.row_items is not None:
            obj.row_items = self.row_items[row_items]
        if self.col_items is not None:
            if self.col_items is self.row_items and row_items is col_items:
                obj.col_items = obj.row_items
            else:
                obj.col_items = self.col_items[col_items]
        return obj

    @classmethod
    def from_file(cls, filename):
        """
        Load distance matrix from a file

        The file should be preferrably encoded in ascii/utf-8. White space at
        the beginning and end of lines is ignored.

        The first line of the file starts with the matrix dimension. It
        can be followed by a list flags

        - *axis=<number>*: the axis number
        - *symmetric*: the matrix is symmetric; when reading the element (i, j)
          it's value is also assigned to (j, i)
        - *asymmetric*: the matrix is asymmetric
        - *row_labels*: the file contains row labels
        - *col_labels*: the file contains column labels

        By default, matrices are symmetric, have axis 1 and no labels are given.
        Flags *labeled* and *labelled* are obsolete aliases for *row_labels*.

        If the file has column labels, they follow in the second line.
        Row labels appear at the beginning of each row.
        Labels are arbitrary strings that cannot contain newlines and
        tabulators. Labels are stored as instances of `Table` with a single
        meta attribute named "label".

        The remaining lines contain tab-separated numbers, preceded with labels,
        if present. Lines are padded with zeros if necessary. If the matrix is
        symmetric, the file contains the lower triangle; any data above the
        diagonal is ignored.

        Args:
            filename: file name
        """
        with open(filename, encoding=detect_encoding(filename)) as fle:
            line = fle.readline()
            if not line:
                raise ValueError("empty file")
            data = line.strip().split()
            if not data[0].strip().isdigit():
                raise ValueError("distance file must begin with dimension")
            n = int(data.pop(0))
            symmetric = True
            axis = 1
            col_labels = row_labels = None
            for flag in data:
                if flag in ("labelled", "labeled", "row_labels"):
                    row_labels = []
                elif flag == "col_labels":
                    col_labels = []
                elif flag == "symmetric":
                    symmetric = True
                elif flag == "asymmetric":
                    symmetric = False
                else:
                    flag_data = flag.split("=")
                    if len(flag_data) == 2:
                        name, value = map(str.strip, flag_data)
                    else:
                        name, value = "", None
                    if name == "axis" and value.isdigit():
                        axis = int(value)
                    else:
                        raise ValueError("invalid flag '{}'".format(
                            flag, filename))
            if col_labels is not None:
                col_labels = [x.strip()
                              for x in fle.readline().strip().split("\t")]
                if len(col_labels) != n:
                    raise ValueError("mismatching number of column labels")

            matrix = np.zeros((n, n))
            for i, line in enumerate(fle):
                if i >= n:
                    raise ValueError("too many rows".format(filename))
                line = line.strip().split("\t")
                if row_labels is not None:
                    row_labels.append(line.pop(0).strip())
                if len(line) > n:
                    raise ValueError("too many columns in matrix row {}".
                                     format("'{}'".format(row_labels[i])
                                            if row_labels else i + 1))
                for j, e in enumerate(line[:i + 1 if symmetric else n]):
                    try:
                        matrix[i, j] = float(e)
                    except ValueError as exc:
                        raise ValueError(
                            "invalid element at row {}, column {}".format(
                                "'{}'".format(row_labels[i])
                                if row_labels else i + 1,
                                "'{}'".format(col_labels[j])
                                if col_labels else j + 1)) from exc
                    if symmetric:
                        matrix[j, i] = matrix[i, j]
        if col_labels:
            col_labels = Table.from_list(
                Domain([], metas=[StringVariable("label")]),
                [[item] for item in col_labels])
        if row_labels:
            row_labels = Table.from_list(
                Domain([], metas=[StringVariable("label")]),
                [[item] for item in row_labels])
        return cls(matrix, row_labels, col_labels, axis)

    @staticmethod
    def _trivial_labels(items):
        return items and \
               isinstance(items, Table) and \
               len(items.domain.metas) == 1 and \
               isinstance(items.domain.metas[0], StringVariable)

    def has_row_labels(self):
        """
        Returns `True` if row labels can be automatically determined from data

        For this, the `row_items` must be an instance of `Orange.data.Table`
        whose domain contains a single meta attribute, which has to be a string.
        The domain may contain other variables, but not meta attributes.
        """
        return self._trivial_labels(self.row_items)

    def has_col_labels(self):
        """
        Returns `True` if column labels can be automatically determined from
        data

        For this, the `col_items` must be an instance of `Orange.data.Table`
        whose domain contains a single meta attribute, which has to be a string.
        The domain may contain other variables, but not meta attributes.
        """
        return self._trivial_labels(self.col_items)

    def save(self, filename):
        """
        Save the distance matrix to a file in the file format described at
        :obj:`~Orange.misc.distmatrix.DistMatrix.from_file`.

        Args:
            filename: file name
        """
        n = len(self)
        data = "{}\taxis={}".format(n, self.axis)
        row_labels = col_labels = None
        if self.has_col_labels():
            data += "\tcol_labels"
            col_labels = self.col_items
        if self.has_row_labels():
            data += "\trow_labels"
            row_labels = self.row_items
        symmetric = np.allclose(self, self.T)
        if not symmetric:
            data += "\tasymmetric"
        with open(filename, "wt") as fle:
            fle.write(data + "\n")
            if col_labels is not None:
                fle.write("\t".join(str(e.metas[0]) for e in col_labels) + "\n")
            for i, row in enumerate(self):
                if row_labels is not None:
                    fle.write(str(row_labels[i].metas[0]) + "\t")
                if symmetric:
                    fle.write("\t".join(map(str, row[:i + 1])) + "\n")
                else:
                    fle.write("\t".join(map(str, row)) + "\n")

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