Skip to content

Commit 69fdc4d

Browse files
Making UnitConverter an abstract base class
1 parent ee3dde4 commit 69fdc4d

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/parcels/_core/converters.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from __future__ import annotations
22

3+
from abc import ABC, abstractmethod
34
from math import pi
45

56
import numpy as np
@@ -28,10 +29,16 @@ def _convert_to_flat_array(var: npt.ArrayLike) -> npt.NDArray:
2829
return np.array(var).flatten()
2930

3031

31-
class UnitConverter:
32+
class UnitConverter(ABC):
3233
source_unit: str | None = None
3334
target_unit: str | None = None
3435

36+
@abstractmethod
37+
def to_target(self, value, z, y, x): ...
38+
39+
@abstractmethod
40+
def to_source(self, value, z, y, x): ...
41+
3542

3643
class Unity(UnitConverter):
3744
"""Interface class for spatial unit conversion during field sampling that performs no conversion."""

0 commit comments

Comments
 (0)