CIL icon indicating copy to clipboard operation
CIL copied to clipboard

TotalVariation not caching its _gradient operator correctly

Open fmwatson opened this issue 7 months ago • 0 comments

Description

TotalVariation does not correctly cache its _gradient, it will instead create a new one every time the gradient_operator property is called

Environment

Effected code snippet:

@property
    def gradient_operator(self):
        r""" GradientOperator is created if it is not instantiated yet. The domain of the `_gradient`,
        is created in the `__call__` and `proximal` methods.

        """
        if self._domain is not None:
            self._gradient = GradientOperator(
                self._domain, correlation=self.correlation, backend=self.backend)
        else:
            raise ValueError(
                " The domain of the TotalVariation is {}. Please use the __call__ or proximal methods first before calling gradient.".format(self._domain))

        return self._gradient

This should also check if self._gradient is not None

fmwatson avatar May 28 '25 10:05 fmwatson