From d9d2ba0528f3d4f9143638a489639ba82e849e8a Mon Sep 17 00:00:00 2001 From: golmschenk Date: Fri, 2 Aug 2024 11:40:19 -0400 Subject: [PATCH] Cache paths list --- src/qusi/internal/light_curve_collection.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/qusi/internal/light_curve_collection.py b/src/qusi/internal/light_curve_collection.py index 0a08d00..2e31d1d 100644 --- a/src/qusi/internal/light_curve_collection.py +++ b/src/qusi/internal/light_curve_collection.py @@ -76,6 +76,7 @@ class PathGetter(PathGetterBase): get_paths_function: Callable[[], Iterable[Path]] random_number_generator: Random _indexable_paths: np.ndarray | None = None + _paths_list: list[Path] | None = None # TODO: Merge with above. @classmethod def new(cls, get_paths_function: Callable[[], Iterable[Path]]) -> Self: @@ -92,9 +93,10 @@ def get_shuffled_paths(self) -> Iterable[Path]: :return: The shuffled paths iterable. """ - light_curve_paths = self.get_paths() - self.random_number_generator.shuffle(light_curve_paths) - return light_curve_paths + if self._paths_list is None: + self._paths_list = self.get_paths() + self.random_number_generator.shuffle(self._paths_list) + return self._paths_list def get_paths(self): """