TomographicImaging / CIL

A versatile python framework for tomographic imaging
https://tomographicimaging.github.io/CIL/
Apache License 2.0
97 stars 45 forks source link

SAPYB for BlockDataContainer #1997

Open samdporter opened 9 hours ago

samdporter commented 9 hours ago

In order to work with other code (e.g SVRGFunction) BlockDataContainer.sapyb method needs to be able to accept out=None and should return a BlockDataContainer

    def sapyb(self, a, y, b, out, num_threads = NUM_THREADS):
        r'''performs axpby element-wise on the BlockDataContainer containers'''
        if out is None:
            out = self*0 
        kwargs = {'a':a, 'b':b, 'out':out, 'num_threads': NUM_THREADS}
        return self.binary_operations(BlockDataContainer.SAPYB, y, **kwargs)

Currently throws error in SVRG.approximate_gradient

MargaretDuff commented 8 hours ago

Thanks @samdporter

Yep, that would be a quick fix to currently not allowing the user to pass None to out: https://github.com/TomographicImaging/CIL/blob/5d569dc054759a8c137ca72611fc7be07be6080e/Wrappers/Python/cil/framework/block.py#L286-L312

Will chat to the team about any checks we might need or if they can remember the thinking in the first place