{"record":{"id":"0b12717370480d97","repo":"matplotlib/matplotlib","slug":"k-r-must-be-len-shape-d-with-shape-text-shap","errorCode":null,"errorMessage":"{k!r} must be {len(shape)}D with shape ({text_shape}), but your input has shape {v.shape}","messagePattern":"(.+?) must be (.+?)D with shape \\((.+?)\\), but your input has shape (.+?)","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"lib/matplotlib/_api/__init__.py","lineNumber":258,"sourceCode":"    --------\n    To check for (N, 2) shaped arrays\n\n    >>> _api.check_shape((None, 2), arg=arg, other_arg=other_arg)\n    \"\"\"\n    for k, v in kwargs.items():\n        data_shape = v.shape\n\n        if (len(data_shape) != len(shape)\n                or any(s != t and t is not None for s, t in zip(data_shape, shape))):\n            dim_labels = iter(itertools.chain(\n                'NMLKJIH',\n                (f\"D{i}\" for i in itertools.count())))\n            text_shape = \", \".join([str(n) if n is not None else next(dim_labels)\n                                    for n in shape[::-1]][::-1])\n            if len(shape) == 1:\n                text_shape += \",\"\n\n            raise ValueError(\n                f\"{k!r} must be {len(shape)}D with shape ({text_shape}), \"\n                f\"but your input has shape {v.shape}\"\n            )\n\n\ndef getitem_checked(mapping, /, _error_cls=ValueError, **kwargs):\n    \"\"\"\n    *kwargs* must consist of a single *key, value* pair.  If *key* is in\n    *mapping*, return ``mapping[value]``; else, raise an appropriate\n    ValueError.\n\n    Parameters\n    ----------\n    _error_cls :\n        Class of error to raise.\n\n    Examples\n    --------","sourceCodeStart":240,"sourceCodeEnd":276,"githubUrl":"https://github.com/matplotlib/matplotlib/blob/b379c1b69e012b142c0f496a52bcb30513802d72/lib/matplotlib/_api/__init__.py#L240-L276","documentation":"Error \"{k!r} must be {len(shape)}D with shape ({text_shape}), but your input has shape {v.shape}\" thrown in matplotlib/matplotlib.","triggerScenarios":"Thrown at lib/matplotlib/_api/__init__.py:258 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":"b379c1b69e012b142c0f496a52bcb30513802d72","analyzedAt":"2026-08-21T23:31:55.468Z","schemaVersion":2},"datasetVersion":"2026-08-22T04:17:13.399Z"}