Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle recursion in imageseries get_region() #787

Merged
merged 1 commit into from
Mar 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion hexrd/imageseries/baseclass.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Base class for imageseries
"""
from .imageseriesabc import ImageSeriesABC
import numpy as np

from .imageseriesabc import ImageSeriesABC, RegionType


class ImageSeries(ImageSeriesABC):
"""collection of images
Expand Down Expand Up @@ -39,3 +42,6 @@ def shape(self):
@property
def metadata(self):
return self._adapter.metadata

def get_region(self, frame_idx: int, region: RegionType) -> np.ndarray:
return self._adapter.get_region(frame_idx, region)
3 changes: 3 additions & 0 deletions hexrd/imageseries/imageseriesabc.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
"""Abstract Base Class"""
import collections.abc

# Type for extracting regions
RegionType = tuple[tuple[int, int], tuple[int, int]]


class ImageSeriesABC(collections.abc.Sequence):
pass
4 changes: 1 addition & 3 deletions hexrd/imageseries/load/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,9 @@
import pkgutil
import numpy as np

from ..imageseriesabc import ImageSeriesABC
from ..imageseriesabc import ImageSeriesABC, RegionType
from .registry import Registry

RegionType = tuple[tuple[int, int], tuple[int, int]]

# Metaclass for adapter registry

class _RegisterAdapterClass(abc.ABCMeta):
Expand Down
2 changes: 1 addition & 1 deletion hexrd/imageseries/process.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def _subtract_dark(self, img, dark):
return ret

def _rectangle_optimized(self, img_key, r):
return self._imser._adapter.get_region(img_key, r)
return self._imser.get_region(img_key, r)

def _rectangle(self, img, r):
# restrict to rectangle
Expand Down
Loading