Skip to content

base

Base interfaces for plots components.

BaseTextPlotter

Bases: ABC

Abstract base class for text plots.

Source code in src/xwhy/plots/base.py
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
class BaseTextPlotter(abc.ABC):
    """Abstract base class for text plots."""

    @abc.abstractmethod
    def plot(
        self,
        words: Sequence[str],
        scores: np.ndarray,
        **kwargs: Any,  # noqa: ANN401
    ) -> None:
        """Plot the text plot.

        Args:
            words: Sequence of text tokens.
            scores: Array of per-token scores.
            **kwargs: Additional backend-specific plotting arguments.

        """

plot(words, scores, **kwargs) abstractmethod

Plot the text plot.

Parameters:

Name Type Description Default
words Sequence[str]

Sequence of text tokens.

required
scores ndarray

Array of per-token scores.

required
**kwargs Any

Additional backend-specific plotting arguments.

{}
Source code in src/xwhy/plots/base.py
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
@abc.abstractmethod
def plot(
    self,
    words: Sequence[str],
    scores: np.ndarray,
    **kwargs: Any,  # noqa: ANN401
) -> None:
    """Plot the text plot.

    Args:
        words: Sequence of text tokens.
        scores: Array of per-token scores.
        **kwargs: Additional backend-specific plotting arguments.

    """