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

BF+TST: Fix 'frame_order' for single frame files #1387

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

moloney
Copy link
Contributor

@moloney moloney commented Nov 20, 2024

The _frame_indices attribute on the MultiframeWrapper was empty for single frame files, causing use of the frame_order property to raise an exception.

Also, don't assume StackID is int (it is a str), don't assume DimensionIndexValues has more than one value. Fix how we assign multiple values to DimensionIndexValues when making fake test data (need to pass list instead of tuple).

Don't assume StackID is int (it is a str), don't assume
DimensionIndexValues has more than one value.
Copy link

codecov bot commented Nov 20, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 95.38%. Comparing base (d9c479a) to head (b1eb9b0).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #1387   +/-   ##
=======================================
  Coverage   95.37%   95.38%           
=======================================
  Files         207      207           
  Lines       29672    29697   +25     
  Branches     3018     3020    +2     
=======================================
+ Hits        28300    28325   +25     
  Misses        934      934           
  Partials      438      438           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.


🚨 Try these New Features:

Copy link
Member

@effigies effigies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Small suggestion for your consideration.

Comment on lines 758 to +765
try:
frame_indices = np.array(
[frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames]
)
except AttributeError:
raise WrapperError("Can't find frame 'DimensionIndexValues'")
if len(frame_indices.shape) == 1:
frame_indices = frame_indices.reshape(frame_indices.shape + (1,))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should achieve the same result, and I think is a bit more immediately obvious. Might even avoid a copy.

Suggested change
try:
frame_indices = np.array(
[frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames]
)
except AttributeError:
raise WrapperError("Can't find frame 'DimensionIndexValues'")
if len(frame_indices.shape) == 1:
frame_indices = frame_indices.reshape(frame_indices.shape + (1,))
try:
frame_indices = np.atleast_2d(
[frame.FrameContentSequence[0].DimensionIndexValues for frame in self.frames]
)
except AttributeError:
raise WrapperError("Can't find frame 'DimensionIndexValues'")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants