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 with out is DataContainer #1996

Open
samdporter opened this issue Nov 21, 2024 · 2 comments
Open

BlockOperator direct with out is DataContainer #1996

samdporter opened this issue Nov 21, 2024 · 2 comments

Comments

@samdporter
Copy link
Contributor

The direct method needs to catch if out is a DataContainer similarly to the adjoint method, i.e something like:

    def direct(self, x, out=None):
        if out is None:
            blah

        else:
            tmp = self.range_geometry().allocate() # could be a DataContainer
            for row in range(self.shape[0]):
                for col in range(self.shape[1]):
                    if col == 0:
                        if issubclass(out.__class__, DataContainer) or \
                                (has_sirf and issubclass(out.__class__, SIRFDataContainer)):
                            self.get_item(row, col).direct(
                                x_b.get_item(col),
                                out=out)
                        else:
                            self.get_item(row,col).direct(
                                                          x_b.get_item(col),
                                                          out=out.get_item(row))
                    else:
                        if issubclass(out.__class__, DataContainer) or \
                                (has_sirf and issubclass(out.__class__, SIRFDataContainer)):
                            out += self.get_item(row,col).direct(x_b.get_item(col), out=out)                            
                        else:
                            temp_out_row = out.get_item(row) # temp_out_row points to the element in out that we are adding to
                            self.get_item(row,col).direct(
                                                      x_b.get_item(col),
                                                      out=tmp.get_item(row))
                            temp_out_row += tmp.get_item(row)
            return out

@MargaretDuff
Copy link
Member

Many thanks @samdporter! We have a PR currently in review, I think fixing this bug - #1926. What do you think?

@samdporter
Copy link
Contributor Author

Looks about right to me! Thanks, Margaret

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

No branches or pull requests

2 participants