from dataclasses import dataclass @dataclass class MaskedPoissonConfig: """Configuration for masked Poisson solvers on irregular UV domains.""" method: str = "sparse" # "sparse" | "capfft" max_boundary: int = 96 boundary_stride: int = 1 max_iters: int = 3 tol: float = 1e-4 reg: float = 1e-8 def __post_init__(self): if self.method not in ("sparse", "capfft"): raise ValueError("method must be one of: 'sparse', 'capfft'") self.max_boundary = max(0, int(self.max_boundary)) self.boundary_stride = max(1, int(self.boundary_stride)) self.max_iters = max(1, int(self.max_iters)) self.tol = float(self.tol) self.reg = float(self.reg) @classmethod def from_kwargs(cls, kwargs): """Build config from PoissonSolver / nHHD constructor kwargs.""" return cls( method=kwargs.get("masked_poisson_solver", "sparse"), max_boundary=kwargs.get("masked_poisson_max_boundary", 96), boundary_stride=kwargs.get("masked_poisson_boundary_stride", 1), max_iters=kwargs.get("masked_poisson_max_iters", 3), tol=kwargs.get("masked_poisson_tol", 1e-4), reg=kwargs.get("masked_poisson_reg", 1e-8), )