Skip to content

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

Merged
MargaretDuff merged 11 commits into
TomographicImaging:masterfrom
MargaretDuff:blockoperator_1_1
Jan 10, 2025
Merged

BlockOperator direct and adjoint methods: can pass out as a DataContainer instead of a (1,1) BlockDataContainer where geometry permits #1926
MargaretDuff merged 11 commits into
TomographicImaging:masterfrom
MargaretDuff:blockoperator_1_1

Conversation

@MargaretDuff

@MargaretDuff MargaretDuff commented Sep 3, 2024

Copy link
Copy Markdown
Member

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
Copy Markdown
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.

Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
@MargaretDuff
MargaretDuff requested a review from gfardell October 7, 2024 11:59
@MargaretDuff

Copy link
Copy Markdown
Member Author

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

@MargaretDuff

Copy link
Copy Markdown
Member Author

@gfardell - do you want to check the adjoint code and approve if you are happy?

@MargaretDuff

MargaretDuff commented Nov 19, 2024

Copy link
Copy Markdown
Member Author

We need to decide the default. If no out is provided to direct(adjoint) but it should return a 1 by 1 block data container, should this be a data container -to match the range (domain) - or be a block data container?

@gfardell gfardell left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good to me - pending the decision on default behaviour!

@MargaretDuff MargaretDuff linked an issue Dec 11, 2024 that may be closed by this pull request
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated
Comment thread Wrappers/Python/cil/optimisation/operators/BlockOperator.py Outdated

@paskino paskino left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

After a few name changes and error message change it's fine.

@MargaretDuff
MargaretDuff merged commit a54c498 into TomographicImaging:master Jan 10, 2025
@MargaretDuff
MargaretDuff deleted the blockoperator_1_1 branch January 10, 2025 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

BlockOperator direct with out is DataContainer BlockOperator.domain_geometry().allocate() not compatible with in place calls to BlockOperator.direct

3 participants