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

Fix bug with show2D and 3D DataContainers #1539

Merged
merged 6 commits into from
Dec 11, 2023
Merged

Fix bug with show2D and 3D DataContainers #1539

merged 6 commits into from
Dec 11, 2023

Conversation

lauramurgatroyd
Copy link
Member

@lauramurgatroyd lauramurgatroyd commented Oct 13, 2023

Describe your changes

Fixes bug which wouldn't allow 3D DataContainers to be viewed with show2D.
Note, this was just a bug with DataContainers, not with ImageData or AcquisitionData

Describe any testing you have performed

Please add any demo scripts to CIL-Demos/misc/
Tested with a 3D datacontainer
I could not see that there are any unit tests for show2D?
Added unit tests checking get_slice with a DataContainer.

Link relevant issues

Fixes #1536

Checklist when you are ready to request a review

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have implemented unit tests that cover any new or modified functionality
  • CHANGELOG.md has been updated with any functionality change
  • Request review from all relevant developers
  • Change pull request label to 'Waiting for review'

Contribution Notes

Please read and adhere to the developer guide and local patterns and conventions.

  • The content of this Pull Request (the Contribution) is intentionally submitted for inclusion in CIL (the Work) under the terms and conditions of the Apache-2.0 License.
  • I confirm that the contribution does not violate any intellectual property rights of third parties

@lauramurgatroyd lauramurgatroyd marked this pull request as draft October 13, 2023 09:12
@lauramurgatroyd lauramurgatroyd marked this pull request as ready for review October 13, 2023 10:28
@MargaretDuff MargaretDuff self-requested a review October 17, 2023 10:18
Copy link
Member

@MargaretDuff MargaretDuff left a comment

Choose a reason for hiding this comment

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

Looks good.

If I understand correctly, the other way to fix the bug could have been to allow the data container get slice to take the force=True kwarg without raising an error. For the ImageData and AquisitionData case, the force kwarg is used when setting the geometry for the new slice. However, this is not needed for the DataContainer as we do not require a geometry to initiatise a VectorData or DataContainer. Therefore we don't need a force kwarg in the DataContainer case?

@lauramurgatroyd
Copy link
Member Author

Yes, that’s right.

With Acquisition/ImageData it tries to create a new Acquisition/ImageGeometry and Data and if it can’t, if force is set to True then it returns a DataContainer instead.

def get_slice(self,channel=None, angle=None, vertical=None, horizontal=None, force=False):
'''
Returns a new dataset of a single slice of in the requested direction. \
'''
try:
geometry_new = self.geometry.get_slice(channel=channel, angle=angle, vertical=vertical, horizontal=horizontal)
except ValueError:
if force:
geometry_new = None
else:
raise ValueError ("Unable to return slice of requested AcquisitionData. Use 'force=True' to return DataContainer instead.")

I can't see there's anything we can use 'force' for in the case of a DataContainer, so it doesn't make sense for get_slice to take that parameter

@MargaretDuff
Copy link
Member

Thanks @lauramurgatroyd - happy to approve

@lauramurgatroyd lauramurgatroyd merged commit 86f2534 into master Dec 11, 2023
3 checks passed
@lauramurgatroyd lauramurgatroyd deleted the fix_1536 branch December 11, 2023 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Archived in project
Development

Successfully merging this pull request may close these issues.

show2D fails for 3D DataContainers
3 participants