Skip to content

Commit

Permalink
Cache paths list
Browse files Browse the repository at this point in the history
  • Loading branch information
golmschenk committed Aug 2, 2024
1 parent 37165d3 commit d9d2ba0
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/qusi/internal/light_curve_collection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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):
"""
Expand Down

0 comments on commit d9d2ba0

Please sign in to comment.