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

BlockOperator direct and adjoint methods: can pass out as a DataContainer instead of a (1,1) BlockDataContainer where geometry permits #1926

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

Conversation

MargaretDuff
Copy link
Member

@MargaretDuff MargaretDuff commented Sep 3, 2024

Description

Linked to #1863

Changes

Testing you performed

Please add any demo scripts to https://github.com/TomographicImaging/CIL-Demos/tree/main/misc

Related issues/links

Checklist

  • I have performed a self-review of my code
  • I have added docstrings in line with the guidance in the developer guide
  • I have updated the relevant documentation
  • 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

@MargaretDuff
Copy link
Member Author

So in #1802 we changed BlockOperator direct (and adjoint) methods to return a DataContainer in the case it would previously return a (1,1) BlockDataContainer. We also changed the range (and domain) to output the required geometry in this case.

In this PR we allow BlockOperator direct (and adjoint) methods to accept both a (1,1) BlockDataContainer or a DataContainer to out where that fits with the range (and domain) geometry. They already accept both (1,1) BlockDataContainer or a DataContainer as an input argument where the domain (and range) geometry allows.

The question is: should a BlockOperator always return a BlockDataContainer or are (1,1) BlockDataContainers an unnecessary wrapper and they should be DataContainers?

In the first case, we should write an as_array() method for (1,1) BlockDataContainers to fix the original CIL-SIRF issue #1455 and probably leave this fix in. In the second case, we leave #1802 as it is and implement this fix.

if not isinstance(out, BlockDataContainer):
if 1 == shape[0] == shape[1]:
out = BlockDataContainer(out)
flag_return_data_container = True
Copy link
Member Author

Choose a reason for hiding this comment

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

Flag should be called something like "flag_single_block"

@MargaretDuff
Copy link
Member Author

After discussion with Edo and Gemma we decided that this should go in but that we would still further investigate #1863

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Blocked
Development

Successfully merging this pull request may close these issues.

BlockOperator.domain_geometry().allocate() not compatible with in place calls to BlockOperator.direct
1 participant