Skip to content

Commit

Permalink
renamed "SpotAnalysisOperablesStream" to indicate that it is primaril…
Browse files Browse the repository at this point in the history
…y meant for internal library use
  • Loading branch information
bbean23 committed Nov 13, 2024
1 parent 0a28c63 commit 8207a36
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
13 changes: 7 additions & 6 deletions opencsp/common/lib/cv/SpotAnalysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from opencsp.common.lib.cv.spot_analysis.ImagesStream import ImagesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisImagesStream import SpotAnalysisImagesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperable import SpotAnalysisOperable
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperablesStream import SpotAnalysisOperablesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperablesStream import _SpotAnalysisOperablesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperableAttributeParser import SpotAnalysisOperableAttributeParser
import opencsp.common.lib.render.VideoHandler as vh
import opencsp.common.lib.opencsp_path.opencsp_root_path as orp
Expand Down Expand Up @@ -183,7 +183,7 @@ def __init__(
on the first call to process_next(). """
self._prev_result: SpotAnalysisOperable = None
""" The previously returned result. """
self.input_stream: SpotAnalysisOperablesStream = None
self.input_stream: _SpotAnalysisOperablesStream = None
""" The images to be processed. """
self.save_dir: str = save_dir
""" If not None, then primary images will be saved to the given
Expand Down Expand Up @@ -237,8 +237,8 @@ def _images2stream(
return ImagesIterable(images)

def _assign_inputs(self, input_operables: Iterator[SpotAnalysisOperable]):
if not isinstance(input_operables, SpotAnalysisOperablesStream):
input_operables = SpotAnalysisOperablesStream(input_operables)
if not isinstance(input_operables, _SpotAnalysisOperablesStream):
input_operables = _SpotAnalysisOperablesStream(input_operables)
self.input_stream = input_operables
self._prev_result = None
self.image_processors[0].assign_inputs(self.input_stream)
Expand All @@ -257,10 +257,11 @@ def set_primary_images(self, images: list[str] | list[np.ndarray] | vh.VideoHand
See also: set_input_operables()"""
primary_images = self._images2stream(images)
images_stream = SpotAnalysisImagesStream(primary_images, {})
self._assign_inputs(SpotAnalysisOperablesStream(images_stream))
self._assign_inputs(_SpotAnalysisOperablesStream(images_stream))

def set_input_operables(
self, input_operables: SpotAnalysisOperablesStream | list[SpotAnalysisOperable] | Iterator[SpotAnalysisOperable]
self,
input_operables: _SpotAnalysisOperablesStream | list[SpotAnalysisOperable] | Iterator[SpotAnalysisOperable],
):
"""Assigns primary and supporting images, and other necessary data, in preparation for process_next().
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperable import SpotAnalysisOperable


class SpotAnalysisOperablesStream(Iterator[SpotAnalysisOperable]):
class _SpotAnalysisOperablesStream(Iterator[SpotAnalysisOperable]):
"""
This class is meant for internal use. Users of the SpotAnalysis class or
SpotAnalysisImageProcessor classes should not need to know the mechanics of
this class.
A stream that accepts images as input and provides SpotAnalysisOperables as output.
This stream can be set up with default values for supporting images or other
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from opencsp.common.lib.cv.spot_analysis.ImagesIterable import ImagesIterable
from opencsp.common.lib.cv.spot_analysis.ImagesStream import ImagesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperable import SpotAnalysisOperable
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperablesStream import SpotAnalysisOperablesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisOperablesStream import _SpotAnalysisOperablesStream
from opencsp.common.lib.cv.spot_analysis.SpotAnalysisImagesStream import SpotAnalysisImagesStream
import opencsp.common.lib.opencsp_path.opencsp_root_path as orp
import opencsp.common.lib.tool.file_tools as ft
Expand Down Expand Up @@ -265,7 +265,7 @@ def run(
if isinstance(operables, (ImagesIterable, ImagesStream)):
operables = SpotAnalysisImagesStream(operables)
if isinstance(operables, SpotAnalysisImagesStream):
operables = SpotAnalysisOperablesStream(operables)
operables = _SpotAnalysisOperablesStream(operables)
self.assign_inputs(operables)
ret = [result for result in self]
return ret
Expand Down

0 comments on commit 8207a36

Please sign in to comment.