Skip to content

GalacticDynamics/plotting_backends

Repository files navigation

plotting_backends

plotting dispatch backends

Installation

PyPI platforms PyPI version

pip install plotting_backends

Examples

functools.singledispatch

This shows how to use plotting_backends with functools.singledispatch.

import plotting_backends
from functools import singledispatch


@singledispatch
def plotting_func(
    backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
) -> None: ...


@plotting_func.register
def matplotlib(
    backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
) -> None: ...

plum (multiple dispatch)

This example shows how to use plotting_backends in conjunction with plum, a multiple dispatch library.

import plotting_backends
from plum import dispatch


@dispatch.abstract
def plotting_func(
    backend: type[plotting_backends.AbstractPlottingBackend], x: Any, y: Any
) -> None: ...


@dispatch
def plotting_func(
    backend: type[plotting_backends.MatplotlibBackend], x: Any, y: Any
) -> None: ...

Development

Actions Status ruff status

We welcome contributions!