From ceb0642590d1bf07eafd021c0a442c5ab4a9d53d Mon Sep 17 00:00:00 2001 From: Kevin Murphy Date: Thu, 19 Dec 2019 18:47:20 -0800 Subject: [PATCH] FileLoaderBase: First attempt at making `path: str` abstract attr --- ultratrace2/model/files/loaders/base.py | 9 +++++++-- ultratrace2/model/files/loaders/dicom.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ultratrace2/model/files/loaders/base.py b/ultratrace2/model/files/loaders/base.py index b8dd3b6..14af5e9 100644 --- a/ultratrace2/model/files/loaders/base.py +++ b/ultratrace2/model/files/loaders/base.py @@ -16,9 +16,14 @@ class FileLoadError(Exception): class FileLoaderBase(ABC): + @property + @abstractmethod + def path(self) -> str: + return self._path - def __init__(self, path: str): - self.path = path + @path.setter + def path(self, path) -> None: + self._path = path def __repr__(self): return f"{type(self).__name__}({self.path})" diff --git a/ultratrace2/model/files/loaders/dicom.py b/ultratrace2/model/files/loaders/dicom.py index 86670d9..92bc702 100644 --- a/ultratrace2/model/files/loaders/dicom.py +++ b/ultratrace2/model/files/loaders/dicom.py @@ -13,7 +13,7 @@ def __init__(self, path: str, pixels: np.ndarray): The `shape` of the pixel array should be `(n_frames, n_rows, n_columns)` for greyscale images and `(n_frames, n_rows, n_columns, rgb_data)` for full-color images.""" - super().__init__(path) + self.path = path self.pixels = pixels # FIXME: these should be in the `.ultratrace/` dir self.png_dir = f"{self.path}-frames"