Skip to content

Create PlotterConfig dataclass to reduce parameter sprawl #59

@TravisBumgarner

Description

@TravisBumgarner

Description

The _AbstractPlotter.__init__ takes 10 parameters, and these are repeated in Plotter2D/Plotter3D docstrings. Introduce a PlotterConfig dataclass to group common configuration.

Current Problem

def __init__(
    self,
    title: str,
    x_min: float,
    x_max: float,
    y_min: float,
    y_max: float,
    feed_rate: float,
    handle_out_of_bounds: THandleOutOfBounds,
    output_directory: str,
    include_comments: bool,
    return_home_before_plotting: bool,
): ...

Proposed Solution

@dataclass
class PlotterConfig:
    title: str
    x_min: float
    x_max: float
    y_min: float
    y_max: float
    feed_rate: float
    handle_out_of_bounds: HandleOutOfBounds = "Warning"
    output_directory: str = "./output"
    include_comments: bool = True
    return_home_before_plotting: bool = True

The plotter classes can then accept either individual parameters (for backwards compatibility) or a config object.

Acceptance Criteria

  • Create PlotterConfig dataclass in a new config.py file
  • Update _AbstractPlotter to use the config internally
  • Plotter2D and Plotter3D maintain backwards-compatible constructors
  • Docstrings reference the config class instead of repeating all parameters
  • All existing tests pass
  • Export PlotterConfig from package __init__.py

Dependencies

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions