matplotlib/matplotlib · error · ValueError

"\n" + err.explain(0)

Error message

"\n" + err.explain(0)

What it means

Error ""\n" + err.explain(0)" thrown in matplotlib/matplotlib.

Source

Thrown at lib/matplotlib/_mathtext.py:2350

        self._math_expression = p.math

        # To add space to nucleus operators after sub/superscripts
        self._needs_space_after_subsuper = False

    def parse(self, s: str, fonts_object: Fonts, fontsize: float, dpi: float) -> Hlist:
        """
        Parse expression *s* using the given *fonts_object* for
        output, at the given *fontsize* and *dpi*.

        Returns the parse tree of `Node` instances.
        """
        self._state_stack = [
            ParserState(fonts_object, 'default', 'rm', fontsize, dpi)]
        self._em_width_cache: dict[tuple[str, float, float], float] = {}
        try:
            result = self._expression.parse_string(s)
        except ParseBaseException as err:
            raise ValueError("\n" + err.explain(0)) from None
        self._state_stack = []
        self._needs_space_after_subsuper = False
        # prevent operator spacing from leaking into a new expression
        self._em_width_cache = {}
        ParserElement.reset_cache()
        return T.cast(Hlist, result[0])  # Known return type from main.

    def get_state(self) -> ParserState:
        """Get the current `State` of the parser."""
        return self._state_stack[-1]

    def pop_state(self) -> None:
        """Pop a `State` off of the stack."""
        self._state_stack.pop()

    def push_state(self) -> None:
        """Push a new `State` onto the stack, copying the current state."""
        self._state_stack.append(self.get_state().copy())

View on GitHub (pinned to b379c1b69e)

When it happens

Trigger: Thrown at lib/matplotlib/_mathtext.py:2350 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of matplotlib/matplotlib@b379c1b69e (2026-08-21). Data as JSON: /api/errors/9894e126fceaff9c. Report an issue: GitHub.