{"record":{"id":"d98fffc895491c62","repo":"rohitg00/ai-engineering-from-scratch","slug":"unsupported-type-type-other","errorCode":null,"errorMessage":"Unsupported type {type(other)}","messagePattern":"Unsupported type (.+?)","errorType":"exception","errorClass":"TypeError","httpStatus":null,"severity":"error","filePath":"phases/01-math-foundations/12-tensor-operations/code/tensors.py","lineNumber":185,"sourceCode":"\n        return result\n\n    def flatten(self, start_dim=0, end_dim=-1):\n        if end_dim < 0:\n            end_dim = self.rank + end_dim\n        new_shape = (\n            list(self._shape[:start_dim])\n            + [reduce(lambda a, b: a * b, self._shape[start_dim:end_dim + 1], 1)]\n            + list(self._shape[end_dim + 1:])\n        )\n        return self.reshape(tuple(new_shape))\n\n    def _elementwise_op(self, other, op):\n        if isinstance(other, (int, float)):\n            result_data = [op(x, other) for x in self._data]\n            return Tensor(result_data, shape=self._shape)\n        if not isinstance(other, Tensor):\n            raise TypeError(f\"Unsupported type {type(other)}\")\n        if self._shape != other._shape:\n            raise ValueError(\n                f\"Shape mismatch: {self._shape} vs {other._shape}. \"\n                \"Use broadcast() first.\"\n            )\n        result_data = [op(a, b) for a, b in zip(self._data, other._data)]\n        return Tensor(result_data, shape=self._shape)\n\n    def __add__(self, other):\n        return self._elementwise_op(other, lambda a, b: a + b)\n\n    def __mul__(self, other):\n        return self._elementwise_op(other, lambda a, b: a * b)\n\n    def __sub__(self, other):\n        return self._elementwise_op(other, lambda a, b: a - b)\n\n    def sum(self, axis=None):","sourceCodeStart":167,"sourceCodeEnd":203,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/01-math-foundations/12-tensor-operations/code/tensors.py#L167-L203","documentation":"Error \"Unsupported type {type(other)}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/01-math-foundations/12-tensor-operations/code/tensors.py:185 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"39ea8a1c6d0b61f071226eff7ede4d4105fed820","analyzedAt":"2026-08-26T03:13:46.626Z","schemaVersion":2},"datasetVersion":"2026-08-26T07:17:17.940Z"}