nirs4all.visualization.charts.base module

BaseChart - Abstract base class for all prediction visualization charts.

class nirs4all.visualization.charts.base.BaseChart(predictions, dataset_name_override: str | None = None, config: ChartConfig | Dict[str, Any] | None = None, analyzer: PredictionAnalyzer | None = None)[source]

Bases: ABC

Abstract base class for all prediction visualization charts.

Provides common interface and shared functionality for chart implementations. Each chart type should inherit from this class and implement required methods.

Charts can be initialized in two modes: 1. With predictions only (legacy): Direct access to Predictions object 2. With analyzer (recommended): Access through PredictionAnalyzer with caching

When an analyzer is provided, charts use analyzer.get_cached_predictions() to benefit from caching of expensive aggregation operations.

Designed to be operator-ready for future integration with the controller/operator pattern (see SpectraChartController for reference pattern).

predictions

Predictions object containing prediction data.

analyzer

Optional PredictionAnalyzer for cached data access.

dataset_name_override

Optional dataset name override for display.

config

ChartConfig instance for customization.

abstractmethod render(**kwargs) Figure[source]

Render the chart and return matplotlib Figure.

This method must be implemented by all chart subclasses.

Parameters:

**kwargs – Chart-specific rendering parameters.

Returns:

matplotlib Figure object.

Raises:

NotImplementedError – If not implemented by subclass.

abstractmethod validate_inputs(**kwargs) None[source]

Validate input parameters for the chart.

This method should be called before rendering to ensure all required parameters are present and valid.

Parameters:

**kwargs – Chart-specific parameters to validate.

Raises:

ValueError – If validation fails.