From c8ac3ee4c8de8254f347eed5ed1bdc8b53121a08 Mon Sep 17 00:00:00 2001 From: Roman Cattaneo <1116746+romanc@users.noreply.github.com> Date: Tue, 4 Nov 2025 15:09:01 +0100 Subject: [PATCH] refactor: make GridSizer an abstract base class `GridSizer` is de-facto already a base class with abstract methods `get_origin()`, `get_extent()`, and `get_shape()`. This PR just formalizes that intent. --- ndsl/initialization/grid_sizer.py | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/ndsl/initialization/grid_sizer.py b/ndsl/initialization/grid_sizer.py index f3347e27..684fa5ab 100644 --- a/ndsl/initialization/grid_sizer.py +++ b/ndsl/initialization/grid_sizer.py @@ -1,9 +1,10 @@ +from abc import ABC, abstractmethod from collections.abc import Sequence from dataclasses import dataclass @dataclass -class GridSizer: +class GridSizer(ABC): nx: int """Length of the x compute dimension for produced arrays.""" ny: int @@ -15,11 +16,11 @@ class GridSizer: data_dimensions: dict[str, int] """Name/Lengths pair of any non-x/y/z dimensions, such as land or radiation dimensions.""" - def get_origin(self, dims: Sequence[str]) -> tuple[int, ...]: - raise NotImplementedError() + @abstractmethod + def get_origin(self, dims: Sequence[str]) -> tuple[int, ...]: ... - def get_extent(self, dims: Sequence[str]) -> tuple[int, ...]: - raise NotImplementedError() + @abstractmethod + def get_extent(self, dims: Sequence[str]) -> tuple[int, ...]: ... - def get_shape(self, dims: Sequence[str]) -> tuple[int, ...]: - raise NotImplementedError() + @abstractmethod + def get_shape(self, dims: Sequence[str]) -> tuple[int, ...]: ...