arkas
Advanced tools
+1
-1
| Metadata-Version: 2.1 | ||
| Name: arkas | ||
| Version: 0.0.1a7 | ||
| Version: 0.0.1a8 | ||
| Summary: Library to evaluate ML model performances | ||
@@ -5,0 +5,0 @@ Home-page: https://github.com/durandtibo/arkas |
+1
-1
| [tool.poetry] | ||
| name = "arkas" | ||
| version = "0.0.1a7" | ||
| version = "0.0.1a8" | ||
| description = "Library to evaluate ML model performances" | ||
@@ -5,0 +5,0 @@ readme = "README.md" |
@@ -15,2 +15,3 @@ r"""Contain figures.""" | ||
| "figure2html", | ||
| "get_default_config", | ||
| ] | ||
@@ -23,2 +24,2 @@ | ||
| from arkas.figure.plotly import PlotlyFigure, PlotlyFigureConfig | ||
| from arkas.figure.utils import figure2html | ||
| from arkas.figure.utils import figure2html, get_default_config |
@@ -142,5 +142,5 @@ """Contain the base class to implement a figure.""" | ||
| >>> from arkas.figure import MatplotlibFigureConfig | ||
| >>> config = MatplotlibFigureConfig(dpi=300) | ||
| >>> config = MatplotlibFigureConfig() | ||
| >>> config | ||
| MatplotlibFigureConfig(dpi=300) | ||
| MatplotlibFigureConfig(color_norm=None) | ||
@@ -147,0 +147,0 @@ ``` |
@@ -10,3 +10,3 @@ r"""Contain the implementation for matplotlib figures.""" | ||
| import sys | ||
| from typing import Any | ||
| from typing import TYPE_CHECKING, Any | ||
@@ -19,2 +19,5 @@ import matplotlib.pyplot as plt | ||
| if TYPE_CHECKING: | ||
| from matplotlib.colors import Normalize | ||
| if sys.version_info >= (3, 11): | ||
@@ -89,4 +92,5 @@ from typing import Self | ||
| Args: | ||
| **kwargs: Additional keyword arguments to pass to matplotlib | ||
| functions. The valid arguments depend on the context. | ||
| color_norm: The color normalization. | ||
| **kwargs: Additional keyword arguments to pass to | ||
| ``matplotlib.pyplot.subplots``. | ||
@@ -98,5 +102,5 @@ Example usage: | ||
| >>> from arkas.figure import MatplotlibFigureConfig | ||
| >>> config = MatplotlibFigureConfig(dpi=300) | ||
| >>> config = MatplotlibFigureConfig() | ||
| >>> config | ||
| MatplotlibFigureConfig(dpi=300) | ||
| MatplotlibFigureConfig(color_norm=None) | ||
@@ -106,7 +110,8 @@ ``` | ||
| def __init__(self, **kwargs: Any) -> None: | ||
| def __init__(self, color_norm: Normalize | None = None, **kwargs: Any) -> None: | ||
| self._color_norm = color_norm | ||
| self._kwargs = kwargs | ||
| def __repr__(self) -> str: | ||
| args = repr_mapping_line(self.get_args()) | ||
| args = repr_mapping_line({"color_norm": self._color_norm} | self.get_args()) | ||
| return f"{self.__class__.__qualname__}({args})" | ||
@@ -121,2 +126,4 @@ | ||
| return False | ||
| # color_norm is excluded from the comparison as it is not straightforward | ||
| # to compare to Normalize objects. | ||
| return objects_are_equal(self.get_args(), other.get_args(), equal_nan=equal_nan) | ||
@@ -126,1 +133,21 @@ | ||
| return self._kwargs | ||
| def get_color_norm(self) -> Normalize | None: | ||
| r"""Get the color normalization. | ||
| Returns: | ||
| The color normalization. | ||
| Example usage: | ||
| ```pycon | ||
| >>> from matplotlib.colors import LogNorm | ||
| >>> from arkas.figure import MatplotlibFigureConfig | ||
| >>> config = MatplotlibFigureConfig(color_norm=LogNorm()) | ||
| >>> config.get_color_norm() | ||
| <matplotlib.colors.LogNorm object at 0x...> | ||
| ``` | ||
| """ | ||
| return self._color_norm |
@@ -43,5 +43,4 @@ r"""Contain the implementation for plotly figures.""" | ||
| >>> from plotly import pyplot as plt | ||
| >>> from arkas.figure import PlotlyFigure | ||
| >>> fig = PlotlyFigure(plt.subplots()[0]) | ||
| >>> fig = PlotlyFigure(None) | ||
| >>> fig | ||
@@ -48,0 +47,0 @@ PlotlyFigure(reactive=True) |
@@ -5,8 +5,10 @@ r"""Contain utility functions to manage figures.""" | ||
| __all__ = ["MISSING_FIGURE_MESSAGE", "figure2html"] | ||
| __all__ = ["MISSING_FIGURE_MESSAGE", "figure2html", "get_default_config"] | ||
| from typing import TYPE_CHECKING | ||
| from arkas.figure.matplotlib import MatplotlibFigureConfig | ||
| if TYPE_CHECKING: | ||
| from arkas.figure import BaseFigure | ||
| from arkas.figure.base import BaseFigure, BaseFigureConfig | ||
@@ -46,1 +48,21 @@ MISSING_FIGURE_MESSAGE = ( | ||
| return data | ||
| def get_default_config() -> BaseFigureConfig: | ||
| r"""Get the default figure config. | ||
| Returns: | ||
| The default figure config. | ||
| Example usage: | ||
| ```pycon | ||
| >>> from arkas.figure import get_default_config | ||
| >>> config = get_default_config() | ||
| >>> config | ||
| MatplotlibFigureConfig(color_norm=None) | ||
| ``` | ||
| """ | ||
| return MatplotlibFigureConfig() |
@@ -16,6 +16,5 @@ r"""Contain the implementation of a pairwise column co-occurrence | ||
| from arkas.figure.creator import FigureCreatorRegistry | ||
| from arkas.figure.default import DefaultFigureConfig | ||
| from arkas.figure.html import HtmlFigure | ||
| from arkas.figure.matplotlib import MatplotlibFigure, MatplotlibFigureConfig | ||
| from arkas.figure.utils import MISSING_FIGURE_MESSAGE | ||
| from arkas.figure.utils import MISSING_FIGURE_MESSAGE, get_default_config | ||
| from arkas.plot.utils import readable_xticklabels, readable_yticklabels | ||
@@ -107,3 +106,3 @@ from arkas.plotter.base import BasePlotter | ||
| def create( | ||
| self, matrix: np.ndarray, columns: Sequence[str], config: BaseFigureConfig | ||
| self, matrix: np.ndarray, columns: Sequence[str], config: MatplotlibFigureConfig | ||
| ) -> BaseFigure: | ||
@@ -114,3 +113,3 @@ if matrix.shape[0] == 0: | ||
| fig, ax = plt.subplots(**config.get_args()) | ||
| im = ax.imshow(matrix) | ||
| im = ax.imshow(matrix, norm=config.get_color_norm()) | ||
| fig.colorbar(im) | ||
@@ -173,6 +172,3 @@ ax.set_xticks( | ||
| registry: FigureCreatorRegistry = FigureCreatorRegistry( | ||
| { | ||
| DefaultFigureConfig.backend(): MatplotlibFigureCreator(), | ||
| MatplotlibFigureConfig.backend(): MatplotlibFigureCreator(), | ||
| } | ||
| {MatplotlibFigureConfig.backend(): MatplotlibFigureCreator()} | ||
| ) | ||
@@ -188,3 +184,3 @@ | ||
| self._ignore_self = bool(ignore_self) | ||
| self._figure_config = figure_config or DefaultFigureConfig() | ||
| self._figure_config = figure_config or get_default_config() | ||
@@ -191,0 +187,0 @@ def __repr__(self) -> str: |
Alert delta unavailable
Currently unable to show alert delta for PyPI packages.
745780
0.16%18743
0.16%