{"record":{"id":"22f762b3d24d2a8b","repo":"rohitg00/ai-engineering-from-scratch","slug":"expected-len-self-shape-indices-got-len-indi","errorCode":null,"errorMessage":"Expected {len(self._shape)} indices, got {len(indices)}","messagePattern":"Expected (.+?) indices, got (.+?)","errorType":"exception","errorClass":"IndexError","httpStatus":null,"severity":"error","filePath":"phases/01-math-foundations/12-tensor-operations/code/tensors.py","lineNumber":74,"sourceCode":"    @property\n    def shape(self):\n        return self._shape\n\n    @property\n    def rank(self):\n        return len(self._shape)\n\n    @property\n    def size(self):\n        return len(self._data)\n\n    @property\n    def strides(self):\n        return self._strides\n\n    def _flat_index(self, indices):\n        if len(indices) != len(self._shape):\n            raise IndexError(\n                f\"Expected {len(self._shape)} indices, got {len(indices)}\"\n            )\n        idx = 0\n        for i, (ind, stride) in enumerate(zip(indices, self._strides)):\n            if ind < 0 or ind >= self._shape[i]:\n                raise IndexError(\n                    f\"Index {ind} out of range for axis {i} with size {self._shape[i]}\"\n                )\n            idx += ind * stride\n        return idx\n\n    def __getitem__(self, indices):\n        if not isinstance(indices, tuple):\n            indices = (indices,)\n        if len(indices) == len(self._shape):\n            return self._data[self._flat_index(indices)]\n        raise IndexError(\"Partial indexing not supported in this basic implementation\")\n","sourceCodeStart":56,"sourceCodeEnd":92,"githubUrl":"https://github.com/rohitg00/ai-engineering-from-scratch/blob/39ea8a1c6d0b61f071226eff7ede4d4105fed820/phases/01-math-foundations/12-tensor-operations/code/tensors.py#L56-L92","documentation":"Error \"Expected {len(self._shape)} indices, got {len(indices)}\" thrown in rohitg00/ai-engineering-from-scratch.","triggerScenarios":"Thrown at phases/01-math-foundations/12-tensor-operations/code/tensors.py:74 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"}